63{
67
69
71 JLimit_t& numberOfEvents = inputFile.getLimit();
73 string detectorFile;
77 bool profile;
79
80 try {
81
82 JParser<> zap(
"Auxiliary program to trigger time slice data.");
83
84 zap[
'f'] =
make_field(inputFile,
"input file.");
87 zap[
'a'] =
make_field(detectorFile,
"detector file.");
93
94 zap(argc, argv);
95 }
96 catch(const exception &error) {
97 FATAL(error.what() << endl);
98 }
99
100
102
104
105 if (!profile) {
107 }
108
110 DEBUG(
"Reset time [ms] " <<
getRTS() * 1e-6 << endl);
111 DEBUG(
"Trigger" << endl << parameters << endl);
112
114
115 try {
117 }
120 }
121
122
123
124 if (parameters.disableHighRateVeto) {
125
126 NOTICE(
"Disabling high-rate veto of all PMTs." << endl);
127
129 }
130
132
134
135
136
138
141 typedef JTimeslice <hit_type> JTimeslice_t;
142 typedef JBuildL1 <hit_type> JBuildL1_t;
143 typedef JBuildL2 <hit_type> JBuildL2_t;
144
145 const JBuildL1_t buildL1(parameters);
146 const JBuildL2_t buildL2(parameters.L2);
147 const JBuildL2_t buildSN(parameters.SN);
148 const JBuildL2_t buildNB(parameters.NB);
149
150 JTimer timerCC(
"Calibration");
155 JTimer timerRX(
"Timeslice router");
156 JTimer timerTR(
"Trigger");
157 JTimer timerTX(
"Trigger router");
158 JTimer timerTW(
"Timeslice writer");
159 JTimer timerSW(
"Summary writer");
160
162
167
168
170
172
175
176 unsigned int numberOfTriggers = 0;
177
179
181
182 for ( ; in.hasNext() && counter != inputFile.getLimit(); ++counter) {
183
184 STATUS(
"event: " << setw(10) << counter <<
'\r');
DEBUG(endl);
185
187
188 DEBUG(*timeslice << endl);
189
190 timerRX.start();
191
192 timesliceRouter.configure(*timeslice);
193
194 timerRX.stop();
195
196
202
203 for (JDAQTimeslice::const_iterator super_frame = timeslice->begin(); super_frame != timeslice->end(); ++super_frame) {
204
205 if (moduleRouter.hasModule(super_frame->getModuleID())) {
206
207
208
209 timerCC.start();
210
211 const JModule& module = moduleRouter.getModule(super_frame->getModuleID());
212 JSuperFrame2D_t& buffer = JSuperFrame2D_t::demultiplex(*super_frame, module);
213
214 timerCC.stop();
215
216
217
218 buffer.applyHighRateVeto(parameters.highRateVeto_Hz);
219
220
221
222 timerL0.start();
223
224 timesliceL0.push_back(JSuperFrame1D_t(buffer));
225
226 timerL0.stop();
227
228
229
230 if (parameters.triggerNB.enabled) {
231
232 JSuperFrame2D_t::iterator __end = partition(buffer.begin(), buffer.end(), parameters.triggerNB.pmts);
233
234 if (buffer.begin() != __end) {
235
236 timesliceNB.push_back(JSuperFrame1D_t(super_frame->getDAQChronometer(),
237 super_frame->getModuleIdentifier(),
239
240 JSuperFrame1D_t zbuf;
241
242 buildL1(buffer.begin(), __end , back_inserter(zbuf));
243
244 buildNB(buffer.begin() , __end, zbuf, back_inserter(*timesliceNB.rbegin()));
245 }
246 }
247
248
249
250 timerL1.start();
251
252 timesliceL1.push_back(JSuperFrame1D_t(super_frame->getDAQChronometer(),
253 super_frame->getModuleIdentifier(),
255
256 buildL1(*timesliceL0.rbegin(), back_inserter(*timesliceL1.rbegin()));
257
258 timerL1.stop();
259
260
261
262 timerL2.start();
263
264 timesliceL2.push_back(JSuperFrame1D_t(super_frame->getDAQChronometer(),
265 super_frame->getModuleIdentifier(),
267
268 buildL2(buffer, *timesliceL1.rbegin(), back_inserter(*timesliceL2.rbegin()));
269
270 timerL2.stop();
271
272
273
274 timerSN.start();
275
276 timesliceSN.push_back(JSuperFrame1D_t(super_frame->getDAQChronometer(),
277 super_frame->getModuleIdentifier(),
279
280 buildSN(buffer, *timesliceL1.rbegin(), back_inserter(*timesliceSN.rbegin()));
281
282 timerSN.stop();
283 }
284 }
285
286
287
288 if (parameters.triggerNB.enabled) {
289
290 timerTX.start();
291
293
294 for (JTriggerInput::const_iterator hit = trigger_input.begin(); hit != trigger_input.end(); ++hit) {
295
296 if (parameters.triggerNB.write()) {
297
299 getTriggerMask(triggerNB.getTriggerBit()),
300 *hit,
301 timesliceRouter,
302 moduleRouter,
303 parameters.TMaxLocal_ns,
304 parameters.triggerNB.DMax_m,
305 getTimeRange(parameters.triggerNB));
306
308 }
309 }
310
311 timerTX.stop();
312 }
313
314 timerTR.start();
315
318
319 trigger3DMuon (trigger_input, back_inserter(trigger_output));
320 trigger3DShower(trigger_input, back_inserter(trigger_output));
321 triggerMXShower(trigger_input, timesliceL0, back_inserter(trigger_output));
322
324
325 numberOfTriggers += trigger_output.size();
326
327 timerTR.stop();
328
329 DEBUG(
"Number of triggers: " << trigger_output.size() << endl);
330
331 for (JTriggerOutput::const_iterator event = trigger_output.begin(); event != trigger_output.end(); ++event) {
332
333 timerTX.start();
334
336 timesliceRouter,
337 moduleRouter,
338 parameters.TMaxLocal_ns,
339 getTimeRange(parameters));
340
342
343 timerTX.stop();
344 }
345
346 if (parameters.writeL0()) {
347
348 timerTW.start();
349
351
352 timerTW.stop();
353 }
354
355 if (parameters.writeL1()) {
356
357 timerTW.start();
358
360
361 timerTW.stop();
362 }
363
364 if (parameters.writeL2()) {
365
366 timerTW.start();
367
369
370 timerTW.stop();
371 }
372
373 if (parameters.writeSN()) {
374
375 timerTW.start();
376
378
379 timerTW.stop();
380 }
381
382 if (parameters.writeSummary()) {
383
384 timerSW.start();
385
387
388 timerSW.stop();
389 }
390 }
392
394
395 const double factor = 1.0 / (double) counter;
396
397 for (
const JTimer* p : { &timerCC, &timerL0, &timerL1, &timerL2, &timerSN, &timerRX, &timerTR, &timerTX, &timerTW, &timerSW }) {
398 p->print(cout, factor);
399 }
400
401 NOTICE(
"Number of trigger/slices " << numberOfTriggers <<
"/" << counter << endl);
402 NOTICE(
"Trigger rate [Hz] " << numberOfTriggers * 1.0e9 * factor /
getFrameTime() << endl);
403 }
404
406
408
410}
#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 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.
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...