261 {
263
264
265 ATHRNG::RNGWrapper* rngWrapper = nullptr;
266 CLHEP::HepRandomEngine* rngEngine = nullptr;
271 }
272
275
277 if (first) {
280 IdContext drawer_context =
m_tileHWID->drawer_context();
282 const int nchMax = 48;
283 for (
int dr = 0;
dr < ndrawers; ++
dr) {
284 HWIdentifier drawer_id;
285 m_tileHWID->get_id(dr, drawer_id, &drawer_context);
289 IdentifierHash idhash;
290 m_tileHWID->get_hash(drawer_id, idhash, &drawer_context);
291 for (
int ch = 0;
ch < nchMax; ++
ch) {
295 double sigmaHi_Norm = sampleNoise->getHfnNorm(idhash, ch,
TileID::HIGHGAIN);
297 double sigmaLo_Hfn1 = sampleNoise->getHfn1(idhash, ch,
TileID::LOWGAIN);
298 double sigmaLo_Hfn2 = sampleNoise->getHfn2(idhash, ch,
TileID::LOWGAIN);
299 double sigmaLo_Norm = sampleNoise->getHfnNorm(idhash, ch,
TileID::LOWGAIN);
301 << " pedHi="<< pedSimHi
302 << " pedLo="<< pedSimLo
303 << " rmsHi="<< sigmaHi_Hfn1 << "," << sigmaHi_Hfn2 << "," << sigmaHi_Norm
304 << " rmsLo="<< sigmaLo_Hfn1 << "," << sigmaLo_Hfn2 << "," << sigmaLo_Norm);
305
306 }
307 }
308 }
309 }
310
311
312 double Rndm[16];
313 double RndmLo[16];
314 double Rndm_dG[1];
315 double RndmLo_dG[1];
316
317
320
321 SG::ReadHandle<TileHitContainer> hitContainer_DigiHSTruth;
325 }
326
327
328 int nChSum = 0;
329 int nChHiSum = 0;
330 int nChLoSum = 0;
331 int nChHiAcc = 0;
332 int nChLoAcc = 0;
333 int nChHiFlt = 0;
334 int nChLoFlt = 0;
335 int nChHiCut = 0;
336 int nChLoCut = 0;
337 double echtot_Acc = 0.;
338 double echint_Acc = 0.;
339 double echtot_Cut = 0.;
340 double echint_Cut = 0.;
342 double EneSum = 0.;
343 double RChSum = 0.;
344
345
346
347 auto digitsContainer = std::make_unique<TileMutableDigitsContainer>(true,
351
352 std::unique_ptr<TileMutableDigitsContainer> digitsContainer_DigiHSTruth;
354 digitsContainer_DigiHSTruth = std::make_unique<TileMutableDigitsContainer>(true,
357 ATH_CHECK( digitsContainer_DigiHSTruth->status() );
358 }
359
360 std::unique_ptr<TileMutableDigitsContainer> filteredContainer;
362 filteredContainer = std::make_unique<TileMutableDigitsContainer>(true,
366 ATH_CHECK( filteredContainer->status() );
367 }
368
369
370 IdentifierHash idhash;
371 IdContext drawer_context =
m_tileHWID->drawer_context();
372 const int nchMax = 48;
373 std::vector<int>
igain(nchMax, -1);
374 std::vector<int> ntot_ch(nchMax, 0);
375 std::vector<double> ech_tot(nchMax, 0.0);
376 std::vector<double> ech_int(nchMax, 0);
377 std::vector<double> ech_int_DigiHSTruth(nchMax, 0);
378 std::vector<int> over_gain(nchMax, -1);
379
380
382 std::vector<float> digitsBufferLo(
m_nSamples);
383 std::vector<float> digitsBuffer_DigiHSTruth(
m_nSamples);
384 std::vector<float> digitsBufferLo_DigiHSTruth(
m_nSamples);
385
386 std::vector<double> emptyBuffer;
387 std::vector<std::vector<double>> drawerBufferHi(nchMax, std::vector<double>(
m_nSamples));
388 std::vector<std::vector<double>> drawerBufferLo(nchMax, std::vector<double>(
m_nSamples));
389
390 std::vector<std::vector<double>> drawerBufferHi_DigiHSTruth;
391 std::vector<std::vector<double>> drawerBufferLo_DigiHSTruth;
393 drawerBufferHi_DigiHSTruth.resize(nchMax, std::vector<double>(
m_nSamples));
394 drawerBufferLo_DigiHSTruth.resize(nchMax, std::vector<double>(
m_nSamples));
395 }
396
397
398
399
400 Bool_t coherNoiseHi = false;
401 Bool_t coherNoiseLo = false;
402 TMatrixD CorrWeightHi;
403 TMatrixD CorrWeightLo;
404 std::vector<std::unique_ptr<double[]>> CorrRndmVec;
405 std::vector<std::unique_ptr<double[]>> CorrRndmVecLo;
408 CorrRndmVec.push_back(std::make_unique<double[]>(nchMax));
409 }
412 CorrRndmVecLo.push_back(std::make_unique<double[]>(nchMax));
413 }
414 }
415 }
416
419 std::unique_ptr<TileMutableDigitsContainer> backgroundDigitContainer{};
421 backgroundDigitContainer = std::make_unique<TileMutableDigitsContainer>(true,
424 ATH_CHECK( backgroundDigitContainer->status() );
425
428 TimedDigitContList digitContList;
431
432
433 if (digitContList.size() == 0) {
435 return StatusCode::SUCCESS;
436 }
437
438 TimedDigitContList::iterator iTzeroDigitCont(digitContList.begin());
439 for (const auto* digitCollection : *(iTzeroDigitCont->second)) {
440 for (const auto* digit : *digitCollection) {
441 auto pDigits = std::make_unique<TileDigits>(*digit);
442 ATH_CHECK(backgroundDigitContainer->push_back(std::move(pDigits)));
443 }
444 }
445 }
448 if (tileDigitsContainerHandle.isValid()) {
449 for (const auto* digitCollection : *tileDigitsContainerHandle) {
450 for (const auto* digit : *digitCollection) {
451 auto pDigits = std::make_unique<TileDigits>(*digit);
452 ATH_CHECK(backgroundDigitContainer->push_back(std::move(pDigits)));
453 }
454 }
455 }
456 else {
457 ATH_MSG_ERROR(
"ReadHandle to Background Digits is invalid.");
458 return StatusCode::FAILURE;
459 }
460 }
461
462 collItrRndm = backgroundDigitContainer->begin();
463 lastCollRndm = backgroundDigitContainer->end();
464 }
465
466 SG::ReadCondHandle<TileEMScale> emScale(
m_emScaleKey, ctx);
468
469 const TilePulse* pulse = nullptr;
473 pulse = pulseShape.retrieve();
474 }
475
478
479 const TileDQstatus* dqStatus = nullptr;
481 SG::ReadHandle<TileDQstatus> DQstatusHandle(
m_DQstatusKey, ctx);
483 dqStatus = DQstatusHandle.get();
484 }
485
486 const TileBadChannels* badChannels = nullptr;
488 SG::ReadCondHandle<TileBadChannels> badChannelsHandle(
m_badChannelsKey,ctx);
489 ATH_CHECK( badChannelsHandle.isValid() );
490 badChannels = badChannelsHandle.retrieve();
491 }
492
493
494
495 TileHitContainer::const_iterator collItr_DigiHSTruth;
496 if(
m_doDigiTruth) collItr_DigiHSTruth = hitContainer_DigiHSTruth->begin();
497
498
499
500
501
502
503 for (const TileHitCollection* hitCollection : *hitContainer) {
504
505 HWIdentifier drawer_id =
m_tileHWID->drawer_id(hitCollection->identify());
510 ATH_MSG_VERBOSE(
"ROS "<< ros <<
" drawer " << drawer <<
" is connected");
511 } else {
513 ++collItrRndm;
514 }
516 ++collItr_DigiHSTruth;
517 }
518 continue;
519 }
520
521 m_tileHWID->get_hash(drawer_id, idhash, &drawer_context);
522 const std::unique_ptr<HWIdentifier[]>& adc_ids =
m_all_ids[idhash];
523
524
525
526
527
530 std::fill(over_gain.begin(), over_gain.end(), -1);
533 }
534
535 std::fill(ech_tot.begin(), ech_tot.end(), 0.0);
536 std::fill(ech_int.begin(), ech_int.end(), 0.0);
537 std::fill(ntot_ch.begin(), ntot_ch.end(), 0);
538 std::fill(
igain.begin(),
igain.end(), igainch);
539
540 std::vector<std::reference_wrapper<std::vector<std::vector<double>>>> drawerBuffers{drawerBufferHi, drawerBufferLo};
542 drawerBuffers.push_back(drawerBufferHi_DigiHSTruth);
543 drawerBuffers.push_back(drawerBufferLo_DigiHSTruth);
544 }
545 for (std::vector<std::vector<double>>& drawerBuffer : drawerBuffers) {
546 for (std::vector<double>& digitsBuffer : drawerBuffer) {
547 std::fill(digitsBuffer.begin(), digitsBuffer.end(), 0);
548 }
549 }
550
552 const TileDigitsCollection *bkgDigitCollection(*collItrRndm);
554 igain, ros, drawer, drawerIdx, over_gain, *emScale, *sampleNoise, dqStatus, badChannels));
555 ++collItrRndm;
556 }
557
558 std::vector<bool> signal_in_channel(nchMax, false);
559 std::vector<bool> signal_in_channel_DigiHSTruth(nchMax, false);
561 igain, over_gain, ech_int, signal_in_channel, *emScale, *samplingFraction, pulse));
564 igain, over_gain, ech_int_DigiHSTruth, signal_in_channel_DigiHSTruth, *emScale, *samplingFraction, pulse));
565 }
566
567
568
569 if (
msgLvl(MSG::VERBOSE)) {
570 for (int ich = 0; ich < nchMax; ++ich) {
571 if (igain[ich] > -1) {
572 std::vector<double>& digitSamplesHi = drawerBufferHi[ich];
573 std::vector<double>& digitSamplesLo = drawerBufferLo[ich];
574 msg(MSG::VERBOSE) <<
"total: ADC " <<
m_tileHWID->to_string(adc_ids[ich],-1) <<
"/" <<
igain[ich]
575 << " nhit=" << ntot_ch[ich]
576 << " e_ch=" << ech_tot[ich]
577 <<
" AinTHi=" << digitSamplesHi[
m_iTrig]
579 }
580 }
581 }
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
600 << " drawer " << drawer
601 << " with " << nchMax << " channels and "
603
604
605 coherNoiseHi = 1;
606 if (coherNoiseHi) {
609 }
610
611
612 coherNoiseLo = 1;
613 if (coherNoiseLo) {
616 }
617
618
620 double* RndmVec = CorrRndmVec[
k].get();
621 RandGaussQ::shootArray(rngEngine, nchMax, RndmVec, 0.0, 1.0);
622 }
623
626 double * RndmVecLo = CorrRndmVecLo[
k].get();
627 RandGaussQ::shootArray(rngEngine, nchMax, RndmVecLo, 0.0, 1.0);
628 }
629 }
630 }
631
632
633
634 for (int ich = 0; ich < nchMax; ++ich) {
635
636 if (igain[ich] < 0)
637 continue;
638
639
640 ++nChHiSum;
641 HWIdentifier adc_id = adc_ids[ich];
642 HWIdentifier adc_id_lo;
643 Identifier pmt_id =
m_cabling->h2s_pmt_id(adc_id);
645 <<
" PMT " << (pmt_id.
is_valid() ?
m_tileID->to_string(pmt_id,-1) : (signal_in_channel[ich] ?
"fake gap" :
"not connected"))
646 << " gain=" << igain[ich]);
647
651 ++nChLoSum;
652 }
653 }
654
655 bool chanLoIsBad = false;
656 bool chanHiIsBad = false;
660 chanLoIsBad = statusLo.
isBad();
661 chanHiIsBad = statusHi.
isBad();
662 }
663
664
665 double pedSimHi(0.), sigmaHi_Hfn1(0.), sigmaHi_Hfn2(0.), sigmaHi_Norm(0.), pedSimLo(0.),
666 sigmaLo_Hfn1(0.), sigmaLo_Hfn2(0.), sigmaLo_Norm(0.);
667 bool good_ch = (over_gain[ich]<9);
670 bool tileNoiseHG(false),tileNoiseLG(false);
671
672 if (overNoiseHG) {
675
677
678 if (pedSimHi == 0.0 && (signal_in_channel[ich] || pmt_id.
is_valid()))
679 pedSimHi = 50.;
680
683 if (sigmaHi_Hfn1>0 || sigmaHi_Hfn2) {
684 sigmaHi_Norm = sigmaHi_Hfn1 / (sigmaHi_Hfn1
686 } else {
688 sigmaHi_Norm = 1.;
689 }
690 }
691
692 if (overNoiseLG) {
695
697
698 if (pedSimLo == 0.0 && (signal_in_channel[ich] || pmt_id.
is_valid()))
699 pedSimLo = 30.;
700
703 if (sigmaLo_Hfn1 > 0 || sigmaLo_Hfn2) {
704 sigmaLo_Norm = sigmaLo_Hfn1 / (sigmaLo_Hfn1
705 + sigmaLo_Hfn2 * sampleNoise->getHfnNorm(idhash, ich,
TileID::LOWGAIN));
706 } else {
708 sigmaLo_Norm = 1.;
709 }
710 }
711
712
713 if (tileNoiseLG) {
714 RandGaussQ::shootArray(rngEngine,
m_nSamples, Rndm, 0.0, 1.0);
715 RandFlat::shootArray(rngEngine, 1, Rndm_dG, 0.0, 1.0);
717 RandGaussQ::shootArray(rngEngine,
m_nSamples, RndmLo, 0.0, 1.0);
718 RandFlat::shootArray(rngEngine, 1, RndmLo_dG, 0.0, 1.0);
719 }
720 }
721
722 std::vector<double>& digitSamplesHi = drawerBufferHi[ich];
723 std::vector<double>& digitSamplesLo = drawerBufferLo[ich];
724 std::vector<double>& digitSamplesHi_DigiHSTruth = (
m_doDigiTruth) ? drawerBufferHi_DigiHSTruth[ich] : emptyBuffer;
725 std::vector<double>& digitSamplesLo_DigiHSTruth = (
m_doDigiTruth) ? drawerBufferLo_DigiHSTruth[ich] : emptyBuffer;
726
727 ATH_MSG_DEBUG(
" Channel " << ros <<
'/' << drawer <<
'/' << ich
728 <<
" sampHi=" << digitSamplesHi[
m_iTrig]
729 << " pedHi=" << pedSimHi
730 <<
" sampLo=" << digitSamplesLo[
m_iTrig]
731 << " pedLo=" << pedSimLo);
732
733
735
736 digitsBuffer[
js] = digitSamplesHi[
js] + pedSimHi;
738 digitsBuffer_DigiHSTruth[
js] = digitSamplesHi_DigiHSTruth[
js] + pedSimHi;
739 }
740
741 double noiseHi(0.0);
742
743 if (coherNoiseHi) {
744
745 std::unique_ptr<double[]>& CorVec = CorrRndmVec[
js];
746
747 for (
int i = 0;
i < nchMax; ++
i) noiseHi += CorrWeightHi(i, ich) * CorVec[
i];
748 } else if (tileNoiseHG) {
749
750 if (Rndm_dG[0] < sigmaHi_Norm) noiseHi = sigmaHi_Hfn1 * Rndm[
js];
751 else noiseHi = sigmaHi_Hfn2 * Rndm[
js];
752 }
753
754 if (digitsBuffer[js] + noiseHi >= 0.0) {
755 digitsBuffer[
js] += noiseHi;
757 } else {
758 digitsBuffer[
js] -= noiseHi;
760 }
761
762
764 digitsBuffer[
js] =
round(digitsBuffer[js]);
766 }
767
769 digitsBufferLo[
js] = digitSamplesLo[
js] + pedSimLo;
770 if(
m_doDigiTruth) digitsBufferLo_DigiHSTruth[
js] = digitSamplesLo_DigiHSTruth[
js] + pedSimLo;
771 double noiseLo(0.0);
772
773 if (coherNoiseLo) {
774
775 std::unique_ptr<double[]>& CorVecLo = CorrRndmVecLo[
js];
776
777 for (
int i = 0;
i < nchMax; ++
i) noiseLo += CorrWeightLo(i, ich) * CorVecLo[
i];
778 } else if (tileNoiseLG) {
779
780 if (RndmLo_dG[0] < sigmaLo_Norm) noiseLo = sigmaLo_Hfn1 * RndmLo[
js];
781 else noiseLo = sigmaLo_Hfn2 * RndmLo[
js];
782 }
783
784 if (digitsBufferLo[js] + noiseLo >= 0.0) {
785 digitsBufferLo[
js] += noiseLo;
787 } else {
788 digitsBufferLo[
js] -= noiseLo;
790 }
791
793 digitsBufferLo[
js] =
round(digitsBufferLo[js]);
795 }
796
797
799
800 --nChHiSum;
801 ++nChLoSum;
804
805
807 digitsBuffer[
js] = digitSamplesLo[
js] + pedSimLo;
808 if(
m_doDigiTruth) digitsBuffer_DigiHSTruth[
js] = digitSamplesLo_DigiHSTruth[
js] + pedSimLo;
809 double noiseLo(0.0);
810
811 if (coherNoiseLo) {
812
813 double* CorVec = CorrRndmVec[
js].get();
814
815 for (
int i = 0;
i < nchMax; ++
i) noiseLo += CorrWeightLo(i, ich) * CorVec[
i];
816 } else if (tileNoiseLG) {
817
818
819 if (Rndm_dG[0] < sigmaLo_Norm) noiseLo = sigmaLo_Hfn1 * Rndm[
js];
820 else noiseLo = sigmaLo_Hfn2 * Rndm[
js];
821 }
822
823 if (digitsBuffer[js] + noiseLo >= 0.0) {
824 digitsBuffer[
js] += noiseLo;
826 } else {
827 digitsBuffer[
js] -= noiseLo;
829 }
830
831 if (digitsBuffer[js] >
m_f_ADCmax && good_ch) {
834 }
836 digitsBuffer[
js] =
round(digitsBuffer[js]);
838 }
839 }
840
841 overNoiseHG = false;
842
843 if (
msgLvl(MSG::VERBOSE)) {
844 msg(MSG::VERBOSE) <<
"Channel " <<
ros <<
'/' <<
drawer <<
'/' << ich <<
"/" <<
igain[ich]
845 <<
" Switch to low gain Amp(lo)=" << digitsBuffer[
m_iTrig] <<
endmsg;
846 if (overNoiseLG) {
847 if (sigmaLo_Norm<1.0) {
848 msg(MSG::VERBOSE) <<
"LG Ped & noise from DB "
849 << pedSimLo << " " << sigmaLo_Hfn1 << " " << sigmaLo_Hfn2 << " " << sigmaLo_Norm
850 << ((Rndm_dG[0] < sigmaLo_Norm)?(
" sig1 used"):(
" sig2 used")) <<
endmsg;
851 } else {
852 msg(MSG::VERBOSE) <<
"LG Ped & noise from DB "
853 << pedSimLo <<
" " << sigmaLo_Hfn1 <<
endmsg;
854 }
855 }
856 }
857 break;
858 }
859 }
860 if (
msgLvl(MSG::VERBOSE)) {
861 if (overNoiseHG) {
862 if (sigmaHi_Norm<1.0) {
863 msg(MSG::VERBOSE) <<
"HG Ped & noise from DB "
864 << pedSimHi << " " << sigmaHi_Hfn1 << " " << sigmaHi_Hfn2 << " " << sigmaHi_Norm
865 << ((Rndm_dG[0] < sigmaHi_Norm)?(
" sig1 used"):(
" sig2 used")) <<
endmsg;
866 } else {
867 msg(MSG::VERBOSE) <<
"HG Ped & noise from DB "
868 << pedSimHi <<
" " << sigmaHi_Hfn1 <<
endmsg;
869 }
870 }
872 if (sigmaLo_Norm<1.0) {
873 msg(MSG::VERBOSE) <<
"LG Ped & noise from DB "
874 << pedSimLo << " " << sigmaLo_Hfn1 << " " << sigmaLo_Hfn2 << " " << sigmaLo_Norm
875 << ((RndmLo_dG[0] < sigmaLo_Norm)?(
" sig1 used"):(
" sig2 used")) <<
endmsg;
876 } else {
877 msg(MSG::VERBOSE) <<
"LG Ped & noise from DB "
878 << pedSimLo <<
" " << sigmaLo_Hfn1 <<
endmsg;
879 }
880 }
881 }
882
884
885 if (chanHiIsBad) {
888 std::fill(digitsBuffer_DigiHSTruth.begin(), digitsBuffer_DigiHSTruth.end(),
m_f_ADCmaskValue);
889 }
890 ATH_MSG_DEBUG(
"Masking Channel " << ros <<
'/' << drawer <<
'/' << ich <<
"/1 HG" );
891 }
892
893 auto pDigits = std::make_unique<TileDigits>(adc_id, digitsBuffer);
894 ATH_CHECK( digitsContainer->push_back(std::move(pDigits)) );
895
897 auto digits_DigiHSTruth = std::make_unique<TileDigits>(adc_id, digitsBuffer_DigiHSTruth);
898 ATH_CHECK( digitsContainer_DigiHSTruth->push_back(std::move(digits_DigiHSTruth)) );
899 }
900
901 if (chanLoIsBad) {
904 std::fill(digitsBufferLo_DigiHSTruth.begin(), digitsBufferLo_DigiHSTruth.end(),
m_f_ADCmaskValue);
905 }
906
907 ATH_MSG_DEBUG(
"Masking Channel " << ros <<
'/' << drawer <<
'/' << ich <<
"/0 LG");
908 }
909
910 auto pDigitsLo = std::make_unique<TileDigits>(adc_id_lo, digitsBufferLo);
911 ATH_CHECK( digitsContainer->push_back(std::move(pDigitsLo)) );
912
914 auto pDigitsLo_DigiHSTruth = std::make_unique<TileDigits>(adc_id_lo, digitsBufferLo_DigiHSTruth);
915 ATH_CHECK( digitsContainer_DigiHSTruth->push_back(std::move(pDigitsLo_DigiHSTruth)) );
916 }
917 } else {
918
920
921
922 bool isChannelGood = true;
924 if (hiGain) {
925 double ampInTime = digitsBuffer[
m_iTrig] - pedSimHi;
927 ampInTime =
round(ampInTime);
930 isChannelGood = false;
931 } else {
933 isChannelGood = false;
934 }
935 }
936 }
937
938 if (isChannelGood) {
939 echtot_Acc += ech_tot[ich];
940 echint_Acc += fabs(ech_int[ich]);
941 if (hiGain) {
942 ++nChHiAcc;
943 } else {
944 ++nChLoAcc;
945 }
946
947 if (hiGain) {
948
949
950
951
952
953 if (chanHiIsBad) {
957 std::fill(digitsBuffer_DigiHSTruth.begin(), digitsBuffer_DigiHSTruth.end(),
m_f_ADCmaskValue);
958 }
959 } else if (good_ch) {
960 ATH_MSG_DEBUG(
"Disconnected Channel " << ros <<
'/' << drawer <<
'/' << ich);
961 std::fill(digitsBuffer.begin(), digitsBuffer.end(), 0.);
963 std::fill(digitsBuffer_DigiHSTruth.begin(), digitsBuffer_DigiHSTruth.end(), 0.);
964 }
965 }
966 ATH_MSG_DEBUG(
"Masking Channel " << ros <<
'/' << drawer <<
'/' << ich <<
"/1 HG");
967 }
968 } else {
969
970
971
972
973
974 if (chanLoIsBad) {
978 std::fill(digitsBuffer_DigiHSTruth.begin(), digitsBuffer_DigiHSTruth.end(),
m_f_ADCmaskValue);
979 }
980 } else if (good_ch) {
981 ATH_MSG_DEBUG(
"Disconnected Channel " << ros <<
'/' << drawer <<
'/' << ich);
982 std::fill(digitsBuffer.begin(), digitsBuffer.end(), 0.);
984 std::fill(digitsBuffer_DigiHSTruth.begin(), digitsBuffer_DigiHSTruth.end(), 0.);
985 }
986 }
987 ATH_MSG_DEBUG(
"Masking Channel " << ros <<
'/' << drawer <<
'/' << ich <<
"/0 LG");
988 }
989 }
990
991 auto pDigits = std::make_unique<TileDigits>(adc_id, digitsBuffer);
992
994 if (filteredContainer)
ATH_CHECK( filteredContainer->push_back(pDigits.get()) );
995 if (hiGain) {
996 ++nChHiFlt;
997 } else {
998 ++nChLoFlt;
999 }
1000 }
1001
1002 ATH_CHECK( digitsContainer->push_back(std::move(pDigits)) );
1004 auto pDigits_DigiHSTruth = std::make_unique<TileDigits>(adc_id, digitsBuffer_DigiHSTruth);
1005 ATH_CHECK( digitsContainer_DigiHSTruth->push_back(std::move(pDigits_DigiHSTruth)) );
1006 }
1007
1008 if (
msgLvl(MSG::VERBOSE)) {
1009 double pedSim = ((hiGain) ? pedSimHi : pedSimLo);
1010 double ampInTime = digitsBuffer[
m_iTrig] - pedSim;
1012 ampInTime =
round(ampInTime);
1016 << " AinT=" << ampInTime
1017 << " ped=" << pedSim
1018 << " Ech=" << ech_tot[ich]
1019 <<
" EinT=" << ech_int[ich] <<
endmsg;
1020 msg(MSG::VERBOSE) <<
"digits";
1021 for (
unsigned int i = 0;
i < digitsBuffer.size(); ++
i)
1022 msg(MSG::VERBOSE) <<
" " << digitsBuffer[
i];
1024 }
1025 } else {
1026 echtot_Cut += ech_tot[ich];
1027 echint_Cut += ech_int[ich];
1028 if (hiGain) {
1029 ++nChHiCut;
1030 } else {
1031 ++nChLoCut;
1032 }
1033
1034 if (
msgLvl(MSG::VERBOSE)) {
1035 double pedSim = ((hiGain) ? pedSimHi : pedSimLo);
1036 double ampInTime = digitsBuffer[
m_iTrig] - pedSim;
1038 ampInTime =
round(ampInTime);
1039 msg(MSG::VERBOSE) <<
"Reject. ADC " <<
m_tileHWID->to_string(adc_id)
1040 << " AinT=" << ampInTime
1041 << " ped=" << pedSim
1042 << " Ech=" << ech_tot[ich]
1043 <<
" EinT=" << ech_int[ich] <<
endmsg;
1044 }
1045 }
1046 }
1047 }
1049 }
1050
1051 if (
msgLvl(MSG::DEBUG)) {
1052 msg(MSG::DEBUG) <<
"TileDigitsMaker execution completed." <<
endmsg;
1053 msg(MSG::DEBUG) <<
" nCh=" << nChSum
1054 << " nChH/L=" << nChHiSum << "/" << nChLoSum
1055 << " nFltH/L=" << nChHiFlt << "/" << nChLoFlt
1057 << " Ene=" << EneSum
1058 <<
" RChSum=" << RChSum <<
endmsg;
1060 msg(MSG::DEBUG) <<
" Accepted: nChLo/Hi=" << nChLoAcc <<
"/" << nChHiAcc
1061 << " eTot=" << echtot_Acc
1062 <<
" eInT=" << echint_Acc <<
endmsg;
1063 msg(MSG::DEBUG) <<
" Rejected: nChLo/Hi=" << nChLoCut <<
"/" << nChHiCut
1064 << " eTot=" << echtot_Cut
1065 <<
" eInT=" << echint_Cut <<
endmsg;
1066 }
1067 }
1068
1069
1070
1072 ATH_CHECK( digitsCnt.record(std::move(digitsContainer)) );
1073
1076 ATH_CHECK( digits_DigiHSTruth.record(std::move(digitsContainer_DigiHSTruth)) );
1077 }
1078
1079 if (filteredContainer) {
1081 ATH_CHECK( filteredDigitsContainer.record(std::move(filteredContainer)) );
1082 }
1083
1084 return StatusCode::SUCCESS;
1085}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
bool msgLvl(const MSG::Level lvl) const
bool is_valid() const
Check if id is in a valid state.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const TileBchStatus & getAdcStatus(const HWIdentifier adc_id) const
Return Tile ADC status.
static unsigned int getDrawerIdx(unsigned int ros, unsigned int drawer)
Returns a drawer hash.
int m_nSamples
Number of time slices for each channel.
Gaudi::Property< std::string > m_randomStreamName
Random Stream Name.
SG::WriteHandleKey< TileDigitsContainer > m_digitsContainerKey
Gaudi::Property< int > m_allChannels
SG::ReadHandleKey< TileHitContainer > m_hitContainer_DigiHSTruthKey
SG::ReadCondHandleKey< TileBadChannels > m_badChannelsKey
Name of TileBadChannels in condition store.
Gaudi::Property< bool > m_onlyUseContainerName
SG::ReadHandleKey< TileHitContainer > m_hitContainerKey
float m_f_ADCmax
ADC saturation value.
bool m_tileNoise
If true => generate noise in TileDigits.
SG::ReadCondHandleKey< TilePulse > m_pulseShapeKey
Name of TilePulseShape in condition store.
SG::ReadHandleKey< TileDQstatus > m_DQstatusKey
Gaudi::Property< bool > m_rndmEvtOverlay
const TileHWID * m_tileHWID
SG::WriteHandleKey< TileDigitsContainer > m_filteredDigitsContainerKey
Gaudi::Property< bool > m_calibRun
StatusCode fillDigitCollection(const TileHitCollection *hitCollection, std::vector< std::vector< double > > &drawerBufferLo, std::vector< std::vector< double > > &drawerBufferHi, std::vector< int > &igain, std::vector< int > &overgain, std::vector< double > &ech_int, std::vector< bool > &signal_in_channel, const TileEMScale *emScale, const TileSamplingFraction *samplingFraction, const TilePulse *pulse) const
const TileInfo * m_tileInfo
bool m_tileThresh
If true => apply threshold to Digits.
Gaudi::Property< bool > m_useCoolPulseShapes
bool m_tileCoherNoise
If true => generate coherent noise in TileDigits.
ServiceHandle< PileUpMergeSvc > m_mergeSvc
const TileCablingService * m_cabling
TileCabling instance.
int m_iTrig
Index of the triggering time slice.
Gaudi::Property< bool > m_integerDigits
double m_tileThreshHi
Actual threshold value for high gain.
std::string m_inputDigitContainerName
Gaudi::Property< double > m_filterThresholdMBTS
SG::ReadCondHandleKey< TileEMScale > m_emScaleKey
Name of TileEMScale in condition store.
SG::ReadCondHandleKey< TileSampleNoise > m_sampleNoiseKey
Name of TileSampleNoise in condition store.
Gaudi::Property< bool > m_doDigiTruth
float m_f_ADCmaskValue
indicates channels which were masked in background dataset
SG::ReadCondHandleKey< TileSamplingFraction > m_samplingFractionKey
Name of TileSamplingFraction in condition store.
Gaudi::Property< double > m_filterThreshold
Gaudi::Property< bool > m_maskBadChannels
ServiceHandle< IAthRNGSvc > m_rndmSvc
Random number service to use.
SG::ReadHandleKey< TileDigitsContainer > m_inputDigitContainerKey
float m_f_ADCmaxHG
ADC saturation value - 0.5.
StatusCode overlayBackgroundDigits(const TileDigitsCollection *bkgDigitCollection, const TileHitCollection *hitCollection, std::vector< std::vector< double > > &drawerBufferLo, std::vector< std::vector< double > > &drawerBufferHi, std::vector< int > &igain, int ros, int drawer, int drawerIdx, std::vector< int > &over_gain, const TileEMScale *emScale, const TileSampleNoise *sampleNoise, const TileDQstatus *dqStatus, const TileBadChannels *badChannels) const
std::vector< std::unique_ptr< HWIdentifier[]> > m_all_ids
SG::WriteHandleKey< TileDigitsContainer > m_digitsContainer_DigiHSTruthKey
float round(const float toRound, const unsigned int decimals)
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
std::list< value_t > type
type of the collection of timed data object