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
JMuonEnergy.cc File Reference

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

#include <string>
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <algorithm>
#include <limits>
#include <map>
#include <memory>
#include "TMath.h"
#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 "JAAnet/JAAnetToolkit.hh"
#include "JDetector/JDetector.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/JSupport.hh"
#include "JSupport/JMeta.hh"
#include "JSupport/JSummaryFileRouter.hh"
#include "JFit/JEnergy.hh"
#include "JFit/JEnergyRegressor.hh"
#include "JReconstruction/JEvt.hh"
#include "JReconstruction/JEvtToolkit.hh"
#include "JReconstruction/JMuonEnergyParameters_t.hh"
#include "JReconstruction/JEnergyCorrection.hh"
#include "JReconstruction/JMuonEnergy.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, JGandalf> fit using I/O of JFIT::JEvt data.

Author
mdejong

Definition in file JMuonEnergy.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 56 of file JMuonEnergy.cc.

57 {
58  using namespace std;
59  using namespace JPP;
60  using namespace KM3NETDAQ;
61 
63  typedef JParallelFileScanner< JTypeList<JDAQEvent, JFIT::JEvt> > JParallelFileScanner_t;
64  typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
66  JACOUSTICS::JEvt>::typelist calibration_types;
67  typedef JMultipleFileScanner<calibration_types> JCalibration_t;
68 
69  JParallelFileScanner_t inputFile;
71  JLimit_t& numberOfEvents = inputFile.getLimit();
72  string detectorFile;
73  JCalibration_t calibrationFile;
74  double Tmax_s;
75  string pdfFile;
76  JEnergyCorrection correct;
78  int debug;
79 
80  try {
81 
82  JParser<> zap("Program to perform fit of muon energy to data.");
83 
84  zap['f'] = make_field(inputFile);
85  zap['o'] = make_field(outputFile) = "energy.root";
86  zap['a'] = make_field(detectorFile);
87  zap['+'] = make_field(calibrationFile) = JPARSER::initialised();
88  zap['T'] = make_field(Tmax_s) = 100.0;
89  zap['n'] = make_field(numberOfEvents) = JLimit::max();
90  zap['P'] = make_field(pdfFile);
91  zap['E'] = make_field(correct) = JEnergyCorrection(); // off
93  zap['d'] = make_field(debug) = 1;
94 
95  zap(argc, argv);
96  }
97  catch(const exception& error) {
98  FATAL(error.what() << endl);
99  }
100 
101 
102  cout.tie(&cerr);
103 
104 
106 
107  try {
108  load(detectorFile, detector);
109  }
110  catch(const JException& error) {
111  FATAL(error);
112  }
113 
114  getMechanics.load(detector.getID());
115 
116  unique_ptr<JDynamics> dynamics;
117 
118  try {
119 
120  dynamics.reset(new JDynamics(detector, Tmax_s));
121 
122  dynamics->load(calibrationFile);
123  }
124  catch(const exception& error) {
125  if (!calibrationFile.empty()) {
126  FATAL(error.what());
127  }
128  }
129 
130  const JModuleRouter router(dynamics ? dynamics->getDetector() : detector);
131 
132  JSummaryFileRouter summary(inputFile, parameters.R_Hz);
133 
134  JMuonEnergy fit(parameters, router, summary, pdfFile, debug);
135 
136  outputFile.open();
137  outputFile.put(JMeta(argc, argv));
138 
139  while (inputFile.hasNext()) {
140 
141  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
142 
143  multi_pointer_type ps = inputFile.next();
144 
145  const JDAQEvent* tev = ps;
146  const JFIT::JEvt* in = ps;
147 
148  summary.update(*tev);
149 
150  if (dynamics) {
151  dynamics->update(*tev);
152  }
153 
154  // select start values
155  JFIT::JEvt cp = *in;
156 
157  if (parameters.reprocess) {
159  }
160 
161  cp.select(parameters.numberOfPrefits, qualitySorter);
162 
163  if (!cp.empty()) {
164  cp.select(JHistory::is_event(cp.begin()->getHistory()));
165  }
166 
167  // fit
168 
169  JFIT::JEvt out = fit(*tev, cp);
170 
171  // set corrected energy
172 
173  for (JFIT::JEvt::iterator i = out.begin(); i != out.end(); ++i) {
174  i->setE(correct(i->getE()));
175  }
176 
177  if (dynamics) {
178 
179  const JDynamics::coverage_type coverage = dynamics->getCoverage();
180 
181  for (JFIT::JEvt::iterator i = out.begin(); i != out.end(); ++i) {
182  i->setW(JPP_COVERAGE_ORIENTATION, coverage.orientation);
183  i->setW(JPP_COVERAGE_POSITION, coverage.position);
184  }
185  }
186 
187  // apply default sorter
188 
189  sort(out.begin(), out.end(), qualitySorter);
190 
191  copy(in->begin(), in->end(), back_inserter(out));
192 
193  outputFile.put(out);
194  }
195  STATUS(endl);
196 
198 
199  io >> outputFile;
200 
201  outputFile.close();
202 }
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
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
Detector file.
Definition: JHead.hh:224
Auxiliary class for correction of energy determined by JEnergy.cc.
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
Data structure for fit parameters.
#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
Auxiliary class to to determine muon energy.
Definition: JMuonEnergy.hh:58
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.
static const int JMUONENERGY
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