Jpp  17.0.0
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"
    -D "<tripod identifier>"
    -K "<tripod identifier>"

can be used to add, delete 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 file_name;
239  vector<JModifier> mod;
240  vector<JTripod> add;
241  set<int> del;
242  set<int> keep;
243  bool rm;
244  int debug;
245 
246  try {
247 
248  JParser<> zap("Auxiliary program to modify tripod configuration.");
249 
250  zap['f'] = make_field(file_name, "tripod file");
251  zap['T'] = make_field(mod, "tripod modifier") = JPARSER::initialised();
252  zap['A'] = make_field(add, "add tripod") = JPARSER::initialised();
253  zap['D'] = make_field(del, "delete tripod") = JPARSER::initialised();
254  zap['K'] = make_field(keep, "keep tripod") = JPARSER::initialised();
255  zap['r'] = make_field(rm, "remove previous comments");
256  zap['d'] = make_field(debug) = 1;
257 
258  zap(argc, argv);
259  }
260  catch(const exception &error) {
261  FATAL(error.what() << endl);
262  }
263 
264  gRandom->SetSeed(0);
265 
266 
267  if (!del.empty() && !keep.empty()) {
268  FATAL("Use either option -K or -D." << endl);
269  }
270 
271  container_type tripods;
272 
273  try {
274  tripods.load(file_name.c_str());
275  }
276  catch(const exception&) {}
277 
278  if (rm) {
279  tripods.comment.clear();
280  }
281 
282  tripods.comment.add(JMeta(argc, argv));
283 
284  for (vector<JTripod>::const_iterator i = add.begin(); i != add.end(); ++i) {
285  tripods.push_back(*i);
286  }
287 
288  for (vector<JModifier>::const_iterator i = mod.begin(); i != mod.end(); ++i) {
289 
290  for (container_type::iterator target = tripods.begin(); target != tripods.end(); ++target) {
291 
292  if (target->getID() == i->id || i->id == WILDCARD) {
293 
294  DEBUG("Modifier" << ' '
295  << "(" << FILL(2,'0') << target->getID() << FILL() << ")" << ' '
296  << i->action << ' ' << JEEPZ() << i->data << endl);
297 
298  if (!i->apply(*target)) {
299  ERROR("No valid action: " << *i << endl);
300  }
301  }
302  }
303  }
304 
305  if (!del.empty()) {
306  for (container_type::iterator target = tripods.begin(); target != tripods.end(); ) {
307  if (del.count(target->getID()) != 0)
308  target = tripods.erase(target);
309  else
310  ++target;
311  }
312  }
313 
314  if (!keep.empty()) {
315  for (container_type::iterator target = tripods.begin(); target != tripods.end(); ) {
316  if (keep.count(target->getID()) == 0)
317  target = tripods.erase(target);
318  else
319  ++target;
320  }
321  }
322 
323  sort(tripods.begin(), tripods.end(), make_comparator(&JTripod::getID));
324 
325  tripods.store(file_name.c_str());
326 }
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
JComparator< JResult_t T::*, JComparison::lt > make_comparator(JResult_t T::*member)
Helper method to create comparator between values of data member.
Definition: JComparator.hh:185
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: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: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
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62