Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JShowerEnergyPrefit.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/Evt.hh"
#include "JDAQ/JDAQEventIO.hh"
#include "JDAQ/JDAQTimesliceIO.hh"
#include "JDAQ/JDAQSummarysliceIO.hh"
#include "JDetector/JModuleRouter.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JTrigger/JTriggerParameters.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/JShowerEnergyPrefit.hh"
#include "JReconstruction/JShowerEnergyPrefitParameters_t.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 JShowerEnergyPrefit.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 40 of file JShowerEnergyPrefit.cc.

40  {
41 
42  using namespace std;
43  using namespace JPP;
44  using namespace KM3NETDAQ;
45 
47  typedef JParallelFileScanner< JTypeList<JDAQEvent, JEvt> > JParallelFileScanner_t;
48  typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
49 
50  JParallelFileScanner_t inputFile;
53  JLimit_t& numberOfEvents = inputFile.getLimit();
54  string detectorFile;
55  string pdfFile;
56  int debug;
57 
58  try {
59 
60  JParser<> zap;
61 
62  zap['f'] = make_field(inputFile) ;
63  zap['o'] = make_field(outputFile) = "JORCAShowerFit_Output.root";
64  zap['a'] = make_field(detectorFile) ;
65  zap['F'] = make_field(pdfFile) ;
67  zap['n'] = make_field(numberOfEvents) = JLimit::max();
68  zap['d'] = make_field(debug) = 2;
69 
70  zap(argc, argv);
71  }
72  catch(const exception& error) {
73  FATAL(error.what() << endl);
74  }
75 
77 
78  try {
79  load(detectorFile, detector);
80  }
81  catch(const JException& error) {
82  FATAL(error);
83  }
84 
85  outputFile.open();
86  outputFile.put(JMeta(argc, argv));
87 
88  const JModuleRouter router(detector);
89 
90  JSummaryFileRouter summary(inputFile, parameters.R_Hz);
91 
92  JShowerEnergyPrefit fit(parameters, router, summary, pdfFile, debug);
93 
94  while (inputFile.hasNext()) {
95 
96  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
97 
98  multi_pointer_type ps = inputFile.next();
99 
100  JDAQEvent* tev = ps;
101  JEvt* in = ps;
102 
103  summary.update(*tev);
104 
105  // select start values
106  JEvt cp = *in;
107 
108  cp.select(parameters.numberOfPrefits, qualitySorter);
109 
110  if (!cp.empty()) {
111  cp.select(JHistory::is_event(cp.begin()->getHistory()));
112  }
113 
114  // fit
115 
116  JEvt out = fit(*tev, cp);
117 
118  // apply default sorter
119 
120  sort(out.begin(), out.end(), qualitySorter);
121 
122  // reduce output fits
123 
124  JEvt::iterator __end = out.end();
125 
126  advance(__end = out.begin(), min(parameters.numberOfOutfits, (size_t) distance(out.begin(), out.end())));
127 
128  JEvt reduced_out;
129 
130  copy(out.begin(), __end, back_inserter(reduced_out));
131 
132  copy(in->begin(), in->end(), back_inserter(reduced_out));
133 
134  outputFile.put(reduced_out);
135 
136  }
137  STATUS(endl);
138 
140 
141  io >> outputFile;
142 
143  outputFile.close();
144 }
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
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
class to handle the third step of the shower reconstruction, mainly dedicated for ORCA ...
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.
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 typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:36
bool qualitySorter(const JRECONSTRUCTION::JFit &first, const JRECONSTRUCTION::JFit &second)
Comparison of fit results.
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62