Jpp 19.3.0-rc.1
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 59 of file JMuonEnergy.cc.

60{
61 using namespace std;
62 using namespace JPP;
63 using namespace KM3NETDAQ;
64
66 typedef JParallelFileScanner< JTypeList<JDAQEvent, JFIT::JEvt> > JParallelFileScanner_t;
67 typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
69 JACOUSTICS::JEvt>::typelist calibration_types;
70 typedef JMultipleFileScanner<calibration_types> JCalibration_t;
71
72 JParallelFileScanner_t inputFile;
74 JLimit_t& numberOfEvents = inputFile.getLimit();
75 string detectorFile;
76 JCalibration_t calibrationFile;
77 double Tmax_s;
78 string pdfFile;
79 JEnergyCorrection correct;
80 JMuonEnergyParameters_t parameters;
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['P'] = make_field(pdfFile);
95 zap['E'] = make_field(correct) = JEnergyCorrection(); // off
96 zap['@'] = make_field(parameters) = JPARSER::initialised();
97 zap['N'] = make_field(threads, "number of threads") = 0;
98 zap['d'] = make_field(debug) = 1;
99
100 zap(argc, argv);
101 }
102 catch(const exception& error) {
103 FATAL(error.what() << endl);
104 }
105
106
108
110
111 try {
112 load(detectorFile, detector);
113 }
114 catch(const JException& error) {
115 FATAL(error);
116 }
117
118 unique_ptr<JDynamics> dynamics;
119
120 if (!calibrationFile.empty()) {
121
122 try {
123
124 dynamics.reset(new JDynamics(detector, Tmax_s));
125
126 dynamics->load(calibrationFile);
127 }
128 catch(const exception& error) {
129 FATAL(error.what());
130 }
131 }
132
133 outputFile.open();
134 outputFile.put(JMeta(argc, argv));
135
136 {
137 const JModuleRouter router(dynamics ? dynamics->getDetector() : detector);
138
139 JSummaryFileRouter summary(inputFile, parameters.R_Hz);
140
141 const JMuonEnergy::storage_type storage(pdfFile, JTimeRange(parameters.TMin_ns, parameters.TMax_ns));
142
143 JMuonEnergy fit(parameters, storage, correct, debug);
144
145 JMultiThreadedReconstruction<JMuonEnergy> fits(fit, outputFile, threads, 2 * threads);
146
147 while (inputFile.hasNext()) {
148
149 STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
150
151 multi_pointer_type ps = inputFile.next();
152
153 const JDAQEvent* tev = ps;
154 const JFIT::JEvt* in = ps;
155
156 summary.update(*tev);
157
158 if (dynamics) {
159 dynamics->update(*tev);
160 }
161
162 auto input = fit.getInput(router, summary, *tev, *in, dynamics ? dynamics->getCoverage() : coverage_type());
163
164 if (threads > 0)
165 fits.enqueue(input);
166 else
167 outputFile.put(fit(input));
168 }
169 STATUS(endl);
170 }
171
173
174 io >> outputFile;
175
176 outputFile.close();
177}
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.
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