Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
JMuonFeatures.cc
Go to the documentation of this file.
1#include <string>
2#include <iostream>
3#include <iomanip>
4#include <memory>
5
9
10#include "JDAQ/JDAQEventIO.hh"
13
15
19
21
22#include "JSupport/JSupport.hh"
26#include "JSupport/JMeta.hh"
27
31
32#include "Jeep/JParser.hh"
33#include "Jeep/JMessage.hh"
34
35
36/**
37 * \file
38 *
39 * Program to perform JFIT::JRegressor<JFIT::JLine3Z,JFIT::JGandalf> fit with I/O of JFIT::JEvt data.
40 *
41 * \author eleguirriec, mdejong
42 */
43int main(int argc, char **argv)
44{
45 using namespace std;
46 using namespace JPP;
47 using namespace KM3NETDAQ;
48
50 typedef JParallelFileScanner< JTypeList<JDAQEvent, JFIT::JEvt> > JParallelFileScanner_t;
51 typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
53 JACOUSTICS::JEvt>::typelist calibration_types;
54 typedef JMultipleFileScanner<calibration_types> JCalibration_t;
55
56 JParallelFileScanner_t inputFile;
58 JLimit_t& numberOfEvents = inputFile.getLimit();
59 string detectorFile;
60 JCalibration_t calibrationFile;
61 double Tmax_s;
62 string pdfFile;
63 JMuonGandalfParameters_t parameters;
64 int debug;
65
66 try {
67
68 JParser<> zap("Program to perform PDF fit of muon trajectory to data.");
69
70 zap['f'] = make_field(inputFile);
71 zap['o'] = make_field(outputFile) = "gandalf.root";
72 zap['a'] = make_field(detectorFile);
73 zap['+'] = make_field(calibrationFile) = JPARSER::initialised();
74 zap['T'] = make_field(Tmax_s) = 100.0;
75 zap['n'] = make_field(numberOfEvents) = JLimit::max();
76 zap['P'] = make_field(pdfFile);
77 zap['@'] = make_field(parameters) = JPARSER::initialised();
78 zap['d'] = make_field(debug) = 1;
79
80 zap(argc, argv);
81 }
82 catch(const exception& error) {
83 FATAL(error.what() << endl);
84 }
85
86
88
89 try {
90 load(detectorFile, detector);
91 }
92 catch(const JException& error) {
93 FATAL(error);
94 }
95
96 unique_ptr<JDynamics> dynamics;
97
98 try {
99
100 dynamics.reset(new JDynamics(detector, Tmax_s));
101
102 dynamics->load(calibrationFile);
103 }
104 catch(const exception& error) {
105 if (!calibrationFile.empty()) {
106 FATAL(error.what());
107 }
108 }
109
110 const JModuleRouter router(dynamics ? dynamics->getDetector() : detector);
111
112 JSummaryFileRouter summary(inputFile);
113
114 JMuonFeatures fit(parameters, router, summary, pdfFile, debug);
115
116
117 outputFile.open();
118 outputFile.put(JMeta(argc, argv));
119
120 while (inputFile.hasNext()) {
121
122 STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
123
124 multi_pointer_type ps = inputFile.next();
125
126 const JDAQEvent* tev = ps;
127 const JFIT::JEvt* in = ps;
128
129 summary.update(*tev);
130
131 if (dynamics) {
132 dynamics->update(*tev);
133 }
134
135 // select start values
136
137 JFIT::JEvt cp = *in;
138
139 cp.select(parameters.numberOfPrefits, qualitySorter);
140
141 if (!cp.empty()) {
142 cp.select(JHistory::is_event(cp.begin()->getHistory()));
143 }
144
145 // fit
146
147 JFIT::JEvt out = fit(*tev, cp);
148
149 if (dynamics) {
150
151 const JDynamics::coverage_type coverage = dynamics->getCoverage();
152
153 for (JFIT::JEvt::iterator i = out.begin(); i != out.end(); ++i) {
154 i->setW(JPP_COVERAGE_ORIENTATION, coverage.orientation);
155 i->setW(JPP_COVERAGE_POSITION, coverage.position);
156 }
157 }
158
159 // apply default sorter
160
161 sort(out.begin(), out.end(), qualitySorter);
162
163 copy(in->begin(), in->end(), back_inserter(out));
164
165 outputFile.put(out);
166 }
167 STATUS(endl);
168
170
171 io >> outputFile;
172
173 outputFile.close();
174}
175
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:72
ROOT I/O of application specific meta data.
Direct access to module in detector data structure.
int main(int argc, char **argv)
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
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
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:163
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.
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
double position
coverage of detector by available position calibration [0,1]
Definition JCoverage.hh:42
double orientation
coverage of detector by available orientation calibration [0,1]
Definition JCoverage.hh:41
Auxiliary class to test history.
Definition JHistory.hh:136
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
Wrapper class to add features after the final fit of muon trajectory.
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