Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
createPMTMap.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"
12 
13 
14 /**
15  * \file
16  *
17  * Auxiliary program to create map for reference PMTs.
18  *
19  * the option
20  * <pre>
21  * -T "s"
22  * </pre>
23  * or
24  * <pre>
25  * -T{"s1","s2"}
26  * </pre>
27  * has to be used with a vector of strings. This vector contains either the
28  * list of reference PMT identities or the keyword <tt>odd</tt>.
29  * If the keyword <tt>odd</tt> is used, all the PMTs with an odd identity are
30  * listed in the output file. The parity is calculated as following:
31  * <pre>
32  * (floor id - 1)*31 + PMT id
33  * </pre>
34  * \author acreusot
35  */
36 
37 int main(int argc, char **argv)
38 {
39  using namespace std;
40  using namespace JPP;
41  //using namespace KM3NETDAQ;
42 
43  string detectorFile;
44  string outputFile;
45  vector<string> mapType;
46  int debug;
47 
48  try {
49  JParser<> zap("Auxiliary program to create PMT map files.");
50  zap['a'] = make_field(detectorFile);
51  zap['o'] = make_field(outputFile);
52  zap['T'] = make_field(mapType);
53  zap['d'] = make_field(debug) = 1;
54  zap(argc, argv);
55  }
56 
57  catch(const exception &error) {
58  FATAL(error.what() << endl);
59  }
60 
61  fstream outstr(outputFile.c_str(), ofstream::out);
63  try {
64  load(detectorFile, detector);
65  }
66  catch(const JException& error) {
67  FATAL(error);
68  }
69  for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
70  const int floorId = module->getFloor();
71  const int domId = module->getID();
72  for (unsigned int t = 0; t < mapType.size(); ++t) {
73  if (mapType[t] == "odd") {
74  for (unsigned int pmt = 0; pmt < NUMBER_OF_PMTS; ++pmt) {
75  const int id = (floorId - 1)*NUMBER_OF_PMTS + pmt;
76  if (id % 2 != 0) {
77  outstr << domId << ' ' << pmt << endl;
78  }
79  }
80  } else {
81  outstr << domId << ' ' << mapType[t] << endl;
82  }
83  }
84  }
85  outstr.close();
86 
87 }
Utility class to parse command line options.
Definition: JParser.hh:1500
General exception.
Definition: JException.hh:23
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
int debug
debug level
Definition: JSirene.cc:63
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
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Definition: JDAQ.hh:26
int main(int argc, char *argv[])
Definition: Main.cpp:15