Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
JDOMMap.cc File Reference

Auxiliary program to create module map of PMT addresses. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <fstream>
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorCalibration.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JDetectorSupportkit.hh"
#include "JSon/JSon.hh"
#include "Jeep/JeepToolkit.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 create module map of PMT addresses.

Author
mdejong

Definition in file JDOMMap.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 25 of file JDOMMap.cc.

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
63
64
65 const json error = { {Message_t, "" },
66 {Code_t, OK_t },
67 {Arguments_t, json::array() } };
68
69 json js;
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
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
nlohmann::json json
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
Utility class to parse command line options.
Definition JParser.hh:1698
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
void store(const std::string &file_name, const JDetector &detector)
Store detector to output file.
JDetectorAddressMap & getDetectorAddressMap()
Get detector address map.
bool hasDetectorAddressMap(const int id)
Check if detector address map is available.
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.