Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JMuonPrefit.cc
Go to the documentation of this file.
1#include <string>
2#include <iostream>
3#include <iomanip>
4#include <memory>
5
9
10#include "JDAQ/JDAQEventIO.hh"
13#include "JDAQ/JDAQEvaluator.hh"
14
16
20
22
23#include "JSupport/JSupport.hh"
27#include "JSupport/JMeta.hh"
28
33
34#include "Jeep/JParser.hh"
35#include "Jeep/JMessage.hh"
36
37/**
38 * \file
39 *
40 * Program to perform linear fits JFIT::JEstimator<JFIT::JLine1Z> covering the solid angle producing JFIT::JEvt data.
41 *
42 * \author mdejong, gmaggi, azegarelli
43 */
44int main(int argc, char **argv)
45{
46 using namespace std;
47 using namespace JPP;
48 using namespace KM3NETDAQ;
49
53 JACOUSTICS::JEvt>::typelist calibration_types;
54 typedef JMultipleFileScanner<calibration_types> JCalibration_t;
55
56 JSingleFileScanner_t inputFile;
58 JLimit_t& numberOfEvents = inputFile.getLimit();
59 string detectorFile;
60 JCalibration_t calibrationFile;
61 double Tmax_s;
62 JMuonPrefitParameters_t parameters;
63 size_t threads; // number of parallel threads
64 int debug;
65
66 try {
67
68 JParser<> zap("Program to perform pre-fit of muon trajectory to data.");
69
70 zap['f'] = make_field(inputFile);
71 zap['o'] = make_field(outputFile) = "prefit.root";
72 zap['a'] = make_field(detectorFile);
73 zap['+'] = make_field(calibrationFile) = JPARSER::initialised();
74 zap['T'] = make_field(Tmax_s) = 100.0;
75 zap['n'] = make_field(numberOfEvents) = JLimit::max();
76 zap['@'] = make_field(parameters) = JPARSER::initialised();
77 zap['N'] = make_field(threads, "number of threads") = 0;
78 zap['d'] = make_field(debug) = 1;
79
80 zap(argc, argv);
81 }
82 catch(const exception& error) {
83 FATAL(error.what() << endl);
84 }
85
86
88
90
91 try {
92 load(detectorFile, detector);
93 }
94 catch(const JException& error) {
95 FATAL(error);
96 }
97
98 unique_ptr<JDynamics> dynamics;
99
100 if (!calibrationFile.empty()) {
101
102 try {
103
104 dynamics.reset(new JDynamics(detector, Tmax_s));
105
106 dynamics->load(calibrationFile);
107 }
108 catch(const exception& error) {
109 FATAL(error.what());
110 }
111 }
112
113 const JModuleRouter router(dynamics ? dynamics->getDetector() : detector);
114
115 JMuonPrefit fit(parameters, debug);
116
117
118 outputFile.open();
119 outputFile.put(JMeta(argc, argv));
120
121 JTreeScanner<JDAQEvent, JDAQEvaluator> in(inputFile, inputFile.getLimit());
122
123 {
124 JMultiThreadedReconstruction<JMuonPrefit> fits(fit, outputFile, threads, 2 * threads);
125
126 while (in.hasNext()) {
127
128 STATUS("event: " << setw(10) << in.getCounter() << '\r'); DEBUG(endl);
129
130 const JDAQEvent* tev = in.next();
131
132 if (dynamics) {
133 dynamics->update(*tev);
134 }
135
136 auto input = fit.getInput(router, *tev, dynamics ? dynamics->getCoverage() : coverage_type());
137
138 if (threads > 0)
139 fits.enqueue(input);
140 else
141 outputFile.put(fit(input));
142
143 outputFile.put(*tev);
144 }
145 STATUS(endl);
146 }
147
149
150 io >> outputFile;
151
152 outputFile.close();
153}
string outputFile
Data structure for detector geometry and calibration.
Dynamic detector calibration.
Recording of objects on file according a format that follows from the file name extension.
General purpose messaging.
#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:72
ROOT I/O of application specific meta data.
Direct access to module in detector data structure.
int main(int argc, char **argv)
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Scanning of objects from a single file according a format that follows from the extension of each fil...
ROOT TTree parameter settings of various packages.
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.
General exception.
Definition JException.hh:24
Utility class to parse command line options.
Definition JParser.hh:1698
Thread pool for event-by-event reconstruction.
void setSplitLevel(int value)
Set split level.
Object writing to file.
General purpose class for object reading from a list of file names.
Object reading from a list of files.
Template definition for direct access of elements in ROOT TChain.
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).
JTreeParameters & getTreeParameters()
Template definition for method returning TTree parameters.
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
Detector file.
Definition JHead.hh:227
Acoustic event fit.
Orientation of module.
Dynamic detector calibration.
Definition JDynamics.hh:86
Data structure for coverage of detector by dynamical calibrations.
Definition JCoverage.hh:19
Auxiliary class for recursive type list generation.
Definition JTypeList.hh:351
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition JParser.hh:68
Wrapper class to make pre-fit of muon trajectory.
input_type getInput(const JModuleRouter &router, const JDAQEvent &event, const coverage_type &coverage) const
Get input data.
Auxiliary class for defining the range of iterations of objects.
Definition JLimit.hh:45
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
Auxiliary base class for file name.