Jpp  test_elongated_shower_pde
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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/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

int main ( int  argc,
char **  argv 
)

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

52 {
53  using namespace std;
54  using namespace JPP;
55  using namespace KM3NETDAQ;
56 
58  typedef JParallelFileScanner< JTypeList<JDAQEvent, JFIT::JEvt> > JParallelFileScanner_t;
59  typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
61  JACOUSTICS::JEvt>::typelist calibration_types;
62  typedef JMultipleFileScanner<calibration_types> JCalibration_t;
63 
64  JParallelFileScanner_t inputFile;
66  JLimit_t& numberOfEvents = inputFile.getLimit();
67  string detectorFile;
68  JCalibration_t calibrationFile;
69  double Tmax_s;
70  string pdfFile;
72  JK40Rates rates_Hz;
73  int debug;
74 
75  try {
76 
77  JParser<> zap("Program to perform PDF fit of muon trajectory to data.");
78 
79  zap['f'] = make_field(inputFile);
80  zap['o'] = make_field(outputFile) = "start.root";
81  zap['a'] = make_field(detectorFile);
82  zap['+'] = make_field(calibrationFile) = JPARSER::initialised();
83  zap['T'] = make_field(Tmax_s) = 100.0;
84  zap['n'] = make_field(numberOfEvents) = JLimit::max();
85  zap['P'] = make_field(pdfFile);
87  zap['B'] = make_field(rates_Hz) = KM3NET::getK40Rates();
88  zap['d'] = make_field(debug) = 1;
89 
90  zap(argc, argv);
91  }
92  catch(const exception& error) {
93  FATAL(error.what() << endl);
94  }
95 
96 
97  cout.tie(&cerr);
98 
99 
101 
102  try {
103  load(detectorFile, detector);
104  }
105  catch(const JException& error) {
106  FATAL(error);
107  }
108 
109 
110  getMechanics.load(detector.getID());
111 
112  unique_ptr<JDynamics> dynamics;
113 
114  try {
115 
116  dynamics.reset(new JDynamics(detector, Tmax_s));
117 
118  dynamics->load(calibrationFile);
119  }
120  catch(const exception& error) {
121  if (!calibrationFile.empty()) {
122  FATAL(error.what());
123  }
124  }
125 
126  const JModuleRouter router(dynamics ? dynamics->getDetector() : detector);
127 
128  JSummaryFileRouter summary(inputFile, parameters.R_Hz);
129 
130  JMuonStart fit(parameters, router, summary, pdfFile, rates_Hz, debug);
131 
132  outputFile.open();
133  outputFile.put(JMeta(argc, argv));
134 
135  while (inputFile.hasNext()) {
136 
137  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
138 
139  multi_pointer_type ps = inputFile.next();
140 
141  const JDAQEvent* tev = ps;
142  const JFIT::JEvt* in = ps;
143 
144  summary.update(*tev);
145 
146  if (dynamics) {
147  dynamics->update(*tev);
148  }
149 
150  // select start values
151 
152  JFIT::JEvt cp = *in;
153 
154  if (parameters.reprocess) {
156  }
157 
158  cp.select(parameters.numberOfPrefits, qualitySorter);
159 
160  if (!cp.empty()) {
161  cp.select(JHistory::is_event(cp.begin()->getHistory()));
162  }
163 
164  // fit
165 
166  JFIT::JEvt out = fit(*tev, cp);
167 
168  if (dynamics) {
169 
170  const JDynamics::coverage_type coverage = dynamics->getCoverage();
171 
172  for (JFIT::JEvt::iterator i = out.begin(); i != out.end(); ++i) {
173  i->setW(JPP_COVERAGE_ORIENTATION, coverage.orientation);
174  i->setW(JPP_COVERAGE_POSITION, coverage.position);
175  }
176  }
177 
178  // apply default sorter
179 
180  sort(out.begin(), out.end(), qualitySorter);
181 
182  copy(in->begin(), in->end(), back_inserter(out));
183 
184  outputFile.put(out);
185  }
186  STATUS(endl);
187 
189 
190  io >> outputFile;
191 
192  outputFile.close();
193 }
static const int JMUONSTART
JDetector detector
Definition: JRunAnalyzer.hh:23
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
double position
coverage of detector by available position calibration [0,1]
Definition: JDynamics.hh:555
static JDetectorMechanics getMechanics
Function object to get string mechanics.
Definition: JMechanics.hh:243
#define STATUS(A)
Definition: JMessage.hh:63
Detector data structure.
Definition: JDetector.hh:89
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
const JK40Rates & getK40Rates()
Get K40 rates.
Definition: KM3NeT.hh:36
string outputFile
bool qualitySorter(const JFit &first, const JFit &second)
Comparison of fit results.
double orientation
coverage of detector by available orientation calibration [0,1]
Definition: JDynamics.hh:554
Type list.
Definition: JTypeList.hh:22
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
Data structure for fit parameters.
Auxiliary class to determine start and end position of muon trajectory.
Definition: JMuonStart.hh:111
Detector file.
Definition: JHead.hh:224
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
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:68
Data structure for coverage of dynamic calibrations.
Definition: JDynamics.hh:553
#define FATAL(A)
Definition: JMessage.hh:67
static const int JPP_COVERAGE_ORIENTATION
coverage of dynamic orientation calibration from any Jpp application
Dynamic detector calibration.
Definition: JDynamics.hh:62
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.
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
then cp
Orientation of module.
Object reading from a list of files.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
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:42
void select(const JSelector_t &selector)
Select fits.
Auxiliary class for K40 rates.
Definition: JK40Rates.hh:41
then usage $script< detector file >< tripodfile >< stage > input file nInput files correspond to the output of JAcousticsEventBuilder[.sh] nFirst stage eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY eval JPrintDetector a $DETECTOR O CAN source JAcoustics sh $DETECTOR_ID typeset A CONFIGURATION for key in Tmax_s
static const int JPP_COVERAGE_POSITION
coverage of dynamic position calibration from any Jpp application