Jpp  16.0.0-rc.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JEditHydrophone.cc File Reference

Auxiliary program to modify hydrophone configuration. More...

#include <iostream>
#include <iomanip>
#include <vector>
#include "JDetector/JHydrophone.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 modify hydrophone configuration.

Syntax:

    -S "<string number>         (set|add|sub) x y z"
    -S "<string number>         (rot) phi"

For option rot, the angle phi refers to an anti-clockwise rotation around the z-axis.
The rotation angle is defined in radians.

The options

    -A "<string number> <floor> x y z"
    -D "<string number>"

can be used to add and remove a hydrophone, respectively.

Author
mdejong

Definition in file JEditHydrophone.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 170 of file JEditHydrophone.cc.

171 {
172  using namespace std;
173  using namespace JPP;
174 
175  typedef JContainer< vector<JHydrophone> > container_type;
176 
177  string file_name;
178  vector<JModifier> mod;
180  vector<int> del;
181  bool rm;
182  int debug;
183 
184  try {
185 
186  JParser<> zap("Auxiliary program to modify hydrophone configuration.");
187 
188  zap['f'] = make_field(file_name, "hydrophone file");
189  zap['S'] = make_field(mod, "hydrophone modifier") = JPARSER::initialised();
190  zap['A'] = make_field(add, "add hydrophone") = JPARSER::initialised();
191  zap['D'] = make_field(del, "delete hydrophone") = JPARSER::initialised();
192  zap['r'] = make_field(rm, "remove previous comments");
193  zap['d'] = make_field(debug) = 1;
194 
195  zap(argc, argv);
196  }
197  catch(const exception &error) {
198  FATAL(error.what() << endl);
199  }
200 
201  container_type data;
202 
203  try {
204  data.load(file_name.c_str());
205  }
206  catch(const exception&) {}
207 
208  if (rm) {
209  data.comment.clear();
210  }
211 
212  data.comment.add(JMeta(argc, argv));
213 
214  for (vector<JHydrophone>::const_iterator i = add.begin(); i != add.end(); ++i) {
215  data.push_back(*i);
216  }
217 
218  for (vector<JModifier>::const_iterator i = mod.begin(); i != mod.end(); ++i) {
219 
220  for (container_type::iterator target = data.begin(); target != data.end(); ++target) {
221 
222  if (target->getString() == i->id) {
223 
224  DEBUG("Modifier" << ' '
225  << "(" << FILL(4,'0') << target->getString() << "," << FILL(2,'0') << target->getFloor() << FILL() << ")" << ' '
226  << "action" << ' ' << i->action << JEEPZ() << i->data << endl);
227 
228  if (!i->apply(*target)) {
229  ERROR("No valid action: " << *i << endl);
230  }
231  }
232  }
233  }
234 
235  for (vector<int>::const_iterator i = del.begin(); i != del.end(); ++i) {
236  for (container_type::iterator target = data.begin(); target != data.end(); ) {
237  if (target->getString() == *i)
238  target = data.erase(target);
239  else
240  ++target;
241  }
242  }
243 
244  data.store(file_name.c_str());
245 }
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:1500
Target.
Definition: JHead.hh:296
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:66
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:1961
#define ERROR(A)
Definition: JMessage.hh:66
int debug
debug level
Definition: JSirene.cc:63
Auxiliary data structure for streaming of STL containers.
Definition: JPrint.hh:65
Auxiliary data structure for sequence of same character.
Definition: JManip.hh:328
#define FATAL(A)
Definition: JMessage.hh:67
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG