Jpp  pmt_effective_area_update
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/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 40 of file JShowerPrefit.cc.

41 {
42  using namespace std;
43  using namespace JPP;
44  using namespace KM3NETDAQ;
45 
48  JACOUSTICS::JEvt>::typelist calibration_types;
49  typedef JMultipleFileScanner<calibration_types> JCalibration_t;
50 
53  JLimit_t& numberOfEvents = inputFile.getLimit();
54  string detectorFile;
55  JCalibration_t calibrationFile;
56  double Tmax_s;
58  int debug;
59 
60  try {
61 
62  JParser<> zap("Program to perform position pre-fit of shower to data.");
63 
64  zap['f'] = make_field(inputFile);
65  zap['o'] = make_field(outputFile) = "ShowerPrefit.root";
66  zap['a'] = make_field(detectorFile);
67  zap['+'] = make_field(calibrationFile) = JPARSER::initialised();
68  zap['T'] = make_field(Tmax_s) = 100.0;
70  zap['n'] = make_field(numberOfEvents) = JLimit::max();
71  zap['d'] = make_field(debug) = 2;
72 
73  zap(argc, argv);
74  }
75  catch(const exception& error) {
76  FATAL(error.what() << endl);
77  }
78 
79  cout.tie(&cerr);
80 
82 
83  try {
84  load(detectorFile, detector);
85  }
86  catch(const JException& error) {
87  FATAL(error);
88  }
89 
90  getMechanics.load(detector.getID());
91 
92  unique_ptr<JDynamics> dynamics;
93 
94  try {
95 
96  dynamics.reset(new JDynamics(detector, Tmax_s));
97 
98  dynamics->load(calibrationFile);
99  }
100  catch(const exception& error) {
101  if (!calibrationFile.empty()) {
102  FATAL(error.what());
103  }
104  }
105 
106  const JModuleRouter router(dynamics ? dynamics->getDetector() : detector);
107 
108  JShowerPrefit fit(parameters, router, debug);
109 
110  outputFile.open();
111  outputFile.put(JMeta(argc, argv));
112 
113  JTreeScanner<JDAQEvent, JDAQEvaluator> in (inputFile, inputFile.getLimit());
114 
115  while (in.hasNext()) {
116 
117  STATUS("event: " << setw(10) << in.getCounter() << '\r'); DEBUG(endl);
118 
119  const JDAQEvent* tev = in.next();
120 
121  JFIT::JEvt out = fit(*tev);
122 
123  if (dynamics) {
124 
125  const JDynamics::coverage_type coverage = dynamics->getCoverage();
126 
127  for (JFIT::JEvt::iterator i = out.begin(); i != out.end(); ++i) {
128  i->setW(JPP_COVERAGE_ORIENTATION, coverage.orientation);
129  i->setW(JPP_COVERAGE_POSITION, coverage.position);
130  }
131  }
132 
133  if (parameters.numberOfPrefits > 0) {
134 
135  // apply default sorter
136 
137  JFIT::JEvt::iterator __end = out.end();
138 
139  if (parameters.numberOfPrefits < out.size()) {
140 
141  advance(__end = out.begin(), parameters.numberOfPrefits);
142 
143  partial_sort(out.begin(), __end, out.end(), qualitySorter);
144 
145  out.erase(__end, out.end());
146 
147  } else {
148 
149  sort(out.begin(), __end, qualitySorter);
150  }
151 
152  } else {
153 
154  sort(out.begin(), out.end(), qualitySorter);
155  }
156 
157  outputFile.put(*tev);
158  outputFile.put(out);
159 
160  }
161 
162  STATUS(endl);
163 
165 
166  io >> outputFile;
167 
168  outputFile.close();
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:1500
General exception.
Definition: JException.hh:23
double position
coverage of detector by available position calibration [0,1]
Definition: JDynamics.hh:536
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:81
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:66
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.
Definition: JTreeScanner.hh:91
double orientation
coverage of detector by available orientation calibration [0,1]
Definition: JDynamics.hh:535
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
Detector file.
Definition: JHead.hh:196
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:1961
void load(const std::string &file_name)
Load mechanical model parameters from file.
Definition: JMechanics.hh:142
int debug
debug level
Definition: JSirene.cc:63
Data structure for coverage of dynamic calibrations.
Definition: JDynamics.hh:534
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:61
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 usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
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 source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:40
bool qualitySorter(const JRECONSTRUCTION::JFit &first, const JRECONSTRUCTION::JFit &second)
Comparison of fit results.
static const int JPP_COVERAGE_POSITION
coverage of dynamic position calibration from any Jpp application