202{
206
218 string background;
221
222 try {
223
224 JParser<> zap(
"Auxiliary program to determine PMT parameters from K40 data.");
225
240
242 }
243 catch(const exception &error) {
245 }
246
247
248
249
250
251
252 if (selector == JDAQTimesliceL2::Class_Name() ||
253 selector == JDAQTimesliceSN::Class_Name()) {
254 FATAL(
"Option -C <selector> " << selector <<
" not compatible with calibration method." <<
endl);
255 }
256
257 if (selector == JDAQTimeslice ::Class_Name() ||
258 selector == JDAQTimesliceL1::Class_Name()) {
259
261
262 try {
264 }
266 FATAL(
"No trigger parameters from input:" << error.
what() <<
endl);
267 }
268
269 if ((selector == JDAQTimeslice ::Class_Name() && parameters.writeL1.prescale > 0) ||
270 (selector == JDAQTimesliceL1::Class_Name())) {
271
272 if (parameters.TMaxLocal_ns < TMax_ns) {
273 FATAL(
"Option -T <TMax_ns> = " << TMax_ns <<
" is larger than in the trigger " << parameters.TMaxLocal_ns <<
endl);
274 }
275
278 FATAL(
"Option -C <selector> " << selector <<
" incompatible with option -b <background> " << background <<
endl);
279 }
280 }
281 }
282
283 if (!multiplicity.is_valid() || multiplicity.getLowerLimit() < 2 || multiplicity.getUpperLimit() > NUMBER_OF_PMTS) {
284 FATAL(
"Invalid option -M <multiplicity> " << multiplicity <<
endl);
285 }
286
290 }
291
293
296 }
297
298 if (
Tail_ns.getUpperLimit() > TMax_ns) {
299 FATAL(
"Invalid option -B <Tail_ns> " <<
Tail_ns <<
"; upper limit larger than option -T <TMax_ns> " << TMax_ns <<
endl);
300 }
301 }
302
303
304
305
306
308
309 try {
311 }
314 }
315
318 }
319
321
322
323
324
325
327
329 t0.push_back(i * 2 * TMax_ns);
330 }
331
332
333
334
335
337
338 const int NPE = 1;
340 /
342
343
344
345
346
347
349
353
355
357
359
361
363 }
364 }
365
366
370
372
374
375
377
379
381
382 for (JMultipleFileScanner_t::const_iterator i = inputFile.begin(); i != inputFile.end(); ++i) {
383
385
387
390
391 for (
JDAQHeader header; in.hasNext() && counter != numberOfEvents; ++counter) {
392
394
396
399
401
403 }
404
406
408
410
411 ERROR(
"Frame indices do not match at "
412 << "[counter = " << counter << "]"
414 <<
"[summaryslice = " << summary.getFrameIndex() <<
"]" <<
endl);
415
416 continue;
417 }
418 }
419
420 for (JDAQTimeslice::const_iterator frame = timeslice->begin(); frame != timeslice->end(); ++frame) {
421
422 if (router.hasModule(frame->getModuleID())) {
423
424 const JModule&
module = router.getModule(frame->getModuleID());
425
426
427
428
429
432
434
437 }
438
439 }
else if (background ==
tails_t) {
440
441
442
443 }
else if (background ==
rndms_t) {
444
445
446
447 }
else if (background ==
rates_t) {
448
449 if (summary.hasSummaryFrame(frame->getModuleID())) {
450
451 const JDAQSummaryFrame& sum = summary.getSummaryFrame(frame->getModuleID());
452
456 }
457
458 } else {
459
460 FATAL(
"Summary frame of module " << frame->getModuleID() <<
" not found at frame index " << timeslice->
getFrameIndex() <<
endl);
461 }
462 }
463
465
466
467
468
474 }
475 }
476
477 const JHistogram&
histogram = zmap[router.getAddress(frame->getModuleID()).first];
479
483
484
485
486
487
488 JSuperFrame2D_t& buffer = JSuperFrame2D_t::demultiplex(*frame,
module);
489
490 buffer.preprocess(option, match);
491
492 for (JSuperFrame2D_t::iterator i = buffer.begin(); i != buffer.end(); ++i) {
493 if (
veto[i->getPMTAddress()]) {
494 i->reset();
495 }
496 }
497
498 JSuperFrame1D_t&
data = JSuperFrame1D_t::multiplex(buffer);
499
500 DEBUG(
"Number of hits " << timeslice->
getFrameIndex() <<
":" << frame->getModuleID() <<
' ' << frame->size() <<
' ' <<
data.size() <<
endl);
501
502
503
504
506
508
510
512
513 while (++q !=
data.end() && q->getT() - p->getT() <= TMax_ns) {}
514
516
517 if (multiplicity(N)) {
518
520
522
525
532
535 }
536 }
537 }
538
539 t1 = p->getT();
540 }
541 }
542
543 p = q;
544 }
545
546
547
548
550
552 *i =
hit_type(i->getPMT(),
JHit(i->getT() + t0[i->getPMT()], i->getToT()));
553 }
554
556
558
560
562
563 while (++q !=
data.end() && q->getT() - p->getT() <= TMax_ns) {}
564
566
567 if (multiplicity(N)) {
568
570
573
580
581 h1b->Fill((
double)
combinatorics.getIndex(p->getPMT(),q->getPMT()), 1.0);
582 }
583 }
584 }
585
586 t1 = p->getT();
587 }
588 }
589
590 p = q;
591 }
592
593 }
else if (background ==
rates_t ||
595
597
601 }
602 }
603
606
608
611
612
613
614
615
616
617 const double N =
getP((
R1) * 2 * TMax_ns * 1e-9,
618 (R2) * 2 * TMax_ns * 1e-9,
619 (
Rs -
R1 - R2) * 2 * TMax_ns * 1e-9,
620 multiplicity.getLowerLimit(),
621 multiplicity.getUpperLimit()) *
getFrameTime() / (2*TMax_ns);
622
624 }
625 }
626 }
627 }
628
629
630
631
632
634
635 for (
size_t i = 0; i <
combinatorics.getNumberOfPairs(); ++i) {
636
639
641 h1L->Fill(i, livetime_s);
642 }
643 }
644 }
645 }
646 }
647 }
649
651
652 const double R = (2.0*TMax_ns) / ((
ymax -
ymin)/
ny);
653
655
656 if (
hr->is_valid()) {
657
660
661 for (
int ix = 1;
ix <= h1b->GetXaxis()->GetNbins(); ++
ix) {
662
663 double Y = 0.0;
664 double W = 0.0;
665 int N = 0;
666
667 for (
int iy = 1;
iy <= h2s->GetYaxis()->GetNbins(); ++
iy) {
668
669 const double y = h2s->GetYaxis()->GetBinCenter(
iy) ;
670
672 Y += h2s->GetBinContent(
ix,
iy);
673 W += h2s->GetBinError (
ix,
iy) * h2s->GetBinError(
ix,
iy);
674 N += 1;
675 }
676 }
677
678 h1b->SetBinContent(
ix, Y/N * R);
679 h1b->SetBinError (
ix, sqrt(W/N) * R);
680 }
681 }
682 }
683 }
684
685
686
687
688
690
694
698
700
702 if (i->is_valid()) {
703 out << *(i->h2s);
704 out << *(i->h1b);
705 out << *(i->h1L);
706 }
707 }
708
709 out.Write();
710 out.Close();
711}
#define DEBUG(A)
Message macros.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Address of module in detector data structure.
int first
index of module in detector data structure
Router for direct addressing of module data in detector data structure.
Data structure for a composite optical module.
virtual const char * what() const override
Get error message.
Template definition of a multi-dimensional oscillation probability interpolation table.
File router for fast addressing of summary data.
Reduced data structure for L0 hit.
int getDetectorID() const
Get detector identifier.
int getRunNumber() const
Get run number.
int getFrameIndex() const
Get frame index.
const JDAQFrameStatus & getDAQFrameStatus() const
Get DAQ frame status.
Data storage class for rate measurements of all PMTs in one module.
double getRate(const int tdc, const double factor=1.0) const
Get count rate.
JRate_t getValue(const int tdc) const
Get value.
static const char *const WB_t
Named bin for value of TMax_ns in JCalibrateK40.
static const char *const weights_hist_t
Histogram naming.
static const char *const WS_t
Named bin for time residual bin width.
static const char *const W1_overall_t
Named bin for duration of the run.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
double getP(const double expval, bool hit)
Get Poisson probability to observe a hit or not for given expectation value for the number of hits.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
bool putObject(TDirectory &dir, const TObject &object)
Write object to ROOT directory.
JTriggerParameters getTriggerParameters(const JMultipleFileScanner_t &file_list)
Get trigger parameters.
bool getDAQStatus(const JDAQFrameStatus &frame, const JStatus &status)
Test status of DAQ.
bool getPMTStatus(const JStatus &status)
Test status of PMT.
KM3NeT DAQ data structures and auxiliaries.
double getFrameTime()
Get frame time duration.
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Transmission with position.
PMT analogue signal processor.
virtual double getNPE(const double tot_ns) const override
Get number of photo-electrons.
double getIntegralOfChargeProbability(const double xmin, const double xmax, const int NPE) const
Get integral of probability.
Auxiliary data structure for streaming of STL containers.
Auxiliary class to select ROOT class based on class name.
static counter_type max()
Get maximum counter value.
Auxiliary base class for list of file names.
Auxiliary class for specifying the way of pre-processing of hits.
static std::vector< JPreprocessor > getOptions()
Get options.
@ filter_t
filter consecutive hits according match criterion