Jpp  18.3.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JShowerPrefit.cc File Reference
#include <limits>
#include "km3net-dataformat/offline/Head.hh"
#include "km3net-dataformat/offline/MultiHead.hh"
#include "km3net-dataformat/offline/Evt.hh"
#include "JDAQ/JDAQEventIO.hh"
#include "JDAQ/JDAQTimesliceIO.hh"
#include "JDAQ/JDAQSummarysliceIO.hh"
#include "JDAQ/JDAQEvaluator.hh"
#include "JTrigger/JTriggerParameters.hh"
#include "JDetector/JModuleRouter.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDynamics/JDynamics.hh"
#include "JSupport/JSupport.hh"
#include "JSupport/JSingleFileScanner.hh"
#include "JSupport/JTreeScanner.hh"
#include "JSupport/JFileRecorder.hh"
#include "JSupport/JMeta.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
#include "JReconstruction/JEvt.hh"
#include "JReconstruction/JShowerPrefit.hh"
#include "JReconstruction/JShowerPrefitParameters_t.hh"
#include "JLang/JSharedPointer.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

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;
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 }
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
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
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
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
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
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 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:48
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