diff --git a/InnerDetector/InDetDigitization/PixelDigitization/python/PixelDigitizationConfig.py b/InnerDetector/InDetDigitization/PixelDigitization/python/PixelDigitizationConfig.py index 7c7dac77ec8f8d7a5412ef89118ffbea82a5e24b..47502a737764064bbd1e8eb00f664ee5c9d05fb2 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/python/PixelDigitizationConfig.py +++ b/InnerDetector/InDetDigitization/PixelDigitization/python/PixelDigitizationConfig.py @@ -54,6 +54,8 @@ def BichselSimTool(name="BichselSimTool", **kwargs): kwargs.setdefault("DeltaRayCut", 117.) kwargs.setdefault("nCols", 5) kwargs.setdefault("LoopLimit", 100000) + kwargs.setdefault("RndmSvc", digitizationFlags.rndmSvc()) + kwargs.setdefault("RndmEngine", "PixelDigitization") return CfgMgr.BichselSimTool(name, **kwargs) def PixelBarrelBichselChargeTool(name="PixelBarrelBichselChargeTool", **kwargs): @@ -286,6 +288,9 @@ def PixelDigitizationToolSplitNoMergePU(name="PixelDigitizationToolSplitNoMergeP def PixelOverlayDigitizationTool(name="PixelOverlayDigitizationTool",**kwargs): from OverlayCommonAlgs.OverlayFlags import overlayFlags kwargs.setdefault("EvtStore", overlayFlags.evtStore()) + kwargs.setdefault("RDOCollName", overlayFlags.evtStore()+"/PixelRDOs") + kwargs.setdefault("RDOCollNameSPM", overlayFlags.evtStore()+"/PixelRDOs_SPM") + kwargs.setdefault("SDOCollName", overlayFlags.evtStore()+"/PixelSDO_Map") kwargs.setdefault("HardScatterSplittingMode", 0) return BasicPixelDigitizationTool(name,**kwargs) diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/BichselSimTool.cxx b/InnerDetector/InDetDigitization/PixelDigitization/src/BichselSimTool.cxx index 5f9d28bdf95ae43f3a06c5b17900c4d363298ca4..0d156fd84dd86dc10cd6ae69586890fc76d09fa2 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/BichselSimTool.cxx +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/BichselSimTool.cxx @@ -15,12 +15,14 @@ #include "TGraph.h" #include "TString.h" #include "TMath.h" -#include "TRandom3.h" #include "PathResolver/PathResolver.h" #include <fstream> #include <cmath> +#include "AtlasCLHEP_RandomGenerators/RandExpZiggurat.h" +#include "CLHEP/Random/RandFlat.h" + using namespace std; static const InterfaceID IID_IBichselSimTool("BichselSimTool", 1, 0); @@ -28,13 +30,18 @@ const InterfaceID& BichselSimTool::interfaceID( ){ return IID_IBichselSimTool; } // Constructor with parameters: BichselSimTool::BichselSimTool(const std::string& type, const std::string& name,const IInterface* parent): - AthAlgTool(type,name,parent) + AthAlgTool(type,name,parent), + m_rndmSvc("AtDSFMTGenSvc",name), + m_rndmEngineName("PixelDigitization"), + m_rndmEngine(0) { declareInterface< BichselSimTool >( this ); declareProperty("DeltaRayCut", m_DeltaRayCut = 117.); declareProperty("nCols", m_nCols = 1); declareProperty("LoopLimit", m_LoopLimit = 100000); + declareProperty("RndmSvc", m_rndmSvc, "Random Number Service used in BichselSimTool"); + declareProperty("RndmEngine", m_rndmEngineName, "Random engine name"); } // Destructor: @@ -55,8 +62,23 @@ StatusCode BichselSimTool::initialize() { //** define your initialize below **// - // random seed - m_RandomGenerator = new TRandom3(0); + // random svc + if ( m_rndmSvc.retrieve().isFailure() ) { + ATH_MSG_ERROR ( " Can't get RndmSvc " ); + return StatusCode::FAILURE; + } else { + ATH_MSG_DEBUG ( "Retrieved RndmSvc" ); + } + + // get the random stream + ATH_MSG_DEBUG ( "Getting random number engine : <" << m_rndmEngineName << ">" ); + m_rndmEngine = m_rndmSvc->GetEngine(m_rndmEngineName); + if (m_rndmEngine==0) { + ATH_MSG_ERROR ( "Could not find RndmEngine : " << m_rndmEngineName ); + return StatusCode::FAILURE; + } else { + ATH_MSG_DEBUG ( " Found RndmEngine : " << m_rndmEngineName ); + } // clear data table m_BichselData.clear(); @@ -214,7 +236,7 @@ std::vector<std::pair<double,double> > BichselSimTool::BichselSim(double BetaGam // sample hit position -- exponential distribution double HitPosition = 0.; - for(int iHit = 0; iHit < m_nCols; iHit++) HitPosition += m_RandomGenerator->Exp(lambda); + for(int iHit = 0; iHit < m_nCols; iHit++) HitPosition += CLHEP::RandExpZiggurat::shoot(m_rndmEngine, lambda); // termination by hit position // yes, in case m_nCols > 1, we will loose the last m_nCols collisions. So m_nCols cannot be too big @@ -225,7 +247,7 @@ std::vector<std::pair<double,double> > BichselSimTool::BichselSim(double BetaGam double TossEnergyLoss = -1.; // double TossIntX_record; while(TossEnergyLoss <= 0.){ // we have to do this because sometimes TossEnergyLoss will be negative due to too small TossIntX - double TossIntX = m_RandomGenerator->Uniform(0., IntXUpperBound); + double TossIntX = CLHEP::RandFlat::shoot(m_rndmEngine, 0., IntXUpperBound); TossEnergyLoss = GetColE(indices_BetaGammaLog10, TMath::Log10(TossIntX), iData); // TossIntX_record = TossIntX; diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/BichselSimTool.h b/InnerDetector/InDetDigitization/PixelDigitization/src/BichselSimTool.h index 988073bbd0112a434177a849f5df4e072b4dad3c..9af08a336bd18410acd22db7d83915cadf7bf807 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/BichselSimTool.h +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/BichselSimTool.h @@ -20,11 +20,15 @@ #ifndef PIXELDIGITIZATION_BichselSimTool_H #define PIXELDIGITIZATION_BichselSimTool_H +#include "GaudiKernel/ServiceHandle.h" #include "AthenaBaseComps/AthAlgTool.h" - +#include "CLHEP/Random/RandomEngine.h" +#include "AthenaKernel/IAtRndmGenSvc.h" // forward class declaration -class TRandom3; +namespace CLHEP{ + class HepRandomEngine; +} // internal data structure for storage purpose struct BichselData @@ -67,10 +71,15 @@ private: // internal private members // double m_DeltaRayCut; // Threshold to identify a delta ray. unit in keV std::vector<BichselData> m_BichselData; // vector to store Bichsel Data. Each entry is for one particle type - TRandom3* m_RandomGenerator; // Random number generator int m_nCols; // number of collisions to simulate each time. This is mainly to save CPU time if necessary int m_LoopLimit; // upper limit on number of loops. The default value is optimized for current configuration. People can tune this number in case of ITK upgrade (very forward barrel) or other new situation. +protected: + ServiceHandle<IAtRndmGenSvc> m_rndmSvc; + std::string m_rndmEngineName; + CLHEP::HepRandomEngine* m_rndmEngine; + +private: // internal private functions // std::pair<int,int> FastSearch(std::vector<double> vec, double item) const; // A quick implementation of binary search in 2D table std::pair<int,int> GetBetaGammaIndices(double BetaGammaLog10, BichselData& iData) const; // get beta-gamma index. This is so commonly used by other functions that a caching would be beneficial diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitizationTool.cxx b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitizationTool.cxx index fdd506a846bbeb80fe97d6bacc21ab2ad01dbc5c..6d60c3d92fe21bee93266c97e97d8c2f839e89a6 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitizationTool.cxx +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitizationTool.cxx @@ -1187,7 +1187,7 @@ StatusCode PixelDigitizationTool::processBunchXing(int bunchXing, const SiHitCollection* seHitColl(0); if (!seStore.retrieve(seHitColl,m_inputObjectName).isSuccess()) { - msg(MSG::ERROR) << "SubEvent Pixel SiHitCollection not found in StoreGate " << seStore.name() << endreq; + msg(MSG::ERROR) << "SubEvent Pixel SiHitCollection not found in StoreGate " << seStore.name() << endmsg; return StatusCode::FAILURE; } ATH_MSG_DEBUG("SiHitCollection found with " << seHitColl->size() << " hits"); diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelNoisyCellGenerator.cxx b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelNoisyCellGenerator.cxx index 94dc1426b5106d895bb94d78ed44b5f81a19c9d7..5900fa6efbd4dfe61da1f4dddf04082317c0ec6b 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelNoisyCellGenerator.cxx +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelNoisyCellGenerator.cxx @@ -86,13 +86,13 @@ StatusCode PixelNoisyCellGenerator::initialize() { std::string pixelHelperName("PixelID"); if ( StatusCode::SUCCESS!= detStore()->retrieve(m_pixelID,pixelHelperName) ) { - msg(MSG::FATAL) << "Pixel ID helper not found" << endreq; + msg(MSG::FATAL) << "Pixel ID helper not found" << endmsg; return StatusCode::FAILURE; } std::string managerName("Pixel"); if ( StatusCode::SUCCESS!= detStore()->retrieve(m_pixMgr,managerName) ) { - msg(MSG::FATAL) << "PixelDetectorManager not found" << endreq; + msg(MSG::FATAL) << "PixelDetectorManager not found" << endmsg; return StatusCode::FAILURE; }