diff --git a/InnerDetector/InDetDigitization/PixelDigitization/CMakeLists.txt b/InnerDetector/InDetDigitization/PixelDigitization/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..f48cb1b24c588b1cb007a1fe9738d8fa2672cd31 --- /dev/null +++ b/InnerDetector/InDetDigitization/PixelDigitization/CMakeLists.txt @@ -0,0 +1,54 @@ +################################################################################ +# Package: PixelDigitization +################################################################################ + +# Declare the package name: +atlas_subdir( PixelDigitization ) + +# Declare the package's dependencies: +atlas_depends_on_subdirs( PUBLIC + Control/AthenaBaseComps + GaudiKernel + PRIVATE + Commission/CommissionEvent + Control/AthenaKernel + Control/PileUpTools + Control/StoreGate + DetectorDescription/Identifier + Event/xAOD/xAODEventInfo + Generators/GeneratorObjects + InnerDetector/InDetConditions/InDetConditionsSummaryService + InnerDetector/InDetConditions/PixelConditionsData + InnerDetector/InDetConditions/PixelConditionsServices + InnerDetector/InDetConditions/PixelConditionsTools + InnerDetector/InDetConditions/SiPropertiesSvc + InnerDetector/InDetDetDescr/InDetIdentifier + InnerDetector/InDetDetDescr/InDetReadoutGeometry + InnerDetector/InDetDetDescr/PixelCabling + InnerDetector/InDetDetDescr/PixelGeoModel + InnerDetector/InDetDigitization/SiDigitization + InnerDetector/InDetRawEvent/InDetRawData + InnerDetector/InDetRawEvent/InDetSimData + InnerDetector/InDetSimEvent + Simulation/HitManagement + Simulation/Tools/AtlasCLHEP_RandomGenerators + Tools/PathResolver ) + +# External dependencies: +find_package( CLHEP ) +find_package( HepMC ) +find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread ) + +# Component(s) in the package: +atlas_add_component( PixelDigitization + src/*.cxx + src/components/*.cxx + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} ${HEPMC_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} ${HEPMC_LIBRARIES} AthenaBaseComps GaudiKernel CommissionEvent AthenaKernel PileUpToolsLib StoreGateLib SGtests Identifier xAODEventInfo GeneratorObjects PixelConditionsData SiPropertiesSvcLib InDetIdentifier InDetReadoutGeometry SiDigitization InDetRawData InDetSimData InDetSimEvent HitManagement AtlasCLHEP_RandomGenerators PathResolver ) + +# Install files from the package: +atlas_install_headers( PixelDigitization ) +atlas_install_python_modules( python/*.py ) +atlas_install_joboptions( share/PixelDigitization_jobOptions.py share/PixelDigiTool_jobOptions.py ) +atlas_install_runtime( share/3DFEI3-3E-problist-1um_v1.txt share/3DFEI4-2E-problist-1um_v0.txt share/Bichsel_*.dat ) + diff --git a/InnerDetector/InDetDigitization/PixelDigitization/python/PixelDigitizationConfig.py b/InnerDetector/InDetDigitization/PixelDigitization/python/PixelDigitizationConfig.py index cc2197305325b93e315dae9ba1d8e9f3fcff7e83..c5e7f76de935610ff03662392fa7b35555bd4236 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/python/PixelDigitizationConfig.py +++ b/InnerDetector/InDetDigitization/PixelDigitization/python/PixelDigitizationConfig.py @@ -52,8 +52,6 @@ def DBMChargeTool(name="DBMChargeTool", **kwargs): def BichselSimTool(name="BichselSimTool", **kwargs): kwargs.setdefault("DeltaRayCut", 117.) - kwargs.setdefault("nCols", 5) - kwargs.setdefault("LoopLimit", 100000) return CfgMgr.BichselSimTool(name, **kwargs) def PixelBarrelBichselChargeTool(name="PixelBarrelBichselChargeTool", **kwargs): @@ -63,7 +61,6 @@ def PixelBarrelBichselChargeTool(name="PixelBarrelBichselChargeTool", **kwargs): # kwargs.setdefault("doBichsel", False) kwargs.setdefault("doBichselBetaGammaCut", 0.7) # dEdx not quite consistent below this kwargs.setdefault("doDeltaRay", False) # needs validation - kwargs.setdefault("doPU", True) kwargs.setdefault("BichselSimTool", "BichselSimTool") # kwargs.setdefault("OutputFileName", digitizationFlags.BichselOutputFileName()) # kwargs.setdefault("doHITPlots", True) @@ -72,10 +69,9 @@ def PixelBarrelBichselChargeTool(name="PixelBarrelBichselChargeTool", **kwargs): def PixelECBichselChargeTool(name="PixelECBichselChargeTool", **kwargs): kwargs.setdefault("RndmSvc", digitizationFlags.rndmSvc()) kwargs.setdefault("RndmEngine", "PixelDigitization") - # kwargs.setdefault("doBichsel", hasattr(digitizationFlags, "doBichselSimulation") and digitizationFlags.doBichselSimulation()) - kwargs.setdefault("doBichsel", False) # EC is turned off explicitly to save CPU time. Difference is very small in EC region from different modelling + kwargs.setdefault("doBichsel", hasattr(digitizationFlags, "doBichselSimulation") and digitizationFlags.doBichselSimulation()) + # kwargs.setdefault("doBichsel", False) kwargs.setdefault("doBichselBetaGammaCut", 0.7) # dEdx not quite consistent below this - kwargs.setdefault("doPU", True) kwargs.setdefault("BichselSimTool", "BichselSimTool") return CfgMgr.PixelECBichselChargeTool(name, **kwargs) @@ -85,7 +81,6 @@ def IblPlanarBichselChargeTool(name="IblPlanarBichselChargeTool", **kwargs): kwargs.setdefault("doBichsel", hasattr(digitizationFlags, "doBichselSimulation") and digitizationFlags.doBichselSimulation()) kwargs.setdefault("doBichselBetaGammaCut", 0.7) # dEdx not quite consistent below this kwargs.setdefault("doDeltaRay", False) # needs validation - kwargs.setdefault("doPU", True) kwargs.setdefault("BichselSimTool", "BichselSimTool") return CfgMgr.IblPlanarBichselChargeTool(name, **kwargs) @@ -95,7 +90,6 @@ def Ibl3DBichselChargeTool(name="Ibl3DBichselChargeTool", **kwargs): kwargs.setdefault("doBichsel", hasattr(digitizationFlags, "doBichselSimulation") and digitizationFlags.doBichselSimulation()) kwargs.setdefault("doBichselBetaGammaCut", 0.7) # dEdx not quite consistent below this kwargs.setdefault("doDeltaRay", False) # needs validation - kwargs.setdefault("doPU", True) kwargs.setdefault("BichselSimTool", "BichselSimTool") return CfgMgr.Ibl3DBichselChargeTool(name, **kwargs) @@ -186,18 +180,6 @@ def TimeSvc(name="TimeSvc", **kwargs): kwargs.setdefault("TimeBCN",timeBCN) return CfgMgr.TimeSvc(name, **kwargs) -def CalibSvc(name="CalibSvc", **kwargs): - kwargs.setdefault("RndmSvc", digitizationFlags.rndmSvc()) - kwargs.setdefault("RndmEngine", "PixelDigitization") - from AthenaCommon.BeamFlags import jobproperties - from AthenaCommon.Resilience import protectedInclude - protectedInclude("PixelConditionsServices/PixelCalibSvc_jobOptions.py") - from IOVDbSvc.CondDB import conddb - conddb.addFolderSplitMC("PIXEL","/PIXEL/ReadoutSpeed","/PIXEL/ReadoutSpeed") - if jobproperties.Beam.beamType == "cosmics" : - kwargs.setdefault("UsePixMapCondDB", True) - return CfgMgr.CalibSvc(name, **kwargs) - def PixelCellDiscriminator(name="PixelCellDiscriminator", **kwargs): kwargs.setdefault("RndmSvc", digitizationFlags.rndmSvc()) kwargs.setdefault("RndmEngine", "PixelDigitization") @@ -223,39 +205,50 @@ def BasicPixelDigitizationTool(name="PixelDigitizationTool", **kwargs): include.block( "PixelConditionsServices/SpecialPixelMapSvc_jobOptions.py" ) protectedInclude( "PixelConditionsServices/PixelDCSSvc_jobOptions.py" ) include.block( "PixelConditionsServices/PixelDCSSvc_jobOptions.py" ) + protectedInclude("PixelConditionsServices/PixelCalibSvc_jobOptions.py") + from IOVDbSvc.CondDB import conddb + conddb.addFolderSplitMC("PIXEL","/PIXEL/ReadoutSpeed","/PIXEL/ReadoutSpeed") kwargs.setdefault("PixelCablingSvc","PixelCablingSvc") if not hasattr(ServiceMgr, "PixelSiPropertiesSvc"): from SiLorentzAngleSvc.LorentzAngleSvcSetup import lorentzAngleSvc - from SiPropertiesSvc.SiPropertiesSvcConf import SiPropertiesSvc; + from SiPropertiesSvc.SiPropertiesSvcConf import SiPropertiesSvc pixelSiPropertiesSvc = SiPropertiesSvc(name = "PixelSiPropertiesSvc",DetectorName="Pixel",SiConditionsServices = lorentzAngleSvc.pixelSiliconConditionsSvc) ServiceMgr += pixelSiPropertiesSvc kwargs.setdefault("InputObjectName", "PixelHits") - kwargs.setdefault("EnableNoise", digitizationFlags.doInDetNoise.get_Value()) + pixTools = [] + pixTools += ['PixelDiodeCrossTalkGenerator'] + pixTools += ['PixelChargeSmearer'] + pixTools += ['PixelNoisyCellGenerator'] + pixTools += ['PixelGangedMerger'] + pixTools += ['SpecialPixelGenerator'] + pixTools += ['PixelRandomDisabledCellGenerator'] + pixTools += ['PixelCellDiscriminator'] + kwargs.setdefault("PixelTools", pixTools) # Start of special cosmics tuning: if jobproperties.Beam.beamType == "cosmics" : - kwargs.setdefault("CosmicsRun", True) kwargs.setdefault("UseComTime", True) - elif GeometryFlags.isSLHC(): + kwargs.setdefault("PixelConditionsSummarySvc", "") + if GeometryFlags.isSLHC(): kwargs.setdefault("doITk", True) LVL1Latency = [255, 255, 255, 255, 255, 16, 255] - kwargs.setdefault("LVL1Latency", LVL1Latency) ToTMinCut = [0, 0, 0, 0, 0, 0, 0] + ApplyDupli = [False, False, False, False, False, False, False] + LowTOTduplication = [0, 0, 0, 0, 0, 0, 0] + kwargs.setdefault("LVL1Latency", LVL1Latency) kwargs.setdefault("ToTMinCut", ToTMinCut) - ApplyDupli = [0, 0, 0, 0, 0, 0, 0] kwargs.setdefault("ApplyDupli", ApplyDupli) - LowTOTduplication = [0, 0, 0, 0, 0, 0, 0] kwargs.setdefault("LowTOTduplication", LowTOTduplication) else: # For LVL1Latency, ToTMinCut, ApplyDupli and LowTOTduplication, first component [0] is always for IBL, even for run 1 production. # The order is IBL, BL, L1, L2, EC, DBM # For IBL and DBM, values of LVL1Latency and LowToTDupli are superseded by values driven by HitDiscCnfg settings, in PixelDigitizationTool.cxx LVL1Latency = [16, 150, 255, 255, 255, 16] - kwargs.setdefault("LVL1Latency", LVL1Latency) ToTMinCut = [0, 4, 4, 4, 4, 0] - kwargs.setdefault("ToTMinCut", ToTMinCut) ApplyDupli = [True, True, True, True, True, True] - kwargs.setdefault("ApplyDupli", ApplyDupli) LowTOTduplication = [0, 7, 7, 7, 7, 0] + kwargs.setdefault("LVL1Latency", LVL1Latency) + kwargs.setdefault("ToTMinCut", ToTMinCut) + kwargs.setdefault("ApplyDupli", ApplyDupli) kwargs.setdefault("LowTOTduplication", LowTOTduplication) if digitizationFlags.doXingByXingPileUp(): # PileUpTool approach kwargs.setdefault("FirstXing", Pixel_FirstXing() ) @@ -282,7 +275,6 @@ def PixelDigitizationToolPU(name="PixelDigitizationToolPU", **kwargs): return BasicPixelDigitizationTool(name, **kwargs) def PixelDigitizationToolSplitNoMergePU(name="PixelDigitizationToolSplitNoMergePU", **kwargs): - kwargs.setdefault("EnableNoise", False) kwargs.setdefault("HardScatterSplittingMode", 0) kwargs.setdefault("InputObjectName", "PileupPixelHits") kwargs.setdefault("RDOCollName", "Pixel_PU_RDOs") diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/CalibSvc.cxx b/InnerDetector/InDetDigitization/PixelDigitization/src/CalibSvc.cxx deleted file mode 100644 index 5bef924b0fc5b8772a80e48563c9f10513c9dcd8..0000000000000000000000000000000000000000 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/CalibSvc.cxx +++ /dev/null @@ -1,106 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include "CalibSvc.h" -#include "GaudiKernel/ISvcLocator.h" -#include "GaudiKernel/IToolSvc.h" -#include "GaudiKernel/SvcFactory.h" -#include "GaudiKernel/IConversionSvc.h" -#include "GaudiKernel/ServiceHandle.h" -#include "AthenaKernel/IAtRndmGenSvc.h" -#include "GaudiKernel/PropertyMgr.h" -#include "GaudiKernel/PathResolver.h" -#include "CLHEP/Random/RandomEngine.h" -#include "AtlasCLHEP_RandomGenerators/RandGaussZiggurat.h" -#include <fstream> - -/** - ** Constructor(s) - **/ -CalibSvc::CalibSvc(const std::string& name,ISvcLocator* svc) - : AthService(name,svc), - m_rndmSvc("AtDSFMTGenSvc",name), - m_rndmEngineName("PixelDigitization"), - m_rndmEngine(0), - m_useCalibCDB(true), - m_usePixMapCDB(true), - m_pixelCalibSvc("PixelCalibSvc",name) -{ - declareProperty("PixelCalibSvc",m_pixelCalibSvc); - declareProperty("UsePixMapCondDB",m_usePixMapCDB,"Use pixel map conditions DB"); - declareProperty("UseCalibCondDB",m_useCalibCDB,"Use calibration conditions DB"); - declareProperty("RndmSvc", m_rndmSvc, "Random Number Service used in SCT & Pixel digitization"); - declareProperty("RndmEngine", m_rndmEngineName, "Random engine name"); -} - -CalibSvc::~CalibSvc() -{ -} - -inline StatusCode CalibSvc::queryInterface(const InterfaceID& riid, void** ppvIf) -{ - if (riid == CalibSvc::interfaceID()){ - *ppvIf = dynamic_cast<CalibSvc*>(this); - addRef(); - return StatusCode::SUCCESS; - } - return AthService::queryInterface( riid, ppvIf ); - -} - -/** - ** Initialize Service - **/ -StatusCode CalibSvc::initialize() -{ - //MsgStream log(msgSvc(), name()); - - StatusCode result = AthService::initialize(); - if (result.isFailure()) - { - ATH_MSG_FATAL ( "Unable to initialize the service!" ); - return result; - } - if (!m_pixelCalibSvc.retrieve().isSuccess()) { - ATH_MSG_FATAL("Unable to retrieve PixelCalibSvc"); - return StatusCode::FAILURE; - } - ATH_MSG_DEBUG("Retrieved PixelCalibSvc"); - if (!m_useCalibCDB) m_pixelCalibSvc->disableDb(); - // read Charge Collection Probability Maps - if ( m_rndmSvc.retrieve().isFailure() ) { - ATH_MSG_ERROR ( " Can't get RndmSvc " ); - return StatusCode::FAILURE; - } else { ATH_MSG_DEBUG ( "Retrieved RndmSvc" ); - - } - // - // get the PixelDigitization 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 ); - } - ATH_MSG_DEBUG ( "initialized service!" ); - return result; - -} - -StatusCode CalibSvc::finalize() -{ - return StatusCode::SUCCESS; -} - -int CalibSvc::getTot( const Identifier & id, double Q ) const { - // get the 'observed' TOT for a given pixelID and charge Q - double tot = m_pixelCalibSvc->getTotMean(id,Q); - double totsig = m_pixelCalibSvc->getTotRes(id,tot); - int ktot = static_cast<int>( CLHEP::RandGaussZiggurat::shoot(m_rndmEngine,tot,totsig)); - if (ktot<1) ktot=1; - return ktot; -} - diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/CalibSvc.h b/InnerDetector/InDetDigitization/PixelDigitization/src/CalibSvc.h deleted file mode 100644 index 2acb175e846cfed1b06bdf4fe192cec9d62a7509..0000000000000000000000000000000000000000 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/CalibSvc.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////////////// -// CalibSvc.h -// Header file for class CalibSvc -/////////////////////////////////////////////////////////////////// -// (c) ATLAS Detector software -/////////////////////////////////////////////////////////////////// -// -// Configurable Parameters: -// -// -UsePixMapCondDB Use pixel map conditions DB -// -UseCalibCondDB Use calibration conditions DB -// -RndmSvc Random Number Service used in SCT & Pixel digitization -// -RndmEngine Random engine name -// -ToTParA TOT parameter A -// -ToTParE TOT parameter E -// -ToTParC TOT parameter C -// -ToTParP1 TOT smearing parameter p1 -// -ToTParP2 TOT smearing parameter p2 -// -DiscrThresh Discriminator threshold -// -DiscrThreshVar Discriminator threshold sigma -// -IntimeThresh Discriminator in-time threshold -// -NoiseThresh Discriminator noise -// -///////////////////////////////////////////////////////////////////////////////// - -#ifndef PIXELDIGITIZATION_CALIBSVC_H -#define PIXELDIGITIZATION_CALIBSVC_H - -#include "GaudiKernel/ToolHandle.h" -#include "GaudiKernel/Property.h" -#include "GaudiKernel/Service.h" -#include "PixelConditionsServices/IPixelCalibSvc.h" -#include "AthenaBaseComps/AthService.h" -#include "GaudiKernel/IInterface.h" -#include "PixelConditionsServices/IPixelCalibSvc.h" -#include "PixelGeoModel/IBLParameterSvc.h" -class IAtRndmGenSvc; -namespace CLHEP { - class HepRandomEngine; -} - -static const InterfaceID IID_ICalibSvc("CalibSvc",1,0); - -class CalibSvc : public AthService,virtual public IInterface { - -public: - // Standard Constructor - CalibSvc(const std::string& name, ISvcLocator* svc); - // Standard Destructor - virtual ~CalibSvc(); - - virtual StatusCode initialize(); - virtual StatusCode finalize(); - virtual StatusCode queryInterface( const InterfaceID& riid, void** ppvIf ); - static const InterfaceID& interfaceID(); - bool useCalibCDB() {return m_useCalibCDB;} - bool usePixMapCDB() {return m_usePixMapCDB;} - int getCalThreshold( const Identifier & id) const {return(m_pixelCalibSvc->getThreshold(id));} - int getCalThresholdSigma( const Identifier & id ) const {return(m_pixelCalibSvc->getThresholdSigma(id));} - int getCalIntimeThreshold( const Identifier & id) const {return(m_pixelCalibSvc->getTimeWalk(id));} - int getCalNoise( const Identifier & id ) const {return(m_pixelCalibSvc->getNoise(id));} - double getCalQ2TotA( const Identifier & id ) const {return(m_pixelCalibSvc->getQ2TotA(id));} - double getCalQ2TotE( const Identifier & id ) const {return(m_pixelCalibSvc->getQ2TotE(id));} - double getCalQ2TotC( const Identifier & id ) const {return(m_pixelCalibSvc->getQ2TotC(id));} - double getCalTotP1( const Identifier & id ) const {return(m_pixelCalibSvc->getTotP1(id));} - double getCalTotP2( const Identifier & id ) const {return(m_pixelCalibSvc->getTotP2(id));} - int getTot( const Identifier & id, double Q ) const; - -protected: - ServiceHandle<IAtRndmGenSvc> m_rndmSvc; - std::string m_rndmEngineName; - CLHEP::HepRandomEngine* m_rndmEngine; - -private: -bool m_useCalibCDB; -bool m_usePixMapCDB; - -ServiceHandle<IPixelCalibSvc> m_pixelCalibSvc; - -}; - -inline const InterfaceID& CalibSvc::interfaceID(){ - return IID_ICalibSvc; -} - -#endif diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelCellDiscriminator.cxx b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelCellDiscriminator.cxx index 85f9c0584e7537c602ef35dbe2c61441518ec39b..53eead530262bf65792c592358e70206f25aa5a7 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelCellDiscriminator.cxx +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelCellDiscriminator.cxx @@ -12,7 +12,8 @@ #include "PixelCellDiscriminator.h" #include "SiDigitization/SiChargedDiodeCollection.h" #include "SiDigitization/SiHelper.h" -#include "CalibSvc.h" +#include "InDetReadoutGeometry/PixelModuleDesign.h" +#include "PixelConditionsServices/IPixelCalibSvc.h" #include "TimeSvc.h" // random number service #include "CLHEP/Random/RandomEngine.h" @@ -30,19 +31,16 @@ const InterfaceID& PixelCellDiscriminator::interfaceID( ){ return IID_IPixelCell PixelCellDiscriminator::PixelCellDiscriminator(const std::string& type, const std::string& name,const IInterface* parent): AthAlgTool(type,name,parent), m_TimeSvc("TimeSvc",name), - m_CalibSvc("CalibSvc",name), + m_pixelCalibSvc("PixelCalibSvc", name), m_rndmSvc("AtDSFMTGenSvc",name), m_rndmEngineName("PixelDigitization"), m_rndmEngine(0), - m_IBLParameterSvc("IBLParameterSvc",name), - m_IBLabsent(true), m_doITk(false), m_timingTune(2015) { declareInterface< PixelCellDiscriminator >( this ); declareProperty("RndmSvc",m_rndmSvc,"Random Number Service used in Pixel digitization"); declareProperty("RndmEngine",m_rndmEngineName,"Random engine name"); - declareProperty("CalibSvc",m_CalibSvc); declareProperty("TimeSvc",m_TimeSvc); declareProperty("doITk",m_doITk,"Phase-II upgrade ITk flag"); declareProperty("TimingTune",m_timingTune,"Version of the timing tune"); @@ -56,40 +54,23 @@ PixelCellDiscriminator::~PixelCellDiscriminator() // Initialize //---------------------------------------------------------------------- StatusCode PixelCellDiscriminator::initialize() { - StatusCode sc = AthAlgTool::initialize(); - if (sc.isFailure()) { - ATH_MSG_FATAL ( "PixelCellDiscriminator::initialize() failed"); - return sc ; - } - if (m_TimeSvc.retrieve().isFailure()) { - ATH_MSG_ERROR("Can't get TimeSvc"); - return StatusCode::FAILURE; - } - if (m_CalibSvc.retrieve().isFailure()) { - ATH_MSG_ERROR("Can't get CalibSvc"); - return StatusCode::FAILURE; - } - if (m_rndmSvc.retrieve().isFailure()) { - ATH_MSG_ERROR("Can't get RndmSvc"); - return StatusCode::FAILURE; - } - else { - ATH_MSG_DEBUG("Retrieved RndmSvc"); - } + + CHECK(m_TimeSvc.retrieve()); + + CHECK(m_pixelCalibSvc.retrieve()); + + CHECK(m_rndmSvc.retrieve()); m_rndmEngine = m_rndmSvc->GetEngine(m_rndmEngineName); - if (m_rndmEngine==0) { - ATH_MSG_ERROR("Could not find RndmEngine : " << m_rndmEngineName); - return StatusCode::FAILURE; - } - if (m_IBLParameterSvc.retrieve().isFailure()) { - ATH_MSG_WARNING("Could not retrieve IBLParameterSvc"); - } - else { - m_IBLParameterSvc->setBoolParameters(m_IBLabsent,"IBLAbsent"); + if (!m_rndmEngine) { + ATH_MSG_ERROR("Could not find RndmEngine : " << m_rndmEngineName); + return StatusCode::FAILURE; + } + else { + ATH_MSG_DEBUG("Found RndmEngine : " << m_rndmEngineName); } ATH_MSG_DEBUG ( "PixelCellDiscriminator::initialize()"); - return sc ; + return StatusCode::SUCCESS; } //---------------------------------------------------------------------- @@ -108,19 +89,18 @@ StatusCode PixelCellDiscriminator::finalize() { // process the collection of charged diodes void PixelCellDiscriminator::process(SiChargedDiodeCollection &collection) const { - - bool ComputeTW = true; - //if (getReadoutTech(collection.element()) == RD53) ComputeTW = false; - //if (getReadoutTech(collection.element()) == FEI4) ComputeTW = false; - // ... instead for ITk: - if (m_doITk) ComputeTW = false; - // ... and for IBL: - const PixelID* pixelId = static_cast<const PixelID *>((collection.element())->getIdHelper()); - if ((!m_IBLabsent && pixelId->is_blayer(collection.element()->identify())) || - pixelId->barrel_ec(collection.element()->identify())==4 || - pixelId->barrel_ec(collection.element()->identify())==-4) ComputeTW = false; - // discriminator is applied to all cells, even unconnected ones to be - /// able to use the unconnected cells as well + bool ComputeTW = true; + //if (getReadoutTech(collection.element()) == RD53) ComputeTW = false; + //if (getReadoutTech(collection.element()) == FEI4) ComputeTW = false; + // ... instead for ITk: + if (m_doITk) ComputeTW = false; + + const PixelModuleDesign *p_design = dynamic_cast<const PixelModuleDesign*>(&(collection.element()->design())); + if (p_design->getReadoutTechnology()==PixelModuleDesign::FEI4) { + ComputeTW = false; + } + + const PixelID* pixelId = static_cast<const PixelID *>((collection.element())->getIdHelper()); for(SiChargedDiodeIterator i_chargedDiode=collection.begin() ; i_chargedDiode!=collection.end() ; ++i_chargedDiode) { @@ -136,15 +116,15 @@ void PixelCellDiscriminator::process(SiChargedDiodeCollection &collection) const // noise : actually a noise level that logically should be added to // the charge <- TODO! // - double th0 = m_CalibSvc->getCalThreshold(diodeID); - double ith0 = m_CalibSvc->getCalIntimeThreshold(diodeID); + double th0 = m_pixelCalibSvc->getThreshold(diodeID); + double ith0 = m_pixelCalibSvc->getTimeWalk(diodeID); // Flers: here I rely on CalibSvc providing correct values for th0, ith0 // if that's not true, need to figure out if we are in dbm and set // th0, ith0, e.g. // if (dbm) { th0=1200.; ith0=1500.; } double threshold = th0 + - m_CalibSvc->getCalThresholdSigma(diodeID)*CLHEP::RandGaussZiggurat::shoot(m_rndmEngine) + - m_CalibSvc->getCalNoise(diodeID)*CLHEP::RandGaussZiggurat::shoot(m_rndmEngine); + m_pixelCalibSvc->getThresholdSigma(diodeID)*CLHEP::RandGaussZiggurat::shoot(m_rndmEngine) + + m_pixelCalibSvc->getNoise(diodeID)*CLHEP::RandGaussZiggurat::shoot(m_rndmEngine); double intimethreshold = (ith0/th0)*threshold; // double overdrive = intimethreshold - threshold ; diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelCellDiscriminator.h b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelCellDiscriminator.h index d215d52c384539f63825e023f7052175e58f00e2..e4d09da41864dd0b437f36a5ad42c5a7a3defbfa 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelCellDiscriminator.h +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelCellDiscriminator.h @@ -41,13 +41,12 @@ // Base class #include "SiDigitization/ISiChargedDiodesProcessorTool.h" #include "AthenaBaseComps/AthAlgTool.h" -#include "PixelGeoModel/IBLParameterSvc.h" namespace CLHEP { class HepRandomEngine; } class TimeSvc; -class CalibSvc; +class IPixelCalibSvc; class IAtRndmGenSvc; class PixelCellDiscriminator : public AthAlgTool, virtual public ISiChargedDiodesProcessorTool { @@ -80,12 +79,10 @@ private: PixelCellDiscriminator(); ServiceHandle<TimeSvc> m_TimeSvc; - ServiceHandle<CalibSvc> m_CalibSvc; + ServiceHandle<IPixelCalibSvc> m_pixelCalibSvc; ServiceHandle<IAtRndmGenSvc> m_rndmSvc; std::string m_rndmEngineName; CLHEP::HepRandomEngine* m_rndmEngine; - ServiceHandle<IBLParameterSvc> m_IBLParameterSvc; - bool m_IBLabsent; bool m_doITk; int m_timingTune; }; diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitization.cxx b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitization.cxx index de2773bb1001941f1a2c576e7ed41c2225bd0d0e..014feb0f854840e5fca5a5f13f50d02631e79401 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitization.cxx +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitization.cxx @@ -9,7 +9,7 @@ // (c) ATLAS Detector software //////////////////////////////////////////////////////////////////////////// -#include "PixelDigitization/PixelDigitization.h" +#include "PixelDigitization.h" #include "PixelDigitizationTool.h" diff --git a/InnerDetector/InDetDigitization/PixelDigitization/PixelDigitization/PixelDigitization.h b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitization.h similarity index 100% rename from InnerDetector/InDetDigitization/PixelDigitization/PixelDigitization/PixelDigitization.h rename to InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitization.h diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitizationTool.cxx b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitizationTool.cxx index c2b40473f0e4da14eceaafbe3a94e46b94e5ee6e..c9e934a93a41903df8393feb81afae1dda1f505b 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitizationTool.cxx +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitizationTool.cxx @@ -19,13 +19,12 @@ #include "PixelChargeSmearer.h" #include "PixelGangedMerger.h" #include "TimeSvc.h" -#include "CalibSvc.h" #include "PixelRandomDisabledCellGenerator.h" #include "PileUpTools/PileUpMergeSvc.h" #include "AthenaKernel/IAtRndmGenSvc.h" #include "InDetSimEvent/SiHitCollection.h" -// Mother Package includes +// Mother Package includes #include "SiDigitization/SiHelper.h" #include "SiDigitization/SiChargedDiodeCollection.h" #include "SiDigitization/ISiChargedDiodesProcessorTool.h" @@ -51,8 +50,7 @@ // DataHandle #include "StoreGate/DataHandle.h" - -#include "PixelConditionsServices/IPixelOfflineCalibSvc.h" +#include "CxxUtils/make_unique.h" // #include <limits> @@ -63,96 +61,78 @@ static constexpr unsigned int crazyParticleBarcode(std::numeric_limits<int32_t>: using namespace InDetDD; // Constructor with parameters: -PixelDigitizationTool::PixelDigitizationTool(const std::string &type, - const std::string &name, - const IInterface * pIID) : +PixelDigitizationTool::PixelDigitizationTool(const std::string &type, + const std::string &name, + const IInterface * pIID) : PileUpToolBase(type,name,pIID), m_overflowIBLToT(0), m_offlineCalibSvc("PixelOfflineCalibSvc", name), m_managerName("Pixel"), - m_rdoCollName("PixelRDOs"), - m_rdoCollNameSPM(), - m_sdoCollName("PixelSDO_Map"), - m_rdoContainer(NULL), - m_rdoContainerSPM(NULL), - m_simDataColl(NULL), - //m_maxToT(255), - //m_minToT(0), - //m_applyDupli, - //m_maxToTForDupli(255), - m_IBLabsent(true), + m_rdoContainer("PixelRDOs"), + m_rdoContainerSPM("PixelRDOs_SPM"), + m_simDataColl("PixelSDO_Map"), m_doITk(false), m_time_y_eq_zero(0.0), - m_ComTime(NULL), + m_ComTime(nullptr), m_HardScatterSplittingMode(0), m_HardScatterSplittingSkipper(false), m_rndmEngineName("PixelDigitization"), - m_cosmics(false), m_useComTime(false), m_eventIOV(1), m_IOVFlag(PixelDigitizationTool::IOVonce), m_onlyHitElements(false), m_enableHits(true), - m_enableNoise(true), - m_enableSpecialPixels(true), m_doRDOforSPM(false), - m_pixelNoisyCellGenerator("PixelNoisyCellGenerator"), - m_pixelGangedMerger("PixelGangedMerger"), - m_specialPixelGenerator("SpecialPixelGenerator"), - m_pixelCellDiscriminator("PixelCellDiscriminator"), - m_pixelChargeSmearer("PixelChargeSmearer"), - m_pixelDiodeCrossTalkGenerator("PixelDiodeCrossTalkGenerator"), + m_diodesProcsTool(), //TODO add "this" to make the ToolHandles in this ToolHandleArray private + m_specialPixelGenerator(nullptr), m_pixelIdMapping("PixelCablingSvc",name), - m_pixelRandomDisabledCellGenerator("PixelRandomDisabledCellGenerator"), - m_detID(NULL), - m_thpcsi(NULL), + m_pixelCalibSvc("PixelCalibSvc",name), + m_detID(nullptr), + m_thpcsi(nullptr), m_SurfaceChargesTool("SurfaceChargesTool"), + m_chargedDiodes(nullptr), m_vetoThisBarcode(crazyParticleBarcode), m_rndmSvc("AtRndmGenSvc",name), m_mergeSvc("PileUpMergeSvc",name), - m_CalibSvc("CalibSvc",name), m_TimeSvc("TimeSvc",name), - m_IBLParameterSvc("IBLParameterSvc",name), - m_rndmEngine(NULL), - m_atlasID(NULL), - m_detManager(NULL), + m_pixelConditionsSvc("PixelConditionsSummarySvc",name), + m_rndmEngine(nullptr), + m_detManager(nullptr), m_specialPixelMapSvc("SpecialPixelMapSvc",name), m_specialPixelMapKey("SpecialPixelMap"), - m_specialPixelMap(NULL), + m_specialPixelMap(nullptr), m_eventCounter(0), - m_eventNextUpdate(0) + m_eventNextUpdate(0), + m_inputObjectName(""), + m_createNoiseSDO(false) { - + declareInterface<PixelDigitizationTool>(this); - declareProperty("PixelNoisyCellGenerator", m_pixelNoisyCellGenerator, "PixelNoisyCellGenerator"); - declareProperty("PixelCellDiscriminator", m_pixelCellDiscriminator, "PixelCellDiscriminator"); - declareProperty("PixelChargeSmearer", m_pixelChargeSmearer, "PixelChargeSmearer"); - declareProperty("PixelDiodeCrossTalkGenerator", m_pixelDiodeCrossTalkGenerator, "PixelDiodeCrossTalkGenerator"); - declareProperty("PixelGangedMerger", m_pixelGangedMerger, "PixelGangedMerger"); - declareProperty("PixelRandomDisabledCellGenerator", m_pixelRandomDisabledCellGenerator, "PixelRandomDisabledCellGenerator"); - declareProperty("SpecialPixelGenerator", m_specialPixelGenerator, "Special pixel generator"); - declareProperty("SurfaceChargesTool", m_SurfaceChargesTool, "Surface charges tool"); + declareProperty("PixelTools", m_diodesProcsTool, "List of tools"); + declareProperty("SurfaceChargesTool", m_SurfaceChargesTool, "Surface charges tool"); declareProperty("PixelCablingSvc", m_pixelIdMapping, "Pixel Cabling Service"); - declareProperty("RndmSvc", m_rndmSvc, "Random number service used in Pixel Digitization"); - declareProperty("MergeSvc", m_mergeSvc, "Merge service used in Pixel digitization"); - declareProperty("TimeSvc", m_TimeSvc, "Time Svc"); - declareProperty("CalibSvc", m_CalibSvc, "Calib Svc"); - declareProperty("OfflineCalibSvc",m_offlineCalibSvc); - declareProperty("InputObjectName",m_inputObjectName="","Input Object name" ); - declareProperty("CreateNoiseSDO", m_createNoiseSDO=false, "Set create noise SDO flag"); - m_inputObjectName = "PixelHits"; - declareProperty("SpecialPixelMapKey",m_specialPixelMapKey,"Special Pixel Map Key"); - declareProperty("SpecialPixelMapSvc",m_specialPixelMapSvc); + declareProperty("RndmSvc", m_rndmSvc, "Random number service used in Pixel Digitization"); + declareProperty("MergeSvc", m_mergeSvc, "Merge service used in Pixel digitization"); + declareProperty("TimeSvc", m_TimeSvc, "Time Svc"); + declareProperty("PixelCalibSvc", m_pixelCalibSvc); + declareProperty("PixelConditionsSummarySvc",m_pixelConditionsSvc); + declareProperty("OfflineCalibSvc", m_offlineCalibSvc); + declareProperty("InputObjectName", m_inputObjectName, "Input Object name" ); + declareProperty("CreateNoiseSDO", m_createNoiseSDO, "Set create noise SDO flag"); + declareProperty("SpecialPixelMapKey", m_specialPixelMapKey, "Special Pixel Map Key"); + declareProperty("SpecialPixelMapSvc", m_specialPixelMapSvc); - // // Get parameter values from jobOptions file - declareProperty("ManagerName", m_managerName, "Pixel manager name"); - declareProperty("RDOCollName", m_rdoCollName, "RDO collection name"); - declareProperty("SDOCollName", m_sdoCollName, "SDO collection name"); + declareProperty("ManagerName", m_managerName, "Pixel manager name"); + + declareProperty("RDOCollName", m_rdoContainer, "RDO collection name"); + declareProperty("RDOCollNameSPM", m_rdoContainerSPM, "RDO collection name for special pixel map"); + declareProperty("SDOCollName", m_simDataColl, "SDO collection name"); + declareProperty("EventIOV", m_eventIOV, "Number of events per IOV"); declareProperty("IOVFlag", m_IOVFlag, "IOV flag - how to simulate the validity period"); declareProperty("LVL1Latency", m_maxToT, "LVL1 latency (max possible ToT)"); - declareProperty("ToTMinCut", m_minToT, "Minimum ToT cut (online cut) "); + declareProperty("ToTMinCut", m_minToT, "Minimum ToT cut (online cut)"); declareProperty("ApplyDupli", m_applyDupli, "Duplicate low ToT hits"); declareProperty("LowTOTduplication", m_maxToTForDupli, "ToT value below which the hit is duplicated"); declareProperty("doITk", m_doITk, "Phase-II upgrade ITk flag"); @@ -163,11 +143,8 @@ PixelDigitizationTool::PixelDigitizationTool(const std::string &type, declareProperty("RndmEngine", m_rndmEngineName, "Random engine name"); // //For cosmics need to mask some modules - declareProperty("CosmicsRun", m_cosmics, "Cosmics run"); declareProperty("UseComTime", m_useComTime, "Use ComTime for timing"); declareProperty("EnableHits", m_enableHits, "Enable hits"); - declareProperty("EnableNoise", m_enableNoise, "Enable noise generation"); - declareProperty("EnableSpecialPixels",m_enableSpecialPixels, "Enable special pixels"); declareProperty("OnlyHitElements", m_onlyHitElements, "Process only elements with hits"); declareProperty("RDOforSPM", m_doRDOforSPM, "Create RDOs for special pixels"); declareProperty("HardScatterSplittingMode", m_HardScatterSplittingMode, "Control pileup & signal splitting" ); @@ -175,45 +152,26 @@ PixelDigitizationTool::PixelDigitizationTool(const std::string &type, } - // Initialize method: -StatusCode PixelDigitizationTool::initialize() -{ +StatusCode PixelDigitizationTool::initialize() { ATH_MSG_DEBUG("PixelDigitizationTool::Initialize()"); - m_rdoCollNameSPM = m_rdoCollName + "_SPM"; - // - // Print parameter values - // check the input object name + // check the input object name if (m_inputObjectName=="") { ATH_MSG_FATAL ( "Property InputObjectName not set !" ); return StatusCode::FAILURE; } - else ATH_MSG_DEBUG ( "Input objects: '" << m_inputObjectName << "'" ); - - if (m_IBLParameterSvc.retrieve().isFailure()) { - ATH_MSG_WARNING( "Could not retrieve IBLParameterSvc"); - } else { - m_IBLParameterSvc->setBoolParameters(m_enableSpecialPixels,"EnableSpecialPixels"); - m_IBLParameterSvc->setBoolParameters(m_IBLabsent,"IBLAbsent"); + ATH_MSG_DEBUG ( "Input objects: '" << m_inputObjectName << "'" ); } + //============================== // initialize services etc //============================== CHECK( initServices() ); - CHECK( initRandom() ); - - CHECK( initTools() ); - CHECK( initExtras() ); - - unsigned int m_nPixTot = m_detID->pixel_hash_max(); - unsigned int m_nModTot = m_detID->wafer_hash_max(); - m_specialPixelGenerator->setnPixTot(m_nPixTot); - m_specialPixelGenerator->setnModTot(m_nModTot); - + CHECK( initTools() ); //============================== // Create the charge model @@ -234,42 +192,17 @@ StatusCode PixelDigitizationTool::initialize() // ---------------------------------------------------------------- // - // now cross talk (neighbouring pixels) - addCrossTalk(); - - // add charge smearing to pixels with hits - thermal noise - //addChargeSmearing(m_thermalNoise); - addChargeSmearing(); - - // add noise to random pixels - prob controlled by RndNoiseProb - addNoise(); - - // add/merge ganged pixels - addGangedPixels(); - - // mask special pixels - // all pixels with status>0 will be masked out - addSpecialPixels(); - - // add randomly disabled pixels - addRandomDisabled(); - - // add discriminator - // non-masked pixels, with timing ok and above threshold - // will be accepted. - addDiscriminator(); - return StatusCode::SUCCESS; } // Digitize method: -StatusCode PixelDigitizationTool::processAllSubEvents() +StatusCode PixelDigitizationTool::processAllSubEvents() { - if (prepareEvent(0).isFailure()) return StatusCode::FAILURE; + if (prepareEvent(0).isFailure()) return StatusCode::FAILURE; ATH_MSG_VERBOSE("Begin digitizeAllHits"); - if (m_enableHits && !getNextEvent().isFailure()) digitizeAllHits(); + if (m_enableHits && !getNextEvent().isFailure()) digitizeAllHits(); else ATH_MSG_DEBUG("no hits found in event!"); - delete chargedDiodes; + delete m_chargedDiodes; // loop over elements without hits ATH_MSG_DEBUG("Digitized Elements with Hits"); digitizeNonHits(); @@ -280,7 +213,7 @@ StatusCode PixelDigitizationTool::processAllSubEvents() // increment event counter (for simulated IOV) m_eventCounter++; - + ATH_MSG_DEBUG("Digitize success!"); return StatusCode::SUCCESS; } @@ -299,57 +232,37 @@ StatusCode PixelDigitizationTool::createOutputContainers() { // create a new RDO conatiner and store in SG ///////////////////////////////////////////////// - try { - m_rdoContainer=new PixelRDO_Container(m_detID->wafer_hash_max()); - } catch (std::bad_alloc) { - ATH_MSG_FATAL ( "Could not create a new Pixel RawDataContainer !" ); - return StatusCode::FAILURE; - } - ATH_MSG_VERBOSE("About to register rdoCollName in StoreGate"); - StatusCode sc=evtStore()->record(m_rdoContainer,m_rdoCollName); - if (sc.isFailure()) { - ATH_MSG_FATAL ( "Container '" << m_rdoCollName - << "' could not be registered in StoreGate !" ); - return StatusCode::FAILURE; - } else { - ATH_MSG_VERBOSE ( "Container '" << m_rdoCollName - << "' registered in StoreGate" ); + if (!m_rdoContainer.isValid()) { + m_rdoContainer = CxxUtils::make_unique<PixelRDO_Container>(m_detID->wafer_hash_max()); + if (!m_rdoContainer.isValid()) { + ATH_MSG_FATAL("Could not create PixelRDO_Container"); + return StatusCode::FAILURE; + } } + ATH_MSG_DEBUG("PixelRDO_Container " << m_rdoContainer.name() << " registered in StoreGate"); - // do the same for the monitoring RDO if (m_doRDOforSPM) { ATH_MSG_VERBOSE("doRDOforSPM"); - try { - m_rdoContainerSPM=new PixelRDO_Container(m_detID->wafer_hash_max()); - } catch (std::bad_alloc) { - ATH_MSG_FATAL ( "Could not create a new Pixel RawDataContainer for Special Pixels Map !" ); - return StatusCode::FAILURE; + if (!m_rdoContainerSPM.isValid()) { + m_rdoContainerSPM = CxxUtils::make_unique<PixelRDO_Container>(m_detID->wafer_hash_max()); + if (!m_rdoContainerSPM.isValid()) { + ATH_MSG_FATAL("Could not create PixelRDO_Container"); + return StatusCode::FAILURE; + } } - // - sc=evtStore()->record(m_rdoContainerSPM,m_rdoCollNameSPM); - if (sc.isFailure()) { - ATH_MSG_FATAL ( "Container '" << m_rdoCollNameSPM - << "' could not be registered in StoreGate !" ); + ATH_MSG_DEBUG("PixelRDO_Container " << m_rdoContainerSPM.name() << " registered in StoreGate"); + } + + if (!m_simDataColl.isValid()) { + m_simDataColl = CxxUtils::make_unique<InDetSimDataCollection>(); + if (!m_simDataColl.isValid()) { + ATH_MSG_FATAL("Could not create InDetSimDataCollection"); return StatusCode::FAILURE; - } else { - ATH_MSG_DEBUG ( "Container '" << m_rdoCollNameSPM - << "' registered in StoreGate" ); } } - ///////////////////////////////////////////////// - // create a map for the SDO and register into SG - ///////////////////////////////////////////////// - m_simDataColl = new InDetSimDataCollection(); - sc=evtStore()->record(m_simDataColl, m_sdoCollName); - if (sc.isFailure()) { - ATH_MSG_FATAL ( "InDetSimData map '" << m_sdoCollName - << "' could not be registered in StoreGate !" ); - return StatusCode::FAILURE; - } else { - ATH_MSG_DEBUG ( "InDetSimData map '" << m_sdoCollName - << "' registered in StoreGate" ); - } -return StatusCode::SUCCESS; + ATH_MSG_DEBUG("InDetSimDataCollection " << m_simDataColl.name() << " registered in StoreGate"); + + return StatusCode::SUCCESS; } void PixelDigitizationTool::digitizeAllHits() { @@ -370,20 +283,20 @@ void PixelDigitizationTool::digitizeAllHits() { ///////////////////////////////////////////////// ATH_MSG_DEBUG ( "Digitizing hits" ); int hitcount = 0; // First, elements with hits. - while (digitizeElement(chargedDiodes) ) { - ATH_MSG_DEBUG ( "Hit collection ID=" << m_detID->show_to_string( chargedDiodes->identify() ) ); + while (digitizeElement(m_chargedDiodes) ) { + ATH_MSG_DEBUG ( "Hit collection ID=" << m_detID->show_to_string( m_chargedDiodes->identify() ) ); hitcount++; // Hitcount will be a number in the hit collection minus number of hits in missing mods // NB: not really a hit but a collection of hits // When in this loop, we are always in same module (side) - + ATH_MSG_DEBUG ( "in digitize elements with hits: ec - layer - eta - phi " - << m_detID->barrel_ec(chargedDiodes->identify() ) << " - " - << m_detID->layer_disk(chargedDiodes->identify() ) << " - " - << m_detID->eta_module(chargedDiodes->identify() ) << " - " - << m_detID->phi_module(chargedDiodes->identify() ) << " - " - << " processing hit number " << hitcount - ); + << m_detID->barrel_ec(m_chargedDiodes->identify() ) << " - " + << m_detID->layer_disk(m_chargedDiodes->identify() ) << " - " + << m_detID->eta_module(m_chargedDiodes->identify() ) << " - " + << m_detID->phi_module(m_chargedDiodes->identify() ) << " - " + << " processing hit number " << hitcount + ); // Have a flag to check if the module is present or not // Generally assume it is: @@ -392,28 +305,28 @@ void PixelDigitizationTool::digitizeAllHits() { // Pixel EndCap A cosmic test: // --------------------------- // This is the place where we check on the status of the pixel - // endcap module. Whether it was in the readout or not... - // For the cosmic geometry only the endcap elements exist and - // it will only loop over existing modules anyway. At the moment this + // endcap module. Whether it was in the readout or not... + // For the cosmic geometry only the endcap elements exist and + // it will only loop over existing modules anyway. At the moment this // is just a place holder for access to COOL to query the module status. - // - IdentifierHash idHash = chargedDiodes->identifyHash(); - + // + IdentifierHash idHash = m_chargedDiodes->identifyHash(); + assert (idHash < m_processedElements.size()); m_processedElements[idHash] = true; - + // Create and store RDO and SDO // Don't create empty ones. - // if (!chargedDiodes->empty() && m_module_status==0 ) { - if (!chargedDiodes->empty() ) { - StatusCode sc = createAndStoreRDO(chargedDiodes); + // if (!m_chargedDiodes->empty() && m_module_status==0 ) { + if (!m_chargedDiodes->empty() ) { + StatusCode sc = createAndStoreRDO(m_chargedDiodes); if (sc.isSuccess()) // error msg is given inside createAndStoreRDO() - { - addSDO(chargedDiodes); - } + { + addSDO(m_chargedDiodes); + } } - - chargedDiodes->clear(); + + m_chargedDiodes->clear(); } ATH_MSG_DEBUG ( "hits processed" ); return; @@ -424,7 +337,7 @@ void PixelDigitizationTool::digitizeNonHits() { if (m_onlyHitElements) return; // ATH_MSG_DEBUG ( "processing elements without hits" ); - chargedDiodes = new SiChargedDiodeCollection; + m_chargedDiodes = new SiChargedDiodeCollection; for (unsigned int i=0; i < m_processedElements.size(); i++) { if (!m_processedElements[i]) { IdentifierHash idHash = i; @@ -433,41 +346,41 @@ void PixelDigitizationTool::digitizeNonHits() { } const SiDetectorElement * element = m_detManager->getDetectorElement(idHash); if (element) { - ATH_MSG_DEBUG ( - "In digitize of untouched elements: layer - phi - eta " - << m_detID->layer_disk(element->identify() ) << " - " - << m_detID->phi_module(element->identify() ) << " - " - << m_detID->eta_module(element->identify() ) << " - " - << "size: " << m_processedElements.size() - ); - + ATH_MSG_DEBUG ( + "In digitize of untouched elements: layer - phi - eta " + << m_detID->layer_disk(element->identify() ) << " - " + << m_detID->phi_module(element->identify() ) << " - " + << m_detID->eta_module(element->identify() ) << " - " + << "size: " << m_processedElements.size() + ); + // Have a flag to check if the module is present or not - // Generally assume it is: + // Generally assume it is: // m_module_status = 0; // module is present we assume - + // Pixel EndCap A cosmic test: // --------------------------- // This is the place where we check on the status of the pixel // endcap module. Whether it was in the readout or not... // - - - chargedDiodes->setDetectorElement(element); + + + m_chargedDiodes->setDetectorElement(element); ATH_MSG_DEBUG ( "calling digitizeElements() for NON hits" ); - applyProcessorTools(chargedDiodes); - + applyProcessorTools(m_chargedDiodes); + // Create and store RDO and SDO // Don't create empty ones. - if (!chargedDiodes->empty()) { - StatusCode sc = createAndStoreRDO( chargedDiodes); + if (!m_chargedDiodes->empty()) { + StatusCode sc = createAndStoreRDO( m_chargedDiodes); if (sc.isSuccess()) // error msg is given inside createAndStoreRDO() - addSDO(chargedDiodes); + addSDO(m_chargedDiodes); } - chargedDiodes->clear(); + m_chargedDiodes->clear(); } } } - delete chargedDiodes; + delete m_chargedDiodes; return; } @@ -483,35 +396,27 @@ bool PixelDigitizationTool::digitizeElement(SiChargedDiodeCollection* chargedDio } // get the iterator pairs for this DetEl - - TimedHitCollection<SiHit>::const_iterator i, e; + TimedHitCollection<SiHit>::const_iterator i, e; if(m_thpcsi->nextDetectorElement(i, e) == false) { // no more hits delete m_thpcsi; m_thpcsi = 0; - return false; + return false; } - + // create the identifier for the collection: ATH_MSG_DEBUG ( "create ID for the hit collection" ); - Identifier id; + const PixelID* PID = dynamic_cast<const PixelID*>(m_detID); + if (PID==0) { + ATH_MSG_ERROR ( "expected a PixelID but failed..." ); + return false; + } const TimedHitPtr<SiHit>& firstHit = *i; - int Barrel = firstHit->getBarrelEndcap(); + Identifier id = PID->wafer_id(Barrel,firstHit->getLayerDisk(),firstHit->getPhiModule(),firstHit->getEtaModule()); - // For testbeam - if(m_atlasID == NULL) id = 0; - else { - const PixelID* PID = dynamic_cast<const PixelID*>(m_atlasID); - if (PID==0) { - ATH_MSG_ERROR ( "expected a PixelID but failed..." ); - return false; - } - id = PID->wafer_id(Barrel, firstHit->getLayerDisk(), firstHit->getPhiModule(), firstHit->getEtaModule()); - } - // get the det element from the manager SiDetectorElement* sielement = m_detManager->getDetectorElement(id); - + if (sielement==0) { ATH_MSG_DEBUG("Barrel=" << Barrel << " layer=" << firstHit->getLayerDisk() << " Eta=" << firstHit->getEtaModule() << " Phi=" << firstHit->getPhiModule()); ATH_MSG_ERROR ( "detector manager could not find element with id = " << id ); @@ -522,18 +427,18 @@ bool PixelDigitizationTool::digitizeElement(SiChargedDiodeCollection* chargedDio // Loop over the hits and created charged diodes: while (i != e) { - + TimedHitPtr<SiHit> phit(*i++); //skip hits which are more than 10us away - if(fabs(phit->meanTime() ) < 10000. *CLHEP::ns ) { + if(fabs(phit->meanTime() ) < 10000. *CLHEP::ns ) { ATH_MSG_DEBUG("HASH = " << m_detID->wafer_hash(m_detID->wafer_id(phit->getBarrelEndcap(),phit->getLayerDisk(),phit->getPhiModule(),phit->getEtaModule()))); ATH_MSG_DEBUG ( "calling process() for all methods" ); if (m_SurfaceChargesTool->process(phit,*chargedDiodes,*sielement)==StatusCode::FAILURE) return false; ATH_MSG_DEBUG ( "charges filled!" ); } - } - applyProcessorTools(chargedDiodes) ; //!< Use of the new AlgTool surface charges generator class + } + applyProcessorTools(chargedDiodes) ; //!< Use of the new AlgTool surface charges generator class return true; } @@ -541,15 +446,11 @@ bool PixelDigitizationTool::digitizeElement(SiChargedDiodeCollection* chargedDio // Applies processors to the current detector element for the current element: //------------------------------------------------------------------------------ void PixelDigitizationTool::applyProcessorTools(SiChargedDiodeCollection* chargedDiodes) { - ATH_MSG_DEBUG ("applyProcessorTools()" ); - int processorNumber = 0; - - for(std::list<ISiChargedDiodesProcessorTool *>::iterator p_proc= m_diodesProcsTool.begin();p_proc!=m_diodesProcsTool.end() ; ++p_proc) { - (*p_proc)->process(*chargedDiodes); - - processorNumber++; - ATH_MSG_DEBUG("Applied processor # " << processorNumber); - } + ATH_MSG_DEBUG ("applyProcessorTools()" ); + for (unsigned int itool=0; itool<m_diodesProcsTool.size(); itool++) { + ATH_MSG_DEBUG("Executing tool " << m_diodesProcsTool[itool]->name()); + m_diodesProcsTool[itool]->process(*chargedDiodes); + } } //------------------------------------------------------------ @@ -608,11 +509,11 @@ void PixelDigitizationTool::addSDO(SiChargedDiodeCollection* collection) { // loop over the list list_t::const_iterator EndOfChargeList = charges.end(); for ( list_t::const_iterator i_ListOfCharges = charges.begin(); i_ListOfCharges!=EndOfChargeList; ++i_ListOfCharges) { - + const HepMcParticleLink& trkLink = i_ListOfCharges->particleLink(); int barcode = trkLink.barcode(); if ((barcode == 0) || (barcode == m_vetoThisBarcode)){ - continue; + continue; } if(!real_particle_hit) { real_particle_hit = trkLink.isValid(); } // check if this track number has been already used. @@ -622,16 +523,18 @@ void PixelDigitizationTool::addSDO(SiChargedDiodeCollection* collection) { for ( ; i_Deposit != depositsR_end; ++i_Deposit) { if( (*i_Deposit).first == trkLink ) {theDeposit = i_Deposit; break;} } - + // if the charge has already hit the Diode add it to the deposit if(theDeposit != depositsR_end ) (*theDeposit).second += i_ListOfCharges->charge(); else { // create a new deposit InDetSimData::Deposit deposit(trkLink, i_ListOfCharges->charge()); deposits.push_back(deposit); } - } + } // add the simdata object to the map: - if(real_particle_hit || m_createNoiseSDO) m_simDataColl->insert(std::make_pair( collection->getId((*i_chargedDiode).first), InDetSimData(deposits,(*i_chargedDiode).second.flag()))); + if(real_particle_hit || m_createNoiseSDO) { + m_simDataColl->insert(std::make_pair(collection->getId((*i_chargedDiode).first),InDetSimData(deposits,(*i_chargedDiode).second.flag()))); + } } } @@ -640,8 +543,7 @@ void PixelDigitizationTool::addSDO(SiChargedDiodeCollection* collection) { // will create just one collection per event void PixelDigitizationTool::createRDOforSPM() { if (!m_doRDOforSPM) return; - if (m_rdoContainerSPM==0) return; - // + IdentifierHash idhash = 0; PixelRDO_Collection* coll = new PixelRDO_Collection(idhash); const DetectorSpecialPixelMap *spmap = getSpecialPixelMap(); @@ -656,10 +558,10 @@ void PixelDigitizationTool::createRDOforSPM() { for (; spmBegin != spmEnd; ++spmBegin) { IdentifierHash moduleHash(spmBegin - spmap->begin()); Identifier modid = m_detID->wafer_id(moduleHash); - const ModuleSpecialPixelMap* moduleMap = spmap->module(moduleHash); + const ModuleSpecialPixelMap* moduleMap = spmap->module(moduleHash); if (moduleMap == 0) { ATH_MSG_DEBUG ( "BUG TRAP - special modulemap ptr == 0!!!" << - " for module " << moduleHash ); + " for module " << moduleHash ); delete coll; return; } @@ -681,249 +583,149 @@ void PixelDigitizationTool::createRDOforSPM() { pixfe = moduleMap->chipsPerModule()-chip-1; pixcol = moduleMap->columnsPerChip()-pixcol-1; pixrow = 164-pixrow-1; - } - if ( (ecb!=0) && (phi%2==0) ) pixrow=164-pixrow-1; - int nToT=100; + } + if ( (ecb!=0) && (phi%2==0) ) pixrow=164-pixrow-1; + int nToT=100; Identifier idpix = m_pixelIdMapping->getPixelId(modid,pixfe,pixrow,pixcol); Pixel1RawData *p_rdo= new Pixel1RawData(idpix, nToT, 0, 0, 0 ); coll->push_back(p_rdo); ATH_MSG_DEBUG ("RDO for SPM "<< pixelID0 <<","<<pixfe<<","<<pixcol<<","<<pixrow<<","<<idpix<<" status= " << - moduleMap->pixelStatus(pixelID0)); - } + moduleMap->pixelStatus(pixelID0)); + } - // + // // Count noisy pixels in special regions (special chips or special column pairs) - // + // if(moduleMap->hasSpecialChips()||moduleMap->hasSpecialColumnPairs()){ for(unsigned int ichip = 0; ichip < moduleMap->chipsPerModule(); ichip++){ if(moduleMap->chipStatus(ichip)==0){ if(moduleMap->hasSpecialColumnPairs(ichip)){ - for(unsigned int icolp = 0; icolp < moduleMap->columnsPerChip()/2; icolp++){ - if(moduleMap->columnPairStatus(ichip,icolp)!=0 && moduleMap->columnPairStatus(ichip,icolp) & (1 << 15)){ + for(unsigned int icolp = 0; icolp < moduleMap->columnsPerChip()/2; icolp++){ + if(moduleMap->columnPairStatus(ichip,icolp)!=0 && moduleMap->columnPairStatus(ichip,icolp) & (1 << 15)){ for (unsigned int irow = 0; irow < 164; irow++){ - for (unsigned int icol = 2*icolp; icol < 2*(icolp+1); icol++) { - int nToT = 100; - Identifier idpix = m_pixelIdMapping->getPixelId(modid,ichip,irow,icol); + for (unsigned int icol = 2*icolp; icol < 2*(icolp+1); icol++) { + int nToT = 100; + Identifier idpix = m_pixelIdMapping->getPixelId(modid,ichip,irow,icol); Pixel1RawData *p_rdo= new Pixel1RawData(idpix, nToT, 0, 0, 0 ); coll->push_back(p_rdo); ATH_MSG_DEBUG ("RDO for SPM = ? " <<","<<ichip<<","<<icol<<","<<irow<<","<<idpix); - } + } } - } + } } } } else{ if(moduleMap->chipStatus(ichip) & (1 << 15)){ for (unsigned int irow = 0; irow < 164; irow++){ - for (unsigned int icol = 0; icol < moduleMap->columnsPerChip(); icol++){ - int nToT = 100; - Identifier idpix = m_pixelIdMapping->getPixelId(modid,ichip,irow,icol); + for (unsigned int icol = 0; icol < moduleMap->columnsPerChip(); icol++){ + int nToT = 100; + Identifier idpix = m_pixelIdMapping->getPixelId(modid,ichip,irow,icol); Pixel1RawData *p_rdo= new Pixel1RawData(idpix, nToT, 0, 0, 0 ); coll->push_back(p_rdo); ATH_MSG_DEBUG ("RDO for SPM = ? " <<","<<ichip<<","<<icol<<","<<irow<<","<<idpix); } } } - } - } - } + } + } + } } - m_rdoContainerSPM->addCollection( coll, coll->identifyHash() ); + m_rdoContainerSPM->addCollection(coll,coll->identifyHash()); } // initialize random generator -StatusCode PixelDigitizationTool::initRandom() -{ +StatusCode PixelDigitizationTool::initRandom() { - // - // get the Rndmsvc - // - if ( m_rndmSvc.retrieve().isFailure() ) { - ATH_MSG_ERROR ( " Can't get RndmSvc " ); - return StatusCode::FAILURE; - } else { ATH_MSG_DEBUG ( "Retrieved RndmSvc" ); - - } - // - // get the PixelDigitizationTool random stream - // - ATH_MSG_DEBUG ( "Getting random number engine : <" << m_rndmEngineName << ">" ); + CHECK(m_rndmSvc.retrieve()); m_rndmEngine = m_rndmSvc->GetEngine(m_rndmEngineName); - if (m_rndmEngine==0) { - ATH_MSG_ERROR ( "Could not find RndmEngine : " << 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 ); } - // + else { + ATH_MSG_DEBUG("Found RndmEngine : " << m_rndmEngineName); + } + return StatusCode::SUCCESS; } // initialize services -StatusCode PixelDigitizationTool::initServices() -{ - StatusCode result; - if (!m_mergeSvc.retrieve().isSuccess()) { - ATH_MSG_ERROR("Could not find PileUpMergeSvc" ); - return StatusCode::FAILURE; - } - if (!m_rndmSvc.retrieve().isSuccess()) { - ATH_MSG_ERROR("Could not find given RndmSvc" ); - return StatusCode::FAILURE; - } - if (!m_TimeSvc.retrieve().isSuccess()) { - ATH_MSG_ERROR("Could not find given TimeSvc" ); - return StatusCode::FAILURE; - } - if (!m_CalibSvc.retrieve().isSuccess()) { - ATH_MSG_ERROR("Could not find given CalibSvc" ); - return StatusCode::FAILURE; - } +StatusCode PixelDigitizationTool::initServices() { - if ( !m_offlineCalibSvc.empty() ) { - StatusCode sc = m_offlineCalibSvc.retrieve(); - if (sc.isFailure() || !m_offlineCalibSvc ) { - ATH_MSG_ERROR( m_offlineCalibSvc.type() << " not found! "); - return StatusCode::RECOVERABLE; - } - else{ - ATH_MSG_INFO ( "Retrieved tool " << m_offlineCalibSvc.type() ); - } + CHECK(m_mergeSvc.retrieve()); + + CHECK(m_TimeSvc.retrieve()); + + CHECK(m_pixelCalibSvc.retrieve()); + + CHECK(m_pixelConditionsSvc.retrieve()); + + if (!m_offlineCalibSvc.empty()) { + CHECK(m_offlineCalibSvc.retrieve()); + ATH_MSG_INFO("Retrieved tool " << m_offlineCalibSvc.type()); } - - // + // get SpecialPixelMapSvc - // - if (m_CalibSvc->usePixMapCDB()) { - if ( ! m_specialPixelMapSvc.retrieve().isSuccess() ) { - ATH_MSG_FATAL ( "Unable to retrieve SpecialPixelMapSvc" ); - return StatusCode::FAILURE; - } - ATH_MSG_DEBUG ( "Retrieved SpecialPixelMapSvc" ); - // - result = detStore()->regFcn(&ISpecialPixelMapSvc::IOVCallBack, - dynamic_cast<ISpecialPixelMapSvc*>(m_specialPixelMapSvc.operator->()), - &PixelDigitizationTool::specialPixelMapCallBack, - this); - if ( ! result.isSuccess() ) { - ATH_MSG_FATAL ( "Unable to register call back for special pixel map" ); - return StatusCode::FAILURE; - } - } + if (!m_pixelConditionsSvc.empty()) { + CHECK(m_specialPixelMapSvc.retrieve()); + ATH_MSG_DEBUG("Retrieved SpecialPixelMapSvc"); + + CHECK(detStore()->regFcn(&ISpecialPixelMapSvc::IOVCallBack,dynamic_cast<ISpecialPixelMapSvc*>(m_specialPixelMapSvc.operator->()),&PixelDigitizationTool::specialPixelMapCallBack,this)); + ATH_MSG_DEBUG("IOV register called back for special pixel map"); + } - return result; + return StatusCode::SUCCESS; } // initialize tools -StatusCode PixelDigitizationTool::initTools() -{ - StatusCode result; +StatusCode PixelDigitizationTool::initTools() { - result = m_SurfaceChargesTool.retrieve(); - if ( result != StatusCode::SUCCESS ) { - ATH_MSG_ERROR ( "Can't get tool SurfaceChargesTool" ); - return result; - } else { - ATH_MSG_DEBUG ( "Tool SurfaceChargesTool retrieved" ); - } + CHECK(m_diodesProcsTool.retrieve()); + for (unsigned int itool=0; itool<m_diodesProcsTool.size(); itool++) { + ATH_MSG_INFO("Tool " << m_diodesProcsTool[itool].name() << " retrieved"); - if (m_enableNoise) { - result = m_pixelNoisyCellGenerator.retrieve(); - if ( result != StatusCode::SUCCESS ) { - ATH_MSG_ERROR ( "Can't get tool PixelNoisyCellGenerator" ); - return result; - } else { - ATH_MSG_DEBUG ( "Tool PixelNoisyCellGenerator retrieved" ); + // this is a bit ugly... + if (m_diodesProcsTool[itool].name()=="PixelNoisyCellGenerator") { + PixelNoisyCellGenerator *pixelNoisyCellGenerator = dynamic_cast<PixelNoisyCellGenerator*>(m_diodesProcsTool[itool].operator->()); + if (pixelNoisyCellGenerator) { + pixelNoisyCellGenerator->setNoisyPixel(&m_noisyPixel); + } } - } - - result = m_pixelGangedMerger.retrieve(); - if ( result != StatusCode::SUCCESS ) { - ATH_MSG_ERROR ( "Can't get tool PixelGangedMerger" ); - return result; - } else { - ATH_MSG_DEBUG ( "Tool PixelGangedMerger retrieved" ); - } - - if (m_enableSpecialPixels) { - result = m_specialPixelGenerator.retrieve(); - if ( result != StatusCode::SUCCESS ) { - ATH_MSG_ERROR ( "Can't get tool SpecialPixelGenerator" ); - return result; - } else { - ATH_MSG_DEBUG ( "Tool SpecialPixelGenerator retrieved" ); + if (m_diodesProcsTool[itool].name()=="SpecialPixelGenerator") { + m_specialPixelGenerator = dynamic_cast<SpecialPixelGenerator*>(m_diodesProcsTool[itool].operator->()); + if (m_specialPixelGenerator) { + m_specialPixelGenerator->setnPixTot(m_detID->pixel_hash_max()); + m_specialPixelGenerator->setnModTot(m_detID->wafer_hash_max()); + } } - } - result = m_pixelChargeSmearer.retrieve(); - if ( result != StatusCode::SUCCESS ) { - ATH_MSG_ERROR ( "Can't get tool PixelChargeSmearer" ); - return result; - } else { - ATH_MSG_DEBUG ( "Tool PixelChargeSmearer retrieved" ); } - result = m_pixelDiodeCrossTalkGenerator.retrieve(); - if ( result != StatusCode::SUCCESS ) { - ATH_MSG_ERROR ( "Can't get tool PixelDiodeCrossTalkGenerator" ); - return result; - } else { - ATH_MSG_DEBUG ( "Tool PixelDiodeCrossTalkGenerator retrieved" ); - } + CHECK(m_SurfaceChargesTool.retrieve()); + ATH_MSG_DEBUG("Tool SurfaceChargesTool retrieved"); - result = m_pixelCellDiscriminator.retrieve(); - if ( result != StatusCode::SUCCESS ) { - ATH_MSG_ERROR ( "Can't get tool PixelCellDiscriminator" ); - return result; - } else { - ATH_MSG_DEBUG ( "Tool PixelCellDiscriminator retrieved" ); - } + return StatusCode::SUCCESS; +} - // Only used if m_doRDOforSPM true. - if (m_doRDOforSPM) { - result = m_pixelIdMapping.retrieve(); - if ( result != StatusCode::SUCCESS ) { - ATH_MSG_ERROR ( "Can't get tool PixelIdMapping" ); - return result; - } else { - ATH_MSG_DEBUG ( "Tool PixelIdMapping retrieved" ); - } - } +// initialize managers etc +StatusCode PixelDigitizationTool::initExtras() { - result = m_pixelRandomDisabledCellGenerator.retrieve(); - if ( result != StatusCode::SUCCESS ) { - ATH_MSG_ERROR ( "Can't get tool PixelRandomDisabledCellGenerator" ); - return result; - } else { - ATH_MSG_DEBUG ( "Tool PixelRandomDisabledCellGenerator retrieved" ); + // Only used if m_doRDOforSPM true. + if (m_doRDOforSPM) { + CHECK(m_pixelIdMapping.retrieve()); + ATH_MSG_DEBUG("Tool PixelIdMapping retrieved"); } - return result; -} -// initialize managers etc -StatusCode PixelDigitizationTool::initExtras() -{ - // - // get the Pixel detector manager - // + // Get the Pixel Detector Manager const PixelDetectorManager *pixmgr; - if ( ! detStore()->retrieve(pixmgr, m_managerName).isSuccess() ) { - ATH_MSG_ERROR ( "Could not locate PixelDetectorManager: <" << m_managerName << ">" ); - return StatusCode::FAILURE; - } - ATH_MSG_DEBUG ( "PixelDetectorManager: <" << m_managerName << "> retrieved" ); + CHECK(detStore()->retrieve(pixmgr,m_managerName)); + ATH_MSG_DEBUG("PixelDetectorManager: <" << m_managerName << "> retrieved"); setManager(pixmgr); - // - // get PixelID - // - if ( detStore()->retrieve(m_detID,"PixelID").isFailure() ) { - // if this fails, it's probably a bug -> FATAL! - ATH_MSG_FATAL ( "Could not get Pixel ID helper" ); - return StatusCode::FAILURE; - } - ATH_MSG_DEBUG ( "Pixel ID helper retrieved" ); - store(m_detID); + + CHECK(detStore()->retrieve(m_detID,"PixelID")); + ATH_MSG_DEBUG("Pixel ID helper retrieved"); return StatusCode::SUCCESS; } @@ -933,18 +735,15 @@ StatusCode PixelDigitizationTool::createAndStoreRDO(SiChargedDiodeCollection *ch { // Create the RDO collection PixelRDO_Collection *RDOColl=this->createRDO(chDiodeCollection); - - - //StatusCode sc=m_storeGate->record(RDOColl,key_rdo); - StatusCode sc=m_rdoContainer->addCollection(RDOColl,RDOColl->identifyHash()); - if (sc.isFailure()) { - ATH_MSG_FATAL ( "Pixel RDOs could not be added to container !" - ); + + if (m_rdoContainer->addCollection(RDOColl,RDOColl->identifyHash()).isFailure()) { + ATH_MSG_FATAL("Pixel RDOs could not be added to container !"); return StatusCode::FAILURE; - } else { - ATH_MSG_DEBUG ( "Pixel RDOs '" << RDOColl->identifyHash() << "' added to container" - ); } + else { + ATH_MSG_DEBUG("Pixel RDOs '" << RDOColl->identifyHash() << "' added to container"); + } + /* //symlink the collection InDetRawDataCollection<PixelRDORawData> *p_symcoll=0; @@ -966,10 +765,10 @@ PixelDigitizationTool::createRDO(SiChargedDiodeCollection *collection) // // Create the collection // - + Identifier collID = collection->identify(); ATH_MSG_DEBUG ( "PixelDigitizationTool::createRDO() collection : " - << m_detID->show_to_string( collID ) ); + << m_detID->show_to_string( collID ) ); IdentifierHash idhash = collection->identifyHash(); PixelRDO_Collection* PixelRDOColl = new PixelRDO_Collection(idhash); PixelRDOColl->setIdentifier(collID ); @@ -977,32 +776,14 @@ PixelDigitizationTool::createRDO(SiChargedDiodeCollection *collection) // // Determine the Pixel Region (IBL, BL, L1, L2, EC or DBM), to be used for latency, ToT cut and duplication: // - + const PixelID* pixelId = dynamic_cast<const PixelID *>(collection->element()->getIdHelper()); int barrel_ec = pixelId->barrel_ec(collection->element()->identify()); - int layer_disk = pixelId->layer_disk(collection->element()->identify()); - int PixRegion = -1; - int ishift = 0; - if ( barrel_ec == 0 ) { - if ( m_doITk ) { - // PixRegion = 0, 1, 2, 3 for the first four pixel barrel - // layers, 6 for the fifth pixel barrel layer and - // higher (4 and 5 already taken) - PixRegion = layer_disk; - if ( layer_disk >= 4 ) PixRegion = 6; - } - else { - // PixRegion = 0, 1, 2, or 3 for IBL, BL, L1 or L2 - if ( m_IBLabsent ) ishift = 1; - PixRegion = layer_disk + ishift; - } - } - if ( barrel_ec == 2 || barrel_ec == -2 ) PixRegion = 4; // 4 for disks - if ( barrel_ec == 4 || barrel_ec == -4 ) PixRegion = 5; // 5 for DBM - if ( PixRegion < 0 || (!m_doITk && PixRegion > 5) || PixRegion > 6 ) { - ATH_MSG_ERROR ( "PixelDigitizationTool::createRDO() collection : " << " bad Barrel/EC or Layer/Disk " ); - } + int layerIndex = pixelId->layer_disk(collection->element()->identify()); + if (layerIndex>=4) { layerIndex=6; } // ITk 5th layer + if (abs(barrel_ec)==2) { layerIndex=4; } // disks + if (abs(barrel_ec)==4) { layerIndex=5; } // DBM const PixelModuleDesign *p_design = dynamic_cast<const PixelModuleDesign*>(&(collection->element())->design()); std::vector<Pixel1RawData*> p_rdo_small_fei4; @@ -1013,7 +794,7 @@ PixelDigitizationTool::createRDO(SiChargedDiodeCollection *collection) const int maxRow = p_design->rowsPerCircuit(); const int maxCol = p_design->columnsPerCircuit(); std::vector < std::vector < int > > FEI4Map ( maxRow, std::vector < int > ( maxCol) ); - ATH_MSG_DEBUG ( "PixRegion = " << PixRegion << " MaxRow = " << maxRow << " MaxCol = " << maxCol); + ATH_MSG_DEBUG ( "layerIndex = " << layerIndex << " MaxRow = " << maxRow << " MaxCol = " << maxCol); m_overflowIBLToT = (!m_offlineCalibSvc.empty() ? m_offlineCalibSvc->getIBLToToverflow() : 16); ATH_MSG_DEBUG ( " ***** Overflow for IBL = " << m_overflowIBLToT ); @@ -1059,95 +840,95 @@ PixelDigitizationTool::createRDO(SiChargedDiodeCollection *collection) // take the integer value to get the actual observed ToT // minimum ToT = 1 // - int nToT = m_CalibSvc->getTot( diodeID, (*i_chargedDiode).second.charge() ); + // old method: int nToT = m_CalibSvc->getTot( diodeID, (*i_chargedDiode).second.charge() ); + + double tot = m_pixelCalibSvc->getTotMean(diodeID,(*i_chargedDiode).second.charge()); + double totsig = m_pixelCalibSvc->getTotRes(diodeID,tot); + int nToT = static_cast<int>(CLHEP::RandGaussZiggurat::shoot(m_rndmEngine,tot,totsig)); + if (nToT<1) { nToT=1; } + // Fix for IBL, it sets the most probable value for a mip to 8. // Need to keep it hardcoded for a cache (no header change) - // but when moving to full release, one has to accomodate additional + // but when moving to full release, one has to accomodate additional // properties and a proper function. // - HitDiscriminator configuration // - Referenca value (a mip) // - ToT for that reference value - - if (getReadoutTech(collection->element()) == FEI4) { + + if (p_design->getReadoutTechnology()==PixelModuleDesign::FEI4) { const PixelID* pixelId = dynamic_cast<const PixelID *>(collection->element()->getIdHelper()); - if (pixelId->is_dbm(collection->element()->identify())) { - nToT = 8*((*i_chargedDiode).second.charge() - 1200. )/(8000. - 1200.); - } + if (pixelId->is_dbm(collection->element()->identify())) { + nToT = 8*((*i_chargedDiode).second.charge() - 1200. )/(8000. - 1200.); + } if ( nToT<=0 ) nToT=1; - else if ( nToT == 2 && m_overflowIBLToT == 16) nToT = 1; - else if ( nToT >= m_overflowIBLToT ) nToT = m_overflowIBLToT; + else if ( nToT == 2 && m_overflowIBLToT == 16) nToT = 1; + else if ( nToT >= m_overflowIBLToT ) nToT = m_overflowIBLToT; } int flag = (*i_chargedDiode).second.flag(); int bunch = (flag >> 8) & 0xff; // - ATH_MSG_DEBUG ( "RDO: " - << (*i_chargedDiode).second.charge() << " " - << nToT << " " - << bunch << " " - << flag << " " - << PixRegion << " " - ); - if (getReadoutTech(collection->element()) == FEI3) { - if ( nToT > m_maxToT.at(PixRegion) ) continue; // skip hits with ToT exceeding LVL1 Latency - if ( nToT < m_minToT.at(PixRegion) ) continue; // skip hits with ToT less than ToT cut + ATH_MSG_DEBUG("RDO: " << (*i_chargedDiode).second.charge() << " " << nToT << " " << bunch << " " << flag << " " << layerIndex); + + if (p_design->getReadoutTechnology()==PixelModuleDesign::FEI3) { + if ( nToT > m_maxToT.at(layerIndex) ) continue; // skip hits with ToT exceeding LVL1 Latency + if ( nToT < m_minToT.at(layerIndex) ) continue; // skip hits with ToT less than ToT cut } + // float kToT= m_totparA + m_totparB / ( m_totparC + (*i_chargedDiode).second.charge() ) ; - // float kToTs = CLHEP::RandGaussZiggurat::shoot( m_rndmEngine, kToT , m_totparP1 + m_totparP2 * kToT ) ; + // float kToTs = CLHEP::RandGaussZiggurat::shoot( m_rndmEngine, kToT , m_totparP1 + m_totparP2 * kToT ) ; // int nToT = static_cast<int>(kToTs) ; // if( nToT < 1 ) nToT=1; // - // Fill the RDO word as in PixelRDO_Cnv. + // Fill the RDO word as in PixelRDO_Cnv. // This incomprehensible code is to fill the RDO as they do in the // zebra converter. // (code from PixelRDO_Cnv.cxx, some comments removed) // - + SiReadoutCellId cellId=(*i_chargedDiode).second.getReadoutCell(); const Identifier id_readout = collection->element()->identifierFromCellId(cellId); int iirow = cellId.phiIndex(); int iicol = cellId.etaIndex(); - if ( !m_doITk && PixRegion == 0 && iicol >= maxCol ) iicol = iicol - maxCol; // FEI4 copy mechanism works per FE. - - + if (!m_doITk && p_design->getReadoutTechnology()==PixelModuleDesign::FEI4 && iicol>=maxCol) { iicol=iicol-maxCol; } // FEI4 copy mechanism works per FE. + // //if (correct_id_readout!=diodeID) { // ATH_MSG_DEBUG ( "correct_readout_id != diodeID" ); // } // Create hit only if bunch within the acceptance (not for IBL and DBM): - - if ( m_doITk || PixRegion != 0 ) { - if ( bunch >= 0 && bunch < m_TimeSvc->getTimeBCN()) { - Pixel1RawData *p_rdo= new Pixel1RawData(id_readout, nToT, bunch, 0, bunch ); - PixelRDOColl->push_back(p_rdo); + + if (m_doITk || p_design->getReadoutTechnology()==PixelModuleDesign::FEI3 || layerIndex==5) { + if (bunch >= 0 && bunch < m_TimeSvc->getTimeBCN()) { + Pixel1RawData *p_rdo= new Pixel1RawData(id_readout, nToT, bunch, 0, bunch ); + PixelRDOColl->push_back(p_rdo); } } else { // IBL: if big hit, create RDO and record it. If small hit, create RDO and store it in a vector: - + if ( nToT > maxFEI4SmallHit ) { if ( bunch >= 0 && bunch < m_TimeSvc->getTimeBCN()) { - Pixel1RawData *p_rdo= new Pixel1RawData(id_readout, nToT, bunch, 0, bunch ); - PixelRDOColl->push_back(p_rdo); - FEI4Map[iirow][iicol] = 2; //Flag for "big hits" - } + Pixel1RawData *p_rdo= new Pixel1RawData(id_readout, nToT, bunch, 0, bunch ); + PixelRDOColl->push_back(p_rdo); + FEI4Map[iirow][iicol] = 2; //Flag for "big hits" + } } else { if ( bunch >= 0 && bunch < m_TimeSvc->getTimeBCN()) { Pixel1RawData *p_rdo= new Pixel1RawData(id_readout, nToT, bunch, 0, bunch ); - p_rdo_small_fei4.push_back(p_rdo); + p_rdo_small_fei4.push_back(p_rdo); row.push_back(iirow); col.push_back(iicol); - nSmallHitsFEI4++; - FEI4Map[iirow][iicol] = 1; //Flag for low hits + nSmallHitsFEI4++; + FEI4Map[iirow][iicol] = 1; //Flag for low hits ATH_MSG_DEBUG ( "Row small = " << iirow << " col small = " << iicol << " ToT = " << nToT << " Bunch = " << bunch << " ismallhits = " << nSmallHitsFEI4); } - } + } } // Duplication mechanism for FEI3 small hits : - - if ( !m_doITk && PixRegion != 0 && PixRegion != 5 ) { - if ( m_applyDupli.at(PixRegion)) { - if ( nToT <= m_maxToTForDupli.at(PixRegion) && bunch > 0 && bunch <= m_TimeSvc->getTimeBCN()) { - Pixel1RawData *p_rdo= new Pixel1RawData(id_readout, nToT, bunch-1, 0, bunch-1 ); + if (!m_doITk && p_design->getReadoutTechnology()==PixelModuleDesign::FEI3) { + if (m_applyDupli.at(layerIndex)) { + if (nToT<=m_maxToTForDupli.at(layerIndex) && bunch>0 && bunch<=m_TimeSvc->getTimeBCN()) { + Pixel1RawData *p_rdo= new Pixel1RawData(id_readout, nToT, bunch-1, 0, bunch-1 ); PixelRDOColl->push_back(p_rdo); } } @@ -1155,11 +936,10 @@ PixelDigitizationTool::createRDO(SiChargedDiodeCollection *collection) } } // Copy mechanism for IBL small hits: - - if ( !m_doITk && PixRegion == 0 && m_applyDupli.at(PixRegion) && nSmallHitsFEI4 > 0 ){ + if ( !m_doITk && p_design->getReadoutTechnology()==PixelModuleDesign::FEI4 && m_applyDupli.at(layerIndex) && nSmallHitsFEI4>0){ bool recorded = false; //First case: Record small hits which are in the same Pixel Digital Region than a big hit: - + for ( int ismall = 0; ismall != nSmallHitsFEI4; ++ismall ) { int rowPDR = row[ismall]/2; int colPDR = col[ismall]/2; @@ -1167,95 +947,33 @@ PixelDigitizationTool::createRDO(SiChargedDiodeCollection *collection) for ( int colBigHit = 2*colPDR; colBigHit != 2*colPDR+2 && colBigHit < maxCol; ++colBigHit ) { ATH_MSG_DEBUG ( "rowBig = " << rowBigHit << " colBig = " << colBigHit << " Map Content = " << FEI4Map[rowBigHit][colBigHit]); if ( FEI4Map[rowBigHit][colBigHit] == 2 && !recorded) { - PixelRDOColl->push_back(p_rdo_small_fei4[ismall]); - recorded = true; - } + PixelRDOColl->push_back(p_rdo_small_fei4[ismall]); + recorded = true; + } } - } + } // Second case: Record small hits which are phi-neighbours with a big hit: - + if ( !recorded && row[ismall] < maxRow - 1 ) { if ( FEI4Map[row[ismall]+1][col[ismall]] == 2 ) { PixelRDOColl->push_back(p_rdo_small_fei4[ismall]); recorded = true; - } + } } if ( !recorded && row[ismall] != 0 ) { if ( FEI4Map[row[ismall]-1][col[ismall]] == 2 ) { PixelRDOColl->push_back(p_rdo_small_fei4[ismall]); recorded = true; - } + } } } - } + } return PixelRDOColl; } ////////////////////////////////////////////////////////////////////////////// - -void PixelDigitizationTool::addCrossTalk() { - // - // Creating diode-level cross-talk generator - // Use from calib cond db: discriminator threshold - // - ATH_MSG_DEBUG ( "creating diode cross-talk generator..." ); - storeTool(&(*m_pixelDiodeCrossTalkGenerator)) ; -} - -void PixelDigitizationTool::addChargeSmearing() { - // Creating a charge smearer - gaussian with amplitude <amp> - //ATH_MSG_DEBUG ( "creating charge smearer with amplitude = " << amp ); - ATH_MSG_DEBUG ( "creating charge smearer"); - storeTool(&(*m_pixelChargeSmearer)) ; -} - -void PixelDigitizationTool::addSpecialPixels() { - // Creating special pixels generator - // Uses special pixel map - if (m_enableSpecialPixels) { - ATH_MSG_DEBUG ( "creating special pixels generator..." ); - storeTool(&(*m_specialPixelGenerator)) ; - } -} - -void PixelDigitizationTool::addRandomDisabled() { - // add random disabling of pixels - // independant of SpecialPixelMap - ATH_MSG_DEBUG ( "creating random disabling generator..." ); - storeTool(&(*m_pixelRandomDisabledCellGenerator)) ; -} - -void PixelDigitizationTool::addNoise() { - // Creating diode-level noise generator - // Use from calib cond db: discriminator threshold + sigma - // The probability for noise is given by RndNoiseProb. - if (m_enableNoise) { - ATH_MSG_DEBUG ( "creating diode noise generator..." ); - storeTool(&(*m_pixelNoisyCellGenerator)) ; - - m_pixelNoisyCellGenerator->setNoisyPixel(&m_noisyPixel); - } -} - -void PixelDigitizationTool::addGangedPixels() { - // - // Create ganged pixels handler - // - ATH_MSG_DEBUG ( "creating ganged pixels generator..." ); - storeTool(&(*m_pixelGangedMerger)) ; -} - - -void PixelDigitizationTool::addDiscriminator() { - // Creating discriminator - // Uses from cond db: threshold and its sigma - ATH_MSG_DEBUG ( "creating discriminator with timewalk..." ); - storeTool(&(*m_pixelCellDiscriminator)) ; -} - - -const DetectorSpecialPixelMap* PixelDigitizationTool::getSpecialPixelMap() const { - return m_specialPixelGenerator->getDetectorMap(); +const DetectorSpecialPixelMap* PixelDigitizationTool::getSpecialPixelMap() const { + return m_specialPixelGenerator->getDetectorMap(); } @@ -1283,7 +1001,7 @@ void PixelDigitizationTool::setNextUpdate() { } if (m_eventNextUpdate>0) { ATH_MSG_DEBUG ( "next special pixel map update scheduled for event counter = " << m_eventNextUpdate - << " - current counter = " << m_eventCounter ); + << " - current counter = " << m_eventCounter ); } else { ATH_MSG_DEBUG ( "no more special pixel map updates!" ); } @@ -1297,10 +1015,10 @@ StatusCode PixelDigitizationTool::specialPixelMapCallBack(IOVSVC_CALLBACK_ARGS_P if ( !sc.isSuccess() ) { ATH_MSG_DEBUG ( " Unable to retrieve special pixel map " ); } - // + // // Clear noisy pixel map: // - m_noisyPixel.clear(); + m_noisyPixel.clear(); // // Count number of noisy pixels in special pixel map and keep their ID in m_noisyPixel map: // @@ -1312,14 +1030,15 @@ StatusCode PixelDigitizationTool::specialPixelMapCallBack(IOVSVC_CALLBACK_ARGS_P ATH_MSG_DEBUG ( " numNoisy = " << numNoisy ); std::vector<unsigned int> noisypixel; IdentifierHash moduleHash = i; - const ModuleSpecialPixelMap* moduleMap = m_specialPixelMap->module(moduleHash); + const ModuleSpecialPixelMap* moduleMap = m_specialPixelMap->module(moduleHash); if (moduleMap == 0) { ATH_MSG_DEBUG ( "BUG TRAP - special modulemap ptr == 0!!!" - << " for module " - << moduleHash - ); + << " for module " + << moduleHash + ); return StatusCode::FAILURE; } + for(ModuleSpecialPixelMap::const_iterator IterSpe = moduleMap->begin(); IterSpe!=moduleMap->end(); IterSpe++){ unsigned int pixelID; pixelID = IterSpe->first; @@ -1329,7 +1048,7 @@ StatusCode PixelDigitizationTool::specialPixelMapCallBack(IOVSVC_CALLBACK_ARGS_P numNoisy++; ATH_MSG_DEBUG ( " Noisy pixel number " << numNoisy << " Pixel ID = " << pixelID ); } - } + } } // // Count noisy pixels in special regions (special chips or special column pairs) @@ -1345,9 +1064,9 @@ StatusCode PixelDigitizationTool::specialPixelMapCallBack(IOVSVC_CALLBACK_ARGS_P noisypixel.push_back(moduleMap->encodePixelID(ichip,icol,irow)); numNoisy++; ATH_MSG_DEBUG ( " Noisy pixel number " << numNoisy << " Pixel ID = " << moduleMap->encodePixelID(ichip,icol,irow) ); - } + } } - } + } } } } @@ -1366,15 +1085,16 @@ StatusCode PixelDigitizationTool::specialPixelMapCallBack(IOVSVC_CALLBACK_ARGS_P } ATH_MSG_DEBUG ( " Number of noisy Pixels = " << numNoisy ); if (numNoisy > 0){ - m_noisyPixel.insert(std::pair<unsigned int,std::vector<unsigned int> >(i,noisypixel)); + m_noisyPixel.insert(std::pair<unsigned int,std::vector<unsigned int> >(i,noisypixel)); ATH_MSG_DEBUG ( "Module = " << i << " Noisy pixels = " << m_noisyPixel.find(i)->second ); - noisypixel.clear(); + noisypixel.clear(); } else { ATH_MSG_DEBUG ( "No noisy pixels in module " << i << " Size = " << noisypixel.size() ); - } + } } + return sc; -} +} //---------------------------------------------------------------------- @@ -1386,17 +1106,16 @@ StatusCode PixelDigitizationTool::prepareEvent(unsigned int) { ///////////////////////////////////////////////// // update special pixel map ///////////////////////////////////////////////// - if (m_enableSpecialPixels) { - if (!m_CalibSvc->usePixMapCDB()) { - if (doUpdate()) { - ATH_MSG_DEBUG ( "will update generated special pixel map this event" ); - m_specialPixelGenerator->setUpdate(); // set update flag - } - setNextUpdate(); // set next event for update + if (m_pixelConditionsSvc.empty()) { + if (doUpdate()) { + ATH_MSG_DEBUG ( "will update generated special pixel map this event" ); + m_specialPixelGenerator->setUpdate(); // set update flag } - m_specialPixelGenerator->updatePixelMap(); + setNextUpdate(); // set next event for update } + m_specialPixelGenerator->updatePixelMap(); + //Create Output Containers ATH_MSG_DEBUG("Going to create output containers"); if (createOutputContainers().isFailure()) return StatusCode::FAILURE; @@ -1407,8 +1126,8 @@ StatusCode PixelDigitizationTool::prepareEvent(unsigned int) { if ( StatusCode::SUCCESS == evtStore()->retrieve(m_ComTime,"ComTime")) { m_time_y_eq_zero = m_ComTime->getTime() ; ATH_MSG_DEBUG ( "Found tool for cosmic/commissioning timing: ComTime" ); - - } else { + + } else { ATH_MSG_WARNING ( "Did not find tool needed for cosmic/commissioning timing: ComTime" ); } } @@ -1418,8 +1137,8 @@ StatusCode PixelDigitizationTool::prepareEvent(unsigned int) { m_processedElements.clear(); m_processedElements.resize(m_detID->wafer_hash_max(),false); - m_thpcsi = new TimedHitCollection<SiHit>(); - chargedDiodes = new SiChargedDiodeCollection; + m_thpcsi = new TimedHitCollection<SiHit>(); + m_chargedDiodes = new SiChargedDiodeCollection; m_HardScatterSplittingSkipper = false; return StatusCode::SUCCESS; } @@ -1429,17 +1148,17 @@ StatusCode PixelDigitizationTool::prepareEvent(unsigned int) { //---------------------------------------------------------------------- StatusCode PixelDigitizationTool::mergeEvent() { ATH_MSG_VERBOSE("PixelDigitizationTool::mergeEvent()"); - if (m_enableHits) digitizeAllHits(); - delete chargedDiodes; - + if (m_enableHits) digitizeAllHits(); + delete m_chargedDiodes; + digitizeNonHits(); createRDOforSPM(); // increment event counter (for simulated IOV) m_eventCounter++; for (std::vector<SiHitCollection*>::iterator it = hitCollPtrs.begin();it!=hitCollPtrs.end();it++) { - (*it)->Clear(); - delete(*it); + (*it)->Clear(); + delete(*it); } hitCollPtrs.clear(); @@ -1450,11 +1169,10 @@ StatusCode PixelDigitizationTool::mergeEvent() { //---------------------------------------------------------------------- // ProcessBunchXing method: //---------------------------------------------------------------------- - StatusCode PixelDigitizationTool::processBunchXing(int bunchXing, SubEventIterator bSubEvents, SubEventIterator eSubEvents) { - ATH_MSG_DEBUG("PixelDigitizationTool::processBunchXing() " << bunchXing); + ATH_MSG_VERBOSE("PixelDigitizationTool::processBunchXing() " << bunchXing); //decide if this event will be processed depending on HardScatterSplittingMode & bunchXing if (m_HardScatterSplittingMode == 2 && !m_HardScatterSplittingSkipper ) { m_HardScatterSplittingSkipper = true; return StatusCode::SUCCESS; } if (m_HardScatterSplittingMode == 1 && m_HardScatterSplittingSkipper ) { return StatusCode::SUCCESS; } @@ -1467,15 +1185,14 @@ StatusCode PixelDigitizationTool::processBunchXing(int bunchXing, << " bunch crossing : " << bunchXing << " time offset : " << iEvt->time() << " event number : " << iEvt->ptr()->eventNumber() - << " run number : " << iEvt->ptr()->runNumber() - ); + << " run number : " << iEvt->ptr()->runNumber()); - const SiHitCollection* seHitColl(0); + const SiHitCollection* seHitColl(0); if (!seStore.retrieve(seHitColl,m_inputObjectName).isSuccess()) { msg(MSG::ERROR) << "SubEvent Pixel SiHitCollection not found in StoreGate " << seStore.name() << endreq; return StatusCode::FAILURE; - } - ATH_MSG_DEBUG("SiHitCollection found with " << seHitColl->size() << " hits"); + } + ATH_MSG_DEBUG("SiHitCollection found with " << seHitColl->size() << " hits"); PileUpTimeEventIndex timeIndex(iEvt->time(),iEvt->index()); SiHitCollection *hitCollPtr = new SiHitCollection(*seHitColl); m_thpcsi->insert(timeIndex,hitCollPtr); @@ -1484,13 +1201,3 @@ StatusCode PixelDigitizationTool::processBunchXing(int bunchXing, return StatusCode::SUCCESS; } - -PixelDigitizationTool::ReadoutTech PixelDigitizationTool::getReadoutTech(const InDetDD::SiDetectorElement *module) { - if(m_doITk) return RD53; - - const PixelID* pixelId = static_cast<const PixelID *>(module->getIdHelper()); - if ((!m_IBLabsent && pixelId->is_blayer(module->identify())) || - pixelId->barrel_ec(module->identify())==4 || - pixelId->barrel_ec(module->identify())==-4) return FEI4; - return FEI3; -} diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitizationTool.h b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitizationTool.h index 2f8dfce509266341c233da1c3fa796e012f6916f..afdb205c8cfa2aecafed2d52dfac19de4ecabc4d 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitizationTool.h +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitizationTool.h @@ -28,7 +28,6 @@ // -LowTOTduplication ToT value below which the hit is duplicated // -LVL1Latency LVL1 latency (max possible ToT) // -RndmEngine Random engine name -// -CosmicsRun Cosmics run // -UseComTime Use ComTime for timing // -UsePixCondSum Use PixelConditionsSummarySvc // -EnableHits Enable hits @@ -107,26 +106,25 @@ #include "InDetRawData/InDetRawDataCLASS_DEF.h" #include "GaudiKernel/ToolHandle.h" #include "GaudiKernel/ServiceHandle.h" -#include "PixelConditionsServices/IPixelCalibSvc.h" -#include "PixelConditionsServices/ISpecialPixelMapSvc.h" -#include "InDetConditionsSummaryService/IInDetConditionsSvc.h" + #include "SiPropertiesSvc/ISiPropertiesSvc.h" #include "PixelConditionsTools/IModuleDistortionsTool.h" #include "AthenaKernel/IAtRndmGenSvc.h" #include "PixelCabling/IPixelCablingSvc.h" -#include "PixelGeoModel/IBLParameterSvc.h" -// IAB Note no EventInfo includes. Why? -#include "xAODEventInfo/EventInfo.h" // NEW EDM -#include "xAODEventInfo/EventAuxInfo.h" // NEW EDM +#include "StoreGate/WriteHandle.h" +// Conditions +#include "PixelConditionsServices/IPixelCalibSvc.h" +#include "PixelConditionsServices/ISpecialPixelMapSvc.h" +#include "InDetConditionsSummaryService/IInDetConditionsSvc.h" +#include "PixelConditionsServices/IPixelOfflineCalibSvc.h" class PixelID; class SiChargedDiodeCollection; class ISiChargedDiodesProcessorTool; class InDetSimDataCollection; class DetectorSpecialPixelMap; -class PixelNoisyCellGenerator; class PixelGangedMerger; class SpecialPixelGenerator; class PixelCellDiscriminator; @@ -134,20 +132,20 @@ class PixelDiodeCrossTalkGenerator; class PixelChargeSmearer; class SurfaceChargesTool; class TimeSvc; -class CalibSvc; class PixelRandomDisabledCellGenerator; class ISiChargedDiodeCollection; class SurfaceChargesTool; class IPixelOfflineCalibSvc; +class IInDetConditionsSvc; namespace CLHEP { - class HepRandomEngine; + class HepRandomEngine; } namespace InDetDD{ - class SiDetectorElement; - class SiDetectorManager; + class SiDetectorElement; + class SiDetectorManager; } static const InterfaceID IID_IPixelDigitizationTool ("PixelDigitizationTool",1,0); @@ -155,224 +153,185 @@ static const InterfaceID IID_IPixelDigitizationTool ("PixelDigitizationTool",1,0 class PixelDigitizationTool : public PileUpToolBase { public: - static const InterfaceID& interfaceID(); + static const InterfaceID& interfaceID(); + PixelDigitizationTool(const std::string &type, const std::string &name, const IInterface *pIID); - virtual StatusCode prepareEvent(unsigned int) override final; - virtual StatusCode mergeEvent() override final; - /** Constructor with parameters */ - PixelDigitizationTool(const std::string &type, - const std::string &name, - const IInterface *pIID); + virtual StatusCode initialize(); + virtual StatusCode processAllSubEvents(); + virtual StatusCode finalize(); - virtual StatusCode initialize() override final; + StatusCode prepareEvent(unsigned int); + StatusCode mergeEvent(); + StatusCode createAndStoreRDO(SiChargedDiodeCollection *c); // create and store RDO for the given collection - virtual StatusCode processAllSubEvents() override final; + PixelRDO_Collection *createRDO(SiChargedDiodeCollection *c); // create RDO from given collection - called by createAndStoreRDO + void createRDOforSPM(); // create RDO with special pixel map - virtual StatusCode finalize() override final; + /** set next update if using simulated IOV */ + void setNextUpdate(); + /** make just one map in the beginning */ + void setIOVonce() { m_IOVFlag = IOVonce; } + /** make a new map for each event */ + void setIOVall() { m_IOVFlag = IOVall; } + /** make a new map at even intervals (EventIOV)*/ + void setIOVstep() { m_IOVFlag = IOVstep; } + /** make a new map at random intervals (flat dist EventIOV) */ + void setIOVrnd() { m_IOVFlag = IOVrnd; } + /** set number of events per update - used if IOVstep or IOVrnd */ + void setEventIOV( unsigned int de ) { m_eventIOV = (de==0 ? 1:de); } - /** create and store RDO for the given collection */ - virtual StatusCode createAndStoreRDO(SiChargedDiodeCollection *c); + /** Accessors: general */ + const DetectorSpecialPixelMap* getSpecialPixelMap() const; + /** TOT evaluation */ - /** create RDO from given collection - called by createAndStoreRDO */ - PixelRDO_Collection *createRDO(SiChargedDiodeCollection *c); + /** Get a string describing the given IOVFlag */ + static std::string IOVstr(unsigned int flag); + virtual StatusCode specialPixelMapCallBack(IOVSVC_CALLBACK_ARGS); - /** create RDO with special pixel map */ - void createRDOforSPM(); + bool doUpdate() const { return (m_eventCounter==m_eventNextUpdate); } - /** set next update if using simulated IOV */ - void setNextUpdate(); - /** make just one map in the beginning */ - void setIOVonce() { m_IOVFlag = IOVonce; } - /** make a new map for each event */ - void setIOVall() { m_IOVFlag = IOVall; } - /** make a new map at even intervals (EventIOV)*/ - void setIOVstep() { m_IOVFlag = IOVstep; } - /** make a new map at random intervals (flat dist EventIOV) */ - void setIOVrnd() { m_IOVFlag = IOVrnd; } - /** set number of events per update - used if IOVstep or IOVrnd */ - void setEventIOV( unsigned int de ) { m_eventIOV = (de==0 ? 1:de); } + virtual StatusCode processBunchXing(int bunchXing, + SubEventIterator bSubEvents, + SubEventIterator eSubEvents + ) override final; - /** Accessors: general */ - const DetectorSpecialPixelMap* getSpecialPixelMap() const; - /** TOT evaluation */ +protected: + std::map<unsigned int,std::vector<unsigned int> > m_noisyPixel; + bool digitizeElement(SiChargedDiodeCollection* theColl ); + void applyProcessorTools(SiChargedDiodeCollection* theColl); + void addSDO(SiChargedDiodeCollection *collection); - /** Get a string describing the given IOVFlag */ - static std::string IOVstr(unsigned int flag); - virtual StatusCode specialPixelMapCallBack(IOVSVC_CALLBACK_ARGS); + void setManager(const InDetDD::SiDetectorManager *p_manager) {m_detManager = p_manager;} - bool doUpdate() const { return (m_eventCounter==m_eventNextUpdate); } - virtual StatusCode processBunchXing(int bunchXing, - SubEventIterator bSubEvents, - SubEventIterator eSubEvents - ) override final; - protected: - std::map<unsigned int,std::vector<unsigned int> > m_noisyPixel; - bool digitizeElement(SiChargedDiodeCollection* theColl ); - void applyProcessorTools(SiChargedDiodeCollection* theColl); - void addSDO(SiChargedDiodeCollection *collection); - //void storeTool(SurfaceChargesTool *p_generator) {m_SurfaceChargesTool = p_generator;} - void storeTool(ISiChargedDiodesProcessorTool *p_processor) {m_diodesProcsTool.push_back(p_processor);} +private: + mutable int m_overflowIBLToT; + ServiceHandle<IPixelOfflineCalibSvc> m_offlineCalibSvc; - void store(const AtlasDetectorID *p_helper) {m_atlasID = p_helper;} - void setManager(const InDetDD::SiDetectorManager *p_manager) {m_detManager = p_manager;} + virtual StatusCode createOutputContainers(); + StatusCode getNextEvent(); + PixelDigitizationTool(); + PixelDigitizationTool(const PixelDigitizationTool&); + PixelDigitizationTool &operator=(const PixelDigitizationTool&); + /*! @enum IOVFlag + * @brief flags simulated IOV to be used + * This is used only when creating random special pixel maps + */ + enum IOVFlag {IOVonce=0, /**< create once, never update */ + IOVall, /**< update every event */ + IOVstep, /**< update every Nth event */ + IOVrnd}; /**< update at random intervals */ -private: - mutable int m_overflowIBLToT; - ServiceHandle<IPixelOfflineCalibSvc> m_offlineCalibSvc; - - virtual StatusCode createOutputContainers(); - StatusCode getNextEvent(); - enum ReadoutTech {FEI3,FEI4,RD53}; //FIXME define this in a common location see ATLASSIM-2644 - ReadoutTech getReadoutTech(const InDetDD::SiDetectorElement *module); - - PixelDigitizationTool(); - PixelDigitizationTool(const PixelDigitizationTool&); - PixelDigitizationTool &operator=(const PixelDigitizationTool&); - - /*! @enum IOVFlag - * @brief flags simulated IOV to be used - * This is used only when creating random special pixel maps - */ - enum IOVFlag {IOVonce=0, /**< create once, never update */ - IOVall, /**< update every event */ - IOVstep, /**< update every Nth event */ - IOVrnd}; /**< update at random intervals */ - - StatusCode initServices(); /**< get all services */ - StatusCode initTools(); /**< init AlgTools (if any) */ - StatusCode initExtras(); /**< initialize managers etc */ - StatusCode initRandom(); /**< initialize random generator */ - - void digitizeAllHits(); /**< digitize all hits */ - void digitizeNonHits(); /**< digitize pixels without hits */ - - StatusCode makeSpecialPixelMap(); - /** Add charge processors */ - void addCrossTalk(); - void addChargeSmearing(); - void addSpecialPixels(); - void addNoise(); - void addGangedPixels(); - void addDiscriminator(); - void addRandomDisabled(); - - std::vector<SiHitCollection*> hitCollPtrs; - - std::string m_managerName; /**< manager name */ - std::string m_rdoCollName; /**< name for RDO collection */ - std::string m_rdoCollNameSPM; /**< name for RDO collection for Special Pixels */ - std::string m_sdoCollName; /**< name for SDO collection */ - - PixelRDO_Container *m_rdoContainer; - PixelRDO_Container *m_rdoContainerSPM; - InDetSimDataCollection *m_simDataColl; - - std::vector<int> m_maxToT; /**< LVL1 latency (max ToT readout from pixels) */ - std::vector<int> m_minToT; /**< ToT cut */ - std::vector<bool> m_applyDupli; /**< Apply hit duplication */ - std::vector<int> m_maxToTForDupli; /**< Maximum ToT for hit duplication */ - bool m_IBLabsent; /**< No IBL */ - bool m_doITk; /**< SLHC job */ - - double m_time_y_eq_zero; - ComTime *m_ComTime; - - int m_HardScatterSplittingMode; /**< Process all SiHit or just those from signal or background events */ - bool m_HardScatterSplittingSkipper; - std::string m_rndmEngineName;/**< name of random engine, actual pointer in SiDigitization */ - - // - // run flags - // - bool m_cosmics; /**< cosmic run */ - bool m_useComTime; /**< use ComTime for timing */ - - // - // Conditions database options - // - /** mostly in PixelDigitConfig.h now */ - unsigned int m_eventIOV; /**< IOV step in event count */ - unsigned int m_IOVFlag; /**< IOV flag */ - - bool m_onlyHitElements; /**< process only elements with hits */ - bool m_enableHits; /**< enable hits */ - bool m_enableNoise; /**< enable generation of noise */ - bool m_enableSpecialPixels; /**< enable special pixels */ - bool m_doRDOforSPM; /**< true if RDOs for special pixel map are to be created */ - - std::vector<bool> m_processedElements; /**< vector of processed elements - set by digitizeHits() */ - - - // std::vector<double> m_noiseShape; /**< Noise shape of pixels */ - - - ToolHandle<PixelNoisyCellGenerator> m_pixelNoisyCellGenerator; - ToolHandle<PixelGangedMerger> m_pixelGangedMerger; - ToolHandle<SpecialPixelGenerator> m_specialPixelGenerator; - ToolHandle<PixelCellDiscriminator> m_pixelCellDiscriminator; - ToolHandle<PixelChargeSmearer> m_pixelChargeSmearer; - ToolHandle<PixelDiodeCrossTalkGenerator> m_pixelDiodeCrossTalkGenerator; - ServiceHandle<IPixelCablingSvc> m_pixelIdMapping; - ToolHandle<PixelRandomDisabledCellGenerator> m_pixelRandomDisabledCellGenerator; - const PixelID *m_detID; /**< the ID helper */ - TimedHitCollection<SiHit> *m_thpcsi; - ToolHandle<SurfaceChargesTool> m_SurfaceChargesTool; - // various services/helpers - - std::list<ISiChargedDiodesProcessorTool *> m_diodesProcsTool; - SiChargedDiodeCollection *chargedDiodes; - IntegerProperty m_vetoThisBarcode; - - protected: + StatusCode initServices(); /**< get all services */ + StatusCode initTools(); /**< init AlgTools (if any) */ + StatusCode initExtras(); /**< initialize managers etc */ + StatusCode initRandom(); /**< initialize random generator */ + + void digitizeAllHits(); /**< digitize all hits */ + void digitizeNonHits(); /**< digitize pixels without hits */ + + StatusCode makeSpecialPixelMap(); + + std::vector<SiHitCollection*> hitCollPtrs; + + std::string m_managerName; /**< manager name */ + + SG::WriteHandle<PixelRDO_Container> m_rdoContainer; + SG::WriteHandle<PixelRDO_Container> m_rdoContainerSPM; + SG::WriteHandle<InDetSimDataCollection> m_simDataColl; + + std::vector<int> m_maxToT; /**< LVL1 latency (max ToT readout from pixels) */ + std::vector<int> m_minToT; /**< ToT cut */ + std::vector<bool> m_applyDupli; /**< Apply hit duplication */ + std::vector<int> m_maxToTForDupli; /**< Maximum ToT for hit duplication */ + bool m_doITk; + + double m_time_y_eq_zero; + ComTime *m_ComTime; + + int m_HardScatterSplittingMode; /**< Process all SiHit or just those from signal or background events */ + bool m_HardScatterSplittingSkipper; + std::string m_rndmEngineName;/**< name of random engine, actual pointer in SiDigitization */ + + // + // run flags + // + bool m_useComTime; /**< use ComTime for timing */ + + // + // Conditions database options + // + /** mostly in PixelDigitConfig.h now */ + unsigned int m_eventIOV; /**< IOV step in event count */ + unsigned int m_IOVFlag; /**< IOV flag */ + + bool m_onlyHitElements; /**< process only elements with hits */ + bool m_enableHits; /**< enable hits */ + bool m_doRDOforSPM; /**< true if RDOs for special pixel map are to be created */ + + std::vector<bool> m_processedElements; /**< vector of processed elements - set by digitizeHits() */ + + ToolHandleArray<ISiChargedDiodesProcessorTool> m_diodesProcsTool; + + SpecialPixelGenerator *m_specialPixelGenerator; + + ServiceHandle<IPixelCablingSvc> m_pixelIdMapping; + ServiceHandle<IPixelCalibSvc> m_pixelCalibSvc; + const PixelID *m_detID; /**< the ID helper */ + + TimedHitCollection<SiHit> *m_thpcsi; + ToolHandle<SurfaceChargesTool> m_SurfaceChargesTool; + + SiChargedDiodeCollection *m_chargedDiodes; + IntegerProperty m_vetoThisBarcode; + +protected: //The following are copied over from SiDigitization.h ServiceHandle <IAtRndmGenSvc> m_rndmSvc; ServiceHandle <PileUpMergeSvc> m_mergeSvc; - ServiceHandle<CalibSvc> m_CalibSvc; ServiceHandle<TimeSvc> m_TimeSvc; - ServiceHandle<IBLParameterSvc> m_IBLParameterSvc; + ServiceHandle<IInDetConditionsSvc> m_pixelConditionsSvc; + CLHEP::HepRandomEngine *m_rndmEngine; - const AtlasDetectorID* m_atlasID; const InDetDD::SiDetectorManager *m_detManager; ServiceHandle< ISpecialPixelMapSvc > m_specialPixelMapSvc; std::string m_specialPixelMapKey; const DetectorSpecialPixelMap* m_specialPixelMap; - unsigned int m_eventCounter; /**< current event counter */ - unsigned int m_eventNextUpdate; /**< next scheduled special pixels map update */ + unsigned int m_eventCounter; /**< current event counter */ + unsigned int m_eventNextUpdate; /**< next scheduled special pixels map update */ - std::string m_inputObjectName; - std::string m_outputObjectName; - bool m_createNoiseSDO; + std::string m_inputObjectName; + bool m_createNoiseSDO; }; inline std::string PixelDigitizationTool::IOVstr(unsigned int flag) { - std::string iovstr; - switch (flag) { - case PixelDigitizationTool::IOVonce: - iovstr = "once"; - break; - case PixelDigitizationTool::IOVall: - iovstr = "every event"; - break; - case PixelDigitizationTool::IOVstep: - iovstr = "every N event"; - break; - case PixelDigitizationTool::IOVrnd: - iovstr = "random events"; - break; - default: - iovstr = "- unkown IOV flag -"; - break; - } - return iovstr; + std::string iovstr; + switch (flag) { + case PixelDigitizationTool::IOVonce: + iovstr = "once"; + break; + case PixelDigitizationTool::IOVall: + iovstr = "every event"; + break; + case PixelDigitizationTool::IOVstep: + iovstr = "every N event"; + break; + case PixelDigitizationTool::IOVrnd: + iovstr = "random events"; + break; + default: + iovstr = "- unkown IOV flag -"; + break; + } + return iovstr; } inline const InterfaceID& PixelDigitizationTool::interfaceID() { diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelGangedMerger.cxx b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelGangedMerger.cxx index 6937050d7d9f1194b17a7f202a8cd269c9356242..af72cd59f2d34c2c2cd1f4e93d90fd36e7870473 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelGangedMerger.cxx +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelGangedMerger.cxx @@ -38,21 +38,11 @@ PixelGangedMerger::~PixelGangedMerger() // Initialize //---------------------------------------------------------------------- StatusCode PixelGangedMerger::initialize() { - StatusCode sc = AthAlgTool::initialize(); - if (sc.isFailure()) { - ATH_MSG_FATAL ( "PixelGangedMerger::initialize() failed"); - return sc ; - } - ATH_MSG_DEBUG ( "PixelGangedMerger::initialize()"); - // - // get PixelID - // - if ( detStore()->retrieve(m_pixelID,"PixelID").isFailure() ) { - // if this fails, it's probably a bug -> FATAL! - ATH_MSG_FATAL ( "Could not get Pixel ID helper" ); - return StatusCode::FAILURE; - } - return sc ; + + CHECK(detStore()->retrieve(m_pixelID,"PixelID")); + ATH_MSG_DEBUG("PixelGangedMerger::initialize()"); + + return StatusCode::SUCCESS; } //---------------------------------------------------------------------- diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelNoisyCellGenerator.cxx b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelNoisyCellGenerator.cxx index be06a8064d1a4726809e0b54b03b5da3a89e052a..ebd5e531fc2f69c50a9c4973b91c203e7ab7cd0d 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelNoisyCellGenerator.cxx +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelNoisyCellGenerator.cxx @@ -20,7 +20,7 @@ #include "AtlasCLHEP_RandomGenerators/RandGaussZiggurat.h" #include "AthenaKernel/IAtRndmGenSvc.h" #include "TimeSvc.h" -#include "CalibSvc.h" +#include "PixelConditionsServices/IPixelCalibSvc.h" #include<fstream> #include<sstream> @@ -38,7 +38,7 @@ const InterfaceID& PixelNoisyCellGenerator::interfaceID( ){ return IID_IPixelNoi PixelNoisyCellGenerator::PixelNoisyCellGenerator(const std::string& type, const std::string& name,const IInterface* parent): AthAlgTool(type,name,parent), m_TimeSvc("TimeSvc",name), - m_CalibSvc("CalibSvc",name), + m_pixelCalibSvc("PixelCalibSvc", name), m_mergeCharge(false), m_pixelID(0), m_rndmSvc("AtDSFMTGenSvc",name), @@ -64,55 +64,29 @@ PixelNoisyCellGenerator::~PixelNoisyCellGenerator() // Initialize //---------------------------------------------------------------------- StatusCode PixelNoisyCellGenerator::initialize() { - StatusCode sc = AthAlgTool::initialize(); - if (sc.isFailure()) { - ATH_MSG_FATAL ( "PixelNoisyCellGenerator::initialize() failed"); - return sc ; - } - - if (m_TimeSvc.retrieve().isFailure()) { - ATH_MSG_ERROR("Can't get TimeSvc"); - return StatusCode::FAILURE; - } - if (m_CalibSvc.retrieve().isFailure()) { - ATH_MSG_ERROR("Can't get CalibSvc"); - return StatusCode::FAILURE; - } - 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 ); - } - + CHECK(m_TimeSvc.retrieve()); - // - // get PixelID - // - if ( detStore()->retrieve(m_pixelID,"PixelID").isFailure() ) { - // if this fails, it's probably a bug -> FATAL! - ATH_MSG_FATAL ( "Could not get Pixel ID helper" ); + 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")); + ATH_MSG_DEBUG("Pixel ID helper retrieved"); + ATH_MSG_DEBUG ( "PixelNoisyCellGenerator::initialize()"); return StatusCode::SUCCESS; - } - - - //---------------------------------------------------------------------- // finalize //---------------------------------------------------------------------- @@ -292,7 +266,8 @@ void PixelNoisyCellGenerator::addCell(SiChargedDiodeCollection &collection,const << circuit << "," << column << "," << row); #endif ATH_MSG_DEBUG ( "addCell 2 circuit = " << circuit << ", column = " << column << ", row = " << row); - if (row>159) row = row+8; // jump over ganged pixels - rowsPerCircuit == 320 above + + if (row>159 && design->rowsPerCircuit() != 336) 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); @@ -325,9 +300,10 @@ void PixelNoisyCellGenerator::addCell(SiChargedDiodeCollection &collection,const ATH_MSG_DEBUG ( "addCell 7b circuit = " << circuit << ", column = " << column << ", row = " << row); // // now, transform the noise ToT to charge. Kind of "inverted calibration"...: - double totA = m_CalibSvc->getCalQ2TotA( noisyID ); - double totE = m_CalibSvc->getCalQ2TotE( noisyID ); - double totC = m_CalibSvc->getCalQ2TotC( noisyID ); + double totA = m_pixelCalibSvc->getQ2TotA(noisyID); + double totE = m_pixelCalibSvc->getQ2TotE(noisyID); + double totC = m_pixelCalibSvc->getQ2TotC(noisyID); + ATH_MSG_DEBUG ( "addCell 7c circuit = " << circuit << ", column = " << column << ", row = " << row); const double chargeShape = (totA*totE - ToT*totC)/(ToT-totA); ATH_MSG_DEBUG ( "addCell 7d circuit = " << circuit << ", column = " << column << ", row = " << row); diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelNoisyCellGenerator.h b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelNoisyCellGenerator.h index e51777a36caaa64c95e488651b6a294f99dc31f8..28bd1115f012effdb9fa68ccf87db370415b07f0 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelNoisyCellGenerator.h +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelNoisyCellGenerator.h @@ -59,7 +59,7 @@ class PixelID; class TimeSvc; -class CalibSvc; +class IPixelCalibSvc; class IAtRndmGenSvc; namespace CLHEP { @@ -100,7 +100,7 @@ private: private: ServiceHandle<TimeSvc> m_TimeSvc; - ServiceHandle<CalibSvc> m_CalibSvc; + 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; diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelRandomDisabledCellGenerator.cxx b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelRandomDisabledCellGenerator.cxx index 464a610adcebf26d38cd48c089289af81512c19c..3e885f6ecfc7fc5aa444bb147f4a243309040480 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelRandomDisabledCellGenerator.cxx +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelRandomDisabledCellGenerator.cxx @@ -47,34 +47,22 @@ PixelRandomDisabledCellGenerator::~PixelRandomDisabledCellGenerator() // Initialize //---------------------------------------------------------------------- StatusCode PixelRandomDisabledCellGenerator::initialize() { - StatusCode sc = AthAlgTool::initialize(); - if (sc.isFailure()) { - ATH_MSG_FATAL ( "PixelRandomDisabledCellGenerator::initialize() failed"); - return sc ; - } - ATH_MSG_DEBUG ( "PixelRandomDisabledCellGenerator::initialize()"); - 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 << ">" ); + + CHECK(m_rndmSvc.retrieve()); 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 ); + 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"); - return sc ; + ATH_MSG_DEBUG("PixelRandomDisabledCellGenerator::initialize()"); + return StatusCode::SUCCESS; } //---------------------------------------------------------------------- diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/SpecialPixelGenerator.cxx b/InnerDetector/InDetDigitization/PixelDigitization/src/SpecialPixelGenerator.cxx index 2455760918ac755a3cbe36085ac9bed2241c0786..e0e41e0963dd0c5fedfe2c6d6083928ce065099d 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/SpecialPixelGenerator.cxx +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/SpecialPixelGenerator.cxx @@ -43,7 +43,6 @@ SpecialPixelGenerator::SpecialPixelGenerator(const std::string& type, const std: m_specialPixelMapSvc("SpecialPixelMapSvc",name), m_rndmSvc("AtDSFMTGenSvc",name), m_rndmEngineName("PixelDigitization"), - m_CalibSvc("CalibSvc",name), m_rndmEngine(0) { declareInterface< SpecialPixelGenerator >( this ); @@ -57,7 +56,6 @@ SpecialPixelGenerator::SpecialPixelGenerator(const std::string& type, const std: declareProperty("PixelConditionsSummarySvc",m_pixelConditionsSummarySvc); declareProperty("RndmSvc", m_rndmSvc, "Random Number Service used in SCT & Pixel digitization" ); declareProperty("RndmEngine", m_rndmEngineName, "Random engine name"); - declareProperty("CalibSvc",m_CalibSvc,"Calib Svc"); } // Destructor: @@ -68,69 +66,33 @@ SpecialPixelGenerator::~SpecialPixelGenerator() // Initialize //---------------------------------------------------------------------- StatusCode SpecialPixelGenerator::initialize() { - StatusCode sc = AthAlgTool::initialize(); - if (sc.isFailure()) { - ATH_MSG_FATAL ( "SpecialPixelGenerator::initialize() failed" ); - return sc ; - } ATH_MSG_DEBUG ( "SpecialPixelGenerator::initialize()" ); - // - // get PixelID - // - if ( detStore()->retrieve(m_pixelID,"PixelID").isFailure() ) { - // if this fails, it's probably a bug -> FATAL! - ATH_MSG_FATAL ( "Could not get Pixel ID helper" ); - return StatusCode::FAILURE; - } + + CHECK(detStore()->retrieve(m_pixelID,"PixelID")); + ATH_MSG_DEBUG("Pixel ID helper retrieved"); + m_npixTot = m_pixelID->pixel_hash_max(); m_nmodTot = m_pixelID->wafer_hash_max(); - if (m_CalibSvc.retrieve().isFailure()) { - ATH_MSG_ERROR("Can't get CalibSvc"); - return StatusCode::FAILURE; - } - // - // get SpecialPixelMapSvc - // - if (m_CalibSvc->usePixMapCDB()) { - if ( ! m_specialPixelMapSvc.retrieve().isSuccess() ) { - ATH_MSG_FATAL ( "Unable to retrieve SpecialPixelMapSvc" ); - return StatusCode::FAILURE; - } + if (m_usePixCondSum) { + CHECK(m_specialPixelMapSvc.retrieve()); ATH_MSG_DEBUG ( "Retrieved SpecialPixelMapSvc" ); - } - // - // get PixelConditionsSummarySvc - // - if (m_usePixCondSum) { - if ( m_pixelConditionsSummarySvc.retrieve().isFailure() ) { - ATH_MSG_FATAL ( "Unable to retrieve PixelConditionsSummarySvc" ); - return StatusCode::FAILURE; - } + CHECK(m_pixelConditionsSummarySvc.retrieve()); ATH_MSG_DEBUG ( "Retrieved PixelConditionsSummarySvc" ); } - // - // get the Rndmsvc - // - if ( m_rndmSvc.retrieve().isFailure() ) { - ATH_MSG_ERROR ( " Can't get RndmSvc " ); - return StatusCode::FAILURE; - } else { ATH_MSG_DEBUG ( "Retrieved RndmSvc" ); - - } - // - // get the PixelDigitizationTool random stream - // - ATH_MSG_DEBUG ( "Getting random number engine : <" << m_rndmEngineName << ">" ); + CHECK(m_rndmSvc.retrieve()); m_rndmEngine = m_rndmSvc->GetEngine(m_rndmEngineName); - if (m_rndmEngine==0) { - ATH_MSG_ERROR ( "Could not find RndmEngine : " << 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 ); + } + else { + ATH_MSG_DEBUG("Found RndmEngine : " << m_rndmEngineName); } - return sc ; + + return StatusCode::SUCCESS; } //---------------------------------------------------------------------- @@ -148,15 +110,15 @@ StatusCode SpecialPixelGenerator::finalize() { void SpecialPixelGenerator::updatePixelMap(){ // update pixel map - if (m_CalibSvc->usePixMapCDB()) { + if (m_usePixCondSum) { ATH_MSG_DEBUG ( "retrieving special pixel map from cond db" ); m_detectorMap = m_specialPixelMapSvc->getPixelMap(0); if (m_detectorMap == 0) { ATH_MSG_ERROR ( "BUG TRAP - special pixelmap ptr == 0!!!" ); } - - } else { + } + else { if (m_doUpdate) { ATH_MSG_VERBOSE ( "generating a random special pixel map" ); generatePixelMap(); @@ -306,13 +268,17 @@ void SpecialPixelGenerator::process(SiChargedDiodeCollection &collection) const unsigned int pixelID; // numeric pixel id used in SpecialPixelMap // - ATH_MSG_VERBOSE ( "Processing diodes for module " - << m_pixelID->show_to_string(pixid) ); + ATH_MSG_VERBOSE ( "Processing diodes for module "<< m_pixelID->show_to_string(pixid) ); // retrieve the special pixel map for this module, // either from condition DB or from the internally generated one - getID(pixid, pixelID); + + //the encoding of the number of chips should follow this guidelines + //http://acode-browser.usatlas.bnl.gov/lxr/source/atlas/InnerDetector/InDetConditions/PixelConditionsServices/src/PixelConditionsSummarySvc.cxx#0208 + unsigned int mchips = 10*m_detectorMap->module(moduleHash)->chipsPerModule() + m_detectorMap->module(moduleHash)->chipType(); + + getID(pixid, pixelID, mchips); const ModuleSpecialPixelMap *modmap=0; - if (m_CalibSvc->usePixMapCDB()) modmap = m_detectorMap->module(moduleHash); + if (m_usePixCondSum) { modmap = m_detectorMap->module(moduleHash); } else modmap=m_detectorMapGen.module(moduleHash); if ( !modmap ) return; // no special pixels for this module: nothing to do! // process hits @@ -322,7 +288,7 @@ void SpecialPixelGenerator::process(SiChargedDiodeCollection &collection) const pixid = collection.getId((*i_chargedDiode).first); diode = &((*i_chargedDiode).second); // find diode with id pixid in special pixel map - getID( pixid, pixelID ); + getID( pixid, pixelID, mchips ); unsigned int status = modmap->pixelStatus(pixelID); bool pixuseful = modmap->pixelUseful(pixelID); // DO NOT mask out pixels that are not useful (3rd argument of Sihelper method call = false @@ -359,7 +325,7 @@ void SpecialPixelGenerator::process(SiChargedDiodeCollection &collection) const ATH_MSG_VERBOSE ( "Processing done!" ); } -void SpecialPixelGenerator::getID( const Identifier & id, unsigned int & pixID ) const { +void SpecialPixelGenerator::getID( const Identifier & id, unsigned int & pixID, unsigned int mchips ) const { // get pixel id from a pixel identifier // pixID is as follows: // |rrrr|rrrc|cccc|ffff| @@ -371,11 +337,11 @@ void SpecialPixelGenerator::getID( const Identifier & id, unsigned int & pixID ) unsigned int phipix = m_pixelID->phi_index(id ); // pixel phi unsigned int etapix = m_pixelID->eta_index(id ); // pixel eta // - pixID = ModuleSpecialPixelMap::encodePixelID( endcap, phimod, etapix, phipix ); + pixID = ModuleSpecialPixelMap::encodePixelID( endcap, phimod, etapix, phipix, mchips ); } const DetectorSpecialPixelMap* SpecialPixelGenerator::getDetectorMap() const{ - if(m_CalibSvc->usePixMapCDB()) return m_detectorMap; + if (m_usePixCondSum) { return m_detectorMap; } else return &m_detectorMapGen; } diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/SpecialPixelGenerator.h b/InnerDetector/InDetDigitization/PixelDigitization/src/SpecialPixelGenerator.h index a0f5f1bce9c374e6c6d5f9fe6b1b21448d651e8b..57435fda492a080a647bab25a94ea72cf9d525df 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/SpecialPixelGenerator.h +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/SpecialPixelGenerator.h @@ -59,9 +59,6 @@ #include "SiDigitization/ISiChargedDiodesProcessorTool.h" #include "AthenaBaseComps/AthAlgTool.h" -#include "PixelConditionsData/SpecialPixelMap.h" -#include "CalibSvc.h" - class Identifier; class PixelID; @@ -124,7 +121,7 @@ private: SpecialPixelGenerator(); int fillSpecialPixels( double prob, unsigned int status, bool merge ) const; - void getID( const Identifier & id, unsigned int & pixID ) const; + void getID( const Identifier & id, unsigned int & pixID, unsigned int mchips ) const; inline unsigned int setPixelStatus( unsigned int modID, unsigned int pixID, unsigned int status ); inline unsigned int mergePixelStatus( unsigned int modID, unsigned int pixID, unsigned int status ); inline unsigned int getPixelStatus( unsigned int modID, unsigned int pixID ) const; @@ -151,7 +148,6 @@ private: ServiceHandle<ISpecialPixelMapSvc> m_specialPixelMapSvc; ServiceHandle<IAtRndmGenSvc> m_rndmSvc; /** Random number service */ std::string m_rndmEngineName;/** name of random engine, actual pointer in PixelDigitizationToolBaseAlg */ - ServiceHandle<CalibSvc> m_CalibSvc; CLHEP::HepRandomEngine* m_rndmEngine; }; @@ -170,7 +166,7 @@ unsigned int SpecialPixelGenerator::mergePixelStatus( unsigned int modID, unsign unsigned int SpecialPixelGenerator::getPixelStatus( unsigned int modID, unsigned int pixID ) const { const ModuleSpecialPixelMap *modmap=0; - if(m_CalibSvc->usePixMapCDB()) modmap = m_detectorMap->module(modID); + if (m_usePixCondSum) { modmap = m_detectorMap->module(modID); } else modmap=m_detectorMapGen.module(modID); if ( modmap ) return modmap->pixelStatus(pixID); else return 0; @@ -178,7 +174,7 @@ unsigned int SpecialPixelGenerator::getPixelStatus( unsigned int modID, unsigned bool SpecialPixelGenerator::pixelUseful( unsigned int modID, unsigned int pixID ) const { const ModuleSpecialPixelMap *modmap=0; - if(m_CalibSvc->usePixMapCDB()) modmap = m_detectorMap->module(modID); + if (m_usePixCondSum) { modmap = m_detectorMap->module(modID); } else modmap=m_detectorMapGen.module(modID); if ( modmap ) return modmap->pixelUseful(pixID); else return true; diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/TimeSvc.cxx b/InnerDetector/InDetDigitization/PixelDigitization/src/TimeSvc.cxx index 5d30a32d8714c2c00f17db34b76113d328cec06a..12637abe8cb0da862781bc9754bdd88d30090428 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/TimeSvc.cxx +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/TimeSvc.cxx @@ -49,7 +49,6 @@ inline StatusCode TimeSvc::queryInterface(const InterfaceID& riid, void** ppvIf) return StatusCode::SUCCESS; } return AthService::queryInterface( riid, ppvIf ); - } @@ -57,26 +56,19 @@ inline StatusCode TimeSvc::queryInterface(const InterfaceID& riid, void** ppvIf) // Initialize //---------------------------------------------------------------------- StatusCode TimeSvc::initialize() { - StatusCode sc = AthService::initialize(); - if (sc.isFailure()) { - ATH_MSG_FATAL ( "TimeSvc::initialize() failed"); - return sc ; - } - if (m_rndmSvc.retrieve().isFailure()) { - ATH_MSG_ERROR("Can't get RndmSvc"); - return StatusCode::FAILURE; - } + + CHECK(m_rndmSvc.retrieve()); 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 ); + if (!m_rndmEngine) { + ATH_MSG_ERROR("Could not find RndmEngine : " << m_rndmEngineName); + return StatusCode::FAILURE; + } + else { + ATH_MSG_DEBUG("Found RndmEngine : " << m_rndmEngineName); } - ATH_MSG_DEBUG ( "TimeSvc::initialize()"); - return sc ; + return StatusCode::SUCCESS; } //---------------------------------------------------------------------- diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/components/PixelDigitization_entries.cxx b/InnerDetector/InDetDigitization/PixelDigitization/src/components/PixelDigitization_entries.cxx index 44f8553ded7642964297adf8ff90696e8ef6df74..a12b22ac155c8bf3fea3fe6c0622f72c3e666bb7 100755 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/components/PixelDigitization_entries.cxx +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/components/PixelDigitization_entries.cxx @@ -1,6 +1,6 @@ #include "GaudiKernel/DeclareFactoryEntries.h" -#include "PixelDigitization/PixelDigitization.h" +#include "src/PixelDigitization.h" #include "src/PixelDigitizationTool.h" #include "src/SurfaceChargesTool.h" #include "src/PixelNoisyCellGenerator.h" @@ -23,7 +23,6 @@ #include "src/Ibl3DBichselChargeTool.h" #include "src/SubChargesTool.h" #include "src/ChargeCollProbSvc.h" -#include "src/CalibSvc.h" #include "src/BichselSimTool.h" DECLARE_ALGORITHM_FACTORY(PixelDigitization) @@ -50,7 +49,6 @@ DECLARE_TOOL_FACTORY(Ibl3DBichselChargeTool) //DECLARE_TOOL_FACTORY(SubChargesTool) DECLARE_SERVICE_FACTORY(ChargeCollProbSvc) DECLARE_SERVICE_FACTORY(TimeSvc) -DECLARE_SERVICE_FACTORY(CalibSvc) DECLARE_FACTORY_ENTRIES(PixelDigitization) { DECLARE_ALGORITHM(PixelDigitization) @@ -76,6 +74,5 @@ DECLARE_FACTORY_ENTRIES(PixelDigitization) { // DECLARE_TOOL(SubChargesTool) DECLARE_SERVICE(ChargeCollProbSvc) DECLARE_SERVICE(TimeSvc) - DECLARE_SERVICE(CalibSvc) } diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/components/PixelDigitization_load.cxx b/InnerDetector/InDetDigitization/PixelDigitization/src/components/PixelDigitization_load.cxx index 6fa8ead3164259fcf268054dfcf3c0b08332369b..c83509ba10da818331685036f687995ff2198c2a 100755 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/components/PixelDigitization_load.cxx +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/components/PixelDigitization_load.cxx @@ -3,4 +3,3 @@ LOAD_FACTORY_ENTRIES( PixelDigitization ) LOAD_FACTORY_ENTRIES( ChargeCollProbSvc ) LOAD_FACTORY_ENTRIES( TimeSvc ) -LOAD_FACTORY_ENTRIES( CalibSvc )