67{
71
73
76 JLimit_t& numberOfEvents = inputFile.getLimit();
77 string detectorFile;
78 JCalibration_t calibrationFile;
79 double Tmax_s;
82 size_t numberOfFits;
84
85 try {
86
87 JParser<> zap(
"Auxiliary program to convert fit results to Evt format.\
88 \nThe option -L corresponds to the name of a shared library \
89 \nand function so to rearrange the order of fit results.");
90
101
102 zap(argc, argv);
103 }
104 catch(const exception& error) {
105 FATAL(error.what() << endl);
106 }
107
108 if (detectorFile == "" && !calibrationFile.empty()) {
109 FATAL(
"Missing detector file." << endl);
110 }
111
113 typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
114
116
117 if (detectorFile != "") {
118 try {
120 }
123 }
124 }
125
126 unique_ptr<JDynamics> dynamics;
127
128 if (!calibrationFile.empty()) {
129
130 try {
131
133
134 dynamics->load(calibrationFile);
135 }
136 catch(const exception& error) {
138 }
139 }
140
141
144
145
147
149
150 try {
152 } catch(const exception& error) {}
153
155
156
157
159
160 buffer.DAQ.livetime_s =
getLivetime(inputFile.begin(), inputFile.end());
162
163 copy(buffer, header);
164 }
165
166 if (detectorFile != "") {
167
170
171 copy(buffer, header);
172 }
173
174
176
177
179
182
184
186
187 STATUS(
"Processing: " << *i << endl);
188
189 JParallelFileScanner_t in(*i);
191
192 in.setLimit(inputFile.getLimit());
193
195
196 int mc_run_id = 0;
197
198 try {
199
201
203 mc_run_id = head.start_run.run_id;
204
205 } catch(const exception& error) {}
206
207
208 while (in.hasNext()) {
209
210 STATUS(
"event: " << setw(10) << in.getCounter() <<
'\r');
DEBUG(endl);
211
212 multi_pointer_type ps = in.next();
213
216
217 if (dynamics) {
218 dynamics->update(*tev);
219 }
220
221 JFIT::JEvt::iterator __end = evt->end();
222
223 if (numberOfFits > 0) {
224 advance(__end = evt->begin(), min(numberOfFits, evt->size()));
225 }
226
228 partial_sort(evt->begin(), __end, evt->end(),
qualitySorter);
229 }
230
232
233 if (mc.getEntries() != 0) {
234
236
237 if (event != NULL) {
238
239 out = *event;
240
243 }
244
246 i->pos += offset;
247 }
248 }
249 }
250
252
253 if (!pmt_router->empty()) {
254
256
257 if (pmt_router.hasPMT(i->pmt_id)) {
258
259 const JPMTAddress address = pmt_router.getAddress(i->pmt_id);
261 const JPMT& pmt = pmt_router.getPMT(address);
262
263 i->dom_id =
id.
getID();
264 i->channel_id = id.getPMTAddress();
267
268 } else {
269
270 miss_pmt[i->pmt_id] += 1;
271 }
272 }
273 }
274
275 if (!mod_router->empty()) {
276
278
279 if (mod_router.hasModule(i->dom_id)) {
280
282
285
286 const JPMT& pmt = mod_router.getPMT(
id);
287 const int type = parameters.
getType();
288
289 i->pmt_id = pmt.
getID();
293 i->a = cpu.getNPE(i->tot);
294
295 } else {
296
297 miss_mod[i->dom_id] += 1;
298 }
299 }
300 }
301
302 copy(evt->cbegin(), __end, out);
303
304 out.
id = ++number_of_events;
305
307 }
308 }
309
311
312 for (
const auto& i : miss_pmt) {
ERROR(
"Misses PMT " << setw(8) << i.first <<
' ' << setw(8) << i.second << endl); }
313 for (
const auto& i : miss_mod) {
ERROR(
"Misses module " << setw(8) << i.first <<
' ' << setw(8) << i.second << endl); }
314
316
318
320}
#define DEBUG(A)
Message macros.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
JAANET::calibration calibration
const JCalibration & getCalibration() const
Get calibration.
Router for direct addressing of module data in detector data structure.
Address of PMT in detector data structure.
Auxiliary class for map of PMT parameters.
const JPMTParameters & getPMTParameters(const JPMTIdentifier &id) const
Get PMT parameters.
Data structure for PMT parameters.
int getType() const
Get type for for time-slewing correction.
bool slewing
time slewing of analogue signal
Router for direct addressing of PMT data in detector data structure.
Data structure for PMT geometry, calibration and status.
Data structure for set of track fit results.
int getID() const
Get identifier.
Utility class to parse command line options.
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.
Template definition for direct access of elements in ROOT TChain.
JTriggerCounter_t getCounter() const
Get trigger counter.
JDirection3D getDirection(const Vec &dir)
Get direction.
void copy(const Head &from, JHead &to)
Copy header from from to to.
JPosition3D getPosition(const Vec &pos)
Get position.
Vec getOffset(const JHead &header)
Get offset.
std::istream & read(std::istream &in, JTestSummary &summary)
Read test summary.
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.
counter_type advance(counter_type &counter, const counter_type value, const counter_type limit=std::numeric_limits< counter_type >::max())
Advance counter.
Long64_t counter_type
Type definition for counter.
double getLivetime(const std::string &file_name)
Get data taking live time.
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
const char * getTime()
Get current local time conform ISO-8601 standard.
JTRIGGER::JTimeSlewing_t getTimeSlewing
Function object to get time-slewing correction.
KM3NeT DAQ data structures and auxiliaries.
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
std::vector< Hit > hits
list of hits
int mc_run_id
MC run identifier.
std::vector< Hit > mc_hits
MC: list of MC truth hits.
std::vector< Trk > mc_trks
MC: list of MC truth tracks.
int id
offline event identifier
The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred ...
static const std::string dynamical()
PMT analogue signal processor.
Dynamic detector calibration.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
General purpose sorter of fit results.
Auxiliary class for defining the range of iterations of objects.
static counter_type max()
Get maximum counter value.
The Vec class is a straightforward 3-d vector, which also works in pyroot.