Jpp 20.0.0-195-g190c9e876
the software that should make you happy
Loading...
Searching...
No Matches
JMuonGandalf.cc File Reference

Program to perform JFIT::JRegressor<JFIT::JLine3Z,JFIT::JGandalf> fit with I/O of JFIT::JEvt data. More...

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Program to perform JFIT::JRegressor<JFIT::JLine3Z,JFIT::JGandalf> fit with I/O of JFIT::JEvt data.

Author
mdejong, gmaggi

Definition in file JMuonGandalf.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 47 of file JMuonGandalf.cc.

48{
49 using namespace std;
50 using namespace JPP;
51 using namespace KM3NETDAQ;
52
54 typedef JParallelFileScanner< JTypeList<JDAQEvent, JFIT::JEvt> > JParallelFileScanner_t;
55 typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
56 typedef JMultipleFileScanner<calibration_types> JCalibration_t;
57
58 JParallelFileScanner_t inputFile;
60 JLimit_t& numberOfEvents = inputFile.getLimit();
61 string detectorFile;
62 JCalibration_t calibrationFile;
63 double Tmax_s;
64 string pdfFile;
65 JMuonGandalfParameters_t parameters;
66 JPMTParametersMap pmtParameters;
67 size_t threads;
68 int debug;
69
70 try {
71
72 JParser<> zap("Program to perform PDF fit of muon trajectory to data.");
73
74 zap['f'] = make_field(inputFile);
75 zap['o'] = make_field(outputFile);
76 zap['n'] = make_field(numberOfEvents) = JLimit::max();
77 zap['a'] = make_field(detectorFile);
78 zap['+'] = make_field(calibrationFile, "dynamical calibration data") = JPARSER::initialised();
79 zap['T'] = make_field(Tmax_s, "dynamical update time [s]") = 100.0;
80 zap['F'] = make_field(pdfFile, "PDFs");
81 zap['@'] = make_field(parameters, "fit parameters") = JPARSER::initialised();
82 zap['P'] = make_field(pmtParameters, "PMT parameters") = JPARSER::initialised();
83 zap['N'] = make_field(threads, "number of threads") = 0;
84 zap['d'] = make_field(debug) = 1;
85
86 zap(argc, argv);
87 }
88 catch(const exception& error) {
89 FATAL(error.what() << endl);
90 }
91
92
94
96
97 try {
98 load(detectorFile, detector);
99 }
100 catch(const JException& error) {
101 FATAL(error);
102 }
103
104 unique_ptr<JDynamics> dynamics;
105
106 if (!calibrationFile.empty()) {
107
108 try {
109
110 dynamics.reset(new JDynamics(detector, Tmax_s));
111
112 dynamics->load(calibrationFile);
113 }
114 catch(const exception& error) {
115 FATAL(error.what());
116 }
117 }
118
119 outputFile.open();
120 outputFile.put(JMeta(argc, argv));
121
122 {
123 const JModuleRouter router(dynamics ? dynamics->getDetector() : detector);
124
125 JSummaryFileRouter summary(inputFile);
126
127 const JMuonGandalf::storage_type storage(pdfFile, JTimeRange(parameters.TMin_ns, parameters.TMax_ns), parameters.TTS_ns);
128
129 JMuonGandalf fit(parameters, storage, pmtParameters, debug);
130
131 JMultiThreadedReconstruction<JMuonGandalf> fits(fit, outputFile, threads, 2 * threads);
132
133 while (inputFile.hasNext()) {
134
135 STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
136
137 multi_pointer_type ps = inputFile.next();
138
139 const JDAQEvent* tev = ps;
140 const JFIT::JEvt* in = ps;
141
142 summary.update(*tev);
143
144 if (dynamics) {
145 dynamics->update(*tev);
146 }
147
148 auto input = fit.getInput(router, summary, *tev, *in, dynamics ? dynamics->getCoverage() : coverage_type());
149
150 if (threads > 0)
151 fits.enqueue(input);
152 else
153 outputFile.put(fit(input));
154 }
155 STATUS(endl);
156 }
157
159
160 io >> outputFile;
161
162 outputFile.close();
163}
string outputFile
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define STATUS(A)
Definition JMessage.hh:63
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:74
#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.
Auxiliary class for map of PMT parameters.
Data structure for set of track fit results.
General exception.
Definition JException.hh:24
Utility class to parse command line options.
Definition JParser.hh:1698
Thread pool for event-by-event reconstruction.
void setSplitLevel(int value)
Set split level.
Object writing to file.
General purpose class for object reading from a list of file names.
General purpose class for parallel reading of objects from a single file or multiple files.
Object reading from a list of files.
File router for fast addressing of summary data.
JTOOLS::JRange< double > JTimeRange
Type definition for time range (unit [s]).
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
JTreeParameters & getTreeParameters()
Template definition for method returning TTree parameters.
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
Detector file.
Definition JHead.hh:227
Dynamic detector calibration.
Definition JDynamics.hh:81
Data structure for coverage of detector by dynamical calibrations.
Definition JCoverage.hh:19
Type list.
Definition JTypeList.hh:23
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition JParser.hh:68
double TMin_ns
minimal time w.r.t. Cherenkov hypothesis [ns]
double TMax_ns
maximal time w.r.t. Cherenkov hypothesis [ns]
Wrapper class to make final fit of muon trajectory.
Auxiliary class for defining the range of iterations of objects.
Definition JLimit.hh:45
const JLimit & getLimit() const
Get limit.
Definition JLimit.hh:84
static counter_type max()
Get maximum counter value.
Definition JLimit.hh:128
Auxiliary class for ROOT I/O of application specific meta data.
Definition JMeta.hh:72