Jpp 20.0.0-rc.2
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 <set>
6#include <algorithm>
7#include <limits>
8#include <map>
9#include <memory>
10
15
16#include "JDAQ/JDAQEventIO.hh"
19
21
23
28
30
34#include "JSupport/JSupport.hh"
35#include "JSupport/JMeta.hh"
37
38#include "JFit/JEnergy.hh"
40
47
48#include "Jeep/JParser.hh"
49#include "Jeep/JMessage.hh"
50
51
52/**
53 * \file
54 *
55 * Program to perform JFIT::JRegressor<JEnergy, JGandalf> fit using I/O of JFIT::JEvt data.
56 * \author mdejong
57 */
58int main(int argc, char **argv)
59{
60 using namespace std;
61 using namespace JPP;
62 using namespace KM3NETDAQ;
63
65 typedef JParallelFileScanner< JTypeList<JDAQEvent, JFIT::JEvt> > JParallelFileScanner_t;
66 typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
68 JACOUSTICS::JEvt>::typelist calibration_types;
69 typedef JMultipleFileScanner<calibration_types> JCalibration_t;
70
71 JParallelFileScanner_t inputFile;
73 JLimit_t& numberOfEvents = inputFile.getLimit();
74 string detectorFile;
75 JCalibration_t calibrationFile;
76 double Tmax_s;
77 string pdfFile;
78 JEnergyCorrection correct;
79 JMuonEnergyParameters_t parameters;
80 JPMTParametersMap pmtParameters;
81 size_t threads; // number of parallel threads
82 int debug;
83
84 try {
85
86 JParser<> zap("Program to perform fit of muon energy to data.");
87
88 zap['f'] = make_field(inputFile);
89 zap['o'] = make_field(outputFile) = "energy.root";
90 zap['a'] = make_field(detectorFile);
91 zap['+'] = make_field(calibrationFile) = JPARSER::initialised();
92 zap['T'] = make_field(Tmax_s) = 100.0;
93 zap['n'] = make_field(numberOfEvents) = JLimit::max();
94 zap['F'] = make_field(pdfFile);
95 zap['P'] = make_field(pmtParameters, "PMT simulation data (or corresponding file name)") = JPARSER::initialised();
96 zap['E'] = make_field(correct) = JEnergyCorrection(); // off
97 zap['@'] = make_field(parameters) = JPARSER::initialised();
98 zap['N'] = make_field(threads, "number of threads") = 0;
99 zap['d'] = make_field(debug) = 1;
100
101 zap(argc, argv);
102 }
103 catch(const exception& error) {
104 FATAL(error.what() << endl);
105 }
106
107
109
111
112 try {
113 load(detectorFile, detector);
114 }
115 catch(const JException& error) {
116 FATAL(error);
117 }
118
119 unique_ptr<JDynamics> dynamics;
120
121 if (!calibrationFile.empty()) {
122
123 try {
124
125 dynamics.reset(new JDynamics(detector, Tmax_s));
126
127 dynamics->load(calibrationFile);
128 }
129 catch(const exception& error) {
130 FATAL(error.what());
131 }
132 }
133
134 outputFile.open();
135 outputFile.put(JMeta(argc, argv));
136
137 {
138 const JModuleRouter router(dynamics ? dynamics->getDetector() : detector);
139
140 JSummaryFileRouter summary(inputFile);
141
142 const JMuonEnergy::storage_type storage(pdfFile, JTimeRange(parameters.TMin_ns, parameters.TMax_ns));
143
144 JMuonEnergy fit(parameters, storage, pmtParameters, correct, debug);
145
146 JMultiThreadedReconstruction<JMuonEnergy> fits(fit, outputFile, threads, 2 * threads);
147
148 while (inputFile.hasNext()) {
149
150 STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
151
152 multi_pointer_type ps = inputFile.next();
153
154 const JDAQEvent* tev = ps;
155 const JFIT::JEvt* in = ps;
156
157 summary.update(*tev);
158
159 if (dynamics) {
160 dynamics->update(*tev);
161 }
162
163 auto input = fit.getInput(router, summary, *tev, *in, dynamics ? dynamics->getCoverage() : coverage_type());
164
165 if (threads > 0)
166 fits.enqueue(input);
167 else
168 outputFile.put(fit(input));
169 }
170 STATUS(endl);
171 }
172
174
175 io >> outputFile;
176
177 outputFile.close();
178}
Definition of hit and track types and auxiliary methods for handling Monte Carlo data.
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:72
ROOT I/O of application specific meta data.
Direct access to module in detector data structure.
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
Acoustic event fit.
Orientation of module.
Dynamic detector calibration.
Definition JDynamics.hh:86
Data structure for coverage of detector by dynamical calibrations.
Definition JCoverage.hh:19
Auxiliary class for recursive type list generation.
Definition JTypeList.hh:351
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