Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JShowerPositionFit.cc
Go to the documentation of this file.
1 #include <string>
2 #include <limits>
3 
6 
7 #include "JDAQ/JDAQEventIO.hh"
10 
13 
15 #include "JSupport/JSupport.hh"
17 #include "JSupport/JMeta.hh"
18 #include "JSupport/JTreeScanner.hh"
20 
21 #include "Jeep/JParser.hh"
22 #include "Jeep/JMessage.hh"
23 
24 #include "JReconstruction/JEvt.hh"
27 
28 #include "JLang/JSharedPointer.hh"
29 
30 
31 /**
32  * \file
33  *
34  * Program to perform EM Shower Second Position Fit for ORCA with I/O of JFIT::JEvt data.
35  * The reconstruction is made at the HIT level.
36  * \author adomi
37  */
38 
39 int main(int argc, char** argv){
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
ROOT TTree parameter settings of various packages.
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
void update(const JDAQHeader &header)
Update router.
Detector data structure.
Definition: JDetector.hh:80
Recording of objects on file according a format that follows from the file name extension.
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
Parallel scanning of objects from a single file or multiple files according a format that follows fro...
ROOT I/O of application specific meta data.
File router for fast addressing of summary data.
int debug
debug level
Definition: JSirene.cc:63
General purpose messaging.
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
Direct access to module in detector data structure.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
Utility class to parse command line options.
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
int main(int argc, char *argv[])
Definition: Main.cpp:15