diff --git a/LArCalorimeter/LArDigitization/LArDigitization/LArPileUpTool.h b/LArCalorimeter/LArDigitization/LArDigitization/LArPileUpTool.h index 44f1acc5be36ebbd5ae4a91691d12bd694437df2..a1acd7290f4b22fa2cbd0f6ff6ecf7dca7cd09f2 100755 --- a/LArCalorimeter/LArDigitization/LArDigitization/LArPileUpTool.h +++ b/LArCalorimeter/LArDigitization/LArDigitization/LArPileUpTool.h @@ -1,6 +1,6 @@ //Dear emacs, this is -*-c++-*- /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef LARDIGITIZATION_LARPILEUPTOOL_H @@ -18,7 +18,7 @@ #include "PileUpTools/PileUpToolBase.h" #include "LArDigitization/ILArPileUpTool.h" -#include "AthenaKernel/IAtRndmGenSvc.h" +#include "AthenaKernel/IAthRNGSvc.h" #include "CaloIdentifier/CaloGain.h" @@ -100,10 +100,10 @@ class LArPileUpTool : virtual public ILArPileUpTool, public PileUpToolBase StatusCode MakeDigit(const Identifier & cellId, - HWIdentifier & ch_id, - const std::vector<std::pair<float,float> > *TimeE, - //const LArDigit * rndm_digit); - const LArDigit * rndm_digit, const std::vector<std::pair<float,float> > *TimeE_DigiHSTruth = nullptr); + HWIdentifier & ch_id, + const std::vector<std::pair<float,float> > *TimeE, + const LArDigit * rndm_digit, CLHEP::HepRandomEngine * engine, + const std::vector<std::pair<float,float> > *TimeE_DigiHSTruth = nullptr); StatusCode ConvertHits2Samples(const Identifier & cellId, HWIdentifier ch_id, @@ -182,7 +182,6 @@ class LArPileUpTool : virtual public ILArPileUpTool, public PileUpToolBase int m_NSamples; // number of samples in Digit unsigned int m_firstSample; // first sample to use for pulse shape for in time energy deposit bool m_usePhase; // use tbin phase to get shape (default = false for Atlas) - std::string m_rndmSvc; // random service name bool m_rndmEvtRun; // use run,event number for random number seeding bool m_useTriggerTime; bool m_RndmEvtOverlay; // Pileup and noise added by overlaying random events @@ -226,8 +225,7 @@ class LArPileUpTool : virtual public ILArPileUpTool, public PileUpToolBase bool m_skipNoHit; - IAtRndmGenSvc* m_AtRndmGenSvc; - CLHEP::HepRandomEngine* m_engine; + ServiceHandle<IAthRNGSvc> m_rndmGenSvc{this, "RndmSvc", "AthRNGSvc", ""}; bool m_doDigiTruth; diff --git a/LArCalorimeter/LArDigitization/python/LArDigitizationConfig.py b/LArCalorimeter/LArDigitization/python/LArDigitizationConfig.py index 5fc80db22d07b5232ed4f6843f668793044b3d8c..b82b8ac9dfb9436baadeb63b952a941d3c382b6a 100644 --- a/LArCalorimeter/LArDigitization/python/LArDigitizationConfig.py +++ b/LArCalorimeter/LArDigitization/python/LArDigitizationConfig.py @@ -81,8 +81,6 @@ def getLArPileUpTool(name='LArPileUpTool', **kwargs): ## useLArFloat()=True,isOv protectedInclude("LArConditionsCommon/LArConditionsCommon_MC_jobOptions.py") from Digitization.DigitizationFlags import digitizationFlags kwargs.setdefault('NoiseOnOff', digitizationFlags.doCaloNoise.get_Value() ) - kwargs.setdefault('RndmSvc', digitizationFlags.rndmSvc.get_Value() ) - digitizationFlags.rndmSeedList.addSeed("LArDigitization", 1234, 5678 ) kwargs.setdefault('DoDigiTruthReconstruction',digitizationFlags.doDigiTruth()) if digitizationFlags.doXingByXingPileUp(): diff --git a/LArCalorimeter/LArDigitization/share/LArDigitization_G4_jobOptions.py b/LArCalorimeter/LArDigitization/share/LArDigitization_G4_jobOptions.py index af6cc8237d2a4f90b098891dfa712e9118a330da..4f33dbea3c7b7a7cbf703def129a45dfdb9b7836 100755 --- a/LArCalorimeter/LArDigitization/share/LArDigitization_G4_jobOptions.py +++ b/LArCalorimeter/LArDigitization/share/LArDigitization_G4_jobOptions.py @@ -34,14 +34,6 @@ topSequence += digitmaker1 digitmaker1.Nsamples = LArNSamples # Calorimeter Noise digitmaker1.NoiseOnOff = jobproperties.Digitization.doCaloNoise.get_Value() -# rndm service -#digitmaker1.RndmSvc = jobproperties.Digitization.digitizationRndmSvc.get_Value() -digitmaker1.RndmSvc = jobproperties.Digitization.rndmSvc.get_Value() -if LArDigitUseOldSeed: - digitmaker1.UseRndmEvtRun = TRUE -else: -# new random seed initialization - jobproperties.Digitization.rndmSeedList.addSeed("LArDigitization", 1234, 5678 ) # ADC2MeVTool from LArRecUtils.LArADC2MeVToolDefault import LArADC2MeVToolDefault diff --git a/LArCalorimeter/LArDigitization/src/LArPileUpTool.cxx b/LArCalorimeter/LArDigitization/src/LArPileUpTool.cxx index 16d46839f4399e038fbaacbc0d894fe3be1e9835..e470fa540d3e6976f8c662944d460beace87011d 100755 --- a/LArCalorimeter/LArDigitization/src/LArPileUpTool.cxx +++ b/LArCalorimeter/LArDigitization/src/LArPileUpTool.cxx @@ -29,6 +29,9 @@ #include "PileUpTools/PileUpMergeSvc.h" #include "EventInfoUtils/EventIDFromStore.h" +#include "AthenaKernel/RNGWrapper.h" +#include "CLHEP/Random/RandomEngine.h" + #include <CLHEP/Random/Randomize.h> using CLHEP::RandFlat; @@ -47,8 +50,6 @@ LArPileUpTool::LArPileUpTool(const std::string& type, const std::string& name, c m_larhec_id(nullptr), m_larfcal_id(nullptr), m_laronline_id(nullptr), - m_AtRndmGenSvc(nullptr), - m_engine(nullptr), m_nhit_tot(0), m_trigtime(0), m_n_cells(0), @@ -98,7 +99,6 @@ LArPileUpTool::LArPileUpTool(const std::string& type, const std::string& name, c m_NSamples = 5; m_firstSample = 0; m_usePhase = false; - m_rndmSvc = "AtRndmGenSvc"; m_rndmEvtRun = false; m_RndmEvtOverlay = false; m_isMcOverlay = false; @@ -158,7 +158,6 @@ LArPileUpTool::LArPileUpTool(const std::string& type, const std::string& name, c declareProperty("Nsamples",m_NSamples,"Number of ADC samples (default=5)"); declareProperty("firstSample",m_firstSample,"First sample to use for the shape for in-time signal"); declareProperty("UsePhase",m_usePhase,"use 1ns binned pulse shape (default=false)"); - declareProperty("RndmSvc",m_rndmSvc,"Random number service for LAr digitization"); declareProperty("UseRndmEvtRun",m_rndmEvtRun,"Use Run and Event number to seed rndm number (default=false)"); declareProperty("MaskingTool",m_maskingTool,"Tool handle for dead channel masking"); declareProperty("BadFebKey",m_badFebKey,"Key of BadFeb object in ConditionsStore"); @@ -384,25 +383,7 @@ StatusCode LArPileUpTool::initialize() m_triggerTimeTool.disable(); } -// initialize random number service - if ( m_NoiseOnOff || m_addPhase || m_roundingNoNoise) { - static const bool CREATEIFNOTTHERE(true); - sc = service(m_rndmSvc, m_AtRndmGenSvc, CREATEIFNOTTHERE); - if (!sc.isSuccess() || 0 == m_AtRndmGenSvc) { - ATH_MSG_ERROR(" Unable to initialize AtRndmGenSvc"); - return StatusCode::FAILURE; - } - else { - ATH_MSG_INFO(" Found random number service " << m_rndmSvc); - } - if (!m_rndmEvtRun) { - m_engine = m_AtRndmGenSvc->GetEngine("LArDigitization"); - if (m_engine==0) { - ATH_MSG_ERROR(" Could find find random engine LArDigitization "); - return StatusCode::FAILURE; - } - } - } + ATH_CHECK(m_rndmGenSvc.retrieve()); if (m_NSamples>32) { ATH_MSG_WARNING(" Cannot do more than 32 samples: NSamples reset to 32 "); @@ -482,27 +463,6 @@ StatusCode LArPileUpTool::prepareEvent(unsigned int /*nInputEvents */) if (!m_useMBTime) m_energySum_DigiHSTruth.resize(m_hitmap_DigiHSTruth->GetNbCells(),0.); } - - // if noise on, get random number engine and initialize with well defined seeds - if (m_NoiseOnOff ||m_addPhase) { - //if use run-event number for seed - if (m_rndmEvtRun) { - const EventIDBase* evid = EventIDFromStore( evtStore() ); - if( evid ) { - const int iSeedNumber = evid->event_number()+1; - const int iRunNumber = evid->run_number(); - ATH_MSG_DEBUG(" Run/Event " << evid->run_number() << " " << evid->event_number()); - ATH_MSG_DEBUG(" iSeedNumber,iRunNumber " << iSeedNumber << " " << iRunNumber); - m_engine = m_AtRndmGenSvc->setOnDefinedSeeds(iSeedNumber,iRunNumber,this->name()); - } - else { - ATH_MSG_ERROR(" can not retrieve event info. Dummy rndm initialization..."); - int iSeedNumber=1; - m_engine = m_AtRndmGenSvc->setOnDefinedSeeds(iSeedNumber,this->name()); - } - } - } - // get the trigger time if requested m_trigtime=0; @@ -511,9 +471,12 @@ StatusCode LArPileUpTool::prepareEvent(unsigned int /*nInputEvents */) ATH_MSG_DEBUG(" Trigger time used : " << m_trigtime); } + ATHRNG::RNGWrapper* rngWrapper = m_rndmGenSvc->getEngine(this); + rngWrapper->setSeed( name(), Gaudi::Hive::currentContext() ); + // add random phase (i.e subtract it from trigtime) if (m_addPhase) { - m_trigtime = m_trigtime - (m_phaseMin + (m_phaseMax-m_phaseMin)*RandFlat::shoot(m_engine) ); + m_trigtime = m_trigtime - (m_phaseMin + (m_phaseMax-m_phaseMin)*RandFlat::shoot(*rngWrapper) ); } // @@ -878,6 +841,9 @@ StatusCode LArPileUpTool::mergeEvent() const std::vector<std::pair<float,float> >* TimeE; const std::vector<std::pair<float,float> >* TimeE_DigiHSTruth = nullptr; + ATHRNG::RNGWrapper* rngWrapper = m_rndmGenSvc->getEngine(this); + CLHEP::HepRandomEngine * engine = *rngWrapper; + for( ; it!=it_end;++it) // now loop on cells { hitlist = m_hitmap->GetCell(it); @@ -903,7 +869,7 @@ StatusCode LArPileUpTool::mergeEvent() // MakeDigit called if in no overlay mode or // if in overlay mode and random digit exists if( (!m_RndmEvtOverlay) || (m_RndmEvtOverlay && digit) ) { - if ( this->MakeDigit(cellID, ch_id,TimeE, digit, TimeE_DigiHSTruth) + if ( this->MakeDigit(cellID, ch_id,TimeE, digit, engine, TimeE_DigiHSTruth) == StatusCode::FAILURE ) return StatusCode::FAILURE; } } @@ -1907,7 +1873,8 @@ void LArPileUpTool::cross_talk(const IdentifierHash& hashId, StatusCode LArPileUpTool::MakeDigit(const Identifier & cellId, HWIdentifier & ch_id, const std::vector<std::pair<float,float> >* TimeE, - const LArDigit * rndmEvtDigit, const std::vector<std::pair<float,float> >* TimeE_DigiHSTruth) + const LArDigit * rndmEvtDigit, CLHEP::HepRandomEngine * engine, + const std::vector<std::pair<float,float> >* TimeE_DigiHSTruth) { bool createDigit_DigiHSTruth = true; @@ -2154,7 +2121,7 @@ StatusCode LArPileUpTool::MakeDigit(const Identifier & cellId, // Sqrt of noise covariance matrix const std::vector<float>& CorGen=autoCorrNoise->autoCorrSqrt(cellId,igain); - RandGaussZiggurat::shootArray(m_engine,m_NSamples,m_Rndm,0.,1.); + RandGaussZiggurat::shootArray(engine,m_NSamples,m_Rndm,0.,1.); int index; for (int i=0;i<m_NSamples;i++) { @@ -2209,7 +2176,7 @@ StatusCode LArPileUpTool::MakeDigit(const Identifier & cellId, else { if (m_roundingNoNoise) { - float flatRndm = RandFlat::shoot(m_engine); + float flatRndm = RandFlat::shoot(engine); xAdc = m_Samples[i]*energy2adc + Pedestal + flatRndm; if(m_doDigiTruth) { xAdc_DigiHSTruth = m_Samples_DigiHSTruth[i]*energy2adc + Pedestal + flatRndm; diff --git a/Tools/PROCTools/python/RunTier0TestsTools.py b/Tools/PROCTools/python/RunTier0TestsTools.py index 080eabfc8e509fc360ccbb05f1ea4c16bfa17718..00676574e4dfff6f6974a3923dde4820ab64e5fe 100644 --- a/Tools/PROCTools/python/RunTier0TestsTools.py +++ b/Tools/PROCTools/python/RunTier0TestsTools.py @@ -24,5 +24,5 @@ ciRefFileMap = { 's3126-22.0' : 'v2', # OverlayTier0Test_required-test 'overlay-d1498-21.0' : 'v1', - 'overlay-d1498-22.0' : 'v4', + 'overlay-d1498-22.0' : 'v5', }