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

Program to perform EM Shower Second Position 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/Evt.hh"
#include "JDAQ/JDAQEventIO.hh"
#include "JDAQ/JDAQTimesliceIO.hh"
#include "JDAQ/JDAQSummarysliceIO.hh"
#include "JDetector/JModuleRouter.hh"
#include "JDetector/JDetectorToolkit.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/JShowerPositionFitParameters_t.hh"
#include "JReconstruction/JShowerPositionFit.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 Second Position Fit for ORCA with I/O of JFIT::JEvt data.

The reconstruction is made at the HIT level.

Author
adomi

Definition in file JShowerPositionFit.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 39 of file JShowerPositionFit.cc.

39  {
40 
41  using namespace std;
42  using namespace JPP;
43 
44  typedef JParallelFileScanner< JTypeList<JDAQEvent, JEvt> > JParallelFileScanner_t;
46  typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
47 
48  JParallelFileScanner_t inputFile;
51  JLimit_t& numberOfEvents = inputFile.getLimit();
52  string detectorFile;
53  string pdfFile;
54  int debug;
55 
56  try {
57 
58  JParser<> zap;
59 
60  zap['f'] = make_field(inputFile) ;
61  zap['o'] = make_field(outputFile) = "JShowerPositionFit.root";
62  zap['a'] = make_field(detectorFile) ;
63  zap['F'] = make_field(pdfFile) ;
65  zap['n'] = make_field(numberOfEvents) = JLimit::max();
66  zap['d'] = make_field(debug) = 2;
67 
68  zap(argc, argv);
69  }
70  catch(const exception& error) {
71  FATAL(error.what() << endl);
72  }
73 
75 
76  try {
77  load(detectorFile, detector);
78  }
79  catch(const JException& error) {
80  FATAL(error);
81  }
82 
83  outputFile.open();
84  outputFile.put(JMeta(argc, argv));
85 
86  const JModuleRouter router(detector);
87 
88  JSummaryFileRouter summary(inputFile, parameters.R_Hz);
89 
90  JShowerPositionFit fit(parameters, router, summary, pdfFile, debug);
91 
92  while (inputFile.hasNext()) {
93 
94  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
95 
96  multi_pointer_type ps = inputFile.next();
97 
98  JDAQEvent* tev = ps;
99  JEvt* in = ps;
100 
101  summary.update(*tev);
102 
103  // select start values
104  JEvt cp = *in;
105 
106  cp.select(parameters.numberOfPrefits, qualitySorter);
107 
108  if (!cp.empty()) {
109  cp.select(JHistory::is_event(cp.begin()->getHistory()));
110  }
111 
112  // fit
113  JEvt out = fit(*tev, cp);
114 
115  // apply default sorter
116 
117  sort(out.begin(), out.end(), qualitySorter);
118 
119  // reduce output fits
120 
121  JEvt::iterator __end = out.end();
122 
123  advance(__end = out.begin(), min(parameters.numberOfOutfits, (size_t) distance(out.begin(), out.end())));
124 
125  JEvt reduced_out;
126 
127  copy(out.begin(), __end, back_inserter(reduced_out));
128 
129  copy(in->begin(), in->end(), back_inserter(reduced_out));
130 
131  outputFile.put(reduced_out);
132 
133  }
134  STATUS(endl);
135 
137 
138  io >> outputFile;
139 
140  outputFile.close();
141 }
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
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
#define STATUS(A)
Definition: JMessage.hh:63
Detector data structure.
Definition: JDetector.hh:80
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:66
class to handle the second position fit of the shower reconstruction, mainly dedicated for ORCA ...
string outputFile
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:196
Acoustic event fit.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
Auxiliary class to test history.
Definition: JHistory.hh:104
File router for fast addressing of summary data.
int debug
debug level
Definition: JSirene.cc:63
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
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:139
then cp
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:38
bool qualitySorter(const JRECONSTRUCTION::JFit &first, const JRECONSTRUCTION::JFit &second)
Comparison of fit results.