Jpp - the software that should make you happy
 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 
7 
8 #include "JDAQ/JDAQEventIO.hh"
11 
13 
14 #include "JDetector/JDetector.hh"
17 
18 #include "JDynamics/JDynamics.hh"
19 
20 #include "JCompass/JEvt.hh"
21 #include "JCompass/JSupport.hh"
22 
23 #include "JAcoustics/JEvt.hh"
24 #include "JAcoustics/JSupport.hh"
25 
26 #include "JSupport/JSupport.hh"
30 #include "JSupport/JMeta.hh"
31 
32 #include "JReconstruction/JEvt.hh"
35 
36 #include "Jeep/JParser.hh"
37 #include "Jeep/JMessage.hh"
38 
39 
40 /**
41  * \file
42  *
43  * Program to perform JFIT::JRegressor<JFIT::JLine3Z,JFIT::JGandalf> fit with I/O of JFIT::JEvt data.
44  *
45  * \author mdejong, gmaggi
46  */
47 int main(int argc, char **argv)
48 {
49  using namespace std;
50  using namespace JPP;
51  using namespace KM3NETDAQ;
52 
54  typedef JParallelFileScanner< JTypeList<JDAQEvent, JFIT::JEvt> > JParallelFileScanner_t;
55  typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
57  JACOUSTICS::JEvt>::typelist calibration_types;
58  typedef JMultipleFileScanner<calibration_types> JCalibration_t;
59 
60  JParallelFileScanner_t inputFile;
62  JLimit_t& numberOfEvents = inputFile.getLimit();
63  string detectorFile;
64  JCalibration_t calibrationFile;
65  double Tmax_s;
66  string pdfFile;
68  int debug;
69 
70  try {
71 
72  JParser<> zap("Program to perform PDF fit of muon trajectory to data.");
73 
74  zap['f'] = make_field(inputFile);
75  zap['o'] = make_field(outputFile) = "gandalf.root";
76  zap['a'] = make_field(detectorFile);
77  zap['+'] = make_field(calibrationFile) = JPARSER::initialised();
78  zap['T'] = make_field(Tmax_s) = 100.0;
79  zap['n'] = make_field(numberOfEvents) = JLimit::max();
80  zap['P'] = make_field(pdfFile);
82  zap['d'] = make_field(debug) = 1;
83 
84  zap(argc, argv);
85  }
86  catch(const exception& error) {
87  FATAL(error.what() << endl);
88  }
89 
90  cout.tie(&cerr);
91 
93 
94  try {
95  load(detectorFile, detector);
96  }
97  catch(const JException& error) {
98  FATAL(error);
99  }
100 
101 
102  getMechanics.load(detector.getID());
103 
104  JDynamics dynamics(detector, Tmax_s);
105 
106  dynamics.load(calibrationFile);
107 
108 
109  const JModuleRouter router(dynamics);
110 
111  JSummaryFileRouter summary(inputFile, parameters.R_Hz);
112 
113  JMuonGandalf fit(parameters, router, summary, pdfFile, debug);
114 
115 
116  outputFile.open();
117  outputFile.put(JMeta(argc, argv));
118 
119  while (inputFile.hasNext()) {
120 
121  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
122 
123  multi_pointer_type ps = inputFile.next();
124 
125  const JDAQEvent* tev = ps;
126  const JFIT::JEvt* in = ps;
127 
128  summary .update(*tev);
129  dynamics.update(*tev);
130 
131  // select start values
132 
133  JFIT::JEvt cp = *in;
134 
135  if (parameters.reprocess) {
137  }
138 
139  cp.select(parameters.numberOfPrefits, qualitySorter);
140 
141  if (!cp.empty()) {
142  cp.select(JHistory::is_event(cp.begin()->getHistory()));
143  }
144 
145  // fit
146 
147  JFIT::JEvt out = fit(*tev, cp);
148 
149  const JDynamics::coverage_type coverage = dynamics.getCoverage();
150 
151  for (JFIT::JEvt::iterator i = out.begin(); i != out.end(); ++i) {
152  i->setW(JGANDALF_COVERAGE_ORIENTATION, coverage.orientation);
153  i->setW(JGANDALF_COVERAGE_POSITION, coverage.position);
154  }
155 
156  // apply default sorter
157 
158  sort(out.begin(), out.end(), qualitySorter);
159 
160  copy(in->begin(), in->end(), back_inserter(out));
161 
162  outputFile.put(out);
163  }
164  STATUS(endl);
165 
167 
168  io >> outputFile;
169 
170  outputFile.close();
171 }
172 
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
static const int JGANDALF_COVERAGE_ORIENTATION
coverage of dynamic orientation calibration from JGandalf.cc
int main(int argc, char *argv[])
Definition: Main.cc:15
ROOT TTree parameter settings of various packages.
coverage_type getCoverage(const double t1_s) const
Get coverage at given time.
Definition: JDynamics.hh:523
double position
coverage of detector by available position calibration [0,1]
Definition: JDynamics.hh:513
static JDetectorMechanics getMechanics
Function object to get string mechanics.
Definition: JMechanics.hh:243
static const int JGANDALF_COVERAGE_POSITION
coverage of dynamic position calibration from JGandalf.cc
#define STATUS(A)
Definition: JMessage.hh:63
ROOT TTree parameter settings.
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...
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:66
string outputFile
const JDetector & update(const double t1_s)
Get detector calibrated at given time.
Definition: JDynamics.hh:477
Data structure for detector geometry and calibration.
Wrapper class to make final fit of muon trajectory.
Definition: JMuonGandalf.hh:72
ROOT TTree parameter settings.
double orientation
coverage of detector by available orientation calibration [0,1]
Definition: JDynamics.hh:512
void load(JObjectIterator_t &input)
Load calibration data.
Definition: JDynamics.hh:462
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.
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
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.
Dynamic detector calibration.
File router for fast addressing of summary data.
void load(const std::string &file_name)
Load mechanical model parameters from file.
Definition: JMechanics.hh:142
int debug
debug level
Definition: JSirene.cc:63
General purpose messaging.
Data structure for coverage of dynamic calibrations.
Definition: JDynamics.hh:511
#define FATAL(A)
Definition: JMessage.hh:67
Direct access to module in detector data structure.
Dynamic detector calibration.
Definition: JDynamics.hh:59
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
Data structure for set of track fit results.
General purpose class for object reading from a list of file names.
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
Orientation of module.
Object reading from a list of files.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
Compass event data types.
do set_variable DETECTOR_TXT $WORKDIR detector
Acoustic event fit.
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 CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:38
void select(const JSelector_t &selector)
Select fits.
bool qualitySorter(const JRECONSTRUCTION::JFit &first, const JRECONSTRUCTION::JFit &second)
Comparison of fit results.
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62