Jpp 20.0.0-195-g190c9e876
the software that should make you happy
Loading...
Searching...
No Matches
JShowerPositionFit.cc
Go to the documentation of this file.
1#include <string>
2#include <limits>
3
7
8#include "JDAQ/JDAQEventIO.hh"
11
13
18
20
21#include "JSupport/JSupport.hh"
26#include "JSupport/JMeta.hh"
27
32
33#include "Jeep/JParser.hh"
34#include "Jeep/JMessage.hh"
35
36
37/**
38 * \file
39 *
40 * Program to perform EM Shower Second Position Fit for ORCA with I/O of JFIT::JEvt data.
41 * The reconstruction is made at the HIT level.
42 * \author adomi vcarretero
43 */
44
45int main(int argc, char** argv){
46
47 using namespace std;
48 using namespace JPP;
49
51 typedef JParallelFileScanner< JTypeList<JDAQEvent, JFIT::JEvt> > JParallelFileScanner_t;
52 typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
53 typedef JMultipleFileScanner<calibration_types> JCalibration_t;
54
55 JParallelFileScanner_t inputFile;
57 JLimit_t& numberOfEvents = inputFile.getLimit();
58 string detectorFile;
59 JCalibration_t calibrationFile;
60 double Tmax_s;
61 string pdfFile;
63 JPMTParametersMap pmtParameters;
64 size_t threads;
65 int debug;
66
67 try {
68
69 JParser<> zap;
70
71 zap['f'] = make_field(inputFile);
72 zap['o'] = make_field(outputFile);
73 zap['n'] = make_field(numberOfEvents) = JLimit::max();
74 zap['a'] = make_field(detectorFile);
75 zap['+'] = make_field(calibrationFile, "dynamical calibration data") = JPARSER::initialised();
76 zap['T'] = make_field(Tmax_s, "dynamical update time [s]") = 100.0;
77 zap['F'] = make_field(pdfFile, "PDFs");
78 zap['@'] = make_field(parameters, "fit parameters") = JPARSER::initialised();
79 zap['P'] = make_field(pmtParameters, "PMT parameters") = JPARSER::initialised();
80 zap['N'] = make_field(threads, "number of threads") = 0;
81 zap['d'] = make_field(debug) = 1;
82
83 zap(argc, argv);
84 }
85 catch(const exception& error) {
86 FATAL(error.what() << endl);
87 }
88
89
91
93
94 try {
95 load(detectorFile, detector);
96 }
97 catch(const JException& error) {
98 FATAL(error);
99 }
100
101 unique_ptr<JDynamics> dynamics;
102
103 if (!calibrationFile.empty()) {
104 try {
105
106 dynamics.reset(new JDynamics(detector, Tmax_s));
107
108 dynamics->load(calibrationFile);
109 }
110 catch(const exception& error) {
111 FATAL(error.what());
112 }
113 }
114
115 const JModuleRouter router(dynamics ? dynamics->getDetector() : detector);
116
117 outputFile.open();
118 outputFile.put(JMeta(argc, argv));
119
120 JSummaryFileRouter summary(inputFile);
121
122 {
123 const JShowerPositionFit::storage_type storage(pdfFile, JTimeRange(parameters.TMin_ns, parameters.TMax_ns), parameters.TTS_ns);
124
125 JShowerPositionFit fit(parameters, storage, pmtParameters, debug);
126
127 JMultiThreadedReconstruction<JShowerPositionFit> fits(fit, outputFile, threads, 2 * threads);
128
129 while (inputFile.hasNext()) {
130
131 STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
132
133 multi_pointer_type ps = inputFile.next();
134
135 JDAQEvent* tev = ps;
136 JFIT::JEvt* in = ps;
137
138 summary.update(*tev);
139
140 if (dynamics) {
141 dynamics->update(*tev);
142 }
143
144 auto input = fit.getInput(router, summary, *tev, *in, dynamics ? dynamics->getCoverage() : coverage_type());
145
146 if (threads > 0)
147 fits.enqueue(input);
148 else
149 outputFile.put(fit(input));
150
151 }
152 STATUS(endl);
153 }
154
156
157 io >> outputFile;
158
159 outputFile.close();
160}
string outputFile
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
int main(int argc, char **argv)
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
Thread pool for event-by-event reconstruction.
class to handle the second position fit of the shower reconstruction, mainly dedicated for ORCA
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.
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
double TMin_ns
minimum time for local coincidences [ns]
double TMax_ns
maximum time for local coincidences [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