Jpp  15.0.4
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JShowerFit.cc
Go to the documentation of this file.
1 #include <string>
2 #include <limits>
3 
6 
7 #include "JDAQ/JDAQEventIO.hh"
10 
13 
14 #include "JDynamics/JDynamics.hh"
15 
17 #include "JSupport/JSupport.hh"
19 #include "JSupport/JMeta.hh"
20 #include "JSupport/JTreeScanner.hh"
22 
23 #include "Jeep/JParser.hh"
24 #include "Jeep/JMessage.hh"
25 
26 #include "JReconstruction/JEvt.hh"
31 
32 #include "JLang/JSharedPointer.hh"
33 
34 /**
35  * \file
36  *
37  * Program to perform EM Shower Fit for ORCA with I/O of JFIT::JEvt data.
38  * The reconstruction is made at the PMT level.
39  * \author adomi
40  */
41 
42 int main(int argc, char** argv){
43 
44  using namespace std;
45  using namespace JPP;
46  using namespace KM3NETDAQ;
47 
49  typedef JParallelFileScanner< JTypeList<JDAQEvent, JFIT::JEvt> > JParallelFileScanner_t;
50  typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
52  JACOUSTICS::JEvt>::typelist calibration_types;
53  typedef JMultipleFileScanner<calibration_types> JCalibration_t;
54 
55 
56  JParallelFileScanner_t inputFile;
59  JLimit_t& numberOfEvents = inputFile.getLimit();
60  string detectorFile;
61  JCalibration_t calibrationFile;
62  double Tmax_s;
63  string pdfFile;
65  int debug;
66 
67  try {
68 
69  JParser<> zap;
70 
71  zap['f'] = make_field(inputFile) ;
72  zap['o'] = make_field(outputFile) = "JORCAShowerFit_Output.root";
73  zap['a'] = make_field(detectorFile) ;
74  zap['+'] = make_field(calibrationFile) = JPARSER::initialised();
75  zap['T'] = make_field(Tmax_s) = 100.0;
76  zap['F'] = make_field(pdfFile) ;
77  zap['E'] = make_field(correct) = JShowerEnergyCorrection(); // off
79  zap['n'] = make_field(numberOfEvents) = JLimit::max();
80  zap['d'] = make_field(debug) = 2;
81 
82  zap(argc, argv);
83  }
84  catch(const exception& error) {
85  FATAL(error.what() << endl);
86  }
87 
89 
90  try {
91  load(detectorFile, detector);
92  }
93  catch(const JException& error) {
94  FATAL(error);
95  }
96 
97  getMechanics.load(detector.getID());
98 
99  unique_ptr<JDynamics> dynamics;
100 
101  try {
102 
103  dynamics.reset(new JDynamics(detector, Tmax_s));
104 
105  dynamics->load(calibrationFile);
106  }
107  catch(const exception& error) {
108  if (!calibrationFile.empty()) {
109  FATAL(error.what());
110  }
111  }
112 
113  const JModuleRouter router(dynamics ? dynamics->getDetector() : detector);
114 
115  JSummaryFileRouter summary(inputFile, parameters.R_Hz);
116 
117  JShowerFit fit(parameters, router, summary, pdfFile, correct, debug);
118 
119  outputFile.open();
120  outputFile.put(JMeta(argc, argv));
121 
122  while (inputFile.hasNext()) {
123 
124  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
125 
126  multi_pointer_type ps = inputFile.next();
127 
128  JDAQEvent* tev = ps;
129  JFIT::JEvt* in = ps;
130 
131  summary.update(*tev);
132 
133  if (dynamics) {
134  dynamics->update(*tev);
135  }
136 
137  // select start values
138  JFIT::JEvt cp = *in;
139 
140  cp.select(parameters.numberOfPrefits, qualitySorter);
141 
142  if (!cp.empty()) {
143  cp.select(JHistory::is_event(cp.begin()->getHistory()));
144  }
145 
146  // fit
147 
148  JFIT::JEvt out = fit(*tev, cp);
149 
150  if (dynamics) {
151 
152  const JDynamics::coverage_type coverage = dynamics->getCoverage();
153 
154  for (JFIT::JEvt::iterator i = out.begin(); i != out.end(); ++i) {
155  i->setW(JPP_COVERAGE_ORIENTATION, coverage.orientation);
156  i->setW(JPP_COVERAGE_POSITION, coverage.position);
157  }
158  }
159 
160  // apply default sorter
161 
162  sort(out.begin(), out.end(), qualitySorter);
163 
164  // reduce output fits
165 
166  JFIT::JEvt::iterator __end = out.end();
167 
168  copy(in->begin(), in->end(), back_inserter(out));
169 
170  outputFile.put(out);
171 
172  }
173  STATUS(endl);
174 
176 
177  io >> outputFile;
178 
179  outputFile.close();
180 }
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:70
Object writing to file.
Utility class to parse command line options.
Definition: JParser.hh:1500
General exception.
Definition: JException.hh:23
int main(int argc, char *argv[])
Definition: Main.cc:15
ROOT TTree parameter settings of various packages.
double position
coverage of detector by available position calibration [0,1]
Definition: JDynamics.hh:536
static JDetectorMechanics getMechanics
Function object to get string mechanics.
Definition: JMechanics.hh:243
#define STATUS(A)
Definition: JMessage.hh:63
Detector data structure.
Definition: JDetector.hh:89
Auxiliary class for correction of energy determined by JShowerEnergy.cc.
Recording of objects on file according a format that follows from the file name extension.
Router for direct addressing of module data in detector data structure.
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Definition: diff-Tuna.sh:38
General purpose class for parallel reading of objects from a single file or multiple files...
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:66
string outputFile
bool qualitySorter(const JFit &first, const JFit &second)
Comparison of fit results.
double orientation
coverage of detector by available orientation calibration [0,1]
Definition: JDynamics.hh:535
Type list.
Definition: JTypeList.hh:22
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
Detector file.
Definition: JHead.hh:196
Acoustic event fit.
Auxiliary class for recursive type list generation.
Definition: JTypeList.hh:351
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
Auxiliary class to test history.
Definition: JHistory.hh:104
Parallel scanning of objects from a single file or multiple files according a format that follows fro...
ROOT I/O of application specific meta data.
Dynamic detector calibration.
File router for fast addressing of summary data.
void load(const std::string &file_name)
Load mechanical model parameters from file.
Definition: JMechanics.hh:142
int debug
debug level
Definition: JSirene.cc:63
General purpose messaging.
Data structure for coverage of dynamic calibrations.
Definition: JDynamics.hh:534
#define FATAL(A)
Definition: JMessage.hh:67
Direct access to module in detector data structure.
static const int JPP_COVERAGE_ORIENTATION
coverage of dynamic orientation calibration from any Jpp application
Dynamic detector calibration.
Definition: JDynamics.hh:61
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
Data structure for set of track fit results.
Data structure for fit parameters.
General purpose class for object reading from a list of file names.
Utility class to parse command line options.
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:139
then cp
Orientation of module.
Object reading from a list of files.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
class to handle the direction fit of the shower reconstruction, mainly dedicated for ORCA ...
Definition: JShowerFit.hh:73
do set_variable DETECTOR_TXT $WORKDIR detector
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:41
void select(const JSelector_t &selector)
Select fits.
then usage $script< detector file >< tripodfile >< stage > input file nInput files correspond to the output of JAcousticsEventBuilder[.sh] nFirst stage eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY eval JPrintDetector a $DETECTOR O CAN source JAcoustics sh $DETECTOR_ID typeset A CONFIGURATION for key in Tmax_s
static const int JPP_COVERAGE_POSITION
coverage of dynamic position calibration from any Jpp application