262 {
264
265
266 ATHRNG::RNGWrapper* rngWrapper = nullptr;
267 CLHEP::HepRandomEngine* rngEngine = nullptr;
272 }
273
276
278 if (first) {
281 IdContext drawer_context =
m_tileHWID->drawer_context();
283 const int nchMax = 48;
284 for (
int dr = 0;
dr < ndrawers; ++
dr) {
285 HWIdentifier drawer_id;
286 m_tileHWID->get_id(dr, drawer_id, &drawer_context);
290 IdentifierHash idhash;
291 m_tileHWID->get_hash(drawer_id, idhash, &drawer_context);
292 for (
int ch = 0;
ch < nchMax; ++
ch) {
296 double sigmaHi_Norm = sampleNoise->getHfnNorm(idhash, ch,
TileID::HIGHGAIN);
298 double sigmaLo_Hfn1 = sampleNoise->getHfn1(idhash, ch,
TileID::LOWGAIN);
299 double sigmaLo_Hfn2 = sampleNoise->getHfn2(idhash, ch,
TileID::LOWGAIN);
300 double sigmaLo_Norm = sampleNoise->getHfnNorm(idhash, ch,
TileID::LOWGAIN);
302 << " pedHi="<< pedSimHi
303 << " pedLo="<< pedSimLo
304 << " rmsHi="<< sigmaHi_Hfn1 << "," << sigmaHi_Hfn2 << "," << sigmaHi_Norm
305 << " rmsLo="<< sigmaLo_Hfn1 << "," << sigmaLo_Hfn2 << "," << sigmaLo_Norm);
306
307 }
308 }
309 }
310 }
311
312
313 double Rndm[16];
314 double RndmLo[16];
315 double Rndm_dG[1];
316 double RndmLo_dG[1];
317
318
321
322 SG::ReadHandle<TileHitContainer> hitContainer_DigiHSTruth;
326 }
327
328
329 int nChSum = 0;
330 int nChHiSum = 0;
331 int nChLoSum = 0;
332 int nChHiAcc = 0;
333 int nChLoAcc = 0;
334 int nChHiFlt = 0;
335 int nChLoFlt = 0;
336 int nChHiCut = 0;
337 int nChLoCut = 0;
338 double echtot_Acc = 0.;
339 double echint_Acc = 0.;
340 double echtot_Cut = 0.;
341 double echint_Cut = 0.;
343 double EneSum = 0.;
344 double RChSum = 0.;
345
346
347
348 auto digitsContainer = std::make_unique<TileMutableDigitsContainer>(true,
352
353 std::unique_ptr<TileMutableDigitsContainer> digitsContainer_DigiHSTruth;
355 digitsContainer_DigiHSTruth = std::make_unique<TileMutableDigitsContainer>(true,
358 ATH_CHECK( digitsContainer_DigiHSTruth->status() );
359 }
360
361 std::unique_ptr<TileMutableDigitsContainer> filteredContainer;
363 filteredContainer = std::make_unique<TileMutableDigitsContainer>(true,
367 ATH_CHECK( filteredContainer->status() );
368 }
369
370
371 IdentifierHash idhash;
372 IdContext drawer_context =
m_tileHWID->drawer_context();
373 const int nchMax = 48;
374 std::vector<int>
igain(nchMax, -1);
375 std::vector<int> ntot_ch(nchMax, 0);
376 std::vector<double> ech_tot(nchMax, 0.0);
377 std::vector<double> ech_int(nchMax, 0);
378 std::vector<double> ech_int_DigiHSTruth(nchMax, 0);
379 std::vector<int> over_gain(nchMax, -1);
380
381
383 std::vector<float> digitsBufferLo(
m_nSamples);
384 std::vector<float> digitsBuffer_DigiHSTruth(
m_nSamples);
385 std::vector<float> digitsBufferLo_DigiHSTruth(
m_nSamples);
386
387 std::vector<double> emptyBuffer;
388 std::vector<std::vector<double>> drawerBufferHi(nchMax, std::vector<double>(
m_nSamples));
389 std::vector<std::vector<double>> drawerBufferLo(nchMax, std::vector<double>(
m_nSamples));
390
391 std::vector<std::vector<double>> drawerBufferHi_DigiHSTruth;
392 std::vector<std::vector<double>> drawerBufferLo_DigiHSTruth;
394 drawerBufferHi_DigiHSTruth.resize(nchMax, std::vector<double>(
m_nSamples));
395 drawerBufferLo_DigiHSTruth.resize(nchMax, std::vector<double>(
m_nSamples));
396 }
397
398
399
400
401 Bool_t coherNoiseHi = false;
402 Bool_t coherNoiseLo = false;
403 TMatrixD CorrWeightHi;
404 TMatrixD CorrWeightLo;
405 std::vector<std::unique_ptr<double[]>> CorrRndmVec;
406 std::vector<std::unique_ptr<double[]>> CorrRndmVecLo;
409 CorrRndmVec.push_back(std::make_unique<double[]>(nchMax));
410 }
413 CorrRndmVecLo.push_back(std::make_unique<double[]>(nchMax));
414 }
415 }
416 }
417
420 std::unique_ptr<TileMutableDigitsContainer> backgroundDigitContainer{};
422 backgroundDigitContainer = std::make_unique<TileMutableDigitsContainer>(true,
425 ATH_CHECK( backgroundDigitContainer->status() );
426
429 TimedDigitContList digitContList;
432
433
434 if (digitContList.size() == 0) {
436 return StatusCode::SUCCESS;
437 }
438
439 TimedDigitContList::iterator iTzeroDigitCont(digitContList.begin());
440 for (const auto* digitCollection : *(iTzeroDigitCont->second)) {
441 for (const auto* digit : *digitCollection) {
442 auto pDigits = std::make_unique<TileDigits>(*digit);
443 ATH_CHECK(backgroundDigitContainer->push_back(std::move(pDigits)));
444 }
445 }
446 }
447 else {
449 if (tileDigitsContainerHandle.isValid()) {
450 for (const auto* digitCollection : *tileDigitsContainerHandle) {
451 for (const auto* digit : *digitCollection) {
452 auto pDigits = std::make_unique<TileDigits>(*digit);
453 ATH_CHECK(backgroundDigitContainer->push_back(std::move(pDigits)));
454 }
455 }
456 }
457 else {
458 ATH_MSG_ERROR(
"ReadHandle to Background Digits is invalid.");
459 return StatusCode::FAILURE;
460 }
461 }
462
463 collItrRndm = backgroundDigitContainer->begin();
464 lastCollRndm = backgroundDigitContainer->end();
465 }
466
467 SG::ReadCondHandle<TileEMScale> emScale(
m_emScaleKey, ctx);
469
470 const TilePulse* pulse = nullptr;
474 pulse = pulseShape.retrieve();
475 }
476
479
480 const TileDQstatus* dqStatus = nullptr;
482 SG::ReadHandle<TileDQstatus> DQstatusHandle(
m_DQstatusKey, ctx);
484 dqStatus = DQstatusHandle.get();
485 }
486
487 const TileBadChannels* badChannels = nullptr;
489 SG::ReadCondHandle<TileBadChannels> badChannelsHandle(
m_badChannelsKey,ctx);
490 ATH_CHECK( badChannelsHandle.isValid() );
491 badChannels = badChannelsHandle.retrieve();
492 }
493
494
495
496 TileHitContainer::const_iterator collItr_DigiHSTruth;
497 if(
m_doDigiTruth) collItr_DigiHSTruth = hitContainer_DigiHSTruth->begin();
498
499
500
501
502
503
504 for (const TileHitCollection* hitCollection : *hitContainer) {
505
506 HWIdentifier drawer_id =
m_tileHWID->drawer_id(hitCollection->identify());
511 ATH_MSG_VERBOSE(
"ROS "<< ros <<
" drawer " << drawer <<
" is connected");
512 } else {
514 ++collItrRndm;
515 }
517 ++collItr_DigiHSTruth;
518 }
519 continue;
520 }
521
522 m_tileHWID->get_hash(drawer_id, idhash, &drawer_context);
523 const std::unique_ptr<HWIdentifier[]>& adc_ids =
m_all_ids[idhash];
524
525
526
527
528
531 std::fill(over_gain.begin(), over_gain.end(), -1);
534 }
535
536 std::fill(ech_tot.begin(), ech_tot.end(), 0.0);
537 std::fill(ech_int.begin(), ech_int.end(), 0.0);
538 std::fill(ntot_ch.begin(), ntot_ch.end(), 0);
539 std::fill(
igain.begin(),
igain.end(), igainch);
540
541 std::vector<std::reference_wrapper<std::vector<std::vector<double>>>> drawerBuffers{drawerBufferHi, drawerBufferLo};
543 drawerBuffers.push_back(drawerBufferHi_DigiHSTruth);
544 drawerBuffers.push_back(drawerBufferLo_DigiHSTruth);
545 }
546 for (std::vector<std::vector<double>>& drawerBuffer : drawerBuffers) {
547 for (std::vector<double>& digitsBuffer : drawerBuffer) {
548 std::fill(digitsBuffer.begin(), digitsBuffer.end(), 0);
549 }
550 }
551
553 const TileDigitsCollection *bkgDigitCollection(*collItrRndm);
555 igain, ros, drawer, drawerIdx, over_gain, *emScale, *sampleNoise, dqStatus, badChannels));
556 ++collItrRndm;
557 }
558
559 std::vector<bool> signal_in_channel(nchMax, false);
560 std::vector<bool> signal_in_channel_DigiHSTruth(nchMax, false);
562 igain, over_gain, ech_int, signal_in_channel, *emScale, *samplingFraction, pulse));
565 igain, over_gain, ech_int_DigiHSTruth, signal_in_channel_DigiHSTruth, *emScale, *samplingFraction, pulse));
566 }
567
568
569
570 if (
msgLvl(MSG::VERBOSE)) {
571 for (int ich = 0; ich < nchMax; ++ich) {
572 if (igain[ich] > -1) {
573 std::vector<double>& digitSamplesHi = drawerBufferHi[ich];
574 std::vector<double>& digitSamplesLo = drawerBufferLo[ich];
575 msg(MSG::VERBOSE) <<
"total: ADC " <<
m_tileHWID->to_string(adc_ids[ich],-1) <<
"/" <<
igain[ich]
576 << " nhit=" << ntot_ch[ich]
577 << " e_ch=" << ech_tot[ich]
578 <<
" AinTHi=" << digitSamplesHi[
m_iTrig]
580 }
581 }
582 }
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
601 << " drawer " << drawer
602 << " with " << nchMax << " channels and "
604
605
606 coherNoiseHi = 1;
607 if (coherNoiseHi) {
610 }
611
612
613 coherNoiseLo = 1;
614 if (coherNoiseLo) {
617 }
618
619
621 double* RndmVec = CorrRndmVec[
k].get();
622 RandGaussQ::shootArray(rngEngine, nchMax, RndmVec, 0.0, 1.0);
623 }
624
627 double * RndmVecLo = CorrRndmVecLo[
k].get();
628 RandGaussQ::shootArray(rngEngine, nchMax, RndmVecLo, 0.0, 1.0);
629 }
630 }
631 }
632
633
634
635 for (int ich = 0; ich < nchMax; ++ich) {
636
637 if (igain[ich] < 0)
638 continue;
639
640
641 ++nChHiSum;
642 HWIdentifier adc_id = adc_ids[ich];
643 HWIdentifier adc_id_lo;
644 Identifier pmt_id =
m_cabling->h2s_pmt_id(adc_id);
646 <<
" PMT " << (pmt_id.
is_valid() ?
m_tileID->to_string(pmt_id,-1) : (signal_in_channel[ich] ?
"fake gap" :
"not connected"))
647 << " gain=" << igain[ich]);
648
652 ++nChLoSum;
653 }
654 }
655
656 bool chanLoIsBad = false;
657 bool chanHiIsBad = false;
661 chanLoIsBad = statusLo.
isBad();
662 chanHiIsBad = statusHi.
isBad();
663 }
664
665
666 double pedSimHi(0.), sigmaHi_Hfn1(0.), sigmaHi_Hfn2(0.), sigmaHi_Norm(0.), pedSimLo(0.),
667 sigmaLo_Hfn1(0.), sigmaLo_Hfn2(0.), sigmaLo_Norm(0.);
668 bool good_ch = (over_gain[ich]<9);
671 bool tileNoiseHG(false),tileNoiseLG(false);
672
673 if (overNoiseHG) {
676
678
679 if (pedSimHi == 0.0 && (signal_in_channel[ich] || pmt_id.
is_valid()))
680 pedSimHi = 50.;
681
684 if (sigmaHi_Hfn1>0 || sigmaHi_Hfn2) {
685 sigmaHi_Norm = sigmaHi_Hfn1 / (sigmaHi_Hfn1
687 } else {
689 sigmaHi_Norm = 1.;
690 }
691 }
692
693 if (overNoiseLG) {
696
698
699 if (pedSimLo == 0.0 && (signal_in_channel[ich] || pmt_id.
is_valid()))
700 pedSimLo = 30.;
701
704 if (sigmaLo_Hfn1 > 0 || sigmaLo_Hfn2) {
705 sigmaLo_Norm = sigmaLo_Hfn1 / (sigmaLo_Hfn1
706 + sigmaLo_Hfn2 * sampleNoise->getHfnNorm(idhash, ich,
TileID::LOWGAIN));
707 } else {
709 sigmaLo_Norm = 1.;
710 }
711 }
712
713
714 if (tileNoiseLG) {
715 RandGaussQ::shootArray(rngEngine,
m_nSamples, Rndm, 0.0, 1.0);
716 RandFlat::shootArray(rngEngine, 1, Rndm_dG, 0.0, 1.0);
718 RandGaussQ::shootArray(rngEngine,
m_nSamples, RndmLo, 0.0, 1.0);
719 RandFlat::shootArray(rngEngine, 1, RndmLo_dG, 0.0, 1.0);
720 }
721 }
722
723 std::vector<double>& digitSamplesHi = drawerBufferHi[ich];
724 std::vector<double>& digitSamplesLo = drawerBufferLo[ich];
725 std::vector<double>& digitSamplesHi_DigiHSTruth = (
m_doDigiTruth) ? drawerBufferHi_DigiHSTruth[ich] : emptyBuffer;
726 std::vector<double>& digitSamplesLo_DigiHSTruth = (
m_doDigiTruth) ? drawerBufferLo_DigiHSTruth[ich] : emptyBuffer;
727
728 ATH_MSG_DEBUG(
" Channel " << ros <<
'/' << drawer <<
'/' << ich
729 <<
" sampHi=" << digitSamplesHi[
m_iTrig]
730 << " pedHi=" << pedSimHi
731 <<
" sampLo=" << digitSamplesLo[
m_iTrig]
732 << " pedLo=" << pedSimLo);
733
734
736
737 digitsBuffer[
js] = digitSamplesHi[
js] + pedSimHi;
739 digitsBuffer_DigiHSTruth[
js] = digitSamplesHi_DigiHSTruth[
js] + pedSimHi;
740 }
741
742 double noiseHi(0.0);
743
744 if (coherNoiseHi) {
745
746 std::unique_ptr<double[]>& CorVec = CorrRndmVec[
js];
747
748 for (
int i = 0;
i < nchMax; ++
i) noiseHi += CorrWeightHi(i, ich) * CorVec[
i];
749 } else if (tileNoiseHG) {
750
751 if (Rndm_dG[0] < sigmaHi_Norm) noiseHi = sigmaHi_Hfn1 * Rndm[
js];
752 else noiseHi = sigmaHi_Hfn2 * Rndm[
js];
753 }
754
755 if (digitsBuffer[js] + noiseHi >= 0.0) {
756 digitsBuffer[
js] += noiseHi;
758 } else {
759 digitsBuffer[
js] -= noiseHi;
761 }
762
763
765 digitsBuffer[
js] =
round(digitsBuffer[js]);
767 }
768
770 digitsBufferLo[
js] = digitSamplesLo[
js] + pedSimLo;
771 if(
m_doDigiTruth) digitsBufferLo_DigiHSTruth[
js] = digitSamplesLo_DigiHSTruth[
js] + pedSimLo;
772 double noiseLo(0.0);
773
774 if (coherNoiseLo) {
775
776 std::unique_ptr<double[]>& CorVecLo = CorrRndmVecLo[
js];
777
778 for (
int i = 0;
i < nchMax; ++
i) noiseLo += CorrWeightLo(i, ich) * CorVecLo[
i];
779 } else if (tileNoiseLG) {
780
781 if (RndmLo_dG[0] < sigmaLo_Norm) noiseLo = sigmaLo_Hfn1 * RndmLo[
js];
782 else noiseLo = sigmaLo_Hfn2 * RndmLo[
js];
783 }
784
785 if (digitsBufferLo[js] + noiseLo >= 0.0) {
786 digitsBufferLo[
js] += noiseLo;
788 } else {
789 digitsBufferLo[
js] -= noiseLo;
791 }
792
794 digitsBufferLo[
js] =
round(digitsBufferLo[js]);
796 }
797
798
800
801 --nChHiSum;
802 ++nChLoSum;
805
806
808 digitsBuffer[
js] = digitSamplesLo[
js] + pedSimLo;
809 if(
m_doDigiTruth) digitsBuffer_DigiHSTruth[
js] = digitSamplesLo_DigiHSTruth[
js] + pedSimLo;
810 double noiseLo(0.0);
811
812 if (coherNoiseLo) {
813
814 double* CorVec = CorrRndmVec[
js].get();
815
816 for (
int i = 0;
i < nchMax; ++
i) noiseLo += CorrWeightLo(i, ich) * CorVec[
i];
817 } else if (tileNoiseLG) {
818
819
820 if (Rndm_dG[0] < sigmaLo_Norm) noiseLo = sigmaLo_Hfn1 * Rndm[
js];
821 else noiseLo = sigmaLo_Hfn2 * Rndm[
js];
822 }
823
824 if (digitsBuffer[js] + noiseLo >= 0.0) {
825 digitsBuffer[
js] += noiseLo;
827 } else {
828 digitsBuffer[
js] -= noiseLo;
830 }
831
832 if (digitsBuffer[js] >
m_f_ADCmax && good_ch) {
835 }
837 digitsBuffer[
js] =
round(digitsBuffer[js]);
839 }
840 }
841
842 overNoiseHG = false;
843
844 if (
msgLvl(MSG::VERBOSE)) {
845 msg(MSG::VERBOSE) <<
"Channel " <<
ros <<
'/' <<
drawer <<
'/' << ich <<
"/" <<
igain[ich]
846 <<
" Switch to low gain Amp(lo)=" << digitsBuffer[
m_iTrig] <<
endmsg;
847 if (overNoiseLG) {
848 if (sigmaLo_Norm<1.0) {
849 msg(MSG::VERBOSE) <<
"LG Ped & noise from DB "
850 << pedSimLo << " " << sigmaLo_Hfn1 << " " << sigmaLo_Hfn2 << " " << sigmaLo_Norm
851 << ((Rndm_dG[0] < sigmaLo_Norm)?(
" sig1 used"):(
" sig2 used")) <<
endmsg;
852 } else {
853 msg(MSG::VERBOSE) <<
"LG Ped & noise from DB "
854 << pedSimLo <<
" " << sigmaLo_Hfn1 <<
endmsg;
855 }
856 }
857 }
858 break;
859 }
860 }
861 if (
msgLvl(MSG::VERBOSE)) {
862 if (overNoiseHG) {
863 if (sigmaHi_Norm<1.0) {
864 msg(MSG::VERBOSE) <<
"HG Ped & noise from DB "
865 << pedSimHi << " " << sigmaHi_Hfn1 << " " << sigmaHi_Hfn2 << " " << sigmaHi_Norm
866 << ((Rndm_dG[0] < sigmaHi_Norm)?(
" sig1 used"):(
" sig2 used")) <<
endmsg;
867 } else {
868 msg(MSG::VERBOSE) <<
"HG Ped & noise from DB "
869 << pedSimHi <<
" " << sigmaHi_Hfn1 <<
endmsg;
870 }
871 }
873 if (sigmaLo_Norm<1.0) {
874 msg(MSG::VERBOSE) <<
"LG Ped & noise from DB "
875 << pedSimLo << " " << sigmaLo_Hfn1 << " " << sigmaLo_Hfn2 << " " << sigmaLo_Norm
876 << ((RndmLo_dG[0] < sigmaLo_Norm)?(
" sig1 used"):(
" sig2 used")) <<
endmsg;
877 } else {
878 msg(MSG::VERBOSE) <<
"LG Ped & noise from DB "
879 << pedSimLo <<
" " << sigmaLo_Hfn1 <<
endmsg;
880 }
881 }
882 }
883
885
886 if (chanHiIsBad) {
889 std::fill(digitsBuffer_DigiHSTruth.begin(), digitsBuffer_DigiHSTruth.end(),
m_f_ADCmaskValue);
890 }
891 ATH_MSG_DEBUG(
"Masking Channel " << ros <<
'/' << drawer <<
'/' << ich <<
"/1 HG" );
892 }
893
894 auto pDigits = std::make_unique<TileDigits>(adc_id, digitsBuffer);
895 ATH_CHECK( digitsContainer->push_back(std::move(pDigits)) );
896
898 auto digits_DigiHSTruth = std::make_unique<TileDigits>(adc_id, digitsBuffer_DigiHSTruth);
899 ATH_CHECK( digitsContainer_DigiHSTruth->push_back(std::move(digits_DigiHSTruth)) );
900 }
901
902 if (chanLoIsBad) {
905 std::fill(digitsBufferLo_DigiHSTruth.begin(), digitsBufferLo_DigiHSTruth.end(),
m_f_ADCmaskValue);
906 }
907
908 ATH_MSG_DEBUG(
"Masking Channel " << ros <<
'/' << drawer <<
'/' << ich <<
"/0 LG");
909 }
910
911 auto pDigitsLo = std::make_unique<TileDigits>(adc_id_lo, digitsBufferLo);
912 ATH_CHECK( digitsContainer->push_back(std::move(pDigitsLo)) );
913
915 auto pDigitsLo_DigiHSTruth = std::make_unique<TileDigits>(adc_id_lo, digitsBufferLo_DigiHSTruth);
916 ATH_CHECK( digitsContainer_DigiHSTruth->push_back(std::move(pDigitsLo_DigiHSTruth)) );
917 }
918 } else {
919
921
922
923 bool isChannelGood = true;
925 if (hiGain) {
926 double ampInTime = digitsBuffer[
m_iTrig] - pedSimHi;
928 ampInTime =
round(ampInTime);
931 isChannelGood = false;
932 } else {
934 isChannelGood = false;
935 }
936 }
937 }
938
939 if (isChannelGood) {
940 echtot_Acc += ech_tot[ich];
941 echint_Acc += fabs(ech_int[ich]);
942 if (hiGain) {
943 ++nChHiAcc;
944 } else {
945 ++nChLoAcc;
946 }
947
948 if (hiGain) {
949
950
951
952
953
954 if (chanHiIsBad) {
958 std::fill(digitsBuffer_DigiHSTruth.begin(), digitsBuffer_DigiHSTruth.end(),
m_f_ADCmaskValue);
959 }
960 } else if (good_ch) {
961 ATH_MSG_DEBUG(
"Disconnected Channel " << ros <<
'/' << drawer <<
'/' << ich);
962 std::fill(digitsBuffer.begin(), digitsBuffer.end(), 0.);
964 std::fill(digitsBuffer_DigiHSTruth.begin(), digitsBuffer_DigiHSTruth.end(), 0.);
965 }
966 }
967 ATH_MSG_DEBUG(
"Masking Channel " << ros <<
'/' << drawer <<
'/' << ich <<
"/1 HG");
968 }
969 } else {
970
971
972
973
974
975 if (chanLoIsBad) {
979 std::fill(digitsBuffer_DigiHSTruth.begin(), digitsBuffer_DigiHSTruth.end(),
m_f_ADCmaskValue);
980 }
981 } else if (good_ch) {
982 ATH_MSG_DEBUG(
"Disconnected Channel " << ros <<
'/' << drawer <<
'/' << ich);
983 std::fill(digitsBuffer.begin(), digitsBuffer.end(), 0.);
985 std::fill(digitsBuffer_DigiHSTruth.begin(), digitsBuffer_DigiHSTruth.end(), 0.);
986 }
987 }
988 ATH_MSG_DEBUG(
"Masking Channel " << ros <<
'/' << drawer <<
'/' << ich <<
"/0 LG");
989 }
990 }
991
992 auto pDigits = std::make_unique<TileDigits>(adc_id, digitsBuffer);
993
995 if (filteredContainer)
ATH_CHECK( filteredContainer->push_back(pDigits.get()) );
996 if (hiGain) {
997 ++nChHiFlt;
998 } else {
999 ++nChLoFlt;
1000 }
1001 }
1002
1003 ATH_CHECK( digitsContainer->push_back(std::move(pDigits)) );
1005 auto pDigits_DigiHSTruth = std::make_unique<TileDigits>(adc_id, digitsBuffer_DigiHSTruth);
1006 ATH_CHECK( digitsContainer_DigiHSTruth->push_back(std::move(pDigits_DigiHSTruth)) );
1007 }
1008
1009 if (
msgLvl(MSG::VERBOSE)) {
1010 double pedSim = ((hiGain) ? pedSimHi : pedSimLo);
1011 double ampInTime = digitsBuffer[
m_iTrig] - pedSim;
1013 ampInTime =
round(ampInTime);
1017 << " AinT=" << ampInTime
1018 << " ped=" << pedSim
1019 << " Ech=" << ech_tot[ich]
1020 <<
" EinT=" << ech_int[ich] <<
endmsg;
1021 msg(MSG::VERBOSE) <<
"digits";
1022 for (
unsigned int i = 0;
i < digitsBuffer.size(); ++
i)
1023 msg(MSG::VERBOSE) <<
" " << digitsBuffer[
i];
1025 }
1026 } else {
1027 echtot_Cut += ech_tot[ich];
1028 echint_Cut += ech_int[ich];
1029 if (hiGain) {
1030 ++nChHiCut;
1031 } else {
1032 ++nChLoCut;
1033 }
1034
1035 if (
msgLvl(MSG::VERBOSE)) {
1036 double pedSim = ((hiGain) ? pedSimHi : pedSimLo);
1037 double ampInTime = digitsBuffer[
m_iTrig] - pedSim;
1039 ampInTime =
round(ampInTime);
1040 msg(MSG::VERBOSE) <<
"Reject. ADC " <<
m_tileHWID->to_string(adc_id)
1041 << " AinT=" << ampInTime
1042 << " ped=" << pedSim
1043 << " Ech=" << ech_tot[ich]
1044 <<
" EinT=" << ech_int[ich] <<
endmsg;
1045 }
1046 }
1047 }
1048 }
1050 }
1051
1052 if (
msgLvl(MSG::DEBUG)) {
1053 msg(MSG::DEBUG) <<
"TileDigitsMaker execution completed." <<
endmsg;
1054 msg(MSG::DEBUG) <<
" nCh=" << nChSum
1055 << " nChH/L=" << nChHiSum << "/" << nChLoSum
1056 << " nFltH/L=" << nChHiFlt << "/" << nChLoFlt
1058 << " Ene=" << EneSum
1059 <<
" RChSum=" << RChSum <<
endmsg;
1061 msg(MSG::DEBUG) <<
" Accepted: nChLo/Hi=" << nChLoAcc <<
"/" << nChHiAcc
1062 << " eTot=" << echtot_Acc
1063 <<
" eInT=" << echint_Acc <<
endmsg;
1064 msg(MSG::DEBUG) <<
" Rejected: nChLo/Hi=" << nChLoCut <<
"/" << nChHiCut
1065 << " eTot=" << echtot_Cut
1066 <<
" eInT=" << echint_Cut <<
endmsg;
1067 }
1068 }
1069
1070
1071
1073 ATH_CHECK( digitsCnt.record(std::move(digitsContainer)) );
1074
1077 ATH_CHECK( digits_DigiHSTruth.record(std::move(digitsContainer_DigiHSTruth)) );
1078 }
1079
1080 if (filteredContainer) {
1082 ATH_CHECK( filteredDigitsContainer.record(std::move(filteredContainer)) );
1083 }
1084
1085 return StatusCode::SUCCESS;
1086}
#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