Jpp 20.0.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JMuonEnergy.cc File Reference

Program to perform JFIT::JRegressor<JEnergy, JGandalf> fit using 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<JEnergy, JGandalf> fit using I/O of JFIT::JEvt data.

Author
mdejong

Definition in file JMuonEnergy.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 58 of file JMuonEnergy.cc.

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}
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: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.
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.
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
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