Jpp master_rocky-44-g75b7c4f75
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
14
16
18#include "JSupport/JSupport.hh"
20#include "JSupport/JMeta.hh"
23
24#include "Jeep/JParser.hh"
25#include "Jeep/JMessage.hh"
26
30
32
33
34/**
35 * \file
36 *
37 * Program to perform EM Shower Second Position Fit for ORCA with I/O of JFIT::JEvt data.
38 * The reconstruction is made at the HIT level.
39 * \author adomi
40 */
41
42int main(int argc, char** argv){
43
44 using namespace std;
45 using namespace JPP;
46
48 typedef JParallelFileScanner< JTypeList<JDAQEvent, JFIT::JEvt> > JParallelFileScanner_t;
49 typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
51 JACOUSTICS::JEvt>::typelist calibration_types;
52 typedef JMultipleFileScanner<calibration_types> JCalibration_t;
53
54
55 JParallelFileScanner_t inputFile;
58 JLimit_t& numberOfEvents = inputFile.getLimit();
59 string detectorFile;
60 string pdfFile;
61 JCalibration_t calibrationFile;
62 double Tmax_s;
63 int debug;
64
65 try {
66
67 JParser<> zap;
68
69 zap['f'] = make_field(inputFile) ;
70 zap['o'] = make_field(outputFile) = "JShowerPositionFit.root";
71 zap['a'] = make_field(detectorFile) ;
72 zap['+'] = make_field(calibrationFile) = JPARSER::initialised();
73 zap['T'] = make_field(Tmax_s) = 100.0;
74 zap['F'] = make_field(pdfFile) ;
75 zap['@'] = make_field(parameters) = JPARSER::initialised();
76 zap['n'] = make_field(numberOfEvents) = JLimit::max();
77 zap['d'] = make_field(debug) = 2;
78
79 zap(argc, argv);
80 }
81 catch(const exception& error) {
82 FATAL(error.what() << endl);
83 }
84
86
87 try {
88 load(detectorFile, detector);
89 }
90 catch(const JException& error) {
91 FATAL(error);
92 }
93
94 unique_ptr<JDynamics> dynamics;
95
96 try {
97
98 dynamics.reset(new JDynamics(detector, Tmax_s));
99
100 dynamics->load(calibrationFile);
101 }
102 catch(const exception& error) {
103 if (!calibrationFile.empty()) {
104 FATAL(error.what());
105 }
106 }
107
108 const JModuleRouter router(dynamics ? dynamics->getDetector() : detector);
109
110 outputFile.open();
111 outputFile.put(JMeta(argc, argv));
112
113 JSummaryFileRouter summary(inputFile, parameters.R_Hz);
114
115 JShowerPositionFit fit(parameters, router, summary, pdfFile, debug);
116
117 while (inputFile.hasNext()) {
118
119 STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
120
121 multi_pointer_type ps = inputFile.next();
122
123 JDAQEvent* tev = ps;
124 JFIT::JEvt* in = ps;
125
126 summary.update(*tev);
127
128 if (dynamics) {
129 dynamics->update(*tev);
130 }
131
132 // select start values
133 JFIT::JEvt cp = *in;
134
135 cp.select(parameters.numberOfPrefits, qualitySorter);
136
137 if (!cp.empty()) {
138 cp.select(JHistory::is_event(cp.begin()->getHistory()));
139 }
140
141 // fit
142 JFIT::JEvt out = fit(*tev, cp);
143
144 if (dynamics) {
145
146 const JDynamics::coverage_type coverage = dynamics->getCoverage();
147
148 for (JFIT::JEvt::iterator i = out.begin(); i != out.end(); ++i) {
149 i->setW(JPP_COVERAGE_ORIENTATION, coverage.orientation);
150 i->setW(JPP_COVERAGE_POSITION, coverage.position);
151 }
152 }
153
154 // apply default sorter
155
156 sort(out.begin(), out.end(), qualitySorter);
157
158 copy(in->begin(), in->end(), back_inserter(out));
159
160 outputFile.put(out);
161
162 }
163 STATUS(endl);
164
166
167 io >> outputFile;
168
169 outputFile.close();
170}
string outputFile
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:69
ROOT I/O of application specific meta data.
Direct access to module in detector data structure.
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.
Data structure for set of track fit results.
void select(const JSelector_t &selector)
Select fits.
General exception.
Definition JException.hh:24
Utility class to parse command line options.
Definition JParser.hh:1698
class to handle the second position fit of the shower reconstruction, mainly dedicated for ORCA
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.
static const int JPP_COVERAGE_POSITION
coverage of dynamic position calibration from any Jpp application
static const int JPP_COVERAGE_ORIENTATION
coverage of dynamic orientation calibration from any Jpp application
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition JHead.cc:162
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).
bool qualitySorter(const JFit &first, const JFit &second)
Comparison of fit results.
Detector file.
Definition JHead.hh:227
Acoustic event fit.
Orientation of module.
Data structure for coverage of dynamic calibrations.
Definition JDynamics.hh:573
double position
coverage of detector by available position calibration [0,1]
Definition JDynamics.hh:575
double orientation
coverage of detector by available orientation calibration [0,1]
Definition JDynamics.hh:574
Dynamic detector calibration.
Definition JDynamics.hh:84
Auxiliary class to test history.
Definition JHistory.hh:105
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 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