From c5aa163f50b92507b64997a7e539b21e47e4ec07 Mon Sep 17 00:00:00 2001 From: Soshi Tsuno <soshi.tsuno@cern.ch> Date: Mon, 20 Feb 2017 12:39:36 +0100 Subject: [PATCH] Replace ISiChargedDiodesProcessorTool with PixelProcessorTool (PixelDigitization-02-03-31) * Replace ISiChargedDiodesProcessorTool with PixelProcessorTool. * Tagged as PixelDigitization-02-03-31. --- .../python/PixelDigitizationConfig.py | 31 ++--- .../python/PixelDigitizationConfigDb.py | 1 + .../src/PixelChargeSmearer.cxx | 76 ++--------- .../src/PixelChargeSmearer.h | 69 ++-------- .../src/PixelDigitizationTool.cxx | 30 ++--- .../src/PixelDigitizationTool.h | 7 +- .../src/PixelDiodeCrossTalkGenerator.cxx | 123 +++++++----------- .../src/PixelDiodeCrossTalkGenerator.h | 67 ++-------- .../src/PixelGangedMerger.cxx | 63 +++------ .../PixelDigitization/src/PixelGangedMerger.h | 66 ++-------- .../src/PixelNoisyCellGenerator.cxx | 111 ++++------------ .../src/PixelNoisyCellGenerator.h | 118 ++++------------- .../src/PixelProcessorTool.h | 69 ++++++++++ .../src/PixelRandomDisabledCellGenerator.cxx | 67 ++-------- .../src/PixelRandomDisabledCellGenerator.h | 63 ++------- 15 files changed, 279 insertions(+), 682 deletions(-) create mode 100644 InnerDetector/InDetDigitization/PixelDigitization/src/PixelProcessorTool.h diff --git a/InnerDetector/InDetDigitization/PixelDigitization/python/PixelDigitizationConfig.py b/InnerDetector/InDetDigitization/PixelDigitization/python/PixelDigitizationConfig.py index 69ad0c471a0..6e276f90a80 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/python/PixelDigitizationConfig.py +++ b/InnerDetector/InDetDigitization/PixelDigitization/python/PixelDigitizationConfig.py @@ -113,14 +113,17 @@ def SubChargesTool(name="SubChargesTool", **kwargs): kwargs.setdefault("RndmEngine", "PixelDigitization") return CfgMgr.SubChargesTool(name, **kwargs) +def PixelProcessorTool(name="PixelProcessorTool", **kwargs): + kwargs.setdefault("RndmSvc", digitizationFlags.rndmSvc()) + kwargs.setdefault("RndmEngine", "PixelDigitization") + return CfgMgr.PixelProcessorTool(name, **kwargs) + def PixelNoisyCellGenerator(name="PixelNoisyCellGenerator", **kwargs): from AthenaCommon.BeamFlags import jobproperties kwargs.setdefault("MergeCharge", True) NoiseShape = [0.00596, 0.03491, 0.07058, 0.11991, 0.17971, 0.24105, 0.29884, 0.35167, 0.39912, 0.44188, 0.48016, 0.51471, 0.54587, 0.57405, 0.59958, 0.62288, 0.64411, 0.66360, 0.68159, 0.69823, 0.71362, 0.72781, 0.74096, 0.75304, 0.76415, 0.77438, 0.78383, 0.79256, 0.80066, 0.80821, 0.81547, 0.82246, 0.82918, 0.83501, 0.84054, 0.84576, 0.85078, 0.85558, 0.86018, 0.86455, 0.86875, 0.87273, 0.87653, 0.88020, 0.88369, 0.88705, 0.89027, 0.89336, 0.89633, 0.89921, 0.90195, 0.90460, 0.90714, 0.90961, 0.91198, 0.91426, 0.91644, 0.91853, 0.92055, 0.92250, 0.92435, 0.92611, 0.92782, 0.92947, 0.93105, 0.93257, 0.93404, 0.93547, 0.93688, 0.93822, 0.93953, 0.94079, 0.94201, 0.94318, 0.94432, 0.94542, 0.94649, 0.94751, 0.94851, 0.94949, 0.95045, 0.95137, 0.95227, 0.95314, 0.95399, 0.95483, 0.95563, 0.95646, 0.95729, 0.95812, 0.95896, 0.95980, 0.96063, 0.96144, 0.96224, 0.96301, 0.96377, 0.96451, 0.96521, 0.96590, 0.96657, 0.96722, 0.96787, 0.96849, 0.96911, 0.96971, 0.97031, 0.97090, 0.97148, 0.97204, 0.97260, 0.97314, 0.97367, 0.97421, 0.97474, 0.97525, 0.97576, 0.97627, 0.97676, 0.97722, 0.97769, 0.97815, 0.97861, 0.97906, 0.97950, 0.97992, 0.98033, 0.98073, 0.98111, 0.98147, 0.98182, 0.98216, 0.98249, 0.98281, 0.98312, 0.98343, 0.98374, 0.98402, 0.98430, 0.98456, 0.98482, 0.98507, 0.98532, 0.98555, 0.98579, 0.98602, 0.98624, 0.98646, 0.98668, 0.98690, 0.98711, 0.98732, 0.98753, 0.98773, 0.98793, 0.98813, 0.98832, 0.98851, 0.98870, 0.98888, 0.98907, 0.98925, 0.98943, 0.98961, 0.98979, 0.98996, 0.99014, 0.99031, 0.99048, 0.99064, 0.99081, 0.99098, 0.99114, 0.99131, 0.99147, 0.99163, 0.99179, 0.99194, 0.99210, 0.99225, 0.99240, 0.99256, 0.99271, 0.99286, 0.99300, 0.99315, 0.99329, 0.99344, 0.99358, 0.99372, 0.99386, 0.99400, 0.99414, 0.99427, 0.99440, 0.99453, 0.99466, 0.99479, 0.99491, 0.99503, 0.99515, 0.99527, 0.99538, 0.99549, 0.99560, 0.99571, 0.99582, 0.99592, 0.99602, 0.99613, 0.99623, 0.99633, 0.99643, 0.99653, 0.99662, 0.99672, 0.99682, 0.99691, 0.99701, 0.99710, 0.99719, 0.99728, 0.99737, 0.99746, 0.99755, 0.99764, 0.99772, 0.99781, 0.99790, 0.99798, 0.99806, 0.99814, 0.99823, 0.99831, 0.99839, 0.99847, 0.99855, 0.99863, 0.99871, 0.99879, 0.99887, 0.99895, 0.99902, 0.99910, 0.99918, 0.99925, 0.99933, 0.99940, 0.99948, 0.99955, 0.99963, 0.99971, 0.99978, 0.99985, 0.99993, 1.00000] kwargs.setdefault("NoiseShape",NoiseShape) #print "Noise Shape = ",NoiseShape - kwargs.setdefault("RndmSvc", digitizationFlags.rndmSvc()) - kwargs.setdefault("RndmEngine", "PixelDigitization") if jobproperties.Beam.beamType != "cosmics" : kwargs.setdefault("RndNoiseProb", 1.e-10) return CfgMgr.PixelNoisyCellGenerator(name, **kwargs) @@ -129,8 +132,6 @@ def PixelGangedMerger(name="PixelGangedMerger", **kwargs): return CfgMgr.PixelGangedMerger(name, **kwargs) def PixelChargeSmearer(name="PixelChargeSmearer", **kwargs): - kwargs.setdefault("RndmSvc", digitizationFlags.rndmSvc()) - kwargs.setdefault("RndmEngine", "PixelDigitization") kwargs.setdefault("ThermalNoise", 160.0) return CfgMgr.PixelChargeSmearer(name, **kwargs) @@ -159,8 +160,6 @@ def TimeSvc(name="TimeSvc", **kwargs): return CfgMgr.TimeSvc(name, **kwargs) def PixelRandomDisabledCellGenerator(name="PixelRandomDisabledCellGenerator", **kwargs): - kwargs.setdefault("RndmSvc", digitizationFlags.rndmSvc()) - kwargs.setdefault("RndmEngine", "PixelDigitization") return CfgMgr.PixelRandomDisabledCellGenerator(name, **kwargs) def FrontEndSimTool(name="FrontEndSimTool", **kwargs): @@ -218,23 +217,19 @@ def BasicPixelDigitizationTool(name="PixelDigitizationTool", **kwargs): pixelSiPropertiesSvc = SiPropertiesSvc(name = "PixelSiPropertiesSvc",DetectorName="Pixel",SiConditionsServices = lorentzAngleSvc.pixelSiliconConditionsSvc) ServiceMgr += pixelSiPropertiesSvc kwargs.setdefault("InputObjectName", "PixelHits") - pixTools = [] + procTools = [] chargeTools = [] feSimTools = [] if GeometryFlags.isSLHC(): - pixTools += ['PixelDiodeCrossTalkGenerator'] - pixTools += ['PixelChargeSmearer'] - pixTools += ['PixelNoisyCellGenerator'] - pixTools += ['PixelGangedMerger'] - pixTools += ['PixelRandomDisabledCellGenerator'] + procTools += ['PixelDiodeCrossTalkGenerator'] chargeTools += ['IblPlanarBichselChargeTool'] feSimTools += ['FEI4SimTool'] else: - pixTools += ['PixelDiodeCrossTalkGenerator'] - pixTools += ['PixelChargeSmearer'] - pixTools += ['PixelNoisyCellGenerator'] - pixTools += ['PixelGangedMerger'] - pixTools += ['PixelRandomDisabledCellGenerator'] + procTools += ['PixelDiodeCrossTalkGenerator'] + procTools += ['PixelChargeSmearer'] + procTools += ['PixelNoisyCellGenerator'] + procTools += ['PixelGangedMerger'] + procTools += ['PixelRandomDisabledCellGenerator'] chargeTools += ['DBMChargeTool'] chargeTools += ['PixelECBichselChargeTool'] chargeTools += ['PixelBarrelBichselChargeTool'] @@ -242,7 +237,7 @@ def BasicPixelDigitizationTool(name="PixelDigitizationTool", **kwargs): chargeTools += ['Ibl3DBichselChargeTool'] feSimTools += ['FEI4SimTool'] feSimTools += ['FEI3SimTool'] - kwargs.setdefault("PixelTools", pixTools) + kwargs.setdefault("PixelProcessorTools", procTools) kwargs.setdefault("ChargeTools", chargeTools) kwargs.setdefault("FrontEndSimTools", feSimTools) if digitizationFlags.doXingByXingPileUp(): # PileUpTool approach diff --git a/InnerDetector/InDetDigitization/PixelDigitization/python/PixelDigitizationConfigDb.py b/InnerDetector/InDetDigitization/PixelDigitization/python/PixelDigitizationConfigDb.py index 581cbafd9a0..e95ffa52128 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/python/PixelDigitizationConfigDb.py +++ b/InnerDetector/InDetDigitization/PixelDigitization/python/PixelDigitizationConfigDb.py @@ -11,6 +11,7 @@ addAlgorithm("PixelDigitization.PixelDigitizationConfig.PixelDigitizationHS" , addAlgorithm("PixelDigitization.PixelDigitizationConfig.PixelDigitizationPU" , "PixelDigitizationPU") addTool("PixelDigitization.PixelDigitizationConfig.getPixelRange", "PixelRange") addService("PixelDigitization.PixelDigitizationConfig.ChargeCollProbSvc","ChargeCollProbSvc") +addTool("PixelDigitization.PixelDigitizationConfig.PixelProcessorTool","PixelProcessorTool") addTool("PixelDigitization.PixelDigitizationConfig.PixelNoisyCellGenerator", "PixelNoisyCellGenerator") addTool("PixelDigitization.PixelDigitizationConfig.PixelGangedMerger", "PixelGangedMerger") addTool("PixelDigitization.PixelDigitizationConfig.PixelChargeSmearer", "PixelChargeSmearer") diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelChargeSmearer.cxx b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelChargeSmearer.cxx index c4cf0e975fa..0b359a7515d 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelChargeSmearer.cxx +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelChargeSmearer.cxx @@ -12,85 +12,33 @@ #include "PixelChargeSmearer.h" #include "SiDigitization/SiChargedDiodeCollection.h" -#include "CLHEP/Random/RandomEngine.h" -#include "AtlasCLHEP_RandomGenerators/RandGaussZiggurat.h" -#include "AthenaKernel/IAtRndmGenSvc.h" - -static const InterfaceID IID_IPixelChargeSmearer("PixelChargeSmearer", 1, 0); -const InterfaceID& PixelChargeSmearer::interfaceID( ){ return IID_IPixelChargeSmearer; } - -// Constructor with parameters: -PixelChargeSmearer::PixelChargeSmearer(const std::string& type, const std::string& name,const IInterface* parent) : - AthAlgTool(type,name,parent), - m_amplitude(0), - m_rndmSvc("AtDSFMTGenSvc",name), - m_rndmEngineName("PixelDigitization"), - m_rndmEngine(0) +PixelChargeSmearer::PixelChargeSmearer(const std::string& type, const std::string& name,const IInterface* parent): + PixelProcessorTool(type,name,parent), + m_amplitude(0) { - declareInterface< PixelChargeSmearer >( this ); - declareProperty("RndmSvc",m_rndmSvc,"Random Number Service used in Pixel digitization"); - declareProperty("RndmEngine",m_rndmEngineName,"Random engine name"); declareProperty("ThermalNoise",m_amplitude,"Thermal noise amplitude"); } -// Destructor: -PixelChargeSmearer::~PixelChargeSmearer() -{} - -//---------------------------------------------------------------------- -// Initialize -//---------------------------------------------------------------------- +PixelChargeSmearer::~PixelChargeSmearer() {} StatusCode PixelChargeSmearer::initialize() { - StatusCode sc = AthAlgTool::initialize(); - if (sc.isFailure()) { - ATH_MSG_FATAL ( "PixelChargeSmearer::initialize() failed"); - return sc ; - } - if (m_rndmSvc.retrieve().isFailure()) { - ATH_MSG_ERROR("Can't get RndmSvc"); - return StatusCode::FAILURE; - } - else { - ATH_MSG_DEBUG("Retrieved RndmSvc"); - } - - 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 ); - } - - ATH_MSG_DEBUG ( "PixelChargeSmearer::initialize()"); - return sc ; + CHECK(PixelProcessorTool::initialize()); + ATH_MSG_DEBUG("PixelChargeSmearer::initialize()"); + return StatusCode::SUCCESS; } -//---------------------------------------------------------------------- -// finalize -//---------------------------------------------------------------------- StatusCode PixelChargeSmearer::finalize() { - StatusCode sc = AthAlgTool::finalize(); - if (sc.isFailure()) { - ATH_MSG_FATAL ( "PixelChargeSmearer::finalize() failed"); - return sc ; - } - ATH_MSG_DEBUG ( "PixelChargeSmearer::finalize()"); - return sc ; + ATH_MSG_DEBUG("PixelChargeSmearer::finalize()"); + return StatusCode::SUCCESS; } -// process the list of charged diodes -void PixelChargeSmearer::process(SiChargedDiodeCollection &collection) const -{ +void PixelChargeSmearer::process(SiChargedDiodeCollection &collection) { + // if the noise amplitude if 0, do nothing if (0==m_amplitude) return; // loop on all charged diodes - for(SiChargedDiodeIterator i_chargedDiode=collection.begin(); - i_chargedDiode!=collection.end(); - ++i_chargedDiode) { + for (SiChargedDiodeIterator i_chargedDiode=collection.begin(); i_chargedDiode!=collection.end(); ++i_chargedDiode) { // create noise charge SiCharge charge(m_amplitude*CLHEP::RandGaussZiggurat::shoot(m_rndmEngine),0,SiCharge::noise); diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelChargeSmearer.h b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelChargeSmearer.h index a37e7392931..7beaa8d7a47 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelChargeSmearer.h +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelChargeSmearer.h @@ -8,71 +8,26 @@ /////////////////////////////////////////////////////////////////// // (c) ATLAS Detector software /////////////////////////////////////////////////////////////////// -// Class to simulate the diode-level thermal noise for Pixel and SCT -/////////////////////////////////////////////////////////////////// -// -// Configurable Parameters: -// -RndmSvc Random Number Service used in Pixel digitization -// -RndmEngine Random engine name -// -ThermalNoise Thermal noise amplitude -// -/////////////////////////////////////////////////////////////////// - -/** @class PixelChargeSmearer - * @brief smears charges in the given collection - * @author David Calvet - * @author Fredrik Tegenfeldt - * - * \b Description - * - * This class smears a charges using a gaussian with a mean=0 and a sigma given by the user. - * The charge is flaged as noise and added to the total charge of the pixel. - * - */ - #ifndef PIXELDIGITIZATION_PIXELCHARGESMEARER_H #define PIXELDIGITIZATION_PIXELCHARGESMEARER_H -#include "SiDigitization/ISiChargedDiodesProcessorTool.h" -#include "AthenaBaseComps/AthAlgTool.h" - -class IAtRndmGenSvc; - -namespace CLHEP { - class HepRandomEngine; -} - -class PixelChargeSmearer : public AthAlgTool, virtual public ISiChargedDiodesProcessorTool { - -public: - - // Constructor: - PixelChargeSmearer( const std::string& type, const std::string& name,const IInterface* parent); - - /** Destructor */ - virtual ~PixelChargeSmearer(); +#include "PixelProcessorTool.h" - /** AlgTool InterfaceID */ - static const InterfaceID& interfaceID() ; +class PixelChargeSmearer:public PixelProcessorTool { + public: - /** AlgTool initialize */ - virtual StatusCode initialize(); + PixelChargeSmearer( const std::string& type, const std::string& name,const IInterface* parent); - /** AlgTool finalize */ - virtual StatusCode finalize(); + virtual ~PixelChargeSmearer(); + virtual StatusCode initialize(); + virtual StatusCode finalize(); + virtual void process(SiChargedDiodeCollection &collection); - /** process the collection of charged diodes */ - virtual void process(SiChargedDiodeCollection &collection) const; - -private: - /** empty constructor made private */ - PixelChargeSmearer(); + private: + PixelChargeSmearer(); - double m_amplitude; /**< noise amplitude */ - ServiceHandle<IAtRndmGenSvc> m_rndmSvc; - std::string m_rndmEngineName; - CLHEP::HepRandomEngine* m_rndmEngine; - }; + double m_amplitude; +}; #endif // SITHERMALDIODENOISEGENERATOR_H diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitizationTool.cxx b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitizationTool.cxx index 87d5c2d72a4..98b5101d092 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitizationTool.cxx +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitizationTool.cxx @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////////// // (c) ATLAS Detector software //////////////////////////////////////////////////////////////////////////// - -// Pixel digitization includes #include "PixelDigitizationTool.h" #include "PileUpTools/PileUpMergeSvc.h" @@ -19,9 +17,6 @@ #include "Identifier/Identifier.h" #include "InDetIdentifier/PixelID.h" -// STSTST #include "AtlasCLHEP_RandomGenerators/RandGaussZiggurat.h" -// STSTST #include "CLHEP/Random/RandFlat.h" - #include "AthenaKernel/errorcheck.h" #include "StoreGate/DataHandle.h" #include "CxxUtils/make_unique.h" @@ -31,9 +26,6 @@ static constexpr unsigned int crazyParticleBarcode(std::numeric_limits<int32_t>::max()); //Barcodes at the HepMC level are int -// STSTST using namespace InDetDD; - -// Constructor with parameters: PixelDigitizationTool::PixelDigitizationTool(const std::string &type, const std::string &name, const IInterface * pIID) : @@ -44,9 +36,9 @@ PixelDigitizationTool::PixelDigitizationTool(const std::string &type, m_HardScatterSplittingSkipper(false), m_rndmEngineName("PixelDigitization"), m_onlyHitElements(false), - m_diodesProcsTool(), - m_chargeTool(), - m_fesimTool(), + m_processorTool(nullptr), + m_chargeTool(nullptr), + m_fesimTool(nullptr), m_detID(nullptr), m_vetoThisBarcode(crazyParticleBarcode), m_timedHits(nullptr), @@ -57,7 +49,7 @@ PixelDigitizationTool::PixelDigitizationTool(const std::string &type, m_inputObjectName(""), m_createNoiseSDO(false) { - declareProperty("PixelTools", m_diodesProcsTool, "List of processor tools"); + declareProperty("PixelProcessorTools", m_processorTool, "List of processor tools"); declareProperty("ChargeTools", m_chargeTool, "List of charge tools"); declareProperty("FrontEndSimTools", m_fesimTool, "List of Front-End simulation tools"); declareProperty("RndmSvc", m_rndmSvc, "Random number service used in Pixel Digitization"); @@ -105,7 +97,7 @@ StatusCode PixelDigitizationTool::initialize() { ATH_MSG_DEBUG("Pixel ID helper retrieved"); // Initialize tools - CHECK(m_diodesProcsTool.retrieve()); + CHECK(m_processorTool.retrieve()); CHECK(m_chargeTool.retrieve()); @@ -203,9 +195,9 @@ StatusCode PixelDigitizationTool::digitizeEvent() { // Apply processor tools ATH_MSG_DEBUG("Apply processor tools"); - for (unsigned int itool=0; itool<m_diodesProcsTool.size(); itool++) { - ATH_MSG_DEBUG("Executing tool " << m_diodesProcsTool[itool]->name()); - m_diodesProcsTool[itool]->process(*chargedDiodes); + for (unsigned int itool=0; itool<m_processorTool.size(); itool++) { + ATH_MSG_DEBUG("Executing tool " << m_processorTool[itool]->name()); + m_processorTool[itool]->process(*chargedDiodes); } ATH_MSG_DEBUG("Hit collection ID=" << m_detID->show_to_string(chargedDiodes->identify())); @@ -253,9 +245,9 @@ StatusCode PixelDigitizationTool::digitizeEvent() { // Apply processor tools ATH_MSG_DEBUG("Apply processor tools"); - for (unsigned int itool=0; itool<m_diodesProcsTool.size(); itool++) { - ATH_MSG_DEBUG("Executing tool " << m_diodesProcsTool[itool]->name()); - m_diodesProcsTool[itool]->process(*chargedDiodes); + for (unsigned int itool=0; itool<m_processorTool.size(); itool++) { + ATH_MSG_DEBUG("Executing tool " << m_processorTool[itool]->name()); + m_processorTool[itool]->process(*chargedDiodes); } // Create and store RDO and SDO diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitizationTool.h b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitizationTool.h index b4bab15c059..760ebb63838 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitizationTool.h +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitizationTool.h @@ -20,11 +20,11 @@ #include "GaudiKernel/ToolHandle.h" #include "GaudiKernel/ServiceHandle.h" -// STSTST #include "AthenaKernel/IAtRndmGenSvc.h" #include "StoreGate/WriteHandle.h" #include "InDetSimData/InDetSimDataCollection.h" -#include "SiDigitization/ISiChargedDiodesProcessorTool.h" +// STSTST #include "SiDigitization/ISiChargedDiodesProcessorTool.h" +#include "PixelProcessorTool.h" #include "SubChargesTool.h" #include "FrontEndSimTool.h" @@ -64,7 +64,8 @@ class PixelDigitizationTool : public PileUpToolBase { bool m_onlyHitElements; - ToolHandleArray<ISiChargedDiodesProcessorTool> m_diodesProcsTool; +// STSTST ToolHandleArray<ISiChargedDiodesProcessorTool> m_diodesProcsTool; + ToolHandleArray<PixelProcessorTool> m_processorTool; ToolHandleArray<SubChargesTool> m_chargeTool; ToolHandleArray<FrontEndSimTool> m_fesimTool; diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDiodeCrossTalkGenerator.cxx b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDiodeCrossTalkGenerator.cxx index d908f0ff5e6..e74ddba62b5 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDiodeCrossTalkGenerator.cxx +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDiodeCrossTalkGenerator.cxx @@ -17,56 +17,33 @@ using namespace InDetDD; -static const InterfaceID IID_IPixelDiodeCrossTalkGenerator("PixelDiodeCrossTalkGenerator", 1, 0); -const InterfaceID& PixelDiodeCrossTalkGenerator::interfaceID( ){ return IID_IPixelDiodeCrossTalkGenerator; } - -// Constructor with parameters: -PixelDiodeCrossTalkGenerator::PixelDiodeCrossTalkGenerator(const std::string& type, const std::string& name,const IInterface* parent) : - AthAlgTool(type,name,parent), +PixelDiodeCrossTalkGenerator::PixelDiodeCrossTalkGenerator(const std::string& type, const std::string& name,const IInterface* parent): + PixelProcessorTool(type,name,parent), m_diodeCrossTalk(.06) { - declareInterface< PixelDiodeCrossTalkGenerator >( this ); - declareProperty("DiodeCrossTalk",m_diodeCrossTalk,"Diode cross talk factor"); + declareProperty("DiodeCrossTalk",m_diodeCrossTalk,"Diode cross talk factor"); } -// Destructor: -PixelDiodeCrossTalkGenerator::~PixelDiodeCrossTalkGenerator() -{} +PixelDiodeCrossTalkGenerator::~PixelDiodeCrossTalkGenerator() {} -//---------------------------------------------------------------------- -// Initialize -//---------------------------------------------------------------------- StatusCode PixelDiodeCrossTalkGenerator::initialize() { - StatusCode sc = AthAlgTool::initialize(); - if (sc.isFailure()) { - ATH_MSG_FATAL ( "PixelDiodeCrossTalkGenerator::initialize() failed"); - return sc ; - } - ATH_MSG_DEBUG ( "PixelDiodeCrossTalkGenerator::initialize()"); - return sc ; + CHECK(PixelProcessorTool::initialize()); + ATH_MSG_DEBUG("PixelDiodeCrossTalkGenerator::initialize()"); + return StatusCode::SUCCESS; } -//---------------------------------------------------------------------- -// finalize -//---------------------------------------------------------------------- StatusCode PixelDiodeCrossTalkGenerator::finalize() { - StatusCode sc = AthAlgTool::finalize(); - if (sc.isFailure()) { - ATH_MSG_FATAL ( "PixelDiodeCrossTalkGenerator::finalize() failed"); - return sc ; - } - ATH_MSG_DEBUG ( "PixelDiodeCrossTalkGenerator::finalize()"); - return sc ; + ATH_MSG_DEBUG("PixelDiodeCrossTalkGenerator::finalize()"); + return StatusCode::SUCCESS; } -// process the list of charged diodes -void PixelDiodeCrossTalkGenerator::process(SiChargedDiodeCollection &collection) const { +void PixelDiodeCrossTalkGenerator::process(SiChargedDiodeCollection &collection) { + // if the cross talk factor if 0, do nothing if (0==m_diodeCrossTalk) return; // get pixel module design and check it - const PixelModuleDesign *p_design= - dynamic_cast<const PixelModuleDesign *>(&(collection.design())); + const PixelModuleDesign *p_design= static_cast<const PixelModuleDesign *>(&(collection.design())); if (!p_design) return; // create a local copy of the current collection @@ -76,51 +53,43 @@ void PixelDiodeCrossTalkGenerator::process(SiChargedDiodeCollection &collection) // loop on all old charged diodes // -ME fix- for(std::map<Identifier32,SiChargedDiode>::const_iterator p_chargedDiode= - for(SiChargedDiodeMap::const_iterator p_chargedDiode= - oldChargedDiodes.begin() ; - p_chargedDiode!=oldChargedDiodes.end() ; ++p_chargedDiode) { - - // current diode - SiCellId diode=(*p_chargedDiode).second.diode(); - - // get the list of neighbours for this diode - std::vector<SiCellId> neighbours; - p_design->neighboursOfCell(diode,neighbours); - - // loop on all neighbours - for(std::vector<SiCellId>::const_iterator p_neighbour=neighbours.begin() ; - p_neighbour!=neighbours.end() ; ++p_neighbour) { - - // get the intersection length between the two diodes - const double intersection=p_design->intersectionLength(diode,*p_neighbour); - + for (SiChargedDiodeMap::const_iterator p_chargedDiode=oldChargedDiodes.begin(); p_chargedDiode!=oldChargedDiodes.end(); ++p_chargedDiode) { + + // current diode + SiCellId diode=(*p_chargedDiode).second.diode(); + + // get the list of neighbours for this diode + std::vector<SiCellId> neighbours; + p_design->neighboursOfCell(diode,neighbours); + + // loop on all neighbours + for (std::vector<SiCellId>::const_iterator p_neighbour=neighbours.begin(); p_neighbour!=neighbours.end(); ++p_neighbour) { + + // get the intersection length between the two diodes + const double intersection=p_design->intersectionLength(diode,*p_neighbour); + + // add cross talk only if the intersection is non-zero + // if the original pixel is at (col,row) then the intersection length is + // (col+-1, row+-1) : 0 -> diagonal + // (col , row+-1) : 0.4 mm (or 0.6 if long pixel) pixel width = 400um or 600um + // (col+-1, row ) : 0.05 mm , pixel height = 50um + // intersection length is just the length of the contact surface between + // the two pixels + if (intersection>0) { // - // add cross talk only if the intersection is non-zero - // if the original pixel is at (col,row) then the intersection length is - // (col+-1, row+-1) : 0 -> diagonal - // (col , row+-1) : 0.4 mm (or 0.6 if long pixel) pixel width = 400um or 600um - // (col+-1, row ) : 0.05 mm , pixel height = 50um - // intersection length is just the length of the contact surface between - // the two pixels + // create a new charge: + // Q(new) = Q*L*X + // Q = charge of source pixel + // L = intersection length [mm] + // X = crosstalk factor [mm-1] // - if (intersection>0) { - // - // create a new charge: - // Q(new) = Q*L*X - // Q = charge of source pixel - // L = intersection length [mm] - // X = crosstalk factor [mm-1] - // - const SiChargedDiode & chargedDiode = (*p_chargedDiode).second; - SiCharge charge(chargedDiode.charge()*intersection*m_diodeCrossTalk, - chargedDiode.totalCharge().time(), - SiCharge::diodeX_Talk, - chargedDiode.totalCharge().particleLink()); - // add this new charge - collection.add(*p_neighbour,charge); - } + const SiChargedDiode & chargedDiode = (*p_chargedDiode).second; + + SiCharge charge(chargedDiode.charge()*intersection*m_diodeCrossTalk, chargedDiode.totalCharge().time(), SiCharge::diodeX_Talk, chargedDiode.totalCharge().particleLink()); + // add this new charge + collection.add(*p_neighbour,charge); } - //} + } } } diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDiodeCrossTalkGenerator.h b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDiodeCrossTalkGenerator.h index b0e64baee10..c416430a7d3 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDiodeCrossTalkGenerator.h +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDiodeCrossTalkGenerator.h @@ -8,71 +8,26 @@ /////////////////////////////////////////////////////////////////// // (c) ATLAS Detector software /////////////////////////////////////////////////////////////////// -// Class to generate the diode-level cross-talk for Pixel -/////////////////////////////////////////////////////////////////// -// -// Configurable Parameters: -// -DiodeCrossTalk Diode cross talk factor -// -/////////////////////////////////////////////////////////////////// - - - -/** @class PixelDiodeCrossTalkGenerator - * @brief Simulates the discriminator, including the timing - * @author David Calvet (2000) - * @author Fredrik Tegenfeldt (2005-2007) - * - * \b Description - * - * This class generates cross talk from a given charge collection. - * It is assumed that all charges originate from tracks. Therefore it must - * be called directly \e after the surface charge generator. - * - * For a given charged pixel, cross talk charges are generated in the neighboring - * pixels (not diagonal). The algorithm is as follows: - * -# make a copy of the original charge list (avoid creating cross talk on cross talk on ...) - * -# loop over all charged pixels and check if above 3*threshold (the const 3 is hardcoded) - * -# if yes, generate cross talk in neighboring pixels - * -*/ - #ifndef PIXELDIGITIZATION_PIXELDIODECROSSTALKGENERATOR_H #define PIXELDIGITIZATION_PIXELDIODECROSSTALKGENERATOR_H -// Base class -#include "SiDigitization/ISiChargedDiodesProcessorTool.h" -#include "AthenaBaseComps/AthAlgTool.h" - - -class PixelDiodeCrossTalkGenerator : public AthAlgTool, virtual public ISiChargedDiodesProcessorTool { - -public: - - //Constructor: - PixelDiodeCrossTalkGenerator( const std::string& type, const std::string& name,const IInterface* parent); - - /** Destructor */ - virtual ~PixelDiodeCrossTalkGenerator(); +#include "PixelProcessorTool.h" - /** AlgTool InterfaceID */ - static const InterfaceID& interfaceID() ; +class PixelDiodeCrossTalkGenerator:public PixelProcessorTool { - /** AlgTool initialize */ - virtual StatusCode initialize(); + public: - /** AlgTool finalize */ - virtual StatusCode finalize(); + PixelDiodeCrossTalkGenerator( const std::string& type, const std::string& name,const IInterface* parent); - /** process the collection of charged diodes */ - virtual void process(SiChargedDiodeCollection &collection) const; + virtual ~PixelDiodeCrossTalkGenerator(); + virtual StatusCode initialize(); + virtual StatusCode finalize(); + virtual void process(SiChargedDiodeCollection &collection); -private: - /** empty constructor made private */ - PixelDiodeCrossTalkGenerator(); + private: + PixelDiodeCrossTalkGenerator(); -private: - double m_diodeCrossTalk; + double m_diodeCrossTalk; }; #endif // PIXELDIGITIZATION_PIXELDIODECROSSTALKGENERATOR_H diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelGangedMerger.cxx b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelGangedMerger.cxx index af72cd59f2d..cdc5552fcd6 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelGangedMerger.cxx +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelGangedMerger.cxx @@ -8,93 +8,63 @@ /////////////////////////////////////////////////////////////////// // (c) ATLAS Detector software /////////////////////////////////////////////////////////////////// -// Version 1.0 24/03/2007 Fredrik Tegenfeldt <fredrik.tegenfeldt@cern.ch> -/////////////////////////////////////////////////////////////////// #include "PixelGangedMerger.h" -#include "SiDigitization/SiChargedDiodeCollection.h" #include "SiDigitization/SiHelper.h" -#include "InDetIdentifier/PixelID.h" - -using namespace InDetDD; - -static const InterfaceID IID_IPixelGangedMerger("PixelGangedMerger", 1, 0); -const InterfaceID& PixelGangedMerger::interfaceID( ){ return IID_IPixelGangedMerger; } -// Constructor with parameters: PixelGangedMerger::PixelGangedMerger(const std::string& type, const std::string& name,const IInterface* parent): - AthAlgTool(type,name,parent), + PixelProcessorTool(type,name,parent), m_pixelID(0) { - declareInterface< PixelGangedMerger >( this ); } -// Destructor: -PixelGangedMerger::~PixelGangedMerger() -{} +PixelGangedMerger::~PixelGangedMerger() {} - -//---------------------------------------------------------------------- -// Initialize -//---------------------------------------------------------------------- StatusCode PixelGangedMerger::initialize() { + CHECK(PixelProcessorTool::initialize()); CHECK(detStore()->retrieve(m_pixelID,"PixelID")); - ATH_MSG_DEBUG("PixelGangedMerger::initialize()"); + ATH_MSG_DEBUG("PixelGangedMerger::initialize()"); return StatusCode::SUCCESS; } -//---------------------------------------------------------------------- -// finalize -//---------------------------------------------------------------------- StatusCode PixelGangedMerger::finalize() { - StatusCode sc = AthAlgTool::finalize(); - if (sc.isFailure()) { - ATH_MSG_FATAL ( "PixelGangedMerger::finalize() failed"); - return sc ; - } - ATH_MSG_DEBUG ( "PixelGangedMerger::finalize()"); - return sc ; + ATH_MSG_DEBUG("PixelGangedMerger::finalize()"); + return StatusCode::SUCCESS; } -// process the collection of diode collection -void PixelGangedMerger::process(SiChargedDiodeCollection &collection) const -{ +void PixelGangedMerger::process(SiChargedDiodeCollection &collection) { // loop over the collection and check if the diode is a ganged pixel // if ganged, find its ganged partner and merge/copy charge // we need: // * check if ID is ganged // * given an ID, find its ganged partner // * create new charge - // Identifier gangedID; - for(SiChargedDiodeIterator i_chargedDiode=collection.begin(); - i_chargedDiode!=collection.end(); - ++i_chargedDiode) { + for(SiChargedDiodeIterator i_chargedDiode=collection.begin(); i_chargedDiode!=collection.end(); ++i_chargedDiode) { if (isGanged(collection.getId((*i_chargedDiode).first),collection.element(),gangedID)) { SiTotalCharge thisTotalCharge = (*i_chargedDiode).second.totalCharge(); SiChargedDiode *gangedChargeDiode = collection.find(gangedID); int phiGanged = m_pixelID->phi_index(gangedID); int phiThis = m_pixelID->phi_index(collection.getId((*i_chargedDiode).first)); - // + if (gangedChargeDiode) { // merge charges bool maskGanged = ((phiGanged>159) && (phiGanged<168)); bool maskThis = ((phiThis>159) && (phiThis<168)); - // // mask the one ganged pixel that does not correspond to the readout electronics. // not really sure this is needed - // if (maskGanged && maskThis) { - ATH_MSG_ERROR ( "PixelGangedMerger: both ganged pixels are in the mask out region -> BUG!" ); + ATH_MSG_ERROR("PixelGangedMerger: both ganged pixels are in the mask out region -> BUG!"); } if (maskGanged) { - (*i_chargedDiode).second.add( gangedChargeDiode->totalCharge() ); // merged org pixel + (*i_chargedDiode).second.add(gangedChargeDiode->totalCharge()); // merged org pixel // gangedChargeDiode->add(thisTotalCharge); // merged ganged pixel SiHelper::maskOut(*gangedChargeDiode,true); - } else { - gangedChargeDiode->add( (*i_chargedDiode).second.totalCharge() ); // merged org pixel + } + else { + gangedChargeDiode->add((*i_chargedDiode).second.totalCharge()); // merged org pixel // gangedChargeDiode->add(thisTotalCharge); // merged ganged pixel SiHelper::maskOut((*i_chargedDiode).second,true); } @@ -103,10 +73,7 @@ void PixelGangedMerger::process(SiChargedDiodeCollection &collection) const } } -bool PixelGangedMerger::isGanged(const Identifier& rdoID, - const InDetDD::SiDetectorElement* element, - Identifier& gangedID) const -{ +bool PixelGangedMerger::isGanged(const Identifier& rdoID, const InDetDD::SiDetectorElement* element, Identifier& gangedID) const { InDetDD::SiCellId cellID = element->cellIdFromIdentifier(rdoID); // gangedCell will be invalid if cell was not ganged. InDetDD::SiCellId gangedCell = element->gangedCell(cellID); diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelGangedMerger.h b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelGangedMerger.h index 23cff16276e..7175e12c3a7 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelGangedMerger.h +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelGangedMerger.h @@ -8,67 +8,27 @@ /////////////////////////////////////////////////////////////////// // (c) ATLAS Detector software /////////////////////////////////////////////////////////////////// -// Class to add/merge ganged pixels -/////////////////////////////////////////////////////////////////// - -/** @class PixelGangedMerger - * @brief merges ganged pixels - * @author Fredrik Tegenfeldt - * - * \b Description - * - * This class merges ganged pixels. - * The pixel corresponding to the readout electronics is retained and obtains the merged charge. - * The other pixel is masked out. - * - */ - #ifndef PIXELDIGITIZATION_PIXELGANGEDMERGER_H #define PIXELDIGITIZATION_PIXELGANGEDMERGER_H -#include "SiDigitization/ISiChargedDiodesProcessorTool.h" -#include "AthenaBaseComps/AthAlgTool.h" - - -#include "Identifier/Identifier.h" - -namespace InDetDD { - class SiDetectorElement; -} - -class PixelID; - -class PixelGangedMerger : public AthAlgTool, virtual public ISiChargedDiodesProcessorTool { - -public: - - // Constructor: - PixelGangedMerger( const std::string& type, const std::string& name,const IInterface* parent); - - /** Destructor */ - virtual ~PixelGangedMerger(); - - /** AlgTool InterfaceID */ - static const InterfaceID& interfaceID() ; +#include "PixelProcessorTool.h" +#include "InDetIdentifier/PixelID.h" - /** AlgTool initialize */ - virtual StatusCode initialize(); +class PixelGangedMerger:public PixelProcessorTool { - /** AlgTool finalize */ - virtual StatusCode finalize(); + public: + PixelGangedMerger( const std::string& type, const std::string& name,const IInterface* parent); - /** process the collection of pre digits */ - virtual void process(SiChargedDiodeCollection &collection) const; - bool isGanged(const Identifier& rdoID, - const InDetDD::SiDetectorElement* element, - Identifier& gangedID) const; + virtual ~PixelGangedMerger(); + virtual StatusCode initialize(); + virtual StatusCode finalize(); + virtual void process(SiChargedDiodeCollection &collection); -private: + bool isGanged(const Identifier& rdoID, const InDetDD::SiDetectorElement* element, Identifier& gangedID) const; - /** empty constructor mad private */ - PixelGangedMerger(); + private: + PixelGangedMerger(); + const PixelID *m_pixelID; -private: - const PixelID *m_pixelID; /**< the ID helper */ }; #endif // PIXELDIGITIZATION_PIXELGANGEDMERGER_H diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelNoisyCellGenerator.cxx b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelNoisyCellGenerator.cxx index 2470481a397..f6444313136 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelNoisyCellGenerator.cxx +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelNoisyCellGenerator.cxx @@ -10,20 +10,10 @@ /////////////////////////////////////////////////////////////////// #include "PixelNoisyCellGenerator.h" -#include "SiDigitization/SiChargedDiodeCollection.h" #include "InDetReadoutGeometry/SiCellId.h" #include "InDetReadoutGeometry/SiReadoutCellId.h" -#include "CLHEP/Random/RandomEngine.h" #include "CLHEP/Random/RandPoisson.h" -#include "CLHEP/Random/RandFlat.h" -#include "AtlasCLHEP_RandomGenerators/RandGaussZiggurat.h" -#include "AthenaKernel/IAtRndmGenSvc.h" -#include "TimeSvc.h" -#include "PixelConditionsServices/IPixelCalibSvc.h" -#include "InDetReadoutGeometry/PixelDetectorManager.h" -#include "InDetReadoutGeometry/SiDetectorElement.h" -#include "InDetReadoutGeometry/PixelModuleDesign.h" #include<fstream> #include<sstream> @@ -31,125 +21,72 @@ #include<limits> #include<iomanip> -//#define __PIXEL_DEBUG__ - -using namespace InDetDD; - -static const InterfaceID IID_IPixelNoisyCellGenerator("PixelNoisyCellGenerator", 1, 0); -const InterfaceID& PixelNoisyCellGenerator::interfaceID( ){ return IID_IPixelNoisyCellGenerator; } - PixelNoisyCellGenerator::PixelNoisyCellGenerator(const std::string& type, const std::string& name,const IInterface* parent): - AthAlgTool(type,name,parent), + PixelProcessorTool(type,name,parent), m_TimeSvc("TimeSvc",name), m_pixelCalibSvc("PixelCalibSvc", name), m_mergeCharge(false), m_pixelID(0), - m_rndmSvc("AtDSFMTGenSvc",name), - m_rndmEngineName("PixelDigitization"), - m_rndmEngine(0), -// STSTT m_spmNoiseOccu(1e-5), m_rndNoiseProb(5e-8) - //m_pixMgr(0) { - declareInterface< PixelNoisyCellGenerator >( this ); declareProperty("NoiseShape",m_noiseShape,"Vector containing noise ToT shape"); - declareProperty("RndmSvc", m_rndmSvc, "Random Number Service used in SCT & Pixel digitization" ); - declareProperty("RndmEngine", m_rndmEngineName, "Random engine name"); declareProperty("MergeCharge", m_mergeCharge, ""); -// STSTT declareProperty("SpmNoiseOccu", m_spmNoiseOccu, "Special Pixels map gen: probability for a noisy pixel in SPM"); declareProperty("RndNoiseProb", m_rndNoiseProb, "Random noisy pixels, amplitude from calib. - NOT special pixels!"); } -// Destructor: -PixelNoisyCellGenerator::~PixelNoisyCellGenerator() -{} +PixelNoisyCellGenerator::~PixelNoisyCellGenerator() {} -//---------------------------------------------------------------------- -// Initialize -//---------------------------------------------------------------------- StatusCode PixelNoisyCellGenerator::initialize() { + CHECK(PixelProcessorTool::initialize()); CHECK(m_TimeSvc.retrieve()); CHECK(m_pixelCalibSvc.retrieve()); ATH_MSG_DEBUG("Retrieved PixelCalibSvc"); - CHECK(m_rndmSvc.retrieve()); - m_rndmEngine = m_rndmSvc->GetEngine(m_rndmEngineName); - if (!m_rndmEngine) { - ATH_MSG_ERROR("Could not find RndmEngine : " << m_rndmEngineName); - return StatusCode::FAILURE; - } - else { - ATH_MSG_DEBUG("Found RndmEngine : " << m_rndmEngineName); - } + CHECK(detStore()->retrieve(m_pixelID,"PixelID")); - std::string pixelHelperName("PixelID"); - if ( StatusCode::SUCCESS!= detStore()->retrieve(m_pixelID,pixelHelperName) ) { - 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" << endmsg; - return StatusCode::FAILURE; - } + CHECK(detStore()->retrieve(m_pixMgr,"Pixel")); - ATH_MSG_DEBUG ( "PixelNoisyCellGenerator::initialize()"); + ATH_MSG_DEBUG("PixelNoisyCellGenerator::initialize()"); return StatusCode::SUCCESS; } -//---------------------------------------------------------------------- -// finalize -//---------------------------------------------------------------------- StatusCode PixelNoisyCellGenerator::finalize() { + ATH_MSG_DEBUG("PixelNoisyCellGenerator::finalize()"); return StatusCode::SUCCESS; } -// process the collection of diode collection -void PixelNoisyCellGenerator::process(SiChargedDiodeCollection &collection) const { - // +void PixelNoisyCellGenerator::process(SiChargedDiodeCollection &collection) { + // Get Module identifier - // Identifier mmod = collection.identify(); - ATH_MSG_DEBUG ( " Processing diodes for module " - << m_pixelID->show_to_string(mmod)); - // - // if probability is 0, do nothing - // + ATH_MSG_DEBUG(" Processing diodes for module " << m_pixelID->show_to_string(mmod)); double pnoise_rndm(m_rndNoiseProb); if (pnoise_rndm>0) addRandomNoise(collection,pnoise_rndm); - + return; } void PixelNoisyCellGenerator::addRandomNoise(SiChargedDiodeCollection &collection, double occupancy) const { - // - // Get Module identifier - // - //Identifier mmod = collection.identify(); //not used - + // number of bunch crossings int bcn = m_TimeSvc->getTimeBCN(); - // // get pixel module design and check it - // - const PixelModuleDesign *p_design = static_cast<const PixelModuleDesign *>(&(collection.design())); + const InDetDD::PixelModuleDesign *p_design = static_cast<const InDetDD::PixelModuleDesign *>(&(collection.design())); - // // compute number of noisy cells // multiply the number of pixels with BCN since noise will be evenly distributed // over time - // int number_rndm=CLHEP::RandPoisson::shoot(m_rndmEngine, - p_design->numberOfCircuits() // =8 - *p_design->columnsPerCircuit() // =18 - *p_design->rowsPerCircuit() // =320 - *occupancy - *static_cast<double>(bcn)); + p_design->numberOfCircuits() // =8 + *p_design->columnsPerCircuit() // =18 + *p_design->rowsPerCircuit() // =320 + *occupancy + *static_cast<double>(bcn)); + for (int i=0; i<number_rndm; i++) { int circuit = CLHEP::RandFlat::shootInt(m_rndmEngine,p_design->numberOfCircuits()); int column = CLHEP::RandFlat::shootInt(m_rndmEngine,p_design->columnsPerCircuit()); @@ -159,17 +96,17 @@ void PixelNoisyCellGenerator::addRandomNoise(SiChargedDiodeCollection &collectio return; } -void PixelNoisyCellGenerator::addCell(SiChargedDiodeCollection &collection,const PixelModuleDesign *design, int circuit, int column, int row) const { +void PixelNoisyCellGenerator::addCell(SiChargedDiodeCollection &collection,const InDetDD::PixelModuleDesign *design, int circuit, int column, int row) const { ATH_MSG_DEBUG("addCell 1 circuit = " << circuit << ", column = " << column << ", row = " << row); #ifdef __PIXEL_DEBUG__ ATH_MSG_DEBUG("addCell: circuit,column,row=" << circuit << "," << column << "," << row); #endif ATH_MSG_DEBUG("addCell 2 circuit = " << circuit << ", column = " << column << ", row = " << row); - if ( row > 159 && design->getReadoutTechnology() == PixelModuleDesign::FEI3 ) row = row+8; // jump over ganged pixels - rowsPerCircuit == 320 above + if ( row > 159 && design->getReadoutTechnology() == InDetDD::PixelModuleDesign::FEI3 ) row = row+8; // jump over ganged pixels - rowsPerCircuit == 320 above ATH_MSG_DEBUG("addCell 3 circuit = " << circuit << ", column = " << column << ", row = " << row); - SiReadoutCellId roCell(row, design->columnsPerCircuit() * circuit + column); + InDetDD::SiReadoutCellId roCell(row, design->columnsPerCircuit() * circuit + column); ATH_MSG_DEBUG("addCell 4 circuit = " << circuit << ", column = " << column << ", row = " << row); Identifier noisyID=collection.element()->identifierFromCellId(roCell); @@ -178,7 +115,7 @@ void PixelNoisyCellGenerator::addCell(SiChargedDiodeCollection &collection,const // if required, check if the cell is already hit if (!m_mergeCharge) { if (collection.AlreadyHit(noisyID)) { - roCell = SiReadoutCellId(); // Set it to an Invalid ID + roCell = InDetDD::SiReadoutCellId(); // Set it to an Invalid ID } } @@ -189,7 +126,7 @@ void PixelNoisyCellGenerator::addCell(SiChargedDiodeCollection &collection,const ATH_MSG_DEBUG("addCell 6 circuit = " << circuit << ", column = " << column << ", row = " << row); if (roCell.isValid()) { ATH_MSG_DEBUG("addCell 7 circuit = " << circuit << ", column = " << column << ", row = " << row); - SiCellId diode = roCell; + InDetDD::SiCellId diode = roCell; ATH_MSG_DEBUG("addCell 7a circuit = " << circuit << ", column = " << column << ", row = " << row); // create a random charge following the ToT shape of the noise measured in automn 2006 in EndCapA diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelNoisyCellGenerator.h b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelNoisyCellGenerator.h index 61f9122639d..8fd6b926c08 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelNoisyCellGenerator.h +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelNoisyCellGenerator.h @@ -8,110 +8,42 @@ /////////////////////////////////////////////////////////////////// // (c) ATLAS Detector software /////////////////////////////////////////////////////////////////// -// Class to generate the noisy cells for Pixel -/////////////////////////////////////////////////////////////////// -// -// Configurable Parameters: -// -NoiseShape Vector containing noise ToT shape -// -RndmSvc Random Number Service used in SCT & Pixel digitization -// -RndmEngine Random engine name -// -MergeCharge -// -RndNoiseProb Random noisy pixels, amplitude from calib. - NOT special pixels! -// -/////////////////////////////////////////////////////////////////// - -/** @class PixelNoisyCellGenerator - * @brief Generates random noise - * @author David Calvet - * @author Davide Costanzo - * @author Fredrik Tegenfeldt - * - * \b Description - * - * This class generates random noise for random pixels. Which pixels that will receive noise and how much is - * determined in the following way: - * -# Number of pixels is drawn from a Poisson with <em>mean = </em>\f$N_{pixels}\cdot p_{noise}\cdot N_{BC}\f$ - * - \f$N_{pixels}\f$ is the total number of pixels - * - \f$p_{noise}\f$ is the noise probability - * - \f$N_{BC}\f$ is the number of bunches; noise will occur at a random time with a flat distribution - * -# Pixels are then randomly chosen (flat dist) - * -# Noise charge is drawn from a Gaussian with <em>mean = threshold + 3*thresholdSigma</em> and <em>sigma = thresholdSigma</em> - * -# If a pixel is already hit: - * - if \e mergeCharge is \e true then merge the noise charge with the existing charge - * - else, ignore the pixel - * - * Note that if looking at the noise in a simulation, the number of noisy pixels per event - * will not \e quite follow the poisson ditribution with the above mean. The reason for this - * is of course the treatment of already hit pixels. This will certainly be more eveident in events - * with many hits. - * - */ - #ifndef PIXELDIGITIZATION_PIXELNOISYCELLGENERATOR_H #define PIXELDIGITIZATION_PIXELNOISYCELLGENERATOR_H -#include "SiDigitization/ISiChargedDiodesProcessorTool.h" -#include "AthenaBaseComps/AthAlgTool.h" - -#include "InDetReadoutGeometry/PixelModuleDesign.h" - -class PixelID; -class TimeSvc; -class IPixelCalibSvc; +#include "PixelProcessorTool.h" -class IAtRndmGenSvc; -namespace CLHEP { - class HepRandomEngine; -} +#include "TimeSvc.h" +#include "PixelConditionsServices/IPixelCalibSvc.h" -namespace InDetDD { - class PixelDetectorManager; - class SiDetectorElement; - class SiDetectorManager; -} - -class PixelNoisyCellGenerator : public AthAlgTool, virtual public ISiChargedDiodesProcessorTool { - -public: - - //Constructor: - PixelNoisyCellGenerator( const std::string& type, const std::string& name,const IInterface* parent); - - /** Destructor */ - virtual ~PixelNoisyCellGenerator(); - - /** AlgTool InterfaceID */ - static const InterfaceID& interfaceID() ; +#include "InDetReadoutGeometry/PixelModuleDesign.h" +#include "InDetReadoutGeometry/PixelDetectorManager.h" +#include "InDetReadoutGeometry/SiDetectorElement.h" - /** AlgTool initialize */ - virtual StatusCode initialize(); +class PixelNoisyCellGenerator:public PixelProcessorTool { - /** AlgTool finalize */ - virtual StatusCode finalize(); + public: + PixelNoisyCellGenerator( const std::string& type, const std::string& name,const IInterface* parent); - /** Process the collection of pre digits */ - virtual void process(SiChargedDiodeCollection &collection) const; + virtual ~PixelNoisyCellGenerator(); + virtual StatusCode initialize(); + virtual StatusCode finalize(); + virtual void process(SiChargedDiodeCollection &collection); -private: - - /** Empty constructor made private */ - PixelNoisyCellGenerator(); + private: + PixelNoisyCellGenerator(); -private: - ServiceHandle<TimeSvc> m_TimeSvc; - ServiceHandle<IPixelCalibSvc> m_pixelCalibSvc; - bool m_mergeCharge; /**< to merge or not to merge */ - std::vector<double> m_noiseShape; /**< ToT shape of noise*/ - void addRandomNoise(SiChargedDiodeCollection &collection, double occupancy) const; - void addCell(SiChargedDiodeCollection &collection, const InDetDD::PixelModuleDesign *design, int circuit, int column, int row) const; + ServiceHandle<TimeSvc> m_TimeSvc; + ServiceHandle<IPixelCalibSvc> m_pixelCalibSvc; + bool m_mergeCharge; + std::vector<double> m_noiseShape; + void addRandomNoise(SiChargedDiodeCollection &collection, double occupancy) const; + void addCell(SiChargedDiodeCollection &collection, const InDetDD::PixelModuleDesign *design, int circuit, int column, int row) const; - double getNoiseToT() const; - const PixelID *m_pixelID; /**< the ID helper */ - ServiceHandle<IAtRndmGenSvc> m_rndmSvc; - std::string m_rndmEngineName; - CLHEP::HepRandomEngine* m_rndmEngine; - double m_rndNoiseProb; - const InDetDD::PixelDetectorManager *m_pixMgr; + double getNoiseToT() const; + const PixelID *m_pixelID; /**< the ID helper */ + double m_rndNoiseProb; + const InDetDD::PixelDetectorManager *m_pixMgr; }; diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelProcessorTool.h b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelProcessorTool.h new file mode 100644 index 00000000000..28629f18644 --- /dev/null +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelProcessorTool.h @@ -0,0 +1,69 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef PIXELDIGITIZATION_PIXELPROCESSORTOOL_H +#define PIXELDIGITIZATION_PIXELPROCESSORTOOL_H + +#include "AthenaBaseComps/AthAlgTool.h" +#include "GaudiKernel/ServiceHandle.h" +#include "GaudiKernel/ToolHandle.h" +#include "CLHEP/Random/RandomEngine.h" +#include "AtlasCLHEP_RandomGenerators/RandGaussZiggurat.h" +#include "AthenaKernel/IAtRndmGenSvc.h" + +#include "SiDigitization/SiChargedDiodeCollection.h" +// STSSTST #include "InDetRawData/InDetRawDataCLASS_DEF.h" + +// STSSTST #include "InDetConditionsSummaryService/IInDetConditionsSvc.h" +// STSSTST #include "PixelConditionsServices/IPixelCalibSvc.h" +// STSSTST #include "TimeSvc.h" + +static const InterfaceID IID_IPixelProcessorTool("PixelProcessorTool", 1, 0); + +class PixelProcessorTool:public AthAlgTool,virtual public IAlgTool { + + public: + PixelProcessorTool( const std::string& type, const std::string& name,const IInterface* parent): + AthAlgTool(type,name,parent), + m_rndmSvc("AtRndmGenSvc",name), + m_rndmEngineName("PixelDigitization"), + m_rndmEngine(nullptr) + { + declareInterface<PixelProcessorTool>(this); + declareProperty("RndmSvc", m_rndmSvc, "Random number service used in FE simulation"); + declareProperty("RndmEngine", m_rndmEngineName, "Random engine name"); + } + + static const InterfaceID& interfaceID() { return IID_IPixelProcessorTool; } + + virtual StatusCode initialize() { + CHECK(AthAlgTool::initialize()); + + CHECK(m_rndmSvc.retrieve()); + m_rndmEngine = m_rndmSvc->GetEngine(m_rndmEngineName); + if (!m_rndmEngine) { + ATH_MSG_ERROR("Could not find RndmEngine : " << m_rndmEngineName); + return StatusCode::FAILURE; + } + else { + ATH_MSG_DEBUG("Found RndmEngine : " << m_rndmEngineName); + } + return StatusCode::SUCCESS; + } + + virtual StatusCode finalize() { return StatusCode::FAILURE; } + virtual ~PixelProcessorTool() {} + virtual void process(SiChargedDiodeCollection &chargedDiodes) = 0; + + private: + PixelProcessorTool(); + + protected: + ServiceHandle<IAtRndmGenSvc> m_rndmSvc; + std::string m_rndmEngineName; + CLHEP::HepRandomEngine *m_rndmEngine; + +}; + +#endif // PIXELDIGITIZATION_PixelProcessorTool_H diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelRandomDisabledCellGenerator.cxx b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelRandomDisabledCellGenerator.cxx index 3e885f6ecfc..54c5c511094 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelRandomDisabledCellGenerator.cxx +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelRandomDisabledCellGenerator.cxx @@ -12,83 +12,40 @@ #include "PixelRandomDisabledCellGenerator.h" #include "SiDigitization/SiHelper.h" -// random number service -#include "AthenaKernel/IAtRndmGenSvc.h" -#include "CLHEP/Random/RandomEngine.h" #include "CLHEP/Random/RandFlat.h" -#include "CLHEP/Random/RandomEngine.h" -#include "AtlasCLHEP_RandomGenerators/RandGaussZiggurat.h" - -static const InterfaceID IID_IPixelRandomDisabledCellGenerator("PixelRandomDisabledCellGenerator", 1, 0); -const InterfaceID& PixelRandomDisabledCellGenerator::interfaceID( ){ return IID_IPixelRandomDisabledCellGenerator; } - -// Constructor with parameters: PixelRandomDisabledCellGenerator::PixelRandomDisabledCellGenerator(const std::string& type, const std::string& name,const IInterface* parent): - AthAlgTool(type,name,parent), - m_myfunc(0), - m_rndmSvc("AtDSFMTGenSvc",name), - m_rndmEngineName("PixelDigitization"), - m_rndmEngine(0), + PixelProcessorTool(type,name,parent), m_disableProbability(9e-3) { - declareInterface< PixelRandomDisabledCellGenerator >( this ); - declareProperty("RndmSvc",m_rndmSvc,"Random Number Service used in Pixel digitization"); - declareProperty("RndmEngine",m_rndmEngineName,"Random engine name"); declareProperty("TotalBadChannels",m_disableProbability); - } -// Destructor: -PixelRandomDisabledCellGenerator::~PixelRandomDisabledCellGenerator() -{} +PixelRandomDisabledCellGenerator::~PixelRandomDisabledCellGenerator() {} -//---------------------------------------------------------------------- -// Initialize -//---------------------------------------------------------------------- StatusCode PixelRandomDisabledCellGenerator::initialize() { + CHECK(PixelProcessorTool::initialize()); - CHECK(m_rndmSvc.retrieve()); - m_rndmEngine = m_rndmSvc->GetEngine(m_rndmEngineName); - if (!m_rndmEngine) { - ATH_MSG_ERROR("Could not find RndmEngine : " << m_rndmEngineName); - return StatusCode::FAILURE; - } - else { - ATH_MSG_DEBUG("Found RndmEngine : " << m_rndmEngineName); - } - - m_myfunc = SiHelper::disabled; - ATH_MSG_INFO ( "\tCreating disabled cell generator with "<<m_disableProbability<<" probability"); + ATH_MSG_INFO("\tCreating disabled cell generator with "<<m_disableProbability<<" probability"); ATH_MSG_DEBUG("PixelRandomDisabledCellGenerator::initialize()"); return StatusCode::SUCCESS; } -//---------------------------------------------------------------------- -// finalize -//---------------------------------------------------------------------- StatusCode PixelRandomDisabledCellGenerator::finalize() { - StatusCode sc = AthAlgTool::finalize(); - if (sc.isFailure()) { - ATH_MSG_FATAL ( "PixelRandomDisabledCellGenerator::finalize() failed"); - return sc ; - } - ATH_MSG_DEBUG ( "PixelRandomDisabledCellGenerator::finalize()"); - return sc ; + ATH_MSG_DEBUG ("PixelRandomDisabledCellGenerator::finalize()"); + return StatusCode::SUCCESS; } -// process the collection of charged diodes -void PixelRandomDisabledCellGenerator::process(SiChargedDiodeCollection &collection) const -{ +void PixelRandomDisabledCellGenerator::process(SiChargedDiodeCollection &collection) { // disabling is applied to all cells even unconnected or below threshold // ones to be able to use these cells as well - for(SiChargedDiodeIterator i_chargedDiode=collection.begin() ; - i_chargedDiode!=collection.end() ; ++i_chargedDiode) { - + for(SiChargedDiodeIterator i_chargedDiode=collection.begin(); i_chargedDiode!=collection.end(); ++i_chargedDiode) { // disable the diode randomly - if(CLHEP::RandFlat::shoot(m_rndmEngine)<m_disableProbability) (*m_myfunc)((*i_chargedDiode).second,true,false); - + if (CLHEP::RandFlat::shoot(m_rndmEngine)<m_disableProbability) { + SiHelper::disabled((*i_chargedDiode).second,true,false); + } } } + diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelRandomDisabledCellGenerator.h b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelRandomDisabledCellGenerator.h index 214d1e3c855..bdc4d28c474 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelRandomDisabledCellGenerator.h +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelRandomDisabledCellGenerator.h @@ -8,67 +8,26 @@ /////////////////////////////////////////////////////////////////// // (c) ATLAS Detector software ////////////////////////////////////////////////////////////////// -// -// Configurable Parameters: -// -RndmSvc Random Number Service used in Pixel digitization -// -RndmEngine Random engine name -// -TotalBadChannels m_disableProbability -// -////////////////////////////////////////////////////////////////// - -/** @class PixelRandomDisabledCellGenerator - * @brief This can be used for disabling, disconnecting, and flagging bad_tot - * @author - * - * \b Description - * - * - */ #ifndef PIXELDIGITIZATION_PIXELRANDOMDISABLEDCELLGENERATOR_H #define PIXELDIGITIZATION_PIXELRANDOMDISABLEDCELLGENERATOR_H -#include "SiDigitization/ISiChargedDiodesProcessorTool.h" -#include "AthenaBaseComps/AthAlgTool.h" - -#include "SiDigitization/SiChargedDiodeCollection.h" - - -class IAtRndmGenSvc; - -namespace CLHEP { - class HepRandomEngine; -} - -class PixelRandomDisabledCellGenerator : public AthAlgTool, virtual public ISiChargedDiodesProcessorTool { - -public: - - /** constructor */ - PixelRandomDisabledCellGenerator( const std::string& type, const std::string& name,const IInterface* parent); - - /** Destructor */ - virtual ~PixelRandomDisabledCellGenerator(); - - /** AlgTool InterfaceID */ - static const InterfaceID& interfaceID() ; +#include "PixelProcessorTool.h" - /** AlgTool initialize */ - virtual StatusCode initialize(); +class PixelRandomDisabledCellGenerator:public PixelProcessorTool { - /** AlgTool finalize */ - virtual StatusCode finalize(); + public: + PixelRandomDisabledCellGenerator( const std::string& type, const std::string& name,const IInterface* parent); - /** process the collection of charged pixels */ - virtual void process(SiChargedDiodeCollection &collection) const; + virtual ~PixelRandomDisabledCellGenerator(); + virtual StatusCode initialize(); + virtual StatusCode finalize(); + virtual void process(SiChargedDiodeCollection &collection); -private: + private: + PixelRandomDisabledCellGenerator(); - void (*m_myfunc)(SiChargedDiode& chDiode, bool flag1, bool flag2); - ServiceHandle<IAtRndmGenSvc> m_rndmSvc; - std::string m_rndmEngineName; - CLHEP::HepRandomEngine* m_rndmEngine; + double m_disableProbability; // probability that a cell is disabled - double m_disableProbability; // probability that a cell is disabled }; #endif -- GitLab