diff --git a/InnerDetector/InDetDigitization/BCM_Digitization/python/BCM_DigitizationConfig.py b/InnerDetector/InDetDigitization/BCM_Digitization/python/BCM_DigitizationConfig.py index 05620de344b1193ae677601e326464ce40b21a5f..255858393a88d3ffb35a86010d52739560c3343e 100644 --- a/InnerDetector/InDetDigitization/BCM_Digitization/python/BCM_DigitizationConfig.py +++ b/InnerDetector/InDetDigitization/BCM_Digitization/python/BCM_DigitizationConfig.py @@ -58,7 +58,8 @@ def getBCM_Range(name="BCM_Range" , **kwargs): def BCM_OverlayDigitizationTool(name="BCM_OverlayDigitizationTool",**kwargs): from OverlayCommonAlgs.OverlayFlags import overlayFlags - kwargs.setdefault("EvtStore", overlayFlags.evtStore()) + if overlayFlags.isOverlayMT(): + kwargs.setdefault("OnlyUseContainerName", False) return BCM_DigitizationTool(name,**kwargs) def BCM_OverlayDigitization(name="BCM_OverlayDigitization",**kwargs): diff --git a/InnerDetector/InDetDigitization/BCM_Digitization/src/BCM_DigitizationTool.cxx b/InnerDetector/InDetDigitization/BCM_Digitization/src/BCM_DigitizationTool.cxx index bc4d563ff6c4a77ba62dc7990478f98095f456ff..91d93b0140c1d9cc764a707d0ae57de42259c2a2 100644 --- a/InnerDetector/InDetDigitization/BCM_Digitization/src/BCM_DigitizationTool.cxx +++ b/InnerDetector/InDetDigitization/BCM_Digitization/src/BCM_DigitizationTool.cxx @@ -14,8 +14,6 @@ #include "GeneratorObjects/HepMcParticleLink.h" #include "InDetBCM_RawData/BCM_RawData.h" #include "InDetBCM_RawData/BCM_RDO_Collection.h" -#include "InDetSimEvent/SiHitCollection.h" -#include "PileUpTools/PileUpMergeSvc.h" #include "xAODEventInfo/EventInfo.h" // NEW EDM #include "xAODEventInfo/EventAuxInfo.h" // NEW EDM @@ -25,24 +23,11 @@ // Constructor with parameters: //---------------------------------------------------------------------- BCM_DigitizationTool::BCM_DigitizationTool(const std::string &type, const std::string &name, const IInterface *parent) : - PileUpToolBase(type,name,parent), - m_mipDeposit(0.0f), - m_effPrmDistance(0.0f), - m_effPrmSharpness(0.0f), - m_timeDelay(0.0f), - m_rdoContainer(NULL), - m_simDataCollMap(NULL), - m_mergeSvc(NULL) //("PileUpMergeSvc",name) + PileUpToolBase(type,name,parent) { - //declareProperty("PileupMergeSvc", m_mergeSvc, "Pileup merging service"); - declareProperty("HitCollName", m_hitCollName="BCMHits", "Input simulation hits collection name"); declareProperty("ModNoise", m_modNoise, "RMS noise averaged over modules"); declareProperty("ModSignal", m_modSignal, "Average MIP signal in modules"); declareProperty("NinoThr", m_ninoThr, "NINO threshold voltage"); - declareProperty("MIPDeposit", m_mipDeposit, "Most probable MIP deposit in BCM pad"); - declareProperty("EffDistanceParam", m_effPrmDistance, "Distance parameter for efficiency calculation"); - declareProperty("EffSharpnessParam", m_effPrmSharpness, "Sharpness parameter for efficiency calculation"); - declareProperty("TimeDelay", m_timeDelay, "Pulse time delay"); } //---------------------------------------------------------------------- @@ -52,9 +37,22 @@ StatusCode BCM_DigitizationTool::initialize() { ATH_MSG_VERBOSE ( "initialize()"); + ATH_CHECK(m_mergeSvc.retrieve()); + // get random service ATH_CHECK(m_rndmGenSvc.retrieve()); + // check the input object name + if (m_hitsContainerKey.key().empty()) { + ATH_MSG_FATAL("Property InputObjectName not set !"); + return StatusCode::FAILURE; + } + if(m_onlyUseContainerName) m_inputObjectName = m_hitsContainerKey.key(); + ATH_MSG_DEBUG("Input objects in container : '" << m_inputObjectName << "'"); + + // Initialize ReadHandleKey + ATH_CHECK(m_hitsContainerKey.initialize(!m_onlyUseContainerName)); + // Write handle keys ATH_CHECK( m_outputKey.initialize() ); ATH_MSG_VERBOSE("Initialized WriteHandleKey: " << m_outputKey); @@ -167,43 +165,47 @@ StatusCode BCM_DigitizationTool::processAllSubEvents() { ATH_MSG_DEBUG ( "processAllSubEvents()" ); + ATH_CHECK(createOutputContainers()); - if(!m_mergeSvc) { - //locate the PileUpMergeSvc - const bool CREATEIF(true); - if(!(service("PileUpMergeSvc", m_mergeSvc, CREATEIF)).isSuccess() || - !m_mergeSvc) { - ATH_MSG_FATAL("processAllSubEvents(): Could not find PileUpMergeSvc"); + // Fetch SiHitCollections for this bunch crossing + if (!m_onlyUseContainerName) { + SG::ReadHandle<SiHitCollection> hitCollection(m_hitsContainerKey); + if (!hitCollection.isValid()) { + ATH_MSG_ERROR("Could not get BCM SiHitCollection container " << hitCollection.name() << + " from store " << hitCollection.store()); return StatusCode::FAILURE; } - else ATH_MSG_DEBUG("processAllSubEvents(): retrieved PileUpMergeSvc"); - } - else ATH_MSG_DEBUG("processAllSubEvents(): PileUpMergeSvc already available"); - - CHECK(createOutputContainers()); + const unsigned int evtIndex = 0; + const double time = 0.0; + ATH_MSG_DEBUG ( "SiHitCollection found with " << hitCollection->size() << " hits" ); + // Read hits from this collection + for (const auto& siHit : *hitCollection) { + processSiHit(siHit, time, evtIndex); + } - // Fetch SiHitCollections for this bunch crossing - typedef PileUpMergeSvc::TimedList<SiHitCollection>::type TimedHitCollList; - TimedHitCollList hitCollList; - if (!(m_mergeSvc->retrieveSubEvtsData(m_hitCollName, hitCollList).isSuccess()) && hitCollList.size()==0) { - ATH_MSG_ERROR ( "Could not fill TimedHitCollList" ); - return StatusCode::FAILURE; - } else { - ATH_MSG_DEBUG ( hitCollList.size() << " SiHitCollections with key " << m_hitCollName << " found" ); } + else { + typedef PileUpMergeSvc::TimedList<SiHitCollection>::type TimedHitCollList; + TimedHitCollList hitCollList; + if (!(m_mergeSvc->retrieveSubEvtsData(m_inputObjectName, hitCollList).isSuccess()) && hitCollList.size()==0) { + ATH_MSG_ERROR ( "Could not fill TimedHitCollList" ); + return StatusCode::FAILURE; + } else { + ATH_MSG_DEBUG ( hitCollList.size() << " SiHitCollections with key " << m_inputObjectName << " found" ); + } - // Store hit info in vectors and fill SDO map - TimedHitCollList::iterator iColl(hitCollList.begin()); - TimedHitCollList::iterator endColl(hitCollList.end()); - for (; iColl != endColl; ++iColl) { - const SiHitCollection* tmpColl(iColl->second); - HepMcParticleLink::index_type evtIndex = (iColl->first).index(); - ATH_MSG_DEBUG ( "SiHitCollection found with " << tmpColl->size() << " hits" ); - // Read hits from this collection - SiHitCollection::const_iterator i = tmpColl->begin(); - SiHitCollection::const_iterator e = tmpColl->end(); - for (; i!=e; ++i) { - processSiHit(*i, (iColl->first).time(), evtIndex); + // Store hit info in vectors and fill SDO map + TimedHitCollList::iterator iColl(hitCollList.begin()); + TimedHitCollList::iterator endColl(hitCollList.end()); + for (; iColl != endColl; ++iColl) { + const SiHitCollection* tmpColl(iColl->second); + const unsigned int evtIndex = (iColl->first).index(); + const double time = (iColl->first).time(); + ATH_MSG_DEBUG ( "SiHitCollection found with " << tmpColl->size() << " hits" ); + // Read hits from this collection + for (const auto& siHit : *tmpColl) { + processSiHit(siHit, time, evtIndex); + } } } @@ -231,7 +233,7 @@ StatusCode BCM_DigitizationTool::processBunchXing(int bunchXing, << " run number : " << iEvt->ptr()->runNumber() ); const SiHitCollection* seHitColl = 0; - CHECK(seStore.retrieve(seHitColl,m_hitCollName)); + CHECK(seStore.retrieve(seHitColl,m_inputObjectName)); ATH_MSG_DEBUG ( "SiHitCollection found with " << seHitColl->size() << " hits" ); SiHitCollection::const_iterator i = seHitColl->begin(); SiHitCollection::const_iterator e = seHitColl->end(); diff --git a/InnerDetector/InDetDigitization/BCM_Digitization/src/BCM_DigitizationTool.h b/InnerDetector/InDetDigitization/BCM_Digitization/src/BCM_DigitizationTool.h index 46a06f90b2118cf8480c6d3b82413e933c6873a4..904f71c0fdd24657d551e6ea65ffc33c1b18daea 100644 --- a/InnerDetector/InDetDigitization/BCM_Digitization/src/BCM_DigitizationTool.h +++ b/InnerDetector/InDetDigitization/BCM_Digitization/src/BCM_DigitizationTool.h @@ -10,8 +10,11 @@ #include "GaudiKernel/ServiceHandle.h" +#include "PileUpTools/PileUpMergeSvc.h" + #include "InDetSimData/InDetSimData.h" #include "InDetSimData/InDetSimDataCollection.h" +#include "InDetSimEvent/SiHitCollection.h" #include "InDetSimEvent/SiHit.h" #include "InDetBCM_RawData/BCM_RDO_Container.h" @@ -21,9 +24,6 @@ #include <bitset> -// Data member classes -class PileUpMergeSvc; - namespace CLHEP { class HepRandomEngine; @@ -77,24 +77,27 @@ class BCM_DigitizationTool : public PileUpToolBase { void fillRDO(unsigned int chan, int p1x, int p1w, int p2x, int p2w); // Digitization parameters - std::string m_hitCollName; //!< Input simulation hit collection name std::vector<float> m_modNoise; //!< RMS Gaussian noise std::vector<float> m_modSignal; //!< Most probable MIP signal std::vector<float> m_ninoThr; //!< NINO threshold - float m_mipDeposit; //!< Most probable MIP deposit in BCM pad - float m_effPrmDistance; //!< Distance parameter in charge collection efficiency function - float m_effPrmSharpness; //!< Sharpness parameter in charge collection efficiency function - float m_timeDelay; //!< Time delay + Gaudi::Property<float> m_mipDeposit{this, "MIPDeposit", 0.0f, "Most probable MIP deposit in BCM pad"}; + Gaudi::Property<float> m_effPrmDistance{this, "EffDistanceParam", 0.0f, "Distance parameter for efficiency calculation"}; + Gaudi::Property<float> m_effPrmSharpness{this, "EffSharpnessParam", 0.0f, "Sharpness parameter for efficiency calculation"}; + Gaudi::Property<float> m_timeDelay{this, "TimeDelay", 0.0f, "Pulse time delay"}; + + BooleanProperty m_onlyUseContainerName{this, "OnlyUseContainerName", true, "Don't use the ReadHandleKey directly. Just extract the container name from it."}; + SG::ReadHandleKey<SiHitCollection> m_hitsContainerKey{this, "HitCollName", "BCMHits", "Input simulation hits collection name"}; + std::string m_inputObjectName{""}; // Write handle keys SG::WriteHandleKey<BCM_RDO_Container> m_outputKey{this, "OutputRDOKey", "BCM_RDOs", ""}; SG::WriteHandleKey<InDetSimDataCollection> m_outputSDOKey{this, "OutputSDOKey", "BCM_SDO_Map", ""}; // Output objects - BCM_RDO_Container* m_rdoContainer; //!< Output RDO container - InDetSimDataCollection* m_simDataCollMap; //!< Output SDO map + BCM_RDO_Container* m_rdoContainer{}; //!< Output RDO container + InDetSimDataCollection* m_simDataCollMap{}; //!< Output SDO map - PileUpMergeSvc* m_mergeSvc; //!< Handle for pileup merging service + ServiceHandle <PileUpMergeSvc> m_mergeSvc{this, "MergeSvc", "PileUpMergeSvc", "Merge service used in digitization"}; //! ServiceHandle<IAthRNGSvc> m_rndmGenSvc{this, "RndmSvc", "AthRNGSvc", ""}; //!< Random number service // Vectors to store G4 hit information diff --git a/Simulation/Digitization/test/test_MC16a_Digi_tf_configuration.py b/Simulation/Digitization/test/test_MC16a_Digi_tf_configuration.py index 8c8402d34c188ec9f1d9bf85002ad7606b239e1f..2dd23b85fd6280043c8939906a202d7553833e39 100755 --- a/Simulation/Digitization/test/test_MC16a_Digi_tf_configuration.py +++ b/Simulation/Digitization/test/test_MC16a_Digi_tf_configuration.py @@ -215,7 +215,7 @@ class TestDigitizationMC16a(unittest.TestCase): def test___BCM_DigitizationTool_properties(self): tested_configurable_name = 'StandardSignalOnlyTruthPileUpToolsAlg.BCM_DigitizationTool' - expected_property_list = ['DetStore', 'EffDistanceParam', 'EffSharpnessParam', 'EvtStore', 'ExtraInputs', 'ExtraOutputs', 'FirstXing', 'HitCollName', 'LastXing', 'MIPDeposit', 'ModNoise', 'ModSignal', 'NinoThr', 'OutputRDOKey', 'OutputSDOKey', 'RndmSvc', 'TimeDelay'] + expected_property_list = ['DetStore', 'EffDistanceParam', 'EffSharpnessParam', 'EvtStore', 'ExtraInputs', 'ExtraOutputs', 'FirstXing', 'HitCollName', 'LastXing', 'MergeSvc', 'MIPDeposit', 'ModNoise', 'ModSignal', 'NinoThr', 'OutputRDOKey', 'OutputSDOKey', 'RndmSvc', 'TimeDelay'] expected_nonstring_properties = {'LastXing': '0', 'FirstXing': '-25'} expected_string_properties = {'HitCollName': 'BCMHits'} self._detailed_ConfigurablePropertiesCheck(