Jpp  18.0.1-rc.1
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 <string>
#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 232 of file JEditTripod.cc.

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