Jpp  17.0.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JMuonGandalf.cc File Reference

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

#include <string>
#include <iostream>
#include <iomanip>
#include <memory>
#include "km3net-dataformat/offline/Head.hh"
#include "km3net-dataformat/offline/Evt.hh"
#include "JDAQ/JDAQEventIO.hh"
#include "JDAQ/JDAQTimesliceIO.hh"
#include "JDAQ/JDAQSummarysliceIO.hh"
#include "JTrigger/JTriggerParameters.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JModuleRouter.hh"
#include "JDynamics/JDynamics.hh"
#include "JSupport/JSupport.hh"
#include "JSupport/JParallelFileScanner.hh"
#include "JSupport/JFileRecorder.hh"
#include "JSupport/JSummaryFileRouter.hh"
#include "JSupport/JMeta.hh"
#include "JReconstruction/JEvt.hh"
#include "JReconstruction/JMuonGandalf.hh"
#include "JReconstruction/JMuonGandalfParameters_t.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<JFIT::JLine3Z,JFIT::JGandalf> fit with I/O of JFIT::JEvt data.

Author
mdejong, gmaggi

Definition in file JMuonGandalf.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 42 of file JMuonGandalf.cc.

43 {
44  using namespace std;
45  using namespace JPP;
46  using namespace KM3NETDAQ;
47 
49  typedef JParallelFileScanner< JTypeList<JDAQEvent, JFIT::JEvt> > JParallelFileScanner_t;
50  typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
52  JACOUSTICS::JEvt>::typelist calibration_types;
53  typedef JMultipleFileScanner<calibration_types> JCalibration_t;
54 
55  JParallelFileScanner_t inputFile;
57  JLimit_t& numberOfEvents = inputFile.getLimit();
58  string detectorFile;
59  JCalibration_t calibrationFile;
60  double Tmax_s;
61  string pdfFile;
63  int debug;
64 
65  try {
66 
67  JParser<> zap("Program to perform PDF fit of muon trajectory to data.");
68 
69  zap['f'] = make_field(inputFile);
70  zap['o'] = make_field(outputFile) = "gandalf.root";
71  zap['a'] = make_field(detectorFile);
72  zap['+'] = make_field(calibrationFile) = JPARSER::initialised();
73  zap['T'] = make_field(Tmax_s) = 100.0;
74  zap['n'] = make_field(numberOfEvents) = JLimit::max();
75  zap['P'] = make_field(pdfFile);
77  zap['d'] = make_field(debug) = 1;
78 
79  zap(argc, argv);
80  }
81  catch(const exception& error) {
82  FATAL(error.what() << endl);
83  }
84 
85  cout.tie(&cerr);
86 
88 
89  try {
90  load(detectorFile, detector);
91  }
92  catch(const JException& error) {
93  FATAL(error);
94  }
95 
96 
97  getMechanics.load(detector.getID());
98 
99  unique_ptr<JDynamics> dynamics;
100 
101  try {
102 
103  dynamics.reset(new JDynamics(detector, Tmax_s));
104 
105  dynamics->load(calibrationFile);
106  }
107  catch(const exception& error) {
108  if (!calibrationFile.empty()) {
109  FATAL(error.what());
110  }
111  }
112 
113  const JModuleRouter router(dynamics ? dynamics->getDetector() : detector);
114 
115  JSummaryFileRouter summary(inputFile, parameters.R_Hz);
116 
117  JMuonGandalf fit(parameters, router, summary, pdfFile, debug);
118 
119 
120  outputFile.open();
121  outputFile.put(JMeta(argc, argv));
122 
123  while (inputFile.hasNext()) {
124 
125  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
126 
127  multi_pointer_type ps = inputFile.next();
128 
129  const JDAQEvent* tev = ps;
130  const JFIT::JEvt* in = ps;
131 
132  summary.update(*tev);
133 
134  if (dynamics) {
135  dynamics->update(*tev);
136  }
137 
138  // select start values
139 
140  JFIT::JEvt cp = *in;
141 
142  if (parameters.reprocess) {
144  }
145 
146  cp.select(parameters.numberOfPrefits, qualitySorter);
147 
148  if (!cp.empty()) {
149  cp.select(JHistory::is_event(cp.begin()->getHistory()));
150  }
151 
152  // fit
153 
154  JFIT::JEvt out = fit(*tev, cp);
155 
156  if (dynamics) {
157 
158  const JDynamics::coverage_type coverage = dynamics->getCoverage();
159 
160  for (JFIT::JEvt::iterator i = out.begin(); i != out.end(); ++i) {
161  i->setW(JPP_COVERAGE_ORIENTATION, coverage.orientation);
162  i->setW(JPP_COVERAGE_POSITION, coverage.position);
163  }
164  }
165 
166  // apply default sorter
167 
168  sort(out.begin(), out.end(), qualitySorter);
169 
170  copy(in->begin(), in->end(), back_inserter(out));
171 
172  outputFile.put(out);
173  }
174  STATUS(endl);
175 
177 
178  io >> outputFile;
179 
180  outputFile.close();
181 }
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:556
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:153
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:66
string outputFile
Wrapper class to make final fit of muon trajectory.
Definition: JMuonGandalf.hh:72
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:555
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: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:105
static const int JMUONGANDALF
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:66
Data structure for coverage of dynamic calibrations.
Definition: JDynamics.hh:554
#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:63
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.
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
do set_variable DETECTOR_TXT $WORKDIR detector
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 JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46
void select(const JSelector_t &selector)
Select fits.
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
static const int JPP_COVERAGE_POSITION
coverage of dynamic position calibration from any Jpp application