Jpp 20.0.0-195-g190c9e876
the software that should make you happy
Loading...
Searching...
No Matches
software/JReconstruction/JMuonStart.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 <memory>
7
12
13#include "JDAQ/JDAQEventIO.hh"
16
18
23
25
26#include "JSupport/JSupport.hh"
32#include "JSupport/JMeta.hh"
33
39
40#include "JPhysics/JK40Rates.hh"
41#include "JPhysics/KM3NeT.hh"
42
43#include "Jeep/JPrint.hh"
44#include "Jeep/JParser.hh"
45#include "Jeep/JMessage.hh"
46
47/**
48 * \file
49 *
50 * Program to perform JFIT::JRegressor<JEnergy> fit with I/O of JFIT::JEvt data.
51 * \author mdejong, azegarelli, scelli
52 */
53int main(int argc, char **argv)
54{
55 using namespace std;
56 using namespace JPP;
57 using namespace KM3NETDAQ;
58
60 typedef JParallelFileScanner< JTypeList<JDAQEvent, JFIT::JEvt> > JParallelFileScanner_t;
61 typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
62 typedef JMultipleFileScanner<calibration_types> JCalibration_t;
63
64 JParallelFileScanner_t inputFile;
66 JLimit_t& numberOfEvents = inputFile.getLimit();
67 string detectorFile;
68 JCalibration_t calibrationFile;
69 double Tmax_s;
70 string pdfFile;
71 JMuonStartParameters_t parameters;
72 JK40Rates rates_Hz;
73 size_t threads; // number of parallel threads
74 int debug;
75
76 try {
77
78 JParser<> zap("Program to perform PDF fit of muon trajectory to data.");
79
80 zap['f'] = make_field(inputFile);
81 zap['o'] = make_field(outputFile);
82 zap['n'] = make_field(numberOfEvents) = JLimit::max();
83 zap['a'] = make_field(detectorFile);
84 zap['+'] = make_field(calibrationFile, "dynamical calibration data") = JPARSER::initialised();
85 zap['T'] = make_field(Tmax_s, "dynamical update time [s]") = 100.0;
86 zap['F'] = make_field(pdfFile, "PDFs");
87 zap['@'] = make_field(parameters, "fit parameters") = JPARSER::initialised();
88 zap['B'] = make_field(rates_Hz, "coincidence rates [Hz]") = KM3NET::getK40Rates();
89 zap['N'] = make_field(threads, "number of threads") = 0;
90 zap['d'] = make_field(debug) = 1;
91
92 zap(argc, argv);
93 }
94 catch(const exception& error) {
95 FATAL(error.what() << endl);
96 }
97
98
100
102
103 try {
104 load(detectorFile, detector);
105 }
106 catch(const JException& error) {
107 FATAL(error);
108 }
109
110 unique_ptr<JDynamics> dynamics;
111
112 if (!calibrationFile.empty()) {
113
114 try {
115
116 dynamics.reset(new JDynamics(detector, Tmax_s));
117
118 dynamics->load(calibrationFile);
119 }
120 catch(const exception& error) {
121 FATAL(error.what());
122 }
123 }
124
125 outputFile.open();
126 outputFile.put(JMeta(argc, argv));
127
128 {
129 const JModuleRouter router(dynamics ? dynamics->getDetector() : detector);
130
131 JSummaryFileRouter summary(inputFile);
132
133 const JMuonStart::storage_type storage(pdfFile, JTimeRange(parameters.TMin_ns, parameters.TMax_ns));
134
135 JMuonStart fit(parameters, storage, rates_Hz, debug);
136
137 JMultiThreadedReconstruction<JMuonStart> fits(fit, outputFile, threads, 2 * threads);
138
139 while (inputFile.hasNext()) {
140
141 STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
142
143 multi_pointer_type ps = inputFile.next();
144
145 const JDAQEvent* tev = ps;
146 const JFIT::JEvt* in = ps;
147
148 summary.update(*tev);
149
150 if (dynamics) {
151 dynamics->update(*tev);
152 }
153
154 auto input = fit.getInput(router, summary, *tev, *in, dynamics ? dynamics->getCoverage() : coverage_type());
155
156 if (threads > 0)
157 fits.enqueue(input);
158 else
159 outputFile.put(fit(input));
160 }
161 STATUS(endl);
162 }
163
165
166 io >> outputFile;
167
168 outputFile.close();
169}
string outputFile
Auxiliary class to extract a subset of optical modules from a detector.
Data structure for detector geometry and calibration.
Dynamic detector calibration.
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...
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
I/O formatting auxiliaries.
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.
Properties of KM3NeT PMT and deep-sea water.
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
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
int main(int argc, char **argv)
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
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