194 ATH_MSG_VERBOSE(
"ATT: RUN1 settings TilePulseForTileMuonReceiver will end now" );
195 return StatusCode::SUCCESS;
200 const EventContext& ctx = Gaudi::Hive::currentContext();
209 int EBchan[
nEBchan]={17,16,37,38,3,2};
211 int LBchan[
nLBchan]={0,13,14,25,24,41,44,39,40};
213#if (nEBchan > nLBchan)
214 double pDigitSamplesArray[
nEBchan][7];
215 double pDigitSamplesRndmArray[
nEBchan][7];
217 double pDigitSamplesArray[
nLBchan][7];
218 double pDigitSamplesRndmArray[
nLBchan][7];
231 double sigma_Hfn1 = 0.;
232 double sigma_Hfn2 = 0.;
233 double sigma_Norm = 0.;
234 double sigmaSim(0.0);
238 double muRcv_NoiseSigma;
250 badChannels = *badChannelsHandle;
264 sampleNoise = sampleNoiseHandle.
retrieve();
279 auto muRcvDigitsContainer = std::make_unique<TileMutableDigitsContainer>(
true,
282 ATH_CHECK( muRcvDigitsContainer->status() );
286 auto muRcvRawChannelContainer = std::make_unique<TileMutableRawChannelContainer>(
true,
290 ATH_CHECK( muRcvRawChannelContainer->status() );
296 std::unique_ptr<TileMutableDigitsContainer> backgroundDigitContainer{};
300 ATH_MSG_DEBUG(
"Prepare background container for MC Overlay procedure");
302 backgroundDigitContainer = std::make_unique<TileMutableDigitsContainer>(
true,
305 ATH_CHECK( backgroundDigitContainer->status() );
309 TimedDigitContList digitContList;
313 if (digitContList.size() == 0) {
315 return StatusCode::SUCCESS;
318 TimedDigitContList::iterator iTzeroDigitCont(digitContList.begin());
319 for (
const auto* digitCollection : *(iTzeroDigitCont->second)) {
320 for (
const auto* digit : *digitCollection) {
321 auto pDigits = std::make_unique<TileDigits>(*digit);
322 ATH_CHECK(backgroundDigitContainer->push_back(std::move(pDigits)));
327 if (tileDigitsContainerHandle.
isValid()) {
328 for (
const auto* digitCollection : *tileDigitsContainerHandle) {
329 for (
const auto* digit : *digitCollection) {
330 auto pDigits = std::make_unique<TileDigits>(*digit);
331 ATH_CHECK(backgroundDigitContainer->push_back(std::move(pDigits)));
335 ATH_MSG_ERROR(
"ReadHandle to Background Digits is invalid.");
336 return StatusCode::FAILURE;
340 collItrRndm = backgroundDigitContainer->begin();
341 lastCollRndm = backgroundDigitContainer->end();
350 std::vector<float> digitsBuffer_rndm(
m_nSamples);
351 std::vector<bool> good_bkg( 9 ,
false );
375 ATH_MSG_VERBOSE(
"(A.00) Looping over all collections for TMDB in the HIT container");
376 memset(pDigitSamplesArray, 0,
sizeof(pDigitSamplesArray));
378 ATH_MSG_VERBOSE(
"(A.01) Going through collection ROS/DRAWER : "<< ros <<
"/"<< drawer);
379 ATH_MSG_DEBUG(
" Going through collection ROS/DRAWER : "<< ros <<
"/"<< drawer);
382 ATH_MSG_VERBOSE(
"(A.02) ROS: "<< ros <<
" drawer: " << drawer <<
" is connected");
384 ATH_MSG_VERBOSE(
"(A.02) ROS: "<< ros <<
" drawer: " << drawer <<
" is NOT connected");
390 m_tileHWID->get_hash(drawer_id, idhash, &drawer_context);
397 memset(pDigitSamplesRndmArray, 0,
sizeof(pDigitSamplesRndmArray));
403 if (hitCollection->identify() != bkgDigitCollection->
identify()) {
404 ATH_MSG_ERROR (
"Frag IDs for hit collection and digits overlay collection do not match "
405 << MSG::hex << hitCollection->identify() <<
" != " << bkgDigitCollection->
identify()
407 return StatusCode::FAILURE;
410 ATH_MSG_DEBUG(
"Prepare buffer (digitsBuffer_rndm) for MC Overlay procdure: pileup digits");
412 for (
const auto* bkgDigit : *bkgDigitCollection) {
413 bool good_channel =
true;
416 int channel =
m_tileHWID->channel(adc_id_rndm);
417 ATH_MSG_VERBOSE (
"check channels from adc id in rndm container (TMDB channel): "<< channel );
419 digitsBuffer_rndm = (*bkgDigit).samples();
421 int nsamp_rndm = digitsBuffer_rndm.size();
425 for (
int js=nsamp_rndm; js<
m_nSamples; ++js) {
426 digitsBuffer_rndm[js] = digitsBuffer_rndm[js-1];
432 pDigitSamplesRndmArray[channel][j] = digitsBuffer_rndm[j];
435 if (pDigitSamplesRndmArray[channel][j]==0) good_channel =
false;
437 good_bkg[channel] = good_channel;
439 if (
msgLvl(MSG::VERBOSE)){
440 msg(MSG::VERBOSE) <<
" Digits from pileup background " << channel <<
" " << ros <<
" " << drawer <<
" " <<
m_tileHWID->to_string(adc_id_rndm)<<
" | ";
441 for (
int j=0; j< (int) digitsBuffer_rndm.size(); j++)
msg(MSG::VERBOSE) << digitsBuffer_rndm[j] <<
" | ";
442 msg(MSG::VERBOSE) <<
"---> | ";
443 for (
int j=0; j< (int) digitsBuffer_rndm.size(); j++)
msg(MSG::VERBOSE) << pDigitSamplesRndmArray[channel][j] <<
" | ";
454 if ( hitCollection->empty() )
ATH_MSG_DEBUG(
"-- No hits in this drawer! Filling channels with either noise and pedestal or MC pileup overlay. --");
456 for (
const TileHit* tile_hit : *hitCollection) {
464 int tower =
m_tileID->tower(pmt_id);
465 int sample =
m_tileID->sample(pmt_id);
468 ATH_MSG_VERBOSE(
"(B.00) ++ Iterate over all the D layer channels with hits");
478 TMDBchan = 1 -
m_tileID->pmt(pmt_id) + ((tower>9) ? (tower - 10) : 4);
480 TMDBchan =
m_tileID->pmt(pmt_id) + ((tower>9) ? (tower - 10) : 4);
482 TILEchan=EBchan[TMDBchan];
490 TMDBchan = 1 -
m_tileID->pmt(pmt_id) + ((tower<7) ? (tower-1) : 7);
492 TMDBchan =
m_tileID->pmt(pmt_id) + ((tower<7) ? (tower-1) : 7);
495 TILEchan=LBchan[TMDBchan];
498 double* pDigitSamples = pDigitSamplesArray[TMDBchan];
500 if (
msgLvl(MSG::VERBOSE)){
503 ATH_MSG_VERBOSE(
"(B.01) Correct pmt being transported in XXchan[]: "<<TMDBchan<<
" "<<TILEchan<<
"=?"
505 <<
" For reference get TMDB adc_id: " <<
m_tileHWID->to_string(adc_id) );
506 ATH_MSG_VERBOSE(
"(B.02) New hit in ROS/DRAWER/PMT "<<ros<<
"/"<<drawer<<
"/"<<TMDBchan<<
" ("<<TILEchan<<
")"
507 <<
" pmt_id "<<
m_tileID->to_string(pmt_id,-1)
508 <<
" adc_id "<<
m_tileHWID->to_string(adc_id) );
514 double hit_calib = samplingFraction->getSamplingFraction(drawerIdx, channel);
515 hit_calib = std::round(hit_calib * 1000) / 1000;
524 int n_hits = tile_hit->size();
528 for (
int ihit = 0; ihit < n_hits; ++ihit) {
530 ATH_MSG_VERBOSE(
"(C.00) ++ Iterating over the hits of channel " << TILEchan <<
": hit " << ihit <<
"/"<< n_hits);
532 double e_hit = tile_hit->energy(ihit);
533 double e_pmt = e_hit * hit_calib;
535 ATH_MSG_VERBOSE(
"(C.01) Energy in scintillator [MeV]: " << e_hit <<
" true cell energy [MeV]: " << e_pmt);
537 double t_hit = tile_hit->time(ihit);
549 int ishift = (int) (t_hit /
m_timeStep + 0.5);
567 pDigitSamples[js] += e_pmt * shape;
571 <<
" Shape wt. = " << shape
572 <<
" Amp = " << pDigitSamples[js] <<
" [MeV]");
587 <<
" Amp = " << pDigitSamples[js]
588 <<
"[MeV] Energy: " << e_pmt <<
" LOGAIN from TileInfo");
594 ATH_MSG_DEBUG(
"(C.04) Went over " << n_hits <<
" hits for channel"
595 <<
m_tileHWID->to_string(drawer_id,-2) <<
"/" << TMDBchan <<
" (" << TILEchan <<
")"
596 <<
" digits [MeV] "<< pDigitSamples[0]
597 <<
"/" << pDigitSamples[1]
598 <<
"/" << pDigitSamples[2]
599 <<
"/" << pDigitSamples[3]
600 <<
"/" << pDigitSamples[4]
601 <<
"/" << pDigitSamples[5]
602 <<
"/" << pDigitSamples[6]);
603 ATH_MSG_VERBOSE(
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
619 ATH_MSG_VERBOSE(
"++ START filling of channels with background either noise+pedestal or overlay");
621 for (
int TMDBchan = 0; TMDBchan < upperLim; ++TMDBchan) {
623 double* pDigitSamples=pDigitSamplesArray[TMDBchan];
624 int TILEchan = (eb_ros) ? EBchan[TMDBchan] : LBchan[TMDBchan];
628 ATH_MSG_DEBUG(
"(D.) Going now to channel " <<
" TMDBchan: " << TMDBchan <<
" TILEchan: " << TILEchan);
630 <<
" TMDBchan: " << TMDBchan <<
" TILEchan: " << TILEchan
632 <<
" drawer: " << drawer
633 <<
" drawer idx: " << drawerIdx
634 <<
" drawer_id: " <<
m_tileHWID->to_string(drawer_id,-2)
635 <<
" channel: " <<
m_tileHWID->to_string(adc_id,-1));
640 double mev2ADC_factor = muRcv_Calib / emScale->calibrateChannel(drawerIdx,TILEchan,
TileID::LOWGAIN, 1.
644 <<
" adc/pCb: "<< muRcv_Calib
645 <<
" Mev/pCb: "<< emScale->calibrateChannel( drawerIdx,
651 <<
" final calibration factor adc/MeV: "<< mev2ADC_factor);
654 <<
" " << pDigitSamples[0]
655 <<
" " << pDigitSamples[1]
656 <<
" " << pDigitSamples[2]
657 <<
" " << pDigitSamples[3]
658 <<
" " << pDigitSamples[4]
659 <<
" " << pDigitSamples[5]
660 <<
" " << pDigitSamples[6]
661 <<
" [All ZERO if there is no hit in channel.] ");
663 if ( good_bkg[TMDBchan] ) {
673 ATH_MSG_VERBOSE(
"(D.02.0"<< js+1 <<
") sample "<< js+1 <<
" E_{Signal} [adc]: "<< pDigitSamples[js] * mev2ADC_factor <<
" -- Overlay");
674 digitsBuffer[js] = pDigitSamples[js] * mev2ADC_factor;
677 ATH_MSG_VERBOSE(
"(D.02.0"<< js+1 <<
") sample "<< js+1 <<
" E_{PileUp} [adc]: "<< pDigitSamplesRndmArray[TMDBchan][js] <<
" -- Overlay");
678 digitsBuffer[js] += pDigitSamplesRndmArray[TMDBchan][js];
681 if (digitsBuffer[js] > muRcv_Max) digitsBuffer[js] = muRcv_Max;
685 ATH_MSG_VERBOSE(
"(D.02.0"<< js+1 <<
") sample "<< js+1 <<
" calibration [adc/MeV] "<< mev2ADC_factor <<
"-> E_{Signal+PileUp} [adc]: "<< digitsBuffer[js] <<
" -- Overlay");
688 if (
m_rndmEvtOverlay)
ATH_MSG_INFO(
"At least one digit is zero in background file using the stadart path to fill pedestal and noise in digits");
691 muRcv_NoiseSigma =
m_tileInfo->MuRcvNoiseSigma(adc_id);
695 <<
" noi " << muRcv_NoiseSigma
696 <<
" ped " << muRcv_Ped
697 <<
" cal " << muRcv_Calib
698 <<
" max " << muRcv_Max);
710 if (pedSim == 0.0) pedSim = 30.;
719 RandGaussQ::shootArray(*rngWrapper,
m_nSamples, Rndm, 0.0, 1.0);
720 RandFlat::shootArray(*rngWrapper, 1, Rndm_dG, 0.0, 1.0);
723 if (sigma_Hfn1 > 0 || sigma_Hfn2) {
729 if (Rndm_dG[0] < sigma_Norm) sigmaSim = sigma_Hfn1;
730 else sigmaSim = sigma_Hfn2;
732 sigmaSim = muRcv_NoiseSigma;
739 ATH_MSG_VERBOSE(
"(D.02.0"<< js+1 <<
") sample "<< js+1 <<
" E [MeV]: "<< pDigitSamples[js]);
740 digitsBuffer[js] = pDigitSamples[js] * mev2ADC_factor;
741 ATH_MSG_VERBOSE(
"(D.02.0"<< js+1 <<
") sample "<< js+1 <<
" calibration [adc/MeV] "<< mev2ADC_factor <<
"-> E [adc]: "<< digitsBuffer[js]);
744 digitsBuffer[js] += pedSim;
745 ATH_MSG_VERBOSE(
"(D.02.0"<< js+1 <<
") sample "<< js+1 <<
" adding pedestal "<< pedSim <<
"-> E [adc]: "<< digitsBuffer[js]);
749 digitsBuffer[js] += sigmaSim * Rndm[js];
750 ATH_MSG_VERBOSE(
"(D.02.0"<< js+1 <<
") sample "<< js+1 <<
" adding noise "<< sigmaSim * Rndm[js] <<
"-> E [adc]: "<< digitsBuffer[js]);
754 if (digitsBuffer[js] > muRcv_Max) digitsBuffer[js] = muRcv_Max;
763 bool chanIsBad =
false;
767 chanIsBad = status.isBad();
772 digitsBuffer[js] = 255;
774 ATH_MSG_VERBOSE(
"(D.03) Masking Channel: "<< ros <<
'/' << drawer <<
'/' << TILEchan <<
" ("<< TMDBchan <<
") LowGain" );
776 ATH_MSG_VERBOSE(
"(D.03) Good Channel : "<< ros <<
'/' << drawer <<
'/' << TILEchan <<
" ("<< TMDBchan <<
") LowGain" );
779 ATH_MSG_VERBOSE(
"++ Changed to TMDB adc_id: " <<
m_tileHWID->to_string(adc_id) <<
" and save a TileDigits object into a container." );
780 std::unique_ptr<TileDigits> muonReceiverDigits = std::make_unique<TileDigits>(adc_id, digitsBuffer);
781 ATH_MSG_VERBOSE(
"++ Create a TileRawChannelObject object and set it into a container " );
783 ATH_CHECK( muRcvDigitsContainer->push_back(std::move(muonReceiverDigits)) );
784 ATH_CHECK( muRcvRawChannelContainer->push_back(muRcvRawChannel) );
787 <<
" Digitized pulse [ADC] "<< digitsBuffer[0]
788 <<
"/" << digitsBuffer[1]
789 <<
"/" << digitsBuffer[2]
790 <<
"/" << digitsBuffer[3]
791 <<
"/" << digitsBuffer[4]
792 <<
"/" << digitsBuffer[5]
793 <<
"/" << digitsBuffer[6] );
795 <<
" E [ADC]: "<< muRcvRawChannel->
amplitude()
796 <<
" Time [ns]: "<< muRcvRawChannel->
time()
797 <<
" Qf: "<< muRcvRawChannel->
quality() );
801 if (
msgLvl(MSG::VERBOSE)) muRcvDigitsContainer->print();
807 ATH_MSG_VERBOSE (
"(A.05) Send to event store all collected objects " );
813 ATH_CHECK( muRcvRawChannelCnt.
record(std::move(muRcvRawChannelContainer)) );
817 return StatusCode::SUCCESS;
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...