135{
139
141
144 JLimit_t& numberOfEvents = inputFile.getLimit();
147 int run;
153 double sigma_ns;
156
157 try {
158
159 JParser<> zap(
"Auxiliary program to trigger Monte Carlo events.");
160
161 zap[
'f'] =
make_field(inputFile,
"input file (output of detector simulation)");
175
177 }
178 catch(const exception &error) {
180 }
181
183
185
187
190 }
191
192
195
196 try {
199 }
202 }
203
206
208
210 FATAL(
"Invalid PMT parameters " << pmtParameters <<
endl);
211 }
212
213 if (pmtParameters.
getQE() != 1.0) {
214
215 WARNING(
"Correct background rates with global efficiency " << pmtParameters.
getQE() <<
endl);
216
218 }
219
221
222 try {
224 }
227 }
228
232
234
236
238
240
242
244
245 if (!scanner.empty()) {
246 UTC = scanner.begin()->getTimesliceStart();
247 } else {
248 FATAL(
"Run-by-run simulation misses summary data." <<
endl);
249 }
250
251 try {
255 }
258 }
259
260 try {
261
263
264 NOTICE(
"Set trigger parameters from run-by-run input." <<
endl);
265 }
267 WARNING(
"No trigger parameters from run-by-run input;\nrun with default/user input." <<
endl);
268 }
269
270
271
272 JHead buffer(header);
273
276
277 copy(buffer, header);
278
279 } else {
280
281 NOTICE(
"Using fixed rates [Hz]: " << rates_Hz <<
endl);
282
283 try {
287 }
290 }
291 }
292
293
294
295 if (parameters.disableHighRateVeto) {
296
297 NOTICE(
"Disabling high-rate veto of all PMTs." <<
endl);
298
300 }
301
303
306
309
310 const JTimeRange period(-(Tmax + parameters.TMaxLocal_ns),
311 +(Tmax + parameters.TMaxLocal_ns));
312
314
316
322
323 const JBuildL1_t buildL1(parameters);
324 const JBuildL2_t buildL2(parameters.L2);
325 const JBuildL2_t buildSN(parameters.SN);
326
328
332
333
334 TH1D h1(
"Trigger bits",
NULL, NUMBER_OF_TRIGGER_BITS, -0.5, NUMBER_OF_TRIGGER_BITS - 0.5);
335
336
338
341 }
342
347
349 int trigger_counter = 0;
350
351 for (string file_name; inputFile.hasNext(); ) {
352
354
355 Evt*
event = inputFile.next();
356
358
359 if (file_name != inputFile.getFilename()) {
360
361 file_name = inputFile.getFilename();
363 }
364
365 event->mc_run_id =
head.start_run.run_id;
366
367 if (run == -1) {
368 run = event->mc_run_id;
369 }
370
372 int frame_index = inputFile.getCounter() + 1;
374
376
378
380 FATAL(
"Monte Carlo event time undefined." <<
endl);
381 }
382
385
387
388 const Long64_t index = scanner.find(utc);
390
392 p = scanner.getEntry(index - 1);
393 }
394
397 }
398
400
404
406 <<
FIXED(15,3) << event->mc_event_time.AsDouble() <<
" [s] "
407 << utc << ' '
408 <<
FIXED(12,0) << t1 <<
" [ns] "
410 }
411
412 if (!event->mc_hits.empty() &&
frame_time(t1)) {
413
415
417
419
421
423
424 timeRange.
add(event->mc_t);
425 timeRange.
add(period);
426
428
430
432
433
434 timesliceRouter.configure(timeslice);
435
436 JTimeslice_t
timesliceL0(timeslice.getDAQChronometer());
437 JTimeslice_t
timesliceL1(timeslice.getDAQChronometer());
438 JTimeslice_t
timesliceL2(timeslice.getDAQChronometer());
439 JTimeslice_t
timesliceSN(timeslice.getDAQChronometer());
440
442
443 if (moduleRouter.hasModule(
super_frame->getModuleID())) {
444
445
446
447 const JModule&
module = moduleRouter.getModule(super_frame->getModuleID());
448 const JSuperFrame2D_t& buffer = JSuperFrame2D_t::demultiplex(*
super_frame,
module);
449
450
451
453
455
456
457
461
463
465
466
467
471
473
475
476
477 {
478 JTimeslice_t::value_type tv(
super_frame->getDAQChronometer(),
481
483
484 if (!tv.empty()) {
485
487
489 }
490 }
491 }
492 }
493
494
495
496
499
503
505
507
508 for (int i = 0; i != h1.GetNbinsX(); ++i) {
509 if (
to->hasTriggerBit(i)) {
510 h1.Fill((double) i);
511 }
512 }
513
515
518
520 cout <<
"Event time: "
521 <<
to->getFrameIndex() <<
' '
523 << timeRange << ' '
525 }
526
528
530 timesliceRouter,
531 moduleRouter,
532 parameters.TMaxLocal_ns,
533 getTimeRange(parameters));
534
535 tev.setCounter(trigger_counter);
536
538
540 }
541 }
542
543
545
546 if (parameters.writeL0()) {
548 }
549
550 if (parameters.writeL1()) {
552 }
553
554 if (parameters.writeL2()) {
556 }
557
558 if (parameters.writeSN()) {
560 }
561
562 if (parameters.writeSummary()) {
563
565
567
569 }
570 }
571 }
572 }
573
575
577
578 ++trigger_counter;
579 }
580 }
582
583 {
585
587 }
588
592}
#define DEBUG(A)
Message macros.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
static double getSigma()
Get intrinsic time smearing of K40 coincidences.
static void setSigma(const double sigma)
Set intrinsic time smearing of K40 coincidences.
Default implementation of the simulation of K40 background.
Router for direct addressing of module data in detector data structure.
Data structure for a composite optical module.
Default PMT simulation interface.
Auxiliary class for map of PMT parameters.
double getQE(const JPMTIdentifier &id) const
Get QE of given PMT.
bool is_valid() const
Check validity of PMT parameters.
virtual const char * what() const override
Get error message.
static void Throw(const bool option)
Enable/disable throw option.
Template definition of a multi-dimensional oscillation probability interpolation table.
Router for fast addressing of summary data in KM3NETDAQ::JDAQSummaryslice data structure as a functio...
CLB simulation based on run-by-run information.
K40 simulation based on run-by-run information.
PMT simulation based on run-by-run information.
Auxiliary class to build KM3NETDAQ::JDAQEvent for a triggered event.
JDAQUTCExtended getTimesliceStart() const
Get start of timeslice.
Data structure for UTC time.
static const JDAQUTCExtended & getInstance()
Get arbitrary offset (e.g.
JTimeRange getTimeRange(const Evt &event)
Get time range (i.e. time between earliest and latest hit) of Monte Carlo event.
void copy(const Head &from, JHead &to)
Copy header from from to to.
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).
double getTimeDuration(const JDAQUTCTimeRange &utc)
Get time duration of given UTC time range.
JDAQUTCTimeRange getUTCTimeRange()
Get UTC time range.
JTriggerParameters getTriggerParameters(const JMultipleFileScanner_t &file_list)
Get trigger parameters.
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
KM3NeT DAQ data structures and auxiliaries.
double getFrameTime()
Get frame time duration.
void setDAQLongprint(const bool option)
Set DAQ print option.
double getTimeOfFrame(const int frame_index)
Get start time of frame in ns since start of run for a given frame index.
double getMaximalTime(const double R_Hz)
Get maximal time for given rate.
double getTimeDifference(const JDAQChronometer &first, const JDAQChronometer &second)
Get time difference between two chronometers.
JDAQUTCExtended getDAQUTCExtended(const TTimeStamp &t0, const double t1=0.0)
Get DAQ UTC time.
static const int HIGH_RATE_VETO_DISABLE
Enable (disable) use of high-rate veto test if this status bit is 0 (1);.
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Auxiliary data structure for floating point format specification.
The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred ...
Match of two events considering overlap in time and position.
Transmission with position.
Template definition of random value generator.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Auxiliary class for K40 rates.
void correct(const double QE)
Correct rates for global efficiency,.
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...
Timeslice with Monte Carlo event.
Auxiliary class to create summary data.