Jpp  15.0.5
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JMergeDetector.cc File Reference

Auxiliary program to merge detector files. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JModuleRouter.hh"
#include "JDetector/JPMTRouter.hh"
#include "JSupport/JMeta.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 merge detector files.

Author
mdejong

Definition in file JMergeDetector.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 23 of file JMergeDetector.cc.

24 {
25  using namespace std;
26  using namespace JPP;
27 
28  vector<string> detectorFile;
29  string tcalset;
30  string pcalset;
31  string rcalset;
32  string outputFile;
33  int debug;
34 
35  try {
36 
37  JParser<> zap("Auxiliary program to merge detector files.");
38 
39  zap['a'] = make_field(detectorFile);
40  zap['o'] = make_field(outputFile);
41  zap['t'] = make_field(tcalset, "tcal: t0 (time offsets) calibration set from file") = "";
42  zap['p'] = make_field(pcalset, "pcal: position (x,y,z) calibration set from file") = "";
43  zap['q'] = make_field(rcalset, "rcal: orientation (quaterions) calibration set from file") = "";
44  zap['d'] = make_field(debug) = 1;
45 
46  zap(argc, argv);
47  }
48  catch(const exception &error) {
49  FATAL(error.what() << endl);
50  }
51 
52 
54 
55  for (vector<string>::const_iterator i = detectorFile.begin(); i != detectorFile.end(); ++i) {
56 
57  JDetector buffer;
58 
59  try {
60  load(*i, buffer);
61  }
62  catch(const JException& error) {
63  FATAL(error);
64  }
65 
66  if (detector.empty())
67  detector = buffer;
68  else
69  copy(buffer.begin(), buffer.end(), back_inserter(detector));
70  }
71 
72  if (tcalset != "") {
73 
74  JDetector buffer;
75 
76  try {
77  load(tcalset, buffer);
78  }
79  catch(const JException& error) {
80  FATAL(error);
81  }
82 
83  JPMTRouter router(detector);
84 
85  for (const auto& module : buffer) {
86  for (const auto& pmt : module) {
87  if (router.hasPMT(pmt.getID()))
88  detector.getPMT(router.getAddress(pmt.getID())).setCalibration(pmt.getCalibration());
89  else
90  FATAL("Missing PMT " << pmt.getID() << endl);
91  }
92  }
93  }
94 
95  if (pcalset != "") {
96 
97  JDetector buffer;
98 
99  try {
100  load(pcalset, buffer);
101  }
102  catch(const JException& error) {
103  FATAL(error);
104  }
105 
106  JModuleRouter router(detector);
107 
108  for (const auto& module : buffer) {
109  if (router.hasModule(module.getID())) {
110 
111  if (module.getFloor() != 0)
112  detector.getModule(router.getAddress(module.getID())).set(module.getCenter());
113  else
114  detector.getModule(router.getAddress(module.getID())).set(module.getPosition());
115 
116  } else
117  FATAL("Missing module " << module.getID() << endl);
118  }
119  }
120 
121  if (rcalset != "") {
122 
123  JDetector buffer;
124 
125  try {
126  load(rcalset, buffer);
127  }
128  catch(const JException& error) {
129  FATAL(error);
130  }
131 
132  JModuleRouter router(detector);
133 
134  for (const auto& module : buffer) {
135  if (router.hasModule(module.getID()))
136  detector.getModule(router.getAddress(module.getID())).rotate(getRotation(detector.getModule(router.getAddress(module.getID())),module));
137  else
138  FATAL("Missing module " << module.getID() << endl);
139  }
140  }
141 
142  detector.comment.add(JMeta(argc,argv));
143 
144  try {
146  }
147  catch(const JException& error) {
148  FATAL(error);
149  }
150 }
Router for direct addressing of PMT data in detector data structure.
Definition: JPMTRouter.hh:33
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:70
Utility class to parse command line options.
Definition: JParser.hh:1500
General exception.
Definition: JException.hh:23
Detector data structure.
Definition: JDetector.hh:89
Router for direct addressing of module data in detector data structure.
static JRotation getRotation
Function object to get rotation matrix to go from first to second module.
string outputFile
Detector file.
Definition: JHead.hh:196
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
void store(const std::string &file_name, const JDetector &detector)
Store detector to output file.
int debug
debug level
Definition: JSirene.cc:63
#define FATAL(A)
Definition: JMessage.hh:67
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:139
do set_variable DETECTOR_TXT $WORKDIR detector