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

Auxiliary program to modify tripod configuration. More...

#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <algorithm>
#include "TRandom3.h"
#include "JDetector/JTripod.hh"
#include "JSupport/JMeta.hh"
#include "JLang/JComparator.hh"
#include "JLang/JComparison.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 tripod configuration.

Syntax:

    -T "<tripod identifier>     (set|add|sub)    East North depth"
    -T "<tripod identifier>     (setx|addx|subx) East"
    -T "<tripod identifier>     (sety|addy|suby) North"
    -T "<tripod identifier>     (setz|addz|subz) depth"

The options

    -A "<tripod identifier> East North depth"
    -r "<tripod identifier>"
    -k "<tripod identifier>"

can be used to add, remove and keep a specific tripod, respectively.

Author
mdejong

Definition in file JEditTripod.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 231 of file JEditTripod.cc.

232 {
233  using namespace std;
234  using namespace JPP;
235 
236  typedef JContainer< vector<JTripod> > container_type;
237 
238  string inputFile;
239  string outputFile;
240  vector<JModifier> mod;
241  vector<JTripod> add;
242  set<int> rm;
243  set<int> keep;
244  bool squash;
245  int debug;
246 
247  try {
248 
249  JParser<> zap("Auxiliary program to modify tripod configuration.");
250 
251  zap['f'] = make_field(inputFile, "tripod input file");
252  zap['o'] = make_field(outputFile, "tripod output file");
253  zap['T'] = make_field(mod, "tripod modifier") = JPARSER::initialised();
254  zap['A'] = make_field(add, "add tripod") = JPARSER::initialised();
255  zap['r'] = make_field(rm, "remove tripod[s]") = JPARSER::initialised();
256  zap['k'] = make_field(keep, "keep tripod[s]") = JPARSER::initialised();
257  zap['q'] = make_field(squash, "squash meta data");
258  zap['d'] = make_field(debug, "debug level") = 2;
259 
260  zap(argc, argv);
261  }
262  catch(const exception &error) {
263  FATAL(error.what() << endl);
264  }
265 
266  gRandom->SetSeed(0);
267 
268 
269  if (!rm.empty() && !keep.empty()) {
270  FATAL("Use either option -K or -D." << endl);
271  }
272 
273  container_type tripods;
274 
275  try {
276  tripods.load(inputFile.c_str());
277  }
278  catch(const exception&) {}
279 
280  if (squash) {
281  tripods.comment.clear();
282  }
283 
284  tripods.comment.add(JMeta(argc, argv));
285 
286  for (vector<JTripod>::const_iterator i = add.begin(); i != add.end(); ++i) {
287  tripods.push_back(*i);
288  }
289 
290  for (vector<JModifier>::const_iterator i = mod.begin(); i != mod.end(); ++i) {
291 
292  for (container_type::iterator target = tripods.begin(); target != tripods.end(); ++target) {
293 
294  if (target->getID() == i->id || i->id == WILDCARD) {
295 
296  DEBUG("Modifier" << ' '
297  << "(" << FILL(2,'0') << target->getID() << FILL() << ")" << ' '
298  << i->action << ' ' << JEEPZ() << i->data << endl);
299 
300  if (!i->apply(*target)) {
301  ERROR("No valid action: " << *i << endl);
302  }
303  }
304  }
305  }
306 
307  if (!rm.empty()) {
308  for (container_type::iterator target = tripods.begin(); target != tripods.end(); ) {
309  if (rm.count(target->getID()) != 0)
310  target = tripods.erase(target);
311  else
312  ++target;
313  }
314  }
315 
316  if (!keep.empty()) {
317  for (container_type::iterator target = tripods.begin(); target != tripods.end(); ) {
318  if (keep.count(target->getID()) == 0)
319  target = tripods.erase(target);
320  else
321  ++target;
322  }
323  }
324 
325  sort(tripods.begin(), tripods.end(), make_comparator(&JTripod::getID));
326 
327  tripods.store(outputFile.c_str());
328 }
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:1517
Target.
Definition: JHead.hh:298
JComparator< JResult_t T::*, JComparison::lt > make_comparator(JResult_t T::*member)
Helper method to create comparator between values of data member.
then fatal Number of tripods
Definition: JFootprint.sh:45
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:83
string outputFile
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:1993
#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