diff --git a/TileCalorimeter/TileSimAlgs/python/TileMuonReceiverConfig.py b/TileCalorimeter/TileSimAlgs/python/TileMuonReceiverConfig.py index de3dc616bca5a153ff1eaac8d0ac71c263c3aa07..028856119db99e0ccefa95af119a7b12220fbece 100644 --- a/TileCalorimeter/TileSimAlgs/python/TileMuonReceiverConfig.py +++ b/TileCalorimeter/TileSimAlgs/python/TileMuonReceiverConfig.py @@ -19,6 +19,8 @@ def TilePulseForTileMuonReceiverCfg(flags, **kwargs): kwargs.setdefault('MaskBadChannels', False) kwargs.setdefault('UseCoolPulseShapes', True) kwargs.setdefault('UseCoolPedestal', False) + kwargs.setdefault('UseCoolNoise', False) + kwargs.setdefault('TilePulseShape', 'TileMuRcvPulseShape') acc = TileHitVecToCntCfg(flags) @@ -37,9 +39,9 @@ def TilePulseForTileMuonReceiverCfg(flags, **kwargs): from RngComps.RandomServices import AthRNGSvcCfg kwargs['RndmSvc'] = acc.getPrimaryAndMerge(AthRNGSvcCfg(flags)).name - if 'TileCondToolNoiseSample' not in kwargs: - from TileConditions.TileSampleNoiseConfig import TileCondToolNoiseSampleCfg - kwargs['TileCondToolNoiseSample'] = acc.popToolsAndMerge(TileCondToolNoiseSampleCfg(flags)) + if kwargs['UseCoolNoise'] or kwargs['UseCoolPedestal']: + from TileConditions.TileSampleNoiseConfig import TileSampleNoiseCondAlgCfg + acc.merge( TileSampleNoiseCondAlgCfg(flags) ) from TileConditions.TileEMScaleConfig import TileEMScaleCondAlgCfg acc.merge( TileEMScaleCondAlgCfg(flags) ) @@ -48,17 +50,14 @@ def TilePulseForTileMuonReceiverCfg(flags, **kwargs): from TileConditions.TileBadChannelsConfig import TileBadChannelsCondAlgCfg acc.merge( TileBadChannelsCondAlgCfg(flags) ) - if 'TileCondToolPulseShape' not in kwargs: + if kwargs['UseCoolPulseShapes']: + from TileConditions.TilePulseShapeConfig import TilePulseShapeCondAlgCfg + acc.merge( TilePulseShapeCondAlgCfg(flags, Source='FILE', TilePulseShape=kwargs['TilePulseShape'], PulseType='MURCV') ) + + if 'TileRawChannelBuilderMF' not in kwargs: from TileConditions.TilePulseShapeConfig import TileCondToolMuRcvPulseShapeCfg pulseShapeTool = acc.popToolsAndMerge( TileCondToolMuRcvPulseShapeCfg(flags) ) - if kwargs['UseCoolPulseShapes']: - kwargs['TileCondToolPulseShape'] = pulseShapeTool - else: - kwargs['TileCondToolPulseShape'] = None - else: - pulseShapeTool = kwargs['TileCondToolPulseShape'] - if 'TileRawChannelBuilderMF' not in kwargs: from TileConditions.TileOFCConfig import TileCondToolOfcCfg ofcTool = acc.popToolsAndMerge( TileCondToolOfcCfg(flags, OptFilterDeltaCorrelation = True, diff --git a/TileCalorimeter/TileSimAlgs/share/TileMuonReceiver_jobOptions.py b/TileCalorimeter/TileSimAlgs/share/TileMuonReceiver_jobOptions.py index 7d1a0c35cbe449bef32107ce778ccc9c583b58a1..959708bc6939368d962f5bab2dd19274349d1c3d 100644 --- a/TileCalorimeter/TileSimAlgs/share/TileMuonReceiver_jobOptions.py +++ b/TileCalorimeter/TileSimAlgs/share/TileMuonReceiver_jobOptions.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration # # **************************************************************************** @@ -47,14 +47,11 @@ from AthenaCommon.AlgSequence import AlgSequence topSequence = AlgSequence() # Set up TilePulseForTileMuonReceiver -from TileConditions.TileConditionsConf import TileCondToolNoiseSample topSequence += CfgMgr.TilePulseForTileMuonReceiver('TilePulseForTileMuonReceiver' , IntegerDigits = not jobproperties.Digitization.PileUpPresampling() , UseCoolPedestal = False , UseCoolPulseShapes = True - , TileCondToolPulseShape = TileCondToolMuRcvPulseShape - , TileRawChannelBuilderMF = TileMuRcvRawChannelBuilderMF - , TileCondToolNoiseSample = TileCondToolNoiseSample (TileOnlineSampleNoise = '')) + , TileRawChannelBuilderMF = TileMuRcvRawChannelBuilderMF) if jobproperties.Digitization.PileUpPresampling and 'LegacyOverlay' not in jobproperties.Digitization.experimentalDigi(): from OverlayCommonAlgs.OverlayFlags import overlayFlags topSequence.TilePulseForTileMuonReceiver.MuonReceiverDigitsContainer = overlayFlags.bkgPrefix() + "MuRcvDigitsCnt" diff --git a/TileCalorimeter/TileSimAlgs/src/TilePulseForTileMuonReceiver.cxx b/TileCalorimeter/TileSimAlgs/src/TilePulseForTileMuonReceiver.cxx index 684294eaf00041672325b82586061ef8c175a28b..a44337c24b7122d20a63030b371926888fd4da70 100644 --- a/TileCalorimeter/TileSimAlgs/src/TilePulseForTileMuonReceiver.cxx +++ b/TileCalorimeter/TileSimAlgs/src/TilePulseForTileMuonReceiver.cxx @@ -113,6 +113,7 @@ StatusCode TilePulseForTileMuonReceiver::initialize() { ATH_CHECK( m_inputDigitContainerKey.initialize(!m_onlyUseContainerName && m_rndmEvtOverlay && m_runPeriod != 0) ); ATH_CHECK( m_samplingFractionKey.initialize(m_runPeriod != 0) ); ATH_CHECK( m_emScaleKey.initialize(m_runPeriod != 0) ); + ATH_CHECK( m_sampleNoiseKey.initialize((m_runPeriod != 0) && (m_tilePedestal || m_tileNoise)) ); if ( m_runPeriod == 0) { ATH_MSG_INFO("TilePulseForTileMuonReceiver should not be used for RUN1 simulations"); @@ -122,13 +123,11 @@ StatusCode TilePulseForTileMuonReceiver::initialize() { } //=== retrieve TileID helper and TileInfo from det store - CHECK(detStore()->retrieve(m_tileID)); - CHECK(detStore()->retrieve(m_tileHWID)); - CHECK(detStore()->retrieve(m_tileInfo, m_infoName)); - //=== get TileCondToolNoiseSample - CHECK(m_tileToolNoiseSample.retrieve()); + ATH_CHECK(detStore()->retrieve(m_tileID)); + ATH_CHECK(detStore()->retrieve(m_tileHWID)); + ATH_CHECK(detStore()->retrieve(m_tileInfo, m_infoName)); - CHECK(m_MuRcvBuildTool.retrieve()); + ATH_CHECK(m_MuRcvBuildTool.retrieve()); m_nSamples = m_tileInfo->NdigitSamples(); // number of time slices for each chan m_iTrig = m_tileInfo->ItrigSample(); // index of the triggering time slice @@ -159,16 +158,14 @@ StatusCode TilePulseForTileMuonReceiver::initialize() { // --m_nShape; + ATH_CHECK( m_pulseShapeKey.initialize((m_runPeriod != 0) && m_useCoolPulseShapes) ); if (m_useCoolPulseShapes) { ATH_MSG_INFO( "Using pulse from database."); - - CHECK(m_tileToolPulseShape.retrieve()); } else { ATH_MSG_INFO( "Using pulse from TileInfo."); m_shapeMuonReceiver = m_tileInfo->MuRcvFullShape(); m_shapeMuonReceiver.push_back(0.0); - m_tileToolPulseShape.disable(); } ATH_CHECK( m_badChannelsKey.initialize((m_runPeriod != 0) && m_maskBadChannels) ); @@ -259,6 +256,20 @@ StatusCode TilePulseForTileMuonReceiver::execute() { badChannels = *badChannelsHandle; } + const TilePulse* pulse = nullptr; + if (m_useCoolPulseShapes) { + SG::ReadCondHandle<TilePulse> pulseShape(m_pulseShapeKey, ctx); + ATH_CHECK( pulseShape.isValid() ); + pulse = pulseShape.retrieve(); + } + + const TileSampleNoise* sampleNoise = nullptr; + if (m_tilePedestal || m_tileNoise) { + SG::ReadCondHandle<TileSampleNoise> sampleNoiseHandle(m_sampleNoiseKey, ctx); + ATH_CHECK( sampleNoiseHandle.isValid() ); + sampleNoise = sampleNoiseHandle.retrieve(); + } + // Get hit container from TES // SG::ReadHandle<TileHitContainer> hitContainer(m_hitContainerKey, ctx); @@ -557,7 +568,7 @@ StatusCode TilePulseForTileMuonReceiver::execute() { ATH_MSG_VERBOSE( "(C.02.04) phase : " << k << "-" << m_binTime0 << "*" << m_timeStep << " = " << phase); - m_tileToolPulseShape->getPulseShapeYDY(drawerIdx, TMDBchan, TileID::LOWGAIN, phase, y, dy, ctx); + pulse->getPulseShapeYDY(drawerIdx, TMDBchan, TileID::LOWGAIN, phase, y, dy); shape = (double) y; pDigitSamples[js] += e_pmt * shape; // MeV @@ -699,7 +710,7 @@ StatusCode TilePulseForTileMuonReceiver::execute() { // Collecting pedestal from the database // if (m_tilePedestal) { - pedSim = m_tileToolNoiseSample->getPed(idhash, TMDBchan, TileID::LOWGAIN, TileRawChannelUnit::ADCcounts, ctx); + pedSim = sampleNoise->getPed(idhash, TMDBchan, TileID::LOWGAIN); // As in TileDigitsMaker bug fix for wrong ped value in DB // if (pedSim == 0.0) pedSim = 30.; @@ -713,12 +724,12 @@ StatusCode TilePulseForTileMuonReceiver::execute() { // RandGaussQ::shootArray(*rngWrapper, m_nSamples, Rndm, 0.0, 1.0); RandFlat::shootArray(*rngWrapper, 1, Rndm_dG, 0.0, 1.0); - sigma_Hfn1 = m_tileToolNoiseSample->getHfn1(idhash, TMDBchan, TileID::LOWGAIN, ctx); - sigma_Hfn2 = m_tileToolNoiseSample->getHfn2(idhash, TMDBchan, TileID::LOWGAIN, ctx); + sigma_Hfn1 = sampleNoise->getHfn1(idhash, TMDBchan, TileID::LOWGAIN); + sigma_Hfn2 = sampleNoise->getHfn2(idhash, TMDBchan, TileID::LOWGAIN); if (sigma_Hfn1 > 0 || sigma_Hfn2) { - sigma_Norm = sigma_Hfn1 / (sigma_Hfn1 + sigma_Hfn2 * m_tileToolNoiseSample->getHfnNorm(idhash, TMDBchan, TileID::LOWGAIN, ctx)); + sigma_Norm = sigma_Hfn1 / (sigma_Hfn1 + sigma_Hfn2 * sampleNoise->getHfnNorm(idhash, TMDBchan, TileID::LOWGAIN)); } else { - sigma_Hfn1 = m_tileToolNoiseSample->getHfn(idhash, TMDBchan, TileID::LOWGAIN, TileRawChannelUnit::ADCcounts, ctx); + sigma_Hfn1 = sampleNoise->getHfn(idhash, TMDBchan, TileID::LOWGAIN); sigma_Norm = 1.; } if (Rndm_dG[0] < sigma_Norm) sigmaSim = sigma_Hfn1; diff --git a/TileCalorimeter/TileSimAlgs/src/TilePulseForTileMuonReceiver.h b/TileCalorimeter/TileSimAlgs/src/TilePulseForTileMuonReceiver.h index 85625dc76c749450ff5329af8b664d4dc844c226..a1d113c47d67c1f7a89ce26786d1b250bae70900 100644 --- a/TileCalorimeter/TileSimAlgs/src/TilePulseForTileMuonReceiver.h +++ b/TileCalorimeter/TileSimAlgs/src/TilePulseForTileMuonReceiver.h @@ -40,9 +40,9 @@ #include "TileEvent/TileHitContainer.h" #include "TileEvent/TileDigitsContainer.h" #include "TileEvent/TileRawChannelContainer.h" -#include "TileConditions/TileCondToolPulseShape.h" +#include "TileConditions/TilePulse.h" #include "TileConditions/TileEMScale.h" -#include "TileConditions/TileCondToolNoiseSample.h" +#include "TileConditions/TileSampleNoise.h" #include "TileConditions/TileBadChannels.h" #include "TileConditions/TileCablingSvc.h" #include "TileConditions/TileSamplingFraction.h" @@ -117,8 +117,11 @@ class TilePulseForTileMuonReceiver: public AthAlgorithm { /// Random Stream Name Gaudi::Property<std::string> m_randomStreamName{this, "RandomStreamName", "Tile_PulseForTileMuonReceiver", ""}; - ToolHandle<TileCondToolNoiseSample> m_tileToolNoiseSample{this, - "TileCondToolNoiseSample", "TileCondToolNoiseSample", "Tile sample noise tool"}; + /** + * @brief Name of TileSampleNoise in condition store + */ + SG::ReadCondHandleKey<TileSampleNoise> m_sampleNoiseKey{this, + "TileSampleNoise", "TileSampleNoise", "Input Tile sample noise"}; /** * @brief Name of TileEMScale in condition store @@ -126,8 +129,11 @@ class TilePulseForTileMuonReceiver: public AthAlgorithm { SG::ReadCondHandleKey<TileEMScale> m_emScaleKey{this, "TileEMScale", "TileEMScale", "Input Tile EMS calibration constants"}; - ToolHandle<TileCondToolPulseShape> m_tileToolPulseShape{this, - "TileCondToolPulseShape", "TileCondToolPulseShape", "Tile pulse shape tool"}; + /** + * @brief Name of TilePulseShape in condition store + */ + SG::ReadCondHandleKey<TilePulse> m_pulseShapeKey{this, + "TilePulseShape", "TileMuRcvPulseShape", "Input Tile Muon Receiver pulse shape"}; /** * @brief Name of TileBadChannels in condition store