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

Auxiliary program to merge the time offsets of two detector files. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <utility>
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JModuleRouter.hh"
#include "JCalibrate/JTDC_t.hh"
#include "JLang/JObjectIO.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 the time offsets of two detector files.

Author
acreusot, mdejong

Definition in file JMergeTimeOffsets.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 23 of file JMergeTimeOffsets.cc.

24{
25 using namespace std;
26 using namespace JPP;
27
29
30 pair_type detectorFile_a;
31 pair_type detectorFile_b;
32 string outputFile;
33 double precision;
34 int debug;
35
36 try {
37
38 JParser<> zap("Auxiliary program to merge the time offsets of two detector files."\
39 "\nThe TDC constraints correspond to those used in conjuction with the detector file.");
40
41 zap['a'] = make_field(detectorFile_a, "<detector file> <TDC file>");
42 zap['b'] = make_field(detectorFile_b, "<detector file> <TDC file>");
43 zap['o'] = make_field(outputFile) = "";
44 zap['p'] = make_field(precision) = 1.0e-3;
45 zap['d'] = make_field(debug) = 1;
46
47 zap(argc, argv);
48 }
49 catch(const exception &error) {
50 FATAL(error.what() << endl);
51 }
52
53
54 JDetector detector_a;
55 JDetector detector_b;
56
57 try {
58 load(detectorFile_a.first, detector_a);
59 load(detectorFile_b.first, detector_b);
60 }
61 catch(const std::exception& error) {
62 FATAL(error.what());
63 }
64
65 if (detector_a.getID() != detector_b.getID()) {
66 FATAL("Detector identifier " << detector_a.getID() << " != " << detector_b.getID() << endl);
67 }
68
69 const JModuleRouter router(detector_b);
70
71 for (JDetector::iterator module = detector_a.begin(); module != detector_a.end(); ++module) {
72
73 if (!router.hasModule(module->getID())) {
74 FATAL("Missing module " << module->getID() << " in " << detectorFile_b.first << endl);
75 }
76
77 for (size_t pmt = 0; pmt != module->size(); ++pmt) {
78
79 if (detectorFile_a.second.has(module->getID(), pmt)) {
80
81 if (detectorFile_b.second.has(module->getID(), pmt))
82 ASSERT(fabs((*module)[pmt].getT0() - router.getModule(module->getID())[pmt].getT0()) <= precision,
83 "PMT " << setw(10) << module->getID() << '.' << FILL(2,'0') << pmt << FILL() << " constraint.");
84 else
85 (*module)[pmt].setCalibration(router.getModule(module->getID())[pmt].getCalibration());
86 }
87 }
88 }
89
90 NOTICE("Store calibration data on file " << outputFile << endl);
91
92 detector_a.comment.add(JMeta(argc, argv));
93
94 store(outputFile, detector_a);
95}
string outputFile
#define ASSERT(A,...)
Assert macro.
Definition JMessage.hh:90
#define NOTICE(A)
Definition JMessage.hh:64
#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
Detector data structure.
Definition JDetector.hh:96
Router for direct addressing of module data in detector data structure.
int getID() const
Get identifier.
Definition JObjectID.hh:50
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.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure for sequence of same character.
Definition JManip.hh:330
JComment & add(const std::string &comment)
Add comment.
Definition JComment.hh:100
Auxiliary class for ROOT I/O of application specific meta data.
Definition JMeta.hh:72
Data structure for a pair of indices.