Jpp master_rocky-44-g75b7c4f75
the software that should make you happy
Loading...
Searching...
No Matches
JMuonSimplex.cc File Reference

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

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::JSimplex> fit with I/O of JFIT::JEvt data.

Author
mdejong, gmaggi

Definition in file JMuonSimplex.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 42 of file JMuonSimplex.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 JMuonSimplexParameters_t parameters;
62 int debug;
63
64 try {
65
66 JParser<> zap("Program to perform intermediate fit of muon trajectory to data.");
67
68 zap['f'] = make_field(inputFile);
69 zap['o'] = make_field(outputFile) = "simplex.root";
70 zap['a'] = make_field(detectorFile);
71 zap['+'] = make_field(calibrationFile) = JPARSER::initialised();
72 zap['T'] = make_field(Tmax_s) = 100.0;
73 zap['@'] = make_field(parameters) = JPARSER::initialised();
74 zap['n'] = make_field(numberOfEvents) = JLimit::max();
75 zap['d'] = make_field(debug) = 1;
76
77 zap(argc, argv);
78 }
79 catch(const exception& error) {
80 FATAL(error.what() << endl);
81 }
82
83
85
86 try {
87 load(detectorFile, detector);
88 }
89 catch(const JException& error) {
90 FATAL(error);
91 }
92
93 unique_ptr<JDynamics> dynamics;
94
95 try {
96
97 dynamics.reset(new JDynamics(detector, Tmax_s));
98
99 dynamics->load(calibrationFile);
100 }
101 catch(const exception& error) {
102 if (!calibrationFile.empty()) {
103 FATAL(error.what());
104 }
105 }
106
107 const JModuleRouter router(dynamics ? dynamics->getDetector() : detector);
108
109 JMuonSimplex fit(parameters, router, debug);
110
111
112 outputFile.open();
113 outputFile.put(JMeta(argc, argv));
114
115 while (inputFile.hasNext()) {
116
117 STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
118
119 multi_pointer_type ps = inputFile.next();
120
121 const JDAQEvent* tev = ps;
122 const JFIT::JEvt* in = ps;
123
124 if (dynamics) {
125 dynamics->update(*tev);
126 }
127
128 // select start values
129
130 JFIT::JEvt cp = *in;
131
132 if (parameters.reprocess) {
134 }
135
136 cp.select(parameters.numberOfPrefits, qualitySorter);
137
138 if (!cp.empty()) {
139 cp.select(JHistory::is_event(cp.begin()->getHistory()));
140 }
141
142 // fit
143
144 JFIT::JEvt out = fit(*tev, cp);
145
146 if (dynamics) {
147
148 const JDynamics::coverage_type coverage = dynamics->getCoverage();
149
150 for (JFIT::JEvt::iterator i = out.begin(); i != out.end(); ++i) {
151 i->setW(JPP_COVERAGE_ORIENTATION, coverage.orientation);
152 i->setW(JPP_COVERAGE_POSITION, coverage.position);
153 }
154 }
155
156 // apply default sorter
157
158 sort(out.begin(), out.end(), qualitySorter);
159
160 copy(in->begin(), in->end(), back_inserter(out));
161
162 outputFile.put(out);
163 }
164 STATUS(endl);
165
167
168 io >> outputFile;
169
170 outputFile.close();
171}
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.
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
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.
static const int JMUONSIMPLEX
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
Wrapper class to make intermediate fit of muon trajectory.
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