63{
67
69
71 JLimit_t& numberOfEvents = inputFile.getLimit();
73 string detectorFile;
77 bool profile;
80
81 try {
82
83 JParser<> zap(
"Auxiliary program to trigger time slice data.");
84
85 zap[
'f'] =
make_field(inputFile,
"input file.");
88 zap[
'a'] =
make_field(detectorFile,
"detector file.");
93 zap[
'm'] =
make_field(merge,
"Allow merging of files w/o Monte Carlo headers");
95
96 zap(argc, argv);
97 }
98 catch(const exception &error) {
99 FATAL(error.what() << endl);
100 }
101
102
104
106
107 if (!profile) {
109 }
110
112 DEBUG(
"Reset time [ms] " <<
getRTS() * 1e-6 << endl);
113 DEBUG(
"Trigger" << endl << parameters << endl);
114
116
117 try {
119 }
122 }
123
124
125
126 if (parameters.disableHighRateVeto) {
127
128 NOTICE(
"Disabling high-rate veto of all PMTs." << endl);
129
131 }
132
134
136
137
138
140
143 typedef JTimeslice <hit_type> JTimeslice_t;
144 typedef JBuildL1 <hit_type> JBuildL1_t;
145 typedef JBuildL2 <hit_type> JBuildL2_t;
146
147 const JBuildL1_t buildL1(parameters);
148 const JBuildL2_t buildL2(parameters.L2);
149 const JBuildL2_t buildSN(parameters.SN);
150 const JBuildL2_t buildNB(parameters.NB);
151
152 JTimer timerCC(
"Calibration");
157 JTimer timerRX(
"Timeslice router");
158 JTimer timerTR(
"Trigger");
159 JTimer timerTX(
"Trigger router");
160 JTimer timerTW(
"Timeslice writer");
161 JTimer timerSW(
"Summary writer");
162
164
169
170
172
174
177
178 unsigned int numberOfTriggers = 0;
179
181
183
184 for ( ; in.hasNext() && counter != inputFile.getLimit(); ++counter) {
185
186 STATUS(
"event: " << setw(10) << counter <<
'\r');
DEBUG(endl);
187
189
190 DEBUG(*timeslice << endl);
191
192 timerRX.start();
193
194 timesliceRouter.configure(*timeslice);
195
196 timerRX.stop();
197
198
204
205 for (JDAQTimeslice::const_iterator super_frame = timeslice->begin(); super_frame != timeslice->end(); ++super_frame) {
206
207 if (moduleRouter.hasModule(super_frame->getModuleID())) {
208
209
210
211 timerCC.start();
212
213 const JModule& module = moduleRouter.getModule(super_frame->getModuleID());
214 JSuperFrame2D_t& buffer = JSuperFrame2D_t::demultiplex(*super_frame, module);
215
216 timerCC.stop();
217
218
219
220 buffer.applyHighRateVeto(parameters.highRateVeto_Hz);
221
222
223
224 timerL0.start();
225
226 timesliceL0.push_back(JSuperFrame1D_t(buffer));
227
228 timerL0.stop();
229
230
231
232 if (parameters.triggerNB.enabled) {
233
234 JSuperFrame2D_t::iterator __end = partition(buffer.begin(), buffer.end(), parameters.triggerNB.pmts);
235
236 if (buffer.begin() != __end) {
237
238 timesliceNB.push_back(JSuperFrame1D_t(super_frame->getDAQChronometer(),
239 super_frame->getModuleIdentifier(),
241
242 JSuperFrame1D_t zbuf;
243
244 buildL1(buffer.begin(), __end, back_inserter(zbuf));
245
246 buildNB(buffer.begin(), __end, zbuf, back_inserter(*timesliceNB.rbegin()));
247 }
248 }
249
250
251
252 timerL1.start();
253
254 timesliceL1.push_back(JSuperFrame1D_t(super_frame->getDAQChronometer(),
255 super_frame->getModuleIdentifier(),
257
258 buildL1(*timesliceL0.rbegin(), back_inserter(*timesliceL1.rbegin()));
259
260 timerL1.stop();
261
262
263
264 timerL2.start();
265
266 timesliceL2.push_back(JSuperFrame1D_t(super_frame->getDAQChronometer(),
267 super_frame->getModuleIdentifier(),
269
270 buildL2(buffer, *timesliceL1.rbegin(), back_inserter(*timesliceL2.rbegin()));
271
272 timerL2.stop();
273
274
275
276 timerSN.start();
277
278 {
279 JTimeslice_t::value_type tv;(super_frame->getDAQChronometer(),
280 super_frame->getModuleIdentifier(),
282
283 buildSN(buffer, *timesliceL1.rbegin(), back_inserter(tv));
284
285 if (!tv.empty()) {
286 timesliceSN.push_back(tv);
287 }
288 }
289
290 timerSN.stop();
291 }
292 }
293
294
295
296 if (parameters.triggerNB.enabled) {
297
298 timerTX.start();
299
301
302 for (JTriggerInput::const_iterator hit = trigger_input.begin(); hit != trigger_input.end(); ++hit) {
303
304 if (parameters.triggerNB.write()) {
305
307 getTriggerMask(triggerNB.getTriggerBit()),
308 *hit,
309 timesliceRouter,
310 moduleRouter,
311 parameters.TMaxLocal_ns,
312 parameters.triggerNB.DMax_m,
313 getTimeRange(parameters.triggerNB));
314
316 }
317 }
318
319 timerTX.stop();
320 }
321
322 timerTR.start();
323
326
327 trigger3DMuon (trigger_input, back_inserter(trigger_output));
328 trigger3DShower(trigger_input, back_inserter(trigger_output));
329 triggerMXShower(trigger_input, timesliceL0, back_inserter(trigger_output));
330
332
333 numberOfTriggers += trigger_output.size();
334
335 timerTR.stop();
336
337 DEBUG(
"Number of triggers: " << trigger_output.size() << endl);
338
339 for (JTriggerOutput::const_iterator event = trigger_output.begin(); event != trigger_output.end(); ++event) {
340
341 timerTX.start();
342
344 timesliceRouter,
345 moduleRouter,
346 parameters.TMaxLocal_ns,
347 getTimeRange(parameters));
348
350
351 timerTX.stop();
352 }
353
354 if (parameters.writeL0()) {
355
356 timerTW.start();
357
359
360 timerTW.stop();
361 }
362
363 if (parameters.writeL1()) {
364
365 timerTW.start();
366
368
369 timerTW.stop();
370 }
371
372 if (parameters.writeL2()) {
373
374 timerTW.start();
375
377
378 timerTW.stop();
379 }
380
381 if (parameters.writeSN()) {
382
383 timerTW.start();
384
386
387 timerTW.stop();
388 }
389
390 if (parameters.writeSummary()) {
391
392 timerSW.start();
393
395
396 timerSW.stop();
397 }
398 }
400
402
403 const double factor = 1.0 / (double) counter;
404
405 for (
const JTimer* p : { &timerCC, &timerL0, &timerL1, &timerL2, &timerSN, &timerRX, &timerTR, &timerTX, &timerTW, &timerSW }) {
406 p->print(cout, factor);
407 }
408
409 NOTICE(
"Number of trigger/slices " << numberOfTriggers <<
"/" << counter << endl);
410 NOTICE(
"Trigger rate [Hz] " << numberOfTriggers * 1.0e9 * factor /
getFrameTime() << endl);
411 }
412
414
416
418}
#define DEBUG(A)
Message macros.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
void merge(const JMatch_t &match)
Merge events.
Router for direct addressing of module data in detector data structure.
Data structure for a composite optical module.
Auxiliary class for CPU timing and usage.
static void disable()
Disable timers.
const JPosition3D & getPosition() const
Get position.
Auxiliary class for multiplexing object iterators.
Utility class to parse command line options.
General purpose class for object reading from a list of file names.
1-dimensional frame with time calibrated data from one optical module.
2-dimensional frame with time calibrated data from one optical module.
Auxiliary class to build JDAQTimeslice for L1 timeslice.
Auxiliary class to build KM3NETDAQ::JDAQEvent for a triggered event.
const JDAQChronometer & getDAQChronometer() const
Get DAQ chronometer.
Auxiliary class to set DAQ system clock parameters.
void set(const JDAQClock_t clock)
Set clock type.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
double getMaximalDistance(const JDetector &detector, const bool option=false)
Get maximal distance between modules in detector.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
std::set< JROOTClassSelector > getROOTClassSelection(const bool option=false)
Get ROOT class selection.
Long64_t counter_type
Type definition for counter.
KM3NeT DAQ data structures and auxiliaries.
double getFrameTime()
Get frame time duration.
void setDAQLongprint(const bool option)
Set DAQ print option.
double getRTS()
Get TDC dynamic range.
static const int HIGH_RATE_VETO_DISABLE
Enable (disable) use of high-rate veto test if this status bit is 0 (1);.
Match of two events considering overlap in time and position.
Transmission with position.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Auxiliary class to select ROOT class based on class name.
Auxiliary class for defining the range of iterations of objects.
static counter_type max()
Get maximum counter value.
Router for fast addressing of hits in KM3NETDAQ::JDAQTimeslice data structure as a function of the op...