Jpp  18.3.0-209-g56ce19a
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JMuonPrefit.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"
11 #include "JDAQ/JDAQTimesliceIO.hh"
13 #include "JDAQ/JDAQEvaluator.hh"
14 
16 
17 #include "JDetector/JDetector.hh"
20 
21 #include "JDynamics/JDynamics.hh"
22 
23 #include "JSupport/JSupport.hh"
25 #include "JSupport/JTreeScanner.hh"
26 #include "JSupport/JFileRecorder.hh"
27 #include "JSupport/JMeta.hh"
28 
29 #include "JReconstruction/JEvt.hh"
32 
33 #include "JLang/JPredicate.hh"
34 #include "JLang/JComparison.hh"
35 
36 #include "Jeep/JParser.hh"
37 #include "Jeep/JMessage.hh"
38 
39 
40 /**
41  * \file
42  *
43  * Program to perform linear fits JFIT::JEstimator<JFIT::JLine1Z> covering the solid angle producing JFIT::JEvt data.
44  *
45  * \author mdejong, gmaggi, azegarelli
46  */
47 int main(int argc, char **argv)
48 {
49  using namespace std;
50  using namespace JPP;
51  using namespace KM3NETDAQ;
52 
56  JACOUSTICS::JEvt>::typelist calibration_types;
57  typedef JMultipleFileScanner<calibration_types> JCalibration_t;
58 
59  JSingleFileScanner_t inputFile;
61  JLimit_t& numberOfEvents = inputFile.getLimit();
62  string detectorFile;
63  JCalibration_t calibrationFile;
64  double Tmax_s;
66  int debug;
67 
68  try {
69 
70  JParser<> zap("Program to perform pre-fit of muon trajectory to data.");
71 
72  zap['f'] = make_field(inputFile);
73  zap['o'] = make_field(outputFile) = "prefit.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['n'] = make_field(numberOfEvents) = JLimit::max();
79  zap['d'] = make_field(debug) = 1;
80 
81  zap(argc, argv);
82  }
83  catch(const exception& error) {
84  FATAL(error.what() << endl);
85  }
86 
87 
89 
90  try {
91  load(detectorFile, detector);
92  }
93  catch(const JException& error) {
94  FATAL(error);
95  }
96 
97  unique_ptr<JDynamics> dynamics;
98 
99  try {
100 
101  dynamics.reset(new JDynamics(detector, Tmax_s));
102 
103  dynamics->load(calibrationFile);
104  }
105  catch(const exception& error) {
106  if (!calibrationFile.empty()) {
107  FATAL(error.what());
108  }
109  }
110 
111  const JModuleRouter router(dynamics ? dynamics->getDetector() : detector);
112 
113  JMuonPrefit fit(parameters, router, debug);
114 
115 
116  outputFile.open();
117  outputFile.put(JMeta(argc, argv));
118 
119  JTreeScanner<JDAQEvent, JDAQEvaluator> in (inputFile, inputFile.getLimit());
120 
121  while (in.hasNext()) {
122 
123  STATUS("event: " << setw(10) << in.getCounter() << '\r'); DEBUG(endl);
124 
125  const JDAQEvent* tev = in.next();
126 
127  if (dynamics) {
128  dynamics->update(*tev);
129  }
130 
131  JFIT::JEvt out = fit(*tev);
132 
133  if (dynamics) {
134 
135  const JDynamics::coverage_type coverage = dynamics->getCoverage();
136 
137  for (JFIT::JEvt::iterator i = out.begin(); i != out.end(); ++i) {
138  i->setW(JPP_COVERAGE_ORIENTATION, coverage.orientation);
139  i->setW(JPP_COVERAGE_POSITION, coverage.position);
140  }
141  }
142 
143  // apply default sorter
144 
145  sort(out.begin(), out.end(), qualitySorter);
146 
147  outputFile.put(*tev);
148  outputFile.put(out);
149 
150  }
151 
152 
153  STATUS(endl);
154 
156 
157  io >> outputFile;
158 
159  outputFile.close();
160 
161 }
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:1711
General exception.
Definition: JException.hh:24
Wrapper class to make pre-fit of muon trajectory.
Definition: JMuonPrefit.hh:75
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:575
#define STATUS(A)
Definition: JMessage.hh:63
Detector data structure.
Definition: JDetector.hh:89
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.
Data structure for fit parameters.
*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
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:84
string outputFile
Template definition for direct access of elements in ROOT TChain.
Data structure for detector geometry and calibration.
Auxiliary base class for file name.
double orientation
coverage of detector by available orientation calibration [0,1]
Definition: JDynamics.hh:574
Scanning of objects from a single file according a format that follows from the extension of each fil...
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
bool qualitySorter(const JFit &first, const JFit &second)
Comparison of fit results.
Detector file.
Definition: JHead.hh:226
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:2158
ROOT I/O of application specific meta data.
Dynamic detector calibration.
General purpose messaging.
Data structure for coverage of dynamic calibrations.
Definition: JDynamics.hh:573
#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:81
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
Data structure for set of track fit results.
General purpose class for object reading from a list of file names.
then fatal The output file must have the wildcard in the e g root fi eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:48
Utility class to parse command line options.
Orientation of module.
Object reading from a list of files.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:84
do set_variable DETECTOR_TXT $WORKDIR detector
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
static const int JPP_COVERAGE_POSITION
coverage of dynamic position calibration from any Jpp application