Jpp master_rocky-44-g75b7c4f75
the software that should make you happy
Loading...
Searching...
No Matches
JShowerPrefit.cc File Reference

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int argc,
char ** argv )
Author
adomi

Definition at line 39 of file JShowerPrefit.cc.

40{
41 using namespace std;
42 using namespace JPP;
43 using namespace KM3NETDAQ;
44
47 JACOUSTICS::JEvt>::typelist calibration_types;
48 typedef JMultipleFileScanner<calibration_types> JCalibration_t;
49
52 JLimit_t& numberOfEvents = inputFile.getLimit();
53 string detectorFile;
54 JCalibration_t calibrationFile;
55 double Tmax_s;
57 int debug;
58
59 try {
60
61 JParser<> zap("Program to perform position pre-fit of shower to data.");
62
63 zap['f'] = make_field(inputFile);
64 zap['o'] = make_field(outputFile) = "ShowerPrefit.root";
65 zap['a'] = make_field(detectorFile);
66 zap['+'] = make_field(calibrationFile) = JPARSER::initialised();
67 zap['T'] = make_field(Tmax_s) = 100.0;
68 zap['@'] = make_field(parameters) = JPARSER::initialised();
69 zap['n'] = make_field(numberOfEvents) = JLimit::max();
70 zap['d'] = make_field(debug) = 2;
71
72 zap(argc, argv);
73 }
74 catch(const exception& error) {
75 FATAL(error.what() << endl);
76 }
77
78
80
81 try {
82 load(detectorFile, detector);
83 }
84 catch(const JException& error) {
85 FATAL(error);
86 }
87
88 unique_ptr<JDynamics> dynamics;
89
90 try {
91
92 dynamics.reset(new JDynamics(detector, Tmax_s));
93
94 dynamics->load(calibrationFile);
95 }
96 catch(const exception& error) {
97 if (!calibrationFile.empty()) {
98 FATAL(error.what());
99 }
100 }
101
102 const JModuleRouter router(dynamics ? dynamics->getDetector() : detector);
103
104 JShowerPrefit fit(parameters, router, debug);
105
106 outputFile.open();
107 outputFile.put(JMeta(argc, argv));
108
109 JTreeScanner<JDAQEvent, JDAQEvaluator> in (inputFile, inputFile.getLimit());
110
111 while (in.hasNext()) {
112
113 STATUS("event: " << setw(10) << in.getCounter() << '\r'); DEBUG(endl);
114
115 const JDAQEvent* tev = in.next();
116
117 JFIT::JEvt out = fit(*tev);
118
119 if (dynamics) {
120
121 const JDynamics::coverage_type coverage = dynamics->getCoverage();
122
123 for (JFIT::JEvt::iterator i = out.begin(); i != out.end(); ++i) {
124 i->setW(JPP_COVERAGE_ORIENTATION, coverage.orientation);
125 i->setW(JPP_COVERAGE_POSITION, coverage.position);
126 }
127 }
128
129 if (parameters.numberOfPrefits > 0) {
130
131 // apply default sorter
132
133 JFIT::JEvt::iterator __end = out.end();
134
135 if (parameters.numberOfPrefits < out.size()) {
136
137 advance(__end = out.begin(), parameters.numberOfPrefits);
138
139 partial_sort(out.begin(), __end, out.end(), qualitySorter);
140
141 out.erase(__end, out.end());
142
143 } else {
144
145 sort(out.begin(), __end, qualitySorter);
146 }
147
148 } else {
149
150 sort(out.begin(), out.end(), qualitySorter);
151 }
152
153 outputFile.put(*tev);
154 outputFile.put(out);
155
156 }
157
158 STATUS(endl);
159
161
162 io >> outputFile;
163
164 outputFile.close();
165}
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:69
#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
class to handle first step of the shower reconstruction in ORCA: it reconstructs the shower vertex,...
Object writing to file.
General purpose class for object reading from a list of file names.
Object reading from a list of files.
Template definition for direct access of elements in ROOT TChain.
JTriggerCounter_t next()
Increment trigger counter.
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 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.
counter_type advance(counter_type &counter, const counter_type value, const counter_type limit=std::numeric_limits< counter_type >::max())
Advance counter.
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
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 for recursive type list generation.
Definition JTypeList.hh:351
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
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