Jpp  17.3.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JShowerFit.cc File Reference

Program to perform EM Shower Fit for ORCA with I/O of JFIT::JEvt data. More...

#include <string>
#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 "JDetector/JModuleRouter.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDynamics/JDynamics.hh"
#include "JSupport/JParallelFileScanner.hh"
#include "JSupport/JSupport.hh"
#include "JSupport/JFileRecorder.hh"
#include "JSupport/JMeta.hh"
#include "JSupport/JTreeScanner.hh"
#include "JSupport/JSummaryFileRouter.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
#include "JReconstruction/JEvt.hh"
#include "JReconstruction/JShowerEnergyCorrection.hh"
#include "JReconstruction/JShowerParameters.hh"
#include "JReconstruction/JShowerFitParameters_t.hh"
#include "JReconstruction/JShowerFit.hh"
#include "JLang/JSharedPointer.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Program to perform EM Shower Fit for ORCA with I/O of JFIT::JEvt data.

The reconstruction is made at the PMT level.

Author
adomi

Definition in file JShowerFit.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 43 of file JShowerFit.cc.

43  {
44 
45  using namespace std;
46  using namespace JPP;
47  using namespace KM3NETDAQ;
48 
50  typedef JParallelFileScanner< JTypeList<JDAQEvent, JFIT::JEvt> > JParallelFileScanner_t;
51  typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
53  JACOUSTICS::JEvt>::typelist calibration_types;
55 
56 
57  JParallelFileScanner_t inputFile;
60  JLimit_t& numberOfEvents = inputFile.getLimit();
61  string detectorFile;
62  JCalibration_t calibrationFile;
63  double Tmax_s;
64  string pdfFile;
66  int debug;
67 
68  try {
69 
70  JParser<> zap;
71 
72  zap['f'] = make_field(inputFile) ;
73  zap['o'] = make_field(outputFile) = "JORCAShowerFit_Output.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['F'] = make_field(pdfFile) ;
78  zap['E'] = make_field(correct) = JShowerEnergyCorrection(); // off
80  zap['n'] = make_field(numberOfEvents) = JLimit::max();
81  zap['d'] = make_field(debug) = 2;
82 
83  zap(argc, argv);
84  }
85  catch(const exception& error) {
86  FATAL(error.what() << endl);
87  }
88 
90 
91  try {
92  load(detectorFile, detector);
93  }
94  catch(const JException& error) {
95  FATAL(error);
96  }
97 
98  getMechanics.load(detector.getID());
99 
100  unique_ptr<JDynamics> dynamics;
101 
102  try {
103 
104  dynamics.reset(new JDynamics(detector, Tmax_s));
105 
106  dynamics->load(calibrationFile);
107  }
108  catch(const exception& error) {
109  if (!calibrationFile.empty()) {
110  FATAL(error.what());
111  }
112  }
113 
114  const JModuleRouter router(dynamics ? dynamics->getDetector() : detector);
115 
116  JSummaryFileRouter summary(inputFile, parameters.R_Hz);
117 
118  JShowerFit fit(parameters, router, summary, pdfFile, correct, debug);
119 
120  outputFile.open();
121  outputFile.put(JMeta(argc, argv));
122 
123  while (inputFile.hasNext()) {
124 
125  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
126 
127  multi_pointer_type ps = inputFile.next();
128 
129  JDAQEvent* tev = ps;
130  JFIT::JEvt* in = ps;
131 
132  summary.update(*tev);
133 
134  if (dynamics) {
135  dynamics->update(*tev);
136  }
137 
138  // select start values
139  JFIT::JEvt cp = *in;
140 
141  cp.select(parameters.numberOfPrefits, qualitySorter);
142 
143  if (!cp.empty()) {
144  cp.select(JHistory::is_event(cp.begin()->getHistory()));
145  }
146 
147  // fit
148 
149  JFIT::JEvt out = fit(*tev, cp);
150 
151  if (dynamics) {
152 
153  const JDynamics::coverage_type coverage = dynamics->getCoverage();
154 
155  for (JFIT::JEvt::iterator i = out.begin(); i != out.end(); ++i) {
156  i->setW(JPP_COVERAGE_ORIENTATION, coverage.orientation);
157  i->setW(JPP_COVERAGE_POSITION, coverage.position);
158  }
159  }
160 
161  // apply default sorter
162 
163  sort(out.begin(), out.end(), qualitySorter);
164 
165  // reduce output fits
166 
167  copy(in->begin(), in->end(), back_inserter(out));
168 
169  outputFile.put(out);
170  }
171  STATUS(endl);
172 
174 
175  io >> outputFile;
176 
177  outputFile.close();
178 }
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
Auxiliary class for correction of energy determined by JShowerEnergy.cc.
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:83
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:557
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: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
Auxiliary class to test history.
Definition: JHistory.hh:105
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
Data structure for coverage of dynamic calibrations.
Definition: JDynamics.hh:556
#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.
Data structure for fit parameters.
General purpose class for object reading from a list of file names.
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:162
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 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
void select(const JSelector_t &selector)
Select fits.
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