Jpp - the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JShowerPrefit.cc
Go to the documentation of this file.
1 #include <limits>
2 
5 
6 #include "JDAQ/JDAQEventIO.hh"
9 
11 #include "JDetector/JDetectorToolkit.hh"// <- to enable: load
12 
13 #include "JSupport/JSupport.hh"
15 #include "JSupport/JFileRecorder.hh"
16 #include "JSupport/JMeta.hh"
17 
18 #include "Jeep/JParser.hh"
19 #include "Jeep/JMessage.hh"
20 
21 #include "JTools/JPermutation.hh"
22 
23 #include "JReconstruction/JEvt.hh"
26 
27 #include "JLang/JSharedPointer.hh"
28 
29 /**
30  * \author adomi
31  */
32 
33 int main(int argc, char **argv)
34 {
35  using namespace std;
36  using namespace JPP;
37 
39 
42  JLimit_t& numberOfEvents = inputFile.getLimit();
43  string detectorFile;
45  int debug;
46 
47  try {
48 
49  JParser<> zap("Program to perform position pre-fit of shower to data.");
50 
51  zap['f'] = make_field(inputFile);
52  zap['o'] = make_field(outputFile) = "ShowerPrefit.root";
53  zap['a'] = make_field(detectorFile);
55  zap['n'] = make_field(numberOfEvents) = JLimit::max();
56  zap['d'] = make_field(debug) = 2;
57 
58  zap(argc, argv);
59  }
60  catch(const exception& error) {
61  FATAL(error.what() << endl);
62  }
63 
64  cout.tie(&cerr);
65 
67 
68  try {
69  load(detectorFile, detector);
70  }
71  catch(const JException& error) {
72  FATAL(error);
73  }
74 
75  const JModuleRouter router(detector);
76 
77  JShowerPrefit fit(parameters, router, debug);
78 
79  outputFile.open();
80  outputFile.put(JMeta(argc, argv));
81 
82  while (inputFile.hasNext()) {
83 
84  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
85 
86  const JDAQEvent* tev = inputFile.next();
87 
88  JEvt out = fit(*tev);
89 
90  // apply default sorter
91 
92  sort(out.begin(), out.end(), qualitySorter);
93 
94  // reduce output fits
95 
96  JEvt::iterator __end = out.end();
97 
98  advance(__end = out.begin(), min(parameters.numberOfPrefits, (size_t) distance(out.begin(), out.end())));
99 
100  JEvt reduced_out;
101 
102  copy(out.begin(), __end, back_inserter(reduced_out));
103 
104  outputFile.put(reduced_out);
105 
106  }
107 
108  STATUS(endl);
109 
111 
112  io >> outputFile;
113 
114  outputFile.close();
115 }
116 
117 
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
int main(int argc, char *argv[])
Definition: Main.cc:15
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
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
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
Scanning of objects from a single file according a format that follows from the extension of each fil...
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
ROOT I/O of application specific meta 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.
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
Object reading from a list of files.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
do set_variable DETECTOR_TXT $WORKDIR detector
bool qualitySorter(const JRECONSTRUCTION::JFit &first, const JRECONSTRUCTION::JFit &second)
Comparison of fit results.
JTriggerCounter_t next()
Increment trigger counter.