Jpp  16.0.0-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 <vector>
#include "TRandom3.h"
#include "JDetector/JTripod.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 tripod configuration.

Syntax:

    -T "<tripod identifier>     (set|add|sub) east north z"

The options

    -A "<tripod identifier> east north z"
    -D "<tripod identifier>"

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

Author
mdejong

Definition in file JEditTripod.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 127 of file JEditTripod.cc.

128 {
129  using namespace std;
130  using namespace JPP;
131 
132  typedef JContainer< vector<JTripod> > container_type;
133 
134  string file_name;
135  vector<JModifier> mod;
136  vector<JTripod> add;
137  vector<int> del;
138  bool rm;
139  int debug;
140 
141  try {
142 
143  JParser<> zap("Auxiliary program to modify tripod configuration.");
144 
145  zap['f'] = make_field(file_name, "tripod file");
146  zap['T'] = make_field(mod, "tripod modifier") = JPARSER::initialised();
147  zap['A'] = make_field(add, "add tripod") = JPARSER::initialised();
148  zap['D'] = make_field(del, "delete tripod") = JPARSER::initialised();
149  zap['r'] = make_field(rm, "remove previous comments");
150  zap['d'] = make_field(debug) = 1;
151 
152  zap(argc, argv);
153  }
154  catch(const exception &error) {
155  FATAL(error.what() << endl);
156  }
157 
158  gRandom->SetSeed(0);
159 
160  container_type data;
161 
162  try {
163  data.load(file_name.c_str());
164  }
165  catch(const exception&) {}
166 
167  if (rm) {
168  data.comment.clear();
169  }
170 
171  data.comment.add(JMeta(argc, argv));
172 
173  for (vector<JTripod>::const_iterator i = add.begin(); i != add.end(); ++i) {
174  data.push_back(*i);
175  }
176 
177  for (vector<JModifier>::const_iterator i = mod.begin(); i != mod.end(); ++i) {
178 
179  for (container_type::iterator target = data.begin(); target != data.end(); ++target) {
180 
181  if (target->getID() == i->id || i->id == WILDCARD) {
182 
183  DEBUG("Modifier" << ' '
184  << "(" << FILL(2,'0') << target->getID() << FILL() << ")" << ' '
185  << "action" << ' ' << i->pos << endl);
186 
187  if (!i->apply(*target)) {
188  ERROR("No valid action: " << *i << endl);
189  }
190  }
191  }
192  }
193 
194  for (vector<int>::const_iterator i = del.begin(); i != del.end(); ++i) {
195  for (container_type::iterator target = data.begin(); target != data.end(); ) {
196  if (target->getID() == *i)
197  target = data.erase(target);
198  else
199  ++target;
200  }
201  }
202 
203  data.store(file_name.c_str());
204 }
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 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