Jpp  19.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
getLocation.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <iomanip>
4 
5 #include "JDetector/JDetector.hh"
8 
9 #include "Jeep/JParser.hh"
10 #include "Jeep/JMessage.hh"
11 
12 
13 /**
14  * \file
15  *
16  * Auxiliary program to print module location for a given module identifier.
17  * \author mdejong
18  */
19 int main(int argc, char **argv)
20 {
21  using namespace std;
22  using namespace JPP;
23 
24  string detectorFile;
26  bool fatal;
27  int debug;
28 
29  try {
30 
31  JParser<> zap("Auxiliary program to print module location for a given module identifier."
32  "\nInteractive mode in absence of option -M <module>.");
33 
34  zap['a'] = make_field(detectorFile, "Detector file");
35  zap['M'] = make_field(id, "Module identifier") = JModuleIdentifier();
36  zap['F'] = make_field(fatal, "Make error fatal");
37  zap['d'] = make_field(debug) = 1;
38 
39  zap(argc, argv);
40  }
41  catch(const exception &error) {
42  FATAL(error.what() << endl);
43  }
44 
45 
46  JDetector detector;
47 
48  try {
49  load(detectorFile, detector);
50  }
51  catch(const JException& error) {
52  FATAL(error);
53  }
54 
55  const JModuleRouter router(detector);
56 
57  if (id != JModuleIdentifier()) {
58 
59  if (router.hasModule(id))
60  cout << router.getModule(id).getLocation() << endl;
61  else if (fatal)
62  FATAL("Missing module " << id << endl);
63  else
64  cout << JLocation() << endl;
65 
66  } else {
67 
68  while (cin >> id && id != JModuleIdentifier()) {
69 
70  if (router.hasModule(id))
71  cout << router.getModule(id).getLocation() << endl;
72  else if (fatal)
73  FATAL("Missing module " << id << endl);
74  else
75  cout << JLocation() << endl;
76  }
77  }
78 
79  return 0;
80 }
Utility class to parse command line options.
Definition: JParser.hh:1711
int main(int argc, char *argv[])
Definition: Main.cc:15
Data structure for detector geometry and calibration.
JLANG::JObjectID JModuleIdentifier
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2158
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Direct access to module in detector data structure.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
Utility class to parse command line options.
do set_variable DETECTOR_TXT $WORKDIR detector
int debug
debug level