Jpp master_rocky-44-g75b7c4f75
the software that should make you happy
Loading...
Searching...
No Matches
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/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 "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

◆ main()

int main ( int argc,
char ** argv )

Definition at line 58 of file JMuonEnergy.cc.

59{
60 using namespace std;
61 using namespace JPP;
62 using namespace KM3NETDAQ;
63
65 typedef JParallelFileScanner< JTypeList<JDAQEvent, JFIT::JEvt> > JParallelFileScanner_t;
66 typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
68 JACOUSTICS::JEvt>::typelist calibration_types;
69 typedef JMultipleFileScanner<calibration_types> JCalibration_t;
70
71 JParallelFileScanner_t inputFile;
73 JLimit_t& numberOfEvents = inputFile.getLimit();
74 string detectorFile;
75 JCalibration_t calibrationFile;
76 double Tmax_s;
77 string pdfFile;
78 JEnergyCorrection correct;
79 JMuonEnergyParameters_t parameters;
80 int debug;
81
82 try {
83
84 JParser<> zap("Program to perform fit of muon energy to data.");
85
86 zap['f'] = make_field(inputFile);
87 zap['o'] = make_field(outputFile) = "energy.root";
88 zap['a'] = make_field(detectorFile);
89 zap['+'] = make_field(calibrationFile) = JPARSER::initialised();
90 zap['T'] = make_field(Tmax_s) = 100.0;
91 zap['n'] = make_field(numberOfEvents) = JLimit::max();
92 zap['P'] = make_field(pdfFile);
93 zap['E'] = make_field(correct) = JEnergyCorrection(); // off
94 zap['@'] = make_field(parameters) = JPARSER::initialised();
95 zap['d'] = make_field(debug) = 1;
96
97 zap(argc, argv);
98 }
99 catch(const exception& error) {
100 FATAL(error.what() << endl);
101 }
102
103
105
106 try {
107 load(detectorFile, detector);
108 }
109 catch(const JException& error) {
110 FATAL(error);
111 }
112
113 unique_ptr<JDynamics> dynamics;
114
115 try {
116
117 dynamics.reset(new JDynamics(detector, Tmax_s));
118
119 dynamics->load(calibrationFile);
120 }
121 catch(const exception& error) {
122 if (!calibrationFile.empty()) {
123 FATAL(error.what());
124 }
125 }
126
127 const JModuleRouter router(dynamics ? dynamics->getDetector() : detector);
128
129 JSummaryFileRouter summary(inputFile, parameters.R_Hz);
130
131 JMuonEnergy fit(parameters, router, summary, pdfFile, debug);
132
133 outputFile.open();
134 outputFile.put(JMeta(argc, argv));
135
136 while (inputFile.hasNext()) {
137
138 STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
139
140 multi_pointer_type ps = inputFile.next();
141
142 const JDAQEvent* tev = ps;
143 const JFIT::JEvt* in = ps;
144
145 summary.update(*tev);
146
147 if (dynamics) {
148 dynamics->update(*tev);
149 }
150
151 // select start values
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 // set corrected energy
169
170 for (JFIT::JEvt::iterator i = out.begin(); i != out.end(); ++i) {
171 i->setE(correct(i->getE()));
172 }
173
174 if (dynamics) {
175
176 const JDynamics::coverage_type coverage = dynamics->getCoverage();
177
178 for (JFIT::JEvt::iterator i = out.begin(); i != out.end(); ++i) {
179 i->setW(JPP_COVERAGE_ORIENTATION, coverage.orientation);
180 i->setW(JPP_COVERAGE_POSITION, coverage.position);
181 }
182 }
183
184 // apply default sorter
185
186 sort(out.begin(), out.end(), qualitySorter);
187
188 copy(in->begin(), in->end(), back_inserter(out));
189
190 outputFile.put(out);
191 }
192 STATUS(endl);
193
195
196 io >> outputFile;
197
198 outputFile.close();
199}
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:2142
Detector data structure.
Definition JDetector.hh:96
Router for direct addressing of module data in detector data structure.
Auxiliary class for correction of energy determined by JEnergy.cc.
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:1698
Auxiliary class to to determine muon energy.
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 JMUONENERGY
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
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:68
Auxiliary class for defining the range of iterations of objects.
Definition JLimit.hh:45
const JLimit & getLimit() const
Get limit.
Definition JLimit.hh:84
static counter_type max()
Get maximum counter value.
Definition JLimit.hh:128
Auxiliary class for ROOT I/O of application specific meta data.
Definition JMeta.hh:72