Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JMuonStart.cc File Reference

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

Author
mdejong, azegarelli, scelli

Definition in file software/JReconstruction/JMuonStart.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 54 of file software/JReconstruction/JMuonStart.cc.

55{
56 using namespace std;
57 using namespace JPP;
58 using namespace KM3NETDAQ;
59
61 typedef JParallelFileScanner< JTypeList<JDAQEvent, JFIT::JEvt> > JParallelFileScanner_t;
62 typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
64 JACOUSTICS::JEvt>::typelist calibration_types;
65 typedef JMultipleFileScanner<calibration_types> JCalibration_t;
66
67 JParallelFileScanner_t inputFile;
69 JLimit_t& numberOfEvents = inputFile.getLimit();
70 string detectorFile;
71 JCalibration_t calibrationFile;
72 double Tmax_s;
73 string pdfFile;
74 JMuonStartParameters_t parameters;
75 JK40Rates rates_Hz;
76 size_t threads; // number of parallel threads
77 int debug;
78
79 try {
80
81 JParser<> zap("Program to perform PDF fit of muon trajectory to data.");
82
83 zap['f'] = make_field(inputFile);
84 zap['o'] = make_field(outputFile) = "start.root";
85 zap['a'] = make_field(detectorFile);
86 zap['+'] = make_field(calibrationFile) = JPARSER::initialised();
87 zap['T'] = make_field(Tmax_s) = 100.0;
88 zap['n'] = make_field(numberOfEvents) = JLimit::max();
89 zap['P'] = make_field(pdfFile);
90 zap['@'] = make_field(parameters) = JPARSER::initialised();
91 zap['B'] = make_field(rates_Hz) = KM3NET::getK40Rates();
92 zap['N'] = make_field(threads, "number of threads") = 0;
93 zap['d'] = make_field(debug) = 1;
94
95 zap(argc, argv);
96 }
97 catch(const exception& error) {
98 FATAL(error.what() << endl);
99 }
100
101
103
105
106 try {
107 load(detectorFile, detector);
108 }
109 catch(const JException& error) {
110 FATAL(error);
111 }
112
113 unique_ptr<JDynamics> dynamics;
114
115 if (!calibrationFile.empty()) {
116
117 try {
118
119 dynamics.reset(new JDynamics(detector, Tmax_s));
120
121 dynamics->load(calibrationFile);
122 }
123 catch(const exception& error) {
124 FATAL(error.what());
125 }
126 }
127
128 outputFile.open();
129 outputFile.put(JMeta(argc, argv));
130
131 {
132 const JModuleRouter router(dynamics ? dynamics->getDetector() : detector);
133
134 JSummaryFileRouter summary(inputFile);
135
136 const JMuonStart::storage_type storage(pdfFile, JTimeRange(parameters.TMin_ns, parameters.TMax_ns));
137
138 JMuonStart fit(parameters, storage, rates_Hz, debug);
139
140 JMultiThreadedReconstruction<JMuonStart> fits(fit, outputFile, threads, 2 * threads);
141
142 while (inputFile.hasNext()) {
143
144 STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
145
146 multi_pointer_type ps = inputFile.next();
147
148 const JDAQEvent* tev = ps;
149 const JFIT::JEvt* in = ps;
150
151 summary.update(*tev);
152
153 if (dynamics) {
154 dynamics->update(*tev);
155 }
156
157 auto input = fit.getInput(router, summary, *tev, *in, dynamics ? dynamics->getCoverage() : coverage_type());
158
159 if (threads > 0)
160 fits.enqueue(input);
161 else
162 outputFile.put(fit(input));
163 }
164 STATUS(endl);
165 }
166
168
169 io >> outputFile;
170
171 outputFile.close();
172}
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
Thread pool for event-by-event reconstruction.
Auxiliary class to determine start and end position of muon trajectory.
Definition JMuonStart.hh:76
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
const JK40Rates & getK40Rates()
Get K40 rates.
Definition KM3NeT.hh:36
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
Auxiliary class for K40 rates.
Definition JK40Rates.hh:41
Data structure for fit parameters.
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