Jpp  debug
the software that should make you happy
Functions
software/JReconstruction/JMuonStart.cc File Reference

Program to perform JFIT::JRegressor<JEnergy> fit with I/O of JFIT::JEvt data. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <memory>
#include "km3net-dataformat/offline/Head.hh"
#include "km3net-dataformat/offline/MultiHead.hh"
#include "km3net-dataformat/offline/Evt.hh"
#include "km3net-dataformat/definitions/fitparameters.hh"
#include "JDAQ/JDAQEventIO.hh"
#include "JDAQ/JDAQTimesliceIO.hh"
#include "JDAQ/JDAQSummarysliceIO.hh"
#include "JTrigger/JTriggerParameters.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorSubset.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JModuleRouter.hh"
#include "JDynamics/JDynamics.hh"
#include "JSupport/JSingleFileScanner.hh"
#include "JSupport/JParallelFileScanner.hh"
#include "JSupport/JFileRecorder.hh"
#include "JSupport/JSummaryFileRouter.hh"
#include "JSupport/JSupport.hh"
#include "JSupport/JMeta.hh"
#include "JReconstruction/JEvt.hh"
#include "JReconstruction/JEvtToolkit.hh"
#include "JReconstruction/JMuonStartParameters_t.hh"
#include "JReconstruction/JMuonStart.hh"
#include "JPhysics/JK40Rates.hh"
#include "JPhysics/KM3NeT.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Program to perform JFIT::JRegressor<JEnergy> fit with I/O of JFIT::JEvt data.

Author
mdejong, azegarelli, scelli

Definition in file software/JReconstruction/JMuonStart.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 53 of file software/JReconstruction/JMuonStart.cc.

54 {
55  using namespace std;
56  using namespace JPP;
57  using namespace KM3NETDAQ;
58 
60  typedef JParallelFileScanner< JTypeList<JDAQEvent, JFIT::JEvt> > JParallelFileScanner_t;
61  typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
63  JACOUSTICS::JEvt>::typelist calibration_types;
64  typedef JMultipleFileScanner<calibration_types> JCalibration_t;
65 
66  JParallelFileScanner_t inputFile;
68  JLimit_t& numberOfEvents = inputFile.getLimit();
69  string detectorFile;
70  JCalibration_t calibrationFile;
71  double Tmax_s;
72  string pdfFile;
73  JMuonStartParameters_t parameters;
74  JK40Rates rates_Hz;
75  int debug;
76 
77  try {
78 
79  JParser<> zap("Program to perform PDF fit of muon trajectory to data.");
80 
81  zap['f'] = make_field(inputFile);
82  zap['o'] = make_field(outputFile) = "start.root";
83  zap['a'] = make_field(detectorFile);
84  zap['+'] = make_field(calibrationFile) = JPARSER::initialised();
85  zap['T'] = make_field(Tmax_s) = 100.0;
86  zap['n'] = make_field(numberOfEvents) = JLimit::max();
87  zap['P'] = make_field(pdfFile);
88  zap['@'] = make_field(parameters) = JPARSER::initialised();
89  zap['B'] = make_field(rates_Hz) = KM3NET::getK40Rates();
90  zap['d'] = make_field(debug) = 1;
91 
92  zap(argc, argv);
93  }
94  catch(const exception& error) {
95  FATAL(error.what() << endl);
96  }
97 
98 
100 
101  try {
102  load(detectorFile, detector);
103  }
104  catch(const JException& error) {
105  FATAL(error);
106  }
107 
108  unique_ptr<JDynamics> dynamics;
109 
110  try {
111 
112  dynamics.reset(new JDynamics(detector, Tmax_s));
113 
114  dynamics->load(calibrationFile);
115  }
116  catch(const exception& error) {
117  if (!calibrationFile.empty()) {
118  FATAL(error.what());
119  }
120  }
121 
122  const JModuleRouter router(dynamics ? dynamics->getDetector() : detector);
123 
124  JSummaryFileRouter summary(inputFile, parameters.R_Hz);
125 
126  JMuonStart fit(parameters, router, summary, pdfFile, rates_Hz, debug);
127 
128  outputFile.open();
129  outputFile.put(JMeta(argc, argv));
130 
131  while (inputFile.hasNext()) {
132 
133  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
134 
135  multi_pointer_type ps = inputFile.next();
136 
137  const JDAQEvent* tev = ps;
138  const JFIT::JEvt* in = ps;
139 
140  summary.update(*tev);
141 
142  if (dynamics) {
143  dynamics->update(*tev);
144  }
145 
146  // select start values
147 
148  JFIT::JEvt cp = *in;
149 
150  if (parameters.reprocess) {
152  }
153 
154  cp.select(parameters.numberOfPrefits, qualitySorter);
155 
156  if (!cp.empty()) {
157  cp.select(JHistory::is_event(cp.begin()->getHistory()));
158  }
159 
160  // fit
161 
162  JFIT::JEvt out = fit(*tev, cp);
163 
164  if (dynamics) {
165 
166  const JDynamics::coverage_type coverage = dynamics->getCoverage();
167 
168  for (JFIT::JEvt::iterator i = out.begin(); i != out.end(); ++i) {
169  i->setW(JPP_COVERAGE_ORIENTATION, coverage.orientation);
170  i->setW(JPP_COVERAGE_POSITION, coverage.position);
171  }
172  }
173 
174  // apply default sorter
175 
176  sort(out.begin(), out.end(), qualitySorter);
177 
178  copy(in->begin(), in->end(), back_inserter(out));
179 
180  outputFile.put(out);
181  }
182  STATUS(endl);
183 
185 
186  io >> outputFile;
187 
188  outputFile.close();
189 }
string outputFile
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
#define STATUS(A)
Definition: JMessage.hh:63
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
Definition: JSirene.cc:69
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2158
Detector data structure.
Definition: JDetector.hh:96
Router for direct addressing of module data in detector data structure.
Data structure for set of track fit results.
void select(const JSelector_t &selector)
Select fits.
General exception.
Definition: JException.hh:24
Utility class to parse command line options.
Definition: JParser.hh:1714
Auxiliary class to determine start and end position of muon trajectory.
Definition: JMuonStart.hh:115
Object writing to file.
General purpose class for object reading from a list of file names.
General purpose class for parallel reading of objects from a single file or multiple files.
Object reading from a list of files.
File router for fast addressing of summary data.
static const int JMUONSTART
static const int JPP_COVERAGE_POSITION
coverage of dynamic position calibration from any Jpp application
static const int JPP_COVERAGE_ORIENTATION
coverage of dynamic orientation calibration from any Jpp application
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:162
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
bool qualitySorter(const JFit &first, const JFit &second)
Comparison of fit results.
KM3NeT DAQ data structures and auxiliaries.
Definition: DataQueue.cc:39
const JK40Rates & getK40Rates()
Get K40 rates.
Definition: KM3NeT.hh:36
Definition: JSTDTypes.hh:14
Detector file.
Definition: JHead.hh:227
Acoustic event fit.
Orientation of module.
Data structure for coverage of dynamic calibrations.
Definition: JDynamics.hh:573
double position
coverage of detector by available position calibration [0,1]
Definition: JDynamics.hh:575
double orientation
coverage of detector by available orientation calibration [0,1]
Definition: JDynamics.hh:574
Dynamic detector calibration.
Definition: JDynamics.hh:84
Auxiliary class to test history.
Definition: JHistory.hh:105
Auxiliary class to test history.
Definition: JHistory.hh:153
Auxiliary class for recursive type list generation.
Definition: JTypeList.hh:351
Type list.
Definition: JTypeList.hh:23
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:84
Auxiliary class for K40 rates.
Definition: JK40Rates.hh:41
Data structure for fit parameters.
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:45
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:84
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:72