Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JMergeDetector.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <iomanip>
4 
5 #include "JDetector/JDetector.hh"
7 #include "JDetector/JLocation.hh"
8 
9 #include "Jeep/JParser.hh"
10 #include "Jeep/JMessage.hh"
11 
12 
13 /**
14  * \file
15  *
16  * Auxiliary program to merge detector files.
17  *
18  * If the option
19  * <pre>
20  * -N [i]
21  * </pre>
22  * is used with a positive number the strings are renumbered starting from <tt>i</tt>.
23  * Each string gets a unique number based on the order of the detector files
24  * and its original index in its own detector file.
25  *
26  * \author mdejong
27  */
28 int main(int argc, char **argv)
29 {
30  using namespace std;
31  using namespace JPP;
32 
33  vector<string> detectorFile;
34  string outputFile;
35  int debug;
36 
37  try {
38 
39  JParser<> zap("Auxiliary program to merge detector files.");
40 
41  zap['a'] = make_field(detectorFile);
42  zap['o'] = make_field(outputFile);
43  zap['d'] = make_field(debug) = 1;
44 
45  zap(argc, argv);
46  }
47  catch(const exception &error) {
48  FATAL(error.what() << endl);
49  }
50 
51 
53 
54  for (vector<string>::const_iterator i = detectorFile.begin(); i != detectorFile.end(); ++i) {
55 
56  JDetector buffer;
57 
58  try {
59  load(*i, buffer);
60  }
61  catch(const JException& error) {
62  FATAL(error);
63  }
64 
65  if (detector.empty())
66  detector = buffer;
67  else
68  copy(buffer.begin(), buffer.end(), back_inserter(detector));
69  }
70 
71  try {
73  }
74  catch(const JException& error) {
75  FATAL(error);
76  }
77 }
Utility class to parse command line options.
Definition: JParser.hh:1500
General exception.
Definition: JException.hh:23
int main(int argc, char *argv[])
Definition: Main.cc:15
Detector data structure.
Definition: JDetector.hh:80
string outputFile
Data structure for detector geometry and calibration.
Detector file.
Definition: JHead.hh:196
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
void store(const std::string &file_name, const JDetector &detector)
Store detector to output file.
int debug
debug level
Definition: JSirene.cc:63
Logical location of module.
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
Utility class to parse command line options.
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:139
do set_variable DETECTOR_TXT $WORKDIR detector