Jpp  18.0.0
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 <set>
#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"
    -r "<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 171 of file JEditHydrophone.cc.

172 {
173  using namespace std;
174  using namespace JPP;
175 
176  typedef JContainer< vector<JHydrophone> > container_type;
177 
178  string inputFile;
179  string outputFile;
180  vector<JModifier> mod;
182  set<int> rm;
183  bool squash;
184  int debug;
185 
186  try {
187 
188  JParser<> zap("Auxiliary program to modify hydrophone configuration.");
189 
190  zap['f'] = make_field(inputFile, "hydrophone input file");
191  zap['o'] = make_field(outputFile, "hydrophone output file");
192  zap['S'] = make_field(mod, "hydrophone modifier") = JPARSER::initialised();
193  zap['A'] = make_field(add, "add hydrophone") = JPARSER::initialised();
194  zap['r'] = make_field(rm, "remove hydrophone[s]") = JPARSER::initialised();
195  zap['q'] = make_field(squash, "squash meta data");
196  zap['d'] = make_field(debug, "debug level") = 2;
197 
198  zap(argc, argv);
199  }
200  catch(const exception &error) {
201  FATAL(error.what() << endl);
202  }
203 
204  container_type data;
205 
206  try {
207  data.load(inputFile.c_str());
208  }
209  catch(const exception&) {}
210 
211  if (squash) {
212  data.comment.clear();
213  }
214 
215  data.comment.add(JMeta(argc, argv));
216 
217  for (vector<JHydrophone>::const_iterator i = add.begin(); i != add.end(); ++i) {
218  data.push_back(*i);
219  }
220 
221  for (vector<JModifier>::const_iterator i = mod.begin(); i != mod.end(); ++i) {
222 
223  for (container_type::iterator target = data.begin(); target != data.end(); ++target) {
224 
225  if (target->getString() == i->id) {
226 
227  DEBUG("Modifier" << ' '
228  << "(" << FILL(4,'0') << target->getString() << "," << FILL(2,'0') << target->getFloor() << FILL() << ")" << ' '
229  << "action" << ' ' << i->action << JEEPZ() << i->data << endl);
230 
231  if (!i->apply(*target)) {
232  ERROR("No valid action: " << *i << endl);
233  }
234  }
235  }
236  }
237 
238  for (set<int>::const_iterator i = rm.begin(); i != rm.end(); ++i) {
239  for (container_type::iterator target = data.begin(); target != data.end(); ) {
240  if (target->getString() == *i)
241  target = data.erase(target);
242  else
243  ++target;
244  }
245  }
246 
247  data.store(outputFile.c_str());
248 }
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
Target.
Definition: JHead.hh:298
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 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
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62