Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JDOMMap.cc
Go to the documentation of this file.
1#include <string>
2#include <iostream>
3#include <iomanip>
4#include <fstream>
5
10
11#include "JSon/JSon.hh"
12
13#include "Jeep/JeepToolkit.hh"
14#include "Jeep/JPrint.hh"
15#include "Jeep/JParser.hh"
16#include "Jeep/JMessage.hh"
17
18
19/**
20 * \file
21 *
22 * Auxiliary program to create module map of PMT addresses.
23 * \author mdejong
24 */
25int main(int argc, char **argv)
26{
27 using namespace std;
28 using namespace JPP;
29
30 string detectorFile;
31 string outputFile;
32 int debug;
33
34 try {
35
36 JParser<> zap("Auxiliary program to create module map of PMT addresses.");
37
38 zap['a'] = make_field(detectorFile, "detector file");
39 zap['o'] = make_field(outputFile, "JSon formatted output file");
40 zap['d'] = make_field(debug) = 1;
41
42 zap(argc, argv);
43 }
44 catch(const exception &error) {
45 FATAL(error.what() << endl);
46 }
47
48
50
51 try {
52 load(detectorFile, detector);
53 }
54 catch(const JException& error) {
55 FATAL(error);
56 }
57
58 if (!hasDetectorAddressMap(detector.getID())) {
59 FATAL("No detector address map for detector identier " << detector.getID() << endl);
60 }
61
62 const JDetectorAddressMap& demo = getDetectorAddressMap(detector.getID());
63
64
65 const json error = { {Message_t, "" },
66 {Code_t, OK_t },
67 {Arguments_t, json::array() } };
68
69 json js;
70 JModuleMap data;
71
72 for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
73
74 const JModuleAddressMap& memo = demo.get(module->getID());
75
76 JModuleMap_t buffer(module->getID());
77
78 for (size_t i = 0; i != module->size(); ++i) {
79 buffer[memo.getPMTPhysicalAddress(i).toString()] = (*module)[i].getID();
80 }
81
82 data.push_back(buffer);
83 }
84
85 js[Comment_t] = json(detector.comment);
86 js[Data_t][0][DetID_t] = json(detector.getID());
87 js[Data_t][0][DOMMap_t] = json(data);
88 js[Error_t] = json(error);
89
90 store(outputFile.c_str(), js);
91
92 return 0;
93}
string outputFile
int main(int argc, char **argv)
Definition JDOMMap.cc:25
Detector support kit.
Data structure for detector geometry and calibration.
General purpose messaging.
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
I/O formatting auxiliaries.
nlohmann::json json
Auxiliary methods for handling file names, type names and environment.
Lookup table for PMT addresses in detector.
const JModuleAddressMap & get(const int id) const
Get module address map.
Detector data structure.
Definition JDetector.hh:96
Lookup table for PMT addresses in optical module.
const JPMTPhysicalAddress & getPMTPhysicalAddress(const int tdc) const
Get PMT physical address.
std::string toString() const
Convert PMT physical address to string.
General exception.
Definition JException.hh:24
int getID() const
Get identifier.
Definition JObjectID.hh:50
Utility class to parse command line options.
Definition JParser.hh:1698
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Detector file.
Definition JHead.hh:227
Auxiliary data structure for module address map.