Jpp 20.0.0-195-g190c9e876
the software that should make you happy
Loading...
Searching...
No Matches
JMuonEnergy.cc
Go to the documentation of this file.
1#include <string>
2#include <iostream>
3#include <iomanip>
4#include <vector>
5#include <algorithm>
6#include <limits>
7#include <memory>
8
13
14#include "JDAQ/JDAQEventIO.hh"
17
19
24
26
27#include "JSupport/JSupport.hh"
33#include "JSupport/JMeta.hh"
34
35#include "JFit/JEnergy.hh"
37
44
45#include "Jeep/JParser.hh"
46#include "Jeep/JMessage.hh"
47
48
49/**
50 * \file
51 *
52 * Program to perform JFIT::JRegressor<JEnergy, JGandalf> fit using I/O of JFIT::JEvt data.
53 * \author mdejong
54 */
55int main(int argc, char **argv)
56{
57 using namespace std;
58 using namespace JPP;
59 using namespace KM3NETDAQ;
60
62 typedef JParallelFileScanner< JTypeList<JDAQEvent, JFIT::JEvt> > JParallelFileScanner_t;
63 typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
64 typedef JMultipleFileScanner<calibration_types> JCalibration_t;
65
66 JParallelFileScanner_t inputFile;
68 JLimit_t& numberOfEvents = inputFile.getLimit();
69 string detectorFile;
70 JCalibration_t calibrationFile;
71 double Tmax_s;
72 string pdfFile;
73 JMuonEnergyParameters_t parameters;
74 JPMTParametersMap pmtParameters;
75 JEnergyCorrection correct;
76 size_t threads;
77 int debug;
78
79 try {
80
81 JParser<> zap("Program to perform fit of muon energy to data.");
82
83 zap['f'] = make_field(inputFile);
84 zap['o'] = make_field(outputFile);
85 zap['n'] = make_field(numberOfEvents) = JLimit::max();
86 zap['a'] = make_field(detectorFile);
87 zap['+'] = make_field(calibrationFile, "dynamical calibration data") = JPARSER::initialised();
88 zap['T'] = make_field(Tmax_s, "dynamical update time [s]") = 100.0;
89 zap['F'] = make_field(pdfFile, "PDFs");
90 zap['@'] = make_field(parameters, "fit parameters") = JPARSER::initialised();
91 zap['P'] = make_field(pmtParameters, "PMT parameters") = JPARSER::initialised();
92 zap['E'] = make_field(correct, "energy correction") = JEnergyCorrection();
93 zap['N'] = make_field(threads, "number of threads") = 0;
94 zap['d'] = make_field(debug) = 1;
95
96 zap(argc, argv);
97 }
98 catch(const exception& error) {
99 FATAL(error.what() << endl);
100 }
101
102
104
106
107 try {
108 load(detectorFile, detector);
109 }
110 catch(const JException& error) {
111 FATAL(error);
112 }
113
114 unique_ptr<JDynamics> dynamics;
115
116 if (!calibrationFile.empty()) {
117
118 try {
119
120 dynamics.reset(new JDynamics(detector, Tmax_s));
121
122 dynamics->load(calibrationFile);
123 }
124 catch(const exception& error) {
125 FATAL(error.what());
126 }
127 }
128
129 outputFile.open();
130 outputFile.put(JMeta(argc, argv));
131
132 {
133 const JModuleRouter router(dynamics ? dynamics->getDetector() : detector);
134
135 JSummaryFileRouter summary(inputFile);
136
137 const JMuonEnergy::storage_type storage(pdfFile, JTimeRange(parameters.TMin_ns, parameters.TMax_ns));
138
139 JMuonEnergy fit(parameters, storage, pmtParameters, correct, debug);
140
141 JMultiThreadedReconstruction<JMuonEnergy> fits(fit, outputFile, threads, 2 * threads);
142
143 while (inputFile.hasNext()) {
144
145 STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
146
147 multi_pointer_type ps = inputFile.next();
148
149 const JDAQEvent* tev = ps;
150 const JFIT::JEvt* in = ps;
151
152 summary.update(*tev);
153
154 if (dynamics) {
155 dynamics->update(*tev);
156 }
157
158 auto input = fit.getInput(router, summary, *tev, *in, dynamics ? dynamics->getCoverage() : coverage_type());
159
160 if (threads > 0)
161 fits.enqueue(input);
162 else
163 outputFile.put(fit(input));
164 }
165 STATUS(endl);
166 }
167
169
170 io >> outputFile;
171
172 outputFile.close();
173}
string outputFile
Data structure for detector geometry and calibration.
Dynamic detector calibration.
Data regression method for JFIT::JEnergy.
Recording of objects on file according a format that follows from the file name extension.
General purpose messaging.
#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
ROOT I/O of application specific meta data.
Direct access to module in detector data structure.
Scanning of objects from multiple files according a format that follows from the extension of each fi...
int main(int argc, char **argv)
Parallel scanning of objects from a single file or multiple files according a format that follows fro...
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Scanning of objects from a single file according a format that follows from the extension of each fil...
ROOT TTree parameter settings of various packages.
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
Auxiliary class for correction of energy determined by JEnergy.cc.
Thread pool for event-by-event reconstruction.
Auxiliary class to to determine muon energy.
input_type getInput(const JModuleRouter &router, const JSummaryRouter &summary, const JDAQEvent &event, const JEvt &in, const coverage_type &coverage) const
Get input data.
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.
void update(const JDAQHeader &header)
Update router.
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]
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