Jpp  19.1.0-rc.1
the software that should make you happy
JShowerFit.cc
Go to the documentation of this file.
1 #include <string>
2 #include <limits>
3 
7 
8 #include "JDAQ/JDAQEventIO.hh"
11 
14 
15 #include "JDynamics/JDynamics.hh"
16 
18 #include "JSupport/JSupport.hh"
20 #include "JSupport/JMeta.hh"
21 #include "JSupport/JTreeScanner.hh"
23 
24 #include "Jeep/JParser.hh"
25 #include "Jeep/JMessage.hh"
26 
27 #include "JReconstruction/JEvt.hh"
32 
33 #include "JLang/JSharedPointer.hh"
34 
35 /**
36  * \file
37  *
38  * Program to perform EM Shower Fit for ORCA with I/O of JFIT::JEvt data.
39  * The reconstruction is made at the PMT level.
40  * \author adomi
41  */
42 
43 int 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 
57  JParallelFileScanner_t inputFile;
59  JShowerFitParameters_t parameters;
60  JLimit_t& numberOfEvents = inputFile.getLimit();
61  string detectorFile;
62  JCalibration_t calibrationFile;
63  double Tmax_s;
64  string pdfFile;
66  int debug;
67 
68  try {
69 
70  JParser<> zap;
71 
72  zap['f'] = make_field(inputFile) ;
73  zap['o'] = make_field(outputFile) = "JORCAShowerFit_Output.root";
74  zap['a'] = make_field(detectorFile) ;
75  zap['+'] = make_field(calibrationFile) = JPARSER::initialised();
76  zap['T'] = make_field(Tmax_s) = 100.0;
77  zap['F'] = make_field(pdfFile) ;
78  zap['E'] = make_field(correct) = JShowerEnergyCorrection(); // off
79  zap['@'] = make_field(parameters) = JPARSER::initialised();
80  zap['n'] = make_field(numberOfEvents) = JLimit::max();
81  zap['d'] = make_field(debug) = 2;
82 
83  zap(argc, argv);
84  }
85  catch(const exception& error) {
86  FATAL(error.what() << endl);
87  }
88 
90 
91  try {
92  load(detectorFile, detector);
93  }
94  catch(const JException& error) {
95  FATAL(error);
96  }
97 
98  unique_ptr<JDynamics> dynamics;
99 
100  try {
101 
102  dynamics.reset(new JDynamics(detector, Tmax_s));
103 
104  dynamics->load(calibrationFile);
105  }
106  catch(const exception& error) {
107  if (!calibrationFile.empty()) {
108  FATAL(error.what());
109  }
110  }
111 
112  const JModuleRouter router(dynamics ? dynamics->getDetector() : detector);
113 
114  JSummaryFileRouter summary(inputFile, parameters.R_Hz);
115 
116  JShowerFit fit(parameters, router, summary, pdfFile, correct, debug);
117 
118  outputFile.open();
119  outputFile.put(JMeta(argc, argv));
120 
121  while (inputFile.hasNext()) {
122 
123  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
124 
125  multi_pointer_type ps = inputFile.next();
126 
127  JDAQEvent* tev = ps;
128  JFIT::JEvt* in = ps;
129 
130  summary.update(*tev);
131 
132  if (dynamics) {
133  dynamics->update(*tev);
134  }
135 
136  // select start values
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  // reduce output fits
164 
165  copy(in->begin(), in->end(), back_inserter(out));
166 
167  outputFile.put(out);
168  }
169  STATUS(endl);
170 
172 
173  io >> outputFile;
174 
175  outputFile.close();
176 }
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:2158
int main(int argc, char **argv)
Definition: JShowerFit.cc:43
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.
Auxiliary class for correction of energy determined by JShowerEnergy.cc.
General exception.
Definition: JException.hh:24
Utility class to parse command line options.
Definition: JParser.hh:1714
class to handle the direction fit of the shower reconstruction, mainly dedicated for ORCA
Definition: JShowerFit.hh:75
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.
KM3NeT DAQ data structures and auxiliaries.
Definition: DataQueue.cc:39
Definition: JSTDTypes.hh:14
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:84
Data structure for fit parameters.
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:45
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:84
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:72