Jpp  18.2.1-ARCA-DF-PATCH
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JEditMechanics.cc File Reference

Auxiliary program to add or modify mechanical model data of detector string. More...

#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include "JAcoustics/JMechanics.hh"
#include "JSupport/JMeta.hh"
#include "Jeep/JContainer.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Auxiliary program to add or modify mechanical model data of detector string.

Syntax:

    -M "<string number>     (set) a b"

The options

    -A "<string number> a b"
    -r "<string number>"

can be used to add or remove a specific string, respectively.

Author
mdejong

Definition in file JEditMechanics.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 100 of file JEditMechanics.cc.

101 {
102  using namespace std;
103  using namespace JPP;
104 
105  typedef JContainer< map<int, JMechanics> > container_type;
106 
107  string inputFile;
108  string outputFile;
109  vector<JModifier> mod;
111  set<int> rm;
112  bool squash;
113  int debug;
114 
115  try {
116 
117  JParser<> zap("Auxiliary program to add or modify mechanical model data of detector string.");
118 
119  zap['f'] = make_field(inputFile, "mechanics input file");
120  zap['o'] = make_field(outputFile, "mechanics output file");
121  zap['M'] = make_field(mod, "mechanics modifier") = JPARSER::initialised();
122  zap['A'] = make_field(add, "add string mechanics") = JPARSER::initialised();
123  zap['r'] = make_field(rm, "remove string[s]") = JPARSER::initialised();
124  zap['q'] = make_field(squash, "squash meta data");
125  zap['d'] = make_field(debug, "debug level") = 2;
126 
127  zap(argc, argv);
128  }
129  catch(const exception &error) {
130  FATAL(error.what() << endl);
131  }
132 
133  container_type data;
134 
135  try {
136  data.load(inputFile.c_str());
137  }
138  catch(const exception&) {}
139 
140  if (squash) {
141  data.comment.clear();
142  }
143 
144  data.comment.add(JMeta(argc,argv));
145 
146  for (map<int, JMechanics>::const_iterator i = add.begin(); i != add.end(); ++i) {
147  if (data.count(i->first) == 0u)
148  data[i->first] = i->second;
149  else
150  ERROR("String " << i->first << " already exists." << endl);
151  }
152 
153  for (vector<JModifier>::const_iterator i = mod.begin(); i != mod.end(); ++i) {
154 
155  DEBUG("Modifier" << ' '
156  << "(" << FILL(2,'0') << i->id << FILL() << ")" << ' '
157  << "action" << ' ' << i->mechanics << endl);
158 
159  JMechanics mechanics;
160 
161  container_type::iterator p = data.find(i->id);
162 
163  if (p != data.end()) {
164  mechanics = p->second;
165  }
166 
167  if (!i->apply(mechanics))
168  ERROR("No valid action: " << *i << endl);
169  else
170  data[i->id] = mechanics;
171  }
172 
173  for (set<int>::const_iterator i = rm.begin(); i != rm.end(); ++i) {
174 
175  container_type::iterator p = data.find(*i);
176 
177  if (p != data.end()) {
178  data.erase(p);
179  }
180  }
181 
182  data.store(outputFile.c_str());
183 }
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:70
Utility class to parse command line options.
Definition: JParser.hh:1514
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:83
string outputFile
then rm
Definition: sftpput.zsh:30
Auxiliary wrapper for I/O of container with optional comment (see JComment).
Definition: JContainer.hh:39
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
#define ERROR(A)
Definition: JMessage.hh:66
Auxiliary data structure for sequence of same character.
Definition: JManip.hh:328
#define FATAL(A)
Definition: JMessage.hh:67
double u[N+1]
Definition: JPolint.hh:865
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
Auxiliary data structure for parameters of mechanical model.
Definition: JMechanics.hh:41