Jpp  17.2.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 "JTools/JPermutation.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 41 of file JShowerPrefit.cc.

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  cout.tie(&cerr);
81 
83 
84  try {
85  load(detectorFile, detector);
86  }
87  catch(const JException& error) {
88  FATAL(error);
89  }
90 
91  getMechanics.load(detector.getID());
92 
93  unique_ptr<JDynamics> dynamics;
94 
95  try {
96 
97  dynamics.reset(new JDynamics(detector, Tmax_s));
98 
99  dynamics->load(calibrationFile);
100  }
101  catch(const exception& error) {
102  if (!calibrationFile.empty()) {
103  FATAL(error.what());
104  }
105  }
106 
107  const JModuleRouter router(dynamics ? dynamics->getDetector() : detector);
108 
109  JShowerPrefit fit(parameters, router, debug);
110 
111  outputFile.open();
112  outputFile.put(JMeta(argc, argv));
113 
114  JTreeScanner<JDAQEvent, JDAQEvaluator> in (inputFile, inputFile.getLimit());
115 
116  while (in.hasNext()) {
117 
118  STATUS("event: " << setw(10) << in.getCounter() << '\r'); DEBUG(endl);
119 
120  const JDAQEvent* tev = in.next();
121 
122  JFIT::JEvt out = fit(*tev);
123 
124  if (dynamics) {
125 
126  const JDynamics::coverage_type coverage = dynamics->getCoverage();
127 
128  for (JFIT::JEvt::iterator i = out.begin(); i != out.end(); ++i) {
129  i->setW(JPP_COVERAGE_ORIENTATION, coverage.orientation);
130  i->setW(JPP_COVERAGE_POSITION, coverage.position);
131  }
132  }
133 
134  if (parameters.numberOfPrefits > 0) {
135 
136  // apply default sorter
137 
138  JFIT::JEvt::iterator __end = out.end();
139 
140  if (parameters.numberOfPrefits < out.size()) {
141 
142  advance(__end = out.begin(), parameters.numberOfPrefits);
143 
144  partial_sort(out.begin(), __end, out.end(), qualitySorter);
145 
146  out.erase(__end, out.end());
147 
148  } else {
149 
150  sort(out.begin(), __end, qualitySorter);
151  }
152 
153  } else {
154 
155  sort(out.begin(), out.end(), qualitySorter);
156  }
157 
158  outputFile.put(*tev);
159  outputFile.put(out);
160 
161  }
162 
163  STATUS(endl);
164 
166 
167  io >> outputFile;
168 
169  outputFile.close();
170 }
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:1517
General exception.
Definition: JException.hh:23
double position
coverage of detector by available position calibration [0,1]
Definition: JDynamics.hh:558
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
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:557
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:1993
void load(const std::string &file_name)
Load mechanical model parameters from file.
Definition: JMechanics.hh:142
Data structure for coverage of dynamic calibrations.
Definition: JDynamics.hh:556
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:63
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.
Orientation of module.
Object reading from a list of files.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.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 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