Jpp  18.0.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
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/JDetectorAddressMapToolkit.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

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 
49  JDetector detector;
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 }
static const std::string Arguments_t
Utility class to parse command line options.
Definition: JParser.hh:1514
static const std::string Code_t
std::vector< JModuleMap_t > JModuleMap
module map
bool hasDetectorAddressMap(const int id)
Check if detector address map is available.
static const std::string Error_t
string outputFile
static const std::string Comment_t
static const std::string DOMMap_t
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
void store(const std::string &file_name, const JDetector &detector)
Store detector to output file.
JDetectorAddressMap & getDetectorAddressMap()
Get detector address map.
static const std::string Message_t
#define FATAL(A)
Definition: JMessage.hh:67
static const std::string Data_t
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
nlohmann::json json
do set_variable DETECTOR_TXT $WORKDIR detector
static const std::string DetID_t
int debug
debug level
static const std::string OK_t