Jpp  18.1.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JShowerPrefit.cc
Go to the documentation of this file.
1 #include <limits>
2 
6 
7 #include "JDAQ/JDAQEventIO.hh"
10 #include "JDAQ/JDAQEvaluator.hh"
11 
13 
15 #include "JDetector/JDetectorToolkit.hh"// <- to enable: load
17 
18 #include "JDynamics/JDynamics.hh"
19 
20 #include "JSupport/JSupport.hh"
22 #include "JSupport/JTreeScanner.hh"
23 #include "JSupport/JFileRecorder.hh"
24 #include "JSupport/JMeta.hh"
25 
26 #include "Jeep/JParser.hh"
27 #include "Jeep/JMessage.hh"
28 
29 #include "JTools/JPermutation.hh"
30 
31 #include "JReconstruction/JEvt.hh"
34 
35 #include "JLang/JSharedPointer.hh"
36 
37 /**
38  * \author adomi
39  */
40 
41 int main(int argc, char **argv)
42 {
43  using namespace std;
44  using namespace JPP;
45  using namespace KM3NETDAQ;
46 
49  JACOUSTICS::JEvt>::typelist calibration_types;
50  typedef JMultipleFileScanner<calibration_types> JCalibration_t;
51 
54  JLimit_t& numberOfEvents = inputFile.getLimit();
55  string detectorFile;
56  JCalibration_t calibrationFile;
57  double Tmax_s;
59  int debug;
60 
61  try {
62 
63  JParser<> zap("Program to perform position pre-fit of shower to data.");
64 
65  zap['f'] = make_field(inputFile);
66  zap['o'] = make_field(outputFile) = "ShowerPrefit.root";
67  zap['a'] = make_field(detectorFile);
68  zap['+'] = make_field(calibrationFile) = JPARSER::initialised();
69  zap['T'] = make_field(Tmax_s) = 100.0;
71  zap['n'] = make_field(numberOfEvents) = JLimit::max();
72  zap['d'] = make_field(debug) = 2;
73 
74  zap(argc, argv);
75  }
76  catch(const exception& error) {
77  FATAL(error.what() << endl);
78  }
79 
80 
82 
83  try {
84  load(detectorFile, detector);
85  }
86  catch(const JException& error) {
87  FATAL(error);
88  }
89 
90  unique_ptr<JDynamics> dynamics;
91 
92  try {
93 
94  dynamics.reset(new JDynamics(detector, Tmax_s));
95 
96  dynamics->load(calibrationFile);
97  }
98  catch(const exception& error) {
99  if (!calibrationFile.empty()) {
100  FATAL(error.what());
101  }
102  }
103 
104  const JModuleRouter router(dynamics ? dynamics->getDetector() : detector);
105 
106  JShowerPrefit fit(parameters, router, debug);
107 
108  outputFile.open();
109  outputFile.put(JMeta(argc, argv));
110 
111  JTreeScanner<JDAQEvent, JDAQEvaluator> in (inputFile, inputFile.getLimit());
112 
113  while (in.hasNext()) {
114 
115  STATUS("event: " << setw(10) << in.getCounter() << '\r'); DEBUG(endl);
116 
117  const JDAQEvent* tev = in.next();
118 
119  JFIT::JEvt out = fit(*tev);
120 
121  if (dynamics) {
122 
123  const JDynamics::coverage_type coverage = dynamics->getCoverage();
124 
125  for (JFIT::JEvt::iterator i = out.begin(); i != out.end(); ++i) {
126  i->setW(JPP_COVERAGE_ORIENTATION, coverage.orientation);
127  i->setW(JPP_COVERAGE_POSITION, coverage.position);
128  }
129  }
130 
131  if (parameters.numberOfPrefits > 0) {
132 
133  // apply default sorter
134 
135  JFIT::JEvt::iterator __end = out.end();
136 
137  if (parameters.numberOfPrefits < out.size()) {
138 
139  advance(__end = out.begin(), parameters.numberOfPrefits);
140 
141  partial_sort(out.begin(), __end, out.end(), qualitySorter);
142 
143  out.erase(__end, out.end());
144 
145  } else {
146 
147  sort(out.begin(), __end, qualitySorter);
148  }
149 
150  } else {
151 
152  sort(out.begin(), out.end(), qualitySorter);
153  }
154 
155  outputFile.put(*tev);
156  outputFile.put(out);
157 
158  }
159 
160  STATUS(endl);
161 
163 
164  io >> outputFile;
165 
166  outputFile.close();
167 }
168 
169 
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:1514
General exception.
Definition: JException.hh:24
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.
*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:83
class to handle first step of the shower reconstruction in ORCA: it reconstructs the shower vertex...
string outputFile
Template definition for direct access of elements in ROOT TChain.
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: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
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:1989
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
counter_type advance(counter_type &counter, const counter_type value, const counter_type limit=std::numeric_limits< counter_type >::max())
Advance counter.
#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.
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
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 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:46
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