Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JMuonGandalf.cc
Go to the documentation of this file.
1 #include <string>
2 
3 #include "evt/Head.hh"
4 #include "evt/Evt.hh"
5 
6 #include "JDAQ/JDAQEvent.hh"
7 #include "JDAQ/JDAQTimeslice.hh"
8 
11 
15 #include "JSupport/JSupport.hh"
16 #include "JSupport/JMeta.hh"
17 
18 #include "Jeep/JParser.hh"
19 #include "Jeep/JMessage.hh"
20 
21 #include "JFit/JEvt.hh"
22 #include "JFit/JMuonGandalf.hh"
23 #include "JFit/JMuonParameters.hh"
25 
26 #include "JLang/JSharedPointer.hh"
27 
28 
29 /**
30  * \file
31  *
32  * Program to perform JFIT::JRegressor<JLine3Z,JGandalf> fit with I/O of JFIT::JEvt data.
33  * \author gmaggi
34  */
35 int main(int argc, char **argv)
36 {
37  using namespace std;
38  using namespace JPP;
39  using namespace KM3NETDAQ;
40 
42  typedef JParallelFileScanner< JTypeList<JDAQEvent, JEvt> > JParallelFileScanner_t;
43 
44  JParallelFileScanner_t inputFile;
45  JFileRecorder<typelist> outputFile;
46  JLimit_t& numberOfEvents = inputFile.getLimit();
47  string detectorFile;
48  string pdfFile;
49  JMuonParameters muonParams;
50  int debug;
51 
52 
53  try {
54 
55  JParser<> zap("Program to perform PDF fit of muon trajectory to data.");
56 
57  zap['f'] = make_field(inputFile);
58  zap['o'] = make_field(outputFile) = "gandalf.root";
59  zap['a'] = make_field(detectorFile);
60  zap['n'] = make_field(numberOfEvents) = JLimit::max();
61  zap['P'] = make_field(pdfFile);
62  zap['@'] = make_field(muonParams) = JPARSER::initialised();
63  zap['d'] = make_field(debug) = 1;
64 
65  zap(argc, argv);
66  }
67  catch(const exception& error) {
68  FATAL(error.what() << endl);
69  }
70 
71  cout.tie(&cerr);
72 
73  JDetector detector;
74 
75  try {
76  load(detectorFile, detector);
77  }
78  catch(const JException& error) {
79  FATAL(error);
80  }
81 
82  const JSharedPointer<const JModuleRouter> moduleRouter(new JModuleRouter(detector));
83 
84  outputFile.open();
85  outputFile.put(JMeta(argc, argv));
86 
87  const JMuonGandalf muonGandalf(moduleRouter, muonParams, pdfFile);
88 
89  while (inputFile.hasNext()) {
90 
91  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
92 
93  JParallelFileScanner_t::multi_pointer_type ps = inputFile.next();
94 
95  const JDAQEvent* tev = ps;
96  JEvt* in = ps;
97 
98  const JDAQTimeslice timeSlice(*tev, true);
99 
100  JEvt out;
101 
102  muonGandalf.getJEvt(timeSlice, *in, out);
103 
104  outputFile.put(out);
105  }
106  STATUS(endl);
107 
108  JSingleFileScanner<JRemove<typelist, JEvt>::typelist> io(inputFile);
109 
110  io >> outputFile;
111 
112  outputFile.close();
113 }
114 
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:71
Utility class to parse command line options.
Definition: JParser.hh:1410
#define STATUS(A)
Definition: JMessage.hh:61
Recording of objects on file according a format that follows from the file name extension.
Empty structure for specification of parser element that is initialised (i.e.
Definition: JParser.hh:64
string outputFile
JLimit JLimit_t
Type definition of limit.
Definition: JLimit.hh:214
Type list.
Definition: JTypeList.hh:22
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1836
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.
Data time slice.
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
int debug
debug level
Definition: JSirene.cc:59
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:65
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Direct access to module in detector data structure.
Utility class to parse command line options.
ROOT TTree parameter settings.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:72
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:60
int main(int argc, char *argv[])
Definition: Main.cpp:15