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 #include <iostream>
3 #include <iomanip>
4 
5 #include "TROOT.h"
6 #include "TFile.h"
7 #include "TProfile.h"
8 #include "TH2D.h"
9 
12 
13 #include "JDAQ/JDAQEventIO.hh"
14 #include "JDAQ/JDAQTimesliceIO.hh"
16 
18 
19 #include "JDetector/JDetector.hh"
22 
23 #include "JSupport/JSupport.hh"
27 #include "JSupport/JMeta.hh"
28 
29 #include "JReconstruction/JEvt.hh"
32 
33 #include "Jeep/JParser.hh"
34 #include "Jeep/JMessage.hh"
35 
36 
37 /**
38  * \file
39  *
40  * Program to perform JFIT::JRegressor<JFIT::JLine3Z,JFIT::JGandalf> fit with I/O of JFIT::JEvt data.
41  *
42  * \author mdejong, gmaggi
43  */
44 int main(int argc, char **argv)
45 {
46  using namespace std;
47  using namespace JPP;
48  using namespace KM3NETDAQ;
49 
51  typedef JParallelFileScanner< JTypeList<JDAQEvent, JEvt> > JParallelFileScanner_t;
52  typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
53 
54  JParallelFileScanner_t inputFile;
56  JLimit_t& numberOfEvents = inputFile.getLimit();
57  string detectorFile;
58  string pdfFile;
60  int debug;
61 
62 
63  try {
64 
65  JParser<> zap("Program to perform PDF fit of muon trajectory to data.");
66 
67  zap['f'] = make_field(inputFile);
68  zap['o'] = make_field(outputFile) = "gandalf.root";
69  zap['a'] = make_field(detectorFile);
70  zap['n'] = make_field(numberOfEvents) = JLimit::max();
71  zap['P'] = make_field(pdfFile);
73  zap['d'] = make_field(debug) = 1;
74 
75  zap(argc, argv);
76  }
77  catch(const exception& error) {
78  FATAL(error.what() << endl);
79  }
80 
81  cout.tie(&cerr);
82 
84 
85  try {
86  load(detectorFile, detector);
87  }
88  catch(const JException& error) {
89  FATAL(error);
90  }
91 
92  const JModuleRouter router(detector);
93 
94  JSummaryFileRouter summary(inputFile, parameters.R_Hz);
95 
96  JMuonGandalf fit(parameters, router, summary, pdfFile, debug);
97 
98 
99  outputFile.open();
100  outputFile.put(JMeta(argc, argv));
101 
102  while (inputFile.hasNext()) {
103 
104  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
105 
106  multi_pointer_type ps = inputFile.next();
107 
108  const JDAQEvent* tev = ps;
109  const JEvt* in = ps;
110 
111  summary.update(*tev);
112 
113 
114  // select start values
115 
116  JEvt cp = *in;
117 
118  if (parameters.reprocess) {
120  }
121 
122  cp.select(parameters.numberOfPrefits, qualitySorter);
123 
124  if (!cp.empty()) {
125  cp.select(JHistory::is_event(cp.begin()->getHistory()));
126  }
127 
128  // fit
129 
130  JEvt out = fit(*tev, cp);
131 
132 
133  // apply default sorter
134 
135  sort(out.begin(), out.end(), qualitySorter);
136 
137  copy(in->begin(), in->end(), back_inserter(out));
138 
139  outputFile.put(out);
140  }
141  STATUS(endl);
142 
144 
145  io >> outputFile;
146 
147  outputFile.close();
148 }
149 
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:71
Object writing to file.
Utility class to parse command line options.
Definition: JParser.hh:1493
General exception.
Definition: JException.hh:23
ROOT TTree parameter settings.
#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.
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Definition: JSirene.sh:45
*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...
Auxiliary class to test history.
Definition: JHistory.hh:152
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:63
string outputFile
Data structure for detector geometry and calibration.
Wrapper class to make final fit of muon trajectory.
Definition: JMuonGandalf.hh:72
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:130
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
Auxiliary class to test history.
Definition: JHistory.hh:104
static const int JMUONGANDALF
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.
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
int debug
debug level
Definition: JSirene.cc:61
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Direct access to module in detector data structure.
Data structure for set of track fit results.
Definition: JEvt.hh:294
Utility class to parse command line options.
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:153
Object reading from a list of files.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
void select(const JSelector_t &selector)
Select fits.
Definition: JEvt.hh:314
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