diff --git a/ForwardDetectors/ZDC/ZDC_SimuDigitization/ZDC_SimuDigitization/ZDC_PileUpTool.h b/ForwardDetectors/ZDC/ZDC_SimuDigitization/ZDC_SimuDigitization/ZDC_PileUpTool.h index 40b5ece4185d5d69e070c95991ae2b60534de47d..2220c72b2e7c9ec8cd800dad5c6c10c0faf62e47 100644 --- a/ForwardDetectors/ZDC/ZDC_SimuDigitization/ZDC_SimuDigitization/ZDC_PileUpTool.h +++ b/ForwardDetectors/ZDC/ZDC_SimuDigitization/ZDC_SimuDigitization/ZDC_PileUpTool.h @@ -18,7 +18,7 @@ #include "ZdcEvent/ZdcDigitsCollection.h" #include "PileUpTools/PileUpMergeSvc.h" #include <string> -#include <fstream> +#include <fstream> #include <vector> #include <utility> /* pair */ @@ -28,17 +28,17 @@ class IAtRndmGenSvc; class ZDC_PileUpTool: public PileUpToolBase { public: - + ZDC_PileUpTool(const std::string& type, - const std::string& name, - const IInterface* parent); - + const std::string& name, + const IInterface* parent); + virtual StatusCode initialize() override final; virtual StatusCode finalize() override final; /// called before the subevts loop. Not (necessarily) able to access SubEvents virtual StatusCode prepareEvent(const unsigned int nInputEvents) override final; - + /// called for each active bunch-crossing to process current SubEvents bunchXing is in ns virtual StatusCode processBunchXing( int bunchXing, @@ -55,7 +55,7 @@ class ZDC_PileUpTool: public PileUpToolBase { virtual StatusCode processAllSubEvents() override final; private: - + StatusCode recordContainers(ServiceHandle<StoreGateSvc>& evtStore, std::string m_key_digitCnt); void fillStripDigitContainer(const ZDC_SimStripHit_Collection*, CLHEP::HepRandomEngine*); @@ -63,38 +63,48 @@ class ZDC_PileUpTool: public PileUpToolBase { void fillPixelDigitContainer(const ZDC_SimPixelHit_Collection*, CLHEP::HepRandomEngine*); void fillPixelDigitContainer(TimedHitCollection<ZDC_SimPixelHit>&, CLHEP::HepRandomEngine*); - + void createAndStoreStripDigit(int Side, int ModuleNo, int NPhotons, CLHEP::HepRandomEngine* rndEngine); void createAndStorePixelDigit(int Side, int ModuleNo, int PixNum, int NPhotons, CLHEP::HepRandomEngine* rndEngine); - + void SetDumps(bool, bool); - ServiceHandle<PileUpMergeSvc> m_mergeSvc; - ServiceHandle<IAtRndmGenSvc> m_atRndmGenSvc; - CLHEP::HepRandomEngine *m_rndEngine; + ServiceHandle<PileUpMergeSvc> m_mergeSvc{this, "mergeSvc", "PileUpMergeSvc", ""}; + ServiceHandle<IAtRndmGenSvc> m_atRndmGenSvc{this, "RndmSvc", "AtRndmGenSvc", + "Random Number Service used in ZDC digitization"}; + CLHEP::HepRandomEngine *m_rndEngine{nullptr}; + + Gaudi::Property<std::string> m_SimStripHitCollectionName{this, "SimStripHitCollection" , "ZDC_SimStripHit_Collection", + "Name of the input Collection of the simulated Strip Hits"}; + Gaudi::Property<std::string> m_SimPixelHitCollectionName{this, "SimPixelHitCollection" , "ZDC_SimPixelHit_Collection", + "Name of the input Collection of the simulated Pixel Hits"}; + Gaudi::Property<std::string> m_ZdcDigitsContainerName{this, "ZdcDigitsContainerName", "ZdcDigitsCollection", + "Name of the Container to hold the output from the ZDC digitization"}; + + Gaudi::Property<double> m_ScaleStrip{this, "ScaleStrip", 3e-4, ""}; + Gaudi::Property<double> m_ScalePixel{this, "ScalePixel", 5e-3, ""}; // use this to normalize the signal from the strips; + Gaudi::Property<int> m_Pedestal {this, "Pedestal" , 100, ""}; // Pedestal=40 ;RMS=3??(ask Andrei about this) + Gaudi::Property<int> m_MaxTimeBin{this, "MaxTimeBin", 5, ""}; // The number of time-slices after digitization(Typically 5 or 7) + Gaudi::Property<double> m_SigmaNoiseHG_Strip{this, "SigmaNoiseHG_Strip", 1.5, ""}; + Gaudi::Property<double> m_SigmaNoiseHG_Pixel{this, "SigmaNoiseHG_Pixel", 1.0, ""}; + Gaudi::Property<double> m_SigmaNoiseLG_Strip{this, "SigmaNoiseLG_Strip", 1.0, ""}; + Gaudi::Property<double> m_SigmaNoiseLG_Pixel{this, "SigmaNoiseLG_Pixel", 1.0, ""}; + bool m_DumpStrip{false}, m_DumpPixel{false}; + + ZDC_SimStripHit_Collection *m_mergedStripHitList{}; + ZDC_SimPixelHit_Collection *m_mergedPixelHitList{}; - std::string m_SimStripHitCollectionName; - std::string m_SimPixelHitCollectionName; - std::string m_ZdcDigitsContainerName; + std::ofstream m_MyFile; + ZdcDigitsCollection *m_digitContainer{}; - double m_ScaleStrip, m_ScalePixel; // use this to normalize the signal from the strips; - int m_Pedestal; // Pedestal=40 ;RMS=3??(ask Andrei about this) - int m_MaxTimeBin; // The number of time-slices after digitization(Typically 5 or 7) - double m_SigmaNoiseHG_Strip, m_SigmaNoiseHG_Pixel, m_SigmaNoiseLG_Strip, m_SigmaNoiseLG_Pixel; - bool m_DumpStrip, m_DumpPixel; + double HighToLow(double signal, double gain_ratio, double gain_error, CLHEP::HepRandomEngine* rndEngine); - ZDC_SimStripHit_Collection *m_mergedStripHitList; - ZDC_SimPixelHit_Collection *m_mergedPixelHitList; - - std::ofstream m_MyFile; - ZdcDigitsCollection *m_digitContainer; - - double HighToLow(double signal, double gain_ratio, double gain_error, CLHEP::HepRandomEngine* rndEngine); - - double m_GainRatio_Strip[8], m_GainRatioError_Strip[8]; - double m_GainRatio_Pixel, m_GainRatioError_Pixel; - - unsigned int PixelID(int Side=-1, int Module=-1, int PixNo=-1); + double m_GainRatio_Strip[8]; + double m_GainRatioError_Strip[8]; + double m_GainRatio_Pixel{10.0}; + double m_GainRatioError_Pixel{0.5}; + + unsigned int PixelID(int Side=-1, int Module=-1, int PixNo=-1); }; - + #endif diff --git a/ForwardDetectors/ZDC/ZDC_SimuDigitization/src/ZDC_PileUpTool.cxx b/ForwardDetectors/ZDC/ZDC_SimuDigitization/src/ZDC_PileUpTool.cxx index 43e656221b45da2080b76c56c3a26d432a68fffb..0cfb17a0ca212dc528371024641c650602c8a9d4 100644 --- a/ForwardDetectors/ZDC/ZDC_SimuDigitization/src/ZDC_PileUpTool.cxx +++ b/ForwardDetectors/ZDC/ZDC_SimuDigitization/src/ZDC_PileUpTool.cxx @@ -21,22 +21,8 @@ ZDC_PileUpTool::ZDC_PileUpTool(const std::string& type, const std::string& name, const IInterface* parent) : - PileUpToolBase(type, name, parent), - m_mergeSvc ("PileUpMergeSvc", name), - m_atRndmGenSvc("AtRndmGenSvc", name), - m_rndEngine(0), - m_ScaleStrip(3e-4), - m_ScalePixel(5e-3), - m_Pedestal(100), - m_MaxTimeBin(5), - m_SigmaNoiseHG_Strip(1.5), - m_SigmaNoiseHG_Pixel(1.0), - m_SigmaNoiseLG_Strip(1.0), - m_SigmaNoiseLG_Pixel(1.0), - m_DumpStrip(false), - m_DumpPixel(false) + PileUpToolBase(type, name, parent) { - // NOTE: The following variables are actually re-initialized by ZDC_DigiTop::initialize() or ZDC_PileUpTool::initialize() m_GainRatio_Strip[0] = 10.0; m_GainRatioError_Strip[0] = 0.5; m_GainRatio_Strip[1] = 10.0; m_GainRatioError_Strip[1] = 0.5; @@ -48,33 +34,7 @@ ZDC_PileUpTool::ZDC_PileUpTool(const std::string& type, m_GainRatio_Strip[7] = 10.0; m_GainRatioError_Strip[7] = 0.5; m_GainRatio_Pixel = 10.0; m_GainRatioError_Pixel = 0.5; - - m_digitContainer = 0; // initializing to null pointer - // end of ToolBox variables - - m_SimStripHitCollectionName = "ZDC_SimStripHit_Collection"; - m_SimPixelHitCollectionName = "ZDC_SimPixelHit_Collection"; - m_ZdcDigitsContainerName = "ZdcDigitsCollection"; - - m_mergedStripHitList = 0; // initialized to null pointer - m_mergedPixelHitList = 0; - - declareProperty("SimStripHitCollection" , m_SimStripHitCollectionName, "Name of the input Collection of the simulated Strip Hits"); - declareProperty("SimPixelHitCollection" , m_SimPixelHitCollectionName, "Name of the input Collection of the simulated Pixel Hits"); - declareProperty("ZdcDigitsContainerName", m_ZdcDigitsContainerName, "Name of the Container to hold the output from the ZDC digitization"); - declareProperty("RndmSvc", m_atRndmGenSvc, "Random Number Service used in ZDC digitization" ); - declareProperty("mergeSvc", m_mergeSvc, "Store to hold the pile-ups"); - - declareProperty("ScaleStrip", m_ScaleStrip); - declareProperty("ScalePixel", m_ScalePixel); - declareProperty("MaxTimeBin", m_MaxTimeBin); - declareProperty("Pedestal" , m_Pedestal); - - declareProperty("SigmaNoiseHG_Strip", m_SigmaNoiseHG_Strip); - declareProperty("SigmaNoiseHG_Pixel", m_SigmaNoiseHG_Pixel); - declareProperty("SigmaNoiseLG_Strip", m_SigmaNoiseLG_Strip); - declareProperty("SigmaNoiseLG_Pixel", m_SigmaNoiseLG_Pixel); } StatusCode ZDC_PileUpTool::initialize() { @@ -86,13 +46,10 @@ StatusCode ZDC_PileUpTool::initialize() { << " MaxTimeBin: " << m_MaxTimeBin << endmsg << " Pedestal : " << m_Pedestal ); - if (m_atRndmGenSvc.retrieve().isFailure()) { - ATH_MSG_FATAL ( "Could not retrieve RandomNumber Service!" ); - return StatusCode::FAILURE; - } - else { - ATH_MSG_DEBUG ( "Retrieved RandomNumber Service" ); - } + ATH_CHECK(m_atRndmGenSvc.retrieve()); + ATH_MSG_DEBUG ( "Retrieved RandomNumber Service" ); + + ATH_CHECK(m_mergeSvc.retrieve()); m_mergedStripHitList = new ZDC_SimStripHit_Collection("mergedStripHitList"); m_mergedPixelHitList = new ZDC_SimPixelHit_Collection("mergedPixelHitList"); @@ -104,16 +61,6 @@ StatusCode ZDC_PileUpTool::processAllSubEvents() { ATH_MSG_DEBUG ( "ZDC_PileUpTool::processAllSubEvents()" ); - //retrieve the PileUpMergeSvc if necessary - if(!m_mergeSvc) { - if(!m_mergeSvc.retrieve().isSuccess() || !m_mergeSvc) { - ATH_MSG_FATAL("digitize: Could not find PileUpMergeSvc"); - return StatusCode::FAILURE; - } - else ATH_MSG_DEBUG("digitize: retrieved PileUpMergeSvc"); - } - else ATH_MSG_DEBUG("digitize: PileUpMergeSvc already available"); - typedef PileUpMergeSvc::TimedList<ZDC_SimStripHit_Collection>::type TimedStripHitCollList; typedef PileUpMergeSvc::TimedList<ZDC_SimPixelHit_Collection>::type TimedPixelHitCollList; diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitization.cxx b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitization.cxx index c5eb6e59f10bb46aed2ef8d11cfa73d0f95ed30d..c9f05fa8698fb378199c1b1388faa182a3e9b012 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitization.cxx +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitization.cxx @@ -2,16 +2,7 @@ Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ -//////////////////////////////////////////////////////////////////////////// -// PixelDigitization.cxx -// Implementation file for class PixelDigitization -//////////////////////////////////////////////////////////////////////////// -// (c) ATLAS Detector software -//////////////////////////////////////////////////////////////////////////// - #include "PixelDigitization.h" -#include "PixelDigitizationTool.h" - // Constructor with parameters: PixelDigitization::PixelDigitization(const std::string &name, @@ -30,14 +21,9 @@ StatusCode PixelDigitization::initialize() { ATH_MSG_DEBUG ( "Successfully retreived IPixelDigitizaitonTool." ); return StatusCode::SUCCESS; } - + // Execute method: StatusCode PixelDigitization::execute() { ATH_MSG_DEBUG ( "execute()" ); return m_pixelDigitizationTool->processAllSubEvents(); } - -StatusCode PixelDigitization::finalize() { - ATH_MSG_DEBUG ( "finalize()" ); - return StatusCode::SUCCESS; -} diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitization.h b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitization.h index 33c98536842872974e323b951f49d5f3f29c5fee..b93fccb70331dccc850baf28a2ff02fab9bc64ef 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitization.h +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitization.h @@ -2,62 +2,6 @@ Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ -/////////////////////////////////////////////////////////////////// -// PixelDigitization.h -// Header file for class PixelDigitization -/////////////////////////////////////////////////////////////////// -// (c) ATLAS Detector software -/////////////////////////////////////////////////////////////////// -// Top algorithm class for Pixel digitization -/////////////////////////////////////////////////////////////////// -// Version 2.1 10/07/2001 David Calvet -// Revisited version. 04-04-03 Davide Costanzo -// - Moved to the the SiDigitization -// - Added PixelID -// - Added createRDO class -// - creates RDOs instead of digits -// Revisited version. 06-12-06 Marian Zdrazil -// - Modified PixelDigitization to accomodate needs of the Pixel -// EndCap C Cosmic Test. We need to check the status of each -// module, whether it was in a readout and if it has any bad -// channels. The code should be further developed to access the -// conditions database (COOL) just like SCT does. -// Revisited version 04/07/2006 Fredrik Tegenfeldt -// - Made the TOT parameters available via jobOpts -// Restructured/rewritten version 29/08/2013 Matthew Klein -// - Eliminated dependence on SiDigitization -// - Added separate class for each technology to account for addition -// of IBL -// - Functions to choose technology and detect presence of IBL -// - Other structural/minor changes -/////////////////////////////////////////////////////////////////// - -/** @class PixelDigitization - * @brief The main pixel digitization class - * @author David Calvet - * @author Davide Costanzo - * @author Fredrik Tegenfeldt - * @author Matthe Klein - * - * \b Description - * - * This is the main class for the pixel digitization process. That is, for each event it - * reads the Geant 4 produced hits and simulates the detector respons. - * - * The current design uses so called 'charge processors' for each simulated - * process that affects the digitization. - * Such a processor inherits from SiDigitization::SiChargedDiodesProcessor. - * The number of processors is not explicitly limited apart from performance issues. - * - * - * <b>Job options</b> - * - * <table border="1"> - * <tr><td><b>Name</b></td> <td><b>Description</b></td></tr> - * <tr><td>DigitizationTool</td> <td>Pixel Digtization Tool Name</td></tr> - * </table> - */ - #ifndef PIXELDIGITIZATION_PIXELDIGITIZATION_H #define PIXELDIGITIZATION_PIXELDIGITIZATION_H @@ -65,9 +9,8 @@ #include "AthenaBaseComps/AthAlgorithm.h" // Data members #include "GaudiKernel/ToolHandle.h" +#include "PileUpTools/IPileUpTool.h" -#include "PileUpTools/PileUpToolBase.h" -class PixelDigitizationTool; class PixelDigitization : public AthAlgorithm { public: @@ -79,16 +22,13 @@ public: ~PixelDigitization(); /** Algorithm::initialize() */ - virtual StatusCode initialize(); - + virtual StatusCode initialize() override final; + /** Algorithm::execute() */ - virtual StatusCode execute(); - - /** Algorithm::finalize() */ - virtual StatusCode finalize(); + virtual StatusCode execute() override final; private: - ToolHandle<PixelDigitizationTool> m_pixelDigitizationTool{this, "DigitizationTool", "PixelDigitizationTool", "PixelDigitizationTool name"}; + ToolHandle<IPileUpTool> m_pixelDigitizationTool{this, "DigitizationTool", "PixelDigitizationTool", "PixelDigitizationTool name"}; }; - + #endif // PIXELDIGITIZATION_PIXELDIGITIZATION_H diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitizationTool.cxx b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitizationTool.cxx index 314f220d4e6c91990aad151a83ecffa112bdc3e5..78f6ff9c74bc7cf8997e237030a4d997062fede1 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitizationTool.cxx +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitizationTool.cxx @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////////// #include "PixelDigitizationTool.h" -#include "PileUpTools/PileUpMergeSvc.h" - #include "SiDigitization/SiChargedDiodeCollection.h" #include "Identifier/Identifier.h" #include "InDetIdentifier/PixelID.h" @@ -22,29 +20,11 @@ #include <limits> #include <cstdint> + PixelDigitizationTool::PixelDigitizationTool(const std::string &type, const std::string &name, const IInterface * pIID) : - PileUpToolBase(type,name,pIID), - m_rdoContainerKey("PixelRDOs"), - m_simDataCollKey("PixelSDO_Map"), - m_HardScatterSplittingMode(0), - m_HardScatterSplittingSkipper(false), - m_onlyHitElements(false), - m_detID(nullptr), - m_timedHits(nullptr), - m_mergeSvc("PileUpMergeSvc",name), - m_detManager(nullptr), - m_inputObjectName(""), - m_createNoiseSDO(false) -{ - declareProperty("MergeSvc", m_mergeSvc, "Merge service used in Pixel digitization"); - declareProperty("InputObjectName", m_inputObjectName, "Input Object name" ); - declareProperty("CreateNoiseSDO", m_createNoiseSDO, "Set create noise SDO flag"); - declareProperty("RDOCollName", m_rdoContainerKey, "RDO collection name"); - declareProperty("SDOCollName", m_simDataCollKey, "SDO collection name"); - declareProperty("OnlyHitElements", m_onlyHitElements, "Process only elements with hits"); - declareProperty("HardScatterSplittingMode", m_HardScatterSplittingMode, "Control pileup & signal splitting" ); + PileUpToolBase(type,name,pIID) { } //======================================= diff --git a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitizationTool.h b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitizationTool.h index 803fb2c7a013cdcde0ee0342377967d0a879080b..b34b48e4cfd19ac97fdb8e751c45ff4e0d66e18d 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitizationTool.h +++ b/InnerDetector/InDetDigitization/PixelDigitization/src/PixelDigitizationTool.h @@ -58,20 +58,20 @@ class PixelDigitizationTool : public PileUpToolBase { std::vector<SiHitCollection*> m_hitCollPtrs; - SG::ReadHandleKey<SiHitCollection> m_hitsContainerKey{this, "InputSingleHitsName", "", "Input Single HITS name"}; - SG::WriteHandleKey<PixelRDO_Container> m_rdoContainerKey; - SG::WriteHandle<PixelRDO_Container> m_rdoContainer; - SG::WriteHandleKey<InDetSimDataCollection> m_simDataCollKey; - SG::WriteHandle<InDetSimDataCollection> m_simDataColl; + SG::ReadHandleKey<SiHitCollection> m_hitsContainerKey{this, "InputSingleHitsName", "", "Input Single HITS name"}; + SG::WriteHandleKey<PixelRDO_Container> m_rdoContainerKey{this, "RDOCollName", "PixelRDOs", "RDO collection name"}; + SG::WriteHandle<PixelRDO_Container> m_rdoContainer{}; + SG::WriteHandleKey<InDetSimDataCollection> m_simDataCollKey{this, "SDOCollName", "PixelSDO_Map", "SDO collection name"}; + SG::WriteHandle<InDetSimDataCollection> m_simDataColl{}; + Gaudi::Property<int> m_HardScatterSplittingMode{this, "HardScatterSplittingMode", 0, "Control pileup & signal splitting"}; + bool m_HardScatterSplittingSkipper{false}; + Gaudi::Property<bool> m_onlyHitElements{this, "OnlyHitElements", false, "Process only elements with hits"}; + IntegerProperty m_vetoThisBarcode{this, "ParticleBarcodeVeto", crazyParticleBarcode, "Barcode of particle to ignore"}; - int m_HardScatterSplittingMode; - bool m_HardScatterSplittingSkipper; + const PixelID *m_detID{}; - bool m_onlyHitElements; - const PixelID *m_detID; - - TimedHitCollection<SiHit> *m_timedHits; + TimedHitCollection<SiHit> *m_timedHits{}; ToolHandleArray<SensorSimTool> m_chargeTool{this, "ChargeTools", {}, "List of charge tools"}; ToolHandleArray<FrontEndSimTool> m_fesimTool{this, "FrontEndSimTools", {}, "List of Front-End simulation tools"}; @@ -80,12 +80,11 @@ class PixelDigitizationTool : public PileUpToolBase { protected: ServiceHandle<IAthRNGSvc> m_rndmSvc{this, "RndmSvc", "AthRNGSvc", ""}; //!< Random number service - ServiceHandle <PileUpMergeSvc> m_mergeSvc; - - const InDetDD::PixelDetectorManager *m_detManager; + ServiceHandle <PileUpMergeSvc> m_mergeSvc{this, "PileUpMergeSvc", "PileUpMergeSvc", ""}; - std::string m_inputObjectName; - bool m_createNoiseSDO; + const InDetDD::PixelDetectorManager *m_detManager{}; + Gaudi::Property<std::string> m_inputObjectName{this, "InputObjectName", "", "Input Object name"}; + Gaudi::Property<bool> m_createNoiseSDO{this, "CreateNoiseSDO", false, "Set create noise SDO flag"}; }; diff --git a/InnerDetector/InDetDigitization/TRT_Digitization/src/TRTDigitization.cxx b/InnerDetector/InDetDigitization/TRT_Digitization/src/TRTDigitization.cxx index c262428b64b03059fbe134c63206fbd36c7cb57a..90061d7983072d0ce1eba4c43f01c28784c87dd8 100644 --- a/InnerDetector/InDetDigitization/TRT_Digitization/src/TRTDigitization.cxx +++ b/InnerDetector/InDetDigitization/TRT_Digitization/src/TRTDigitization.cxx @@ -1,18 +1,15 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "TRTDigitization.h" -#include "TRTDigitizationTool.h" //---------------------------------------------------------------------- // Constructor with parameters: //---------------------------------------------------------------------- TRTDigitization::TRTDigitization(const std::string &name, ISvcLocator *pSvcLocator) : - AthAlgorithm(name, pSvcLocator), - m_digTool("TRTDigitizationTool", this ) + AthAlgorithm(name, pSvcLocator) { - declareProperty("DigitizationTool", m_digTool, "AthAlgTool which performs the TRT digitization"); } //---------------------------------------------------------------------- @@ -20,10 +17,7 @@ TRTDigitization::TRTDigitization(const std::string &name, ISvcLocator *pSvcLocat //---------------------------------------------------------------------- StatusCode TRTDigitization::initialize() { // intitialize store gate active store - if (m_digTool.retrieve().isFailure()) { - ATH_MSG_FATAL ( "Could not retrieve TRT Digitization Tool!" ); - return StatusCode::FAILURE; - } + ATH_CHECK(m_digTool.retrieve()); ATH_MSG_DEBUG ( "Retrieved TRT Digitization Tool." ); return StatusCode::SUCCESS; } @@ -35,11 +29,3 @@ StatusCode TRTDigitization::execute() { ATH_MSG_DEBUG ( "execute()" ); return m_digTool->processAllSubEvents(); } - -//----------------------------------------------------------------------// -// Finalize method: // -//----------------------------------------------------------------------// -StatusCode TRTDigitization::finalize() { - ATH_MSG_DEBUG ( "finalize()" ); - return StatusCode::SUCCESS; -} diff --git a/InnerDetector/InDetDigitization/TRT_Digitization/src/TRTDigitization.h b/InnerDetector/InDetDigitization/TRT_Digitization/src/TRTDigitization.h index aa15f3cf866c17051aef8ae577f47f1ff86c6e22..4b5785fabc7722287d42c72de724ac454520c25f 100644 --- a/InnerDetector/InDetDigitization/TRT_Digitization/src/TRTDigitization.h +++ b/InnerDetector/InDetDigitization/TRT_Digitization/src/TRTDigitization.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef TRT_DIGITIZATION_TRTDIGITIZATION_H @@ -7,8 +7,7 @@ #include "GaudiKernel/ToolHandle.h" #include "AthenaBaseComps/AthAlgorithm.h" - -class TRTDigitizationTool; +#include "PileUpTools/IPileUpTool.h" /** Top algorithm class for TRT digitization */ class TRTDigitization : public AthAlgorithm { @@ -19,12 +18,11 @@ class TRTDigitization : public AthAlgorithm { TRTDigitization(const std::string &name,ISvcLocator *pSvcLocator); /** Basic algorithm methods */ - virtual StatusCode initialize(); - virtual StatusCode execute(); - virtual StatusCode finalize(); + virtual StatusCode initialize() override final; + virtual StatusCode execute() override final; private: - ToolHandle<TRTDigitizationTool> m_digTool; + ToolHandle<IPileUpTool> m_digTool{this,"DigitizationTool", "TRTDigitizationTool", "AthAlgTool which performs the TRT digitization"}; }; #endif // TRT_DIGITIZATION_TRTDIGITIZATION_H diff --git a/InnerDetector/InDetDigitization/TRT_Digitization/src/TRTDigitizationTool.cxx b/InnerDetector/InDetDigitization/TRT_Digitization/src/TRTDigitizationTool.cxx index f074e6658f3f4eee71dcee28a78cedf4b3e49a3e..c2e904e79feeeb268824946ab7c29967a83387db 100644 --- a/InnerDetector/InDetDigitization/TRT_Digitization/src/TRTDigitizationTool.cxx +++ b/InnerDetector/InDetDigitization/TRT_Digitization/src/TRTDigitizationTool.cxx @@ -25,8 +25,6 @@ #include "Identifier/Identifier.h" #include "InDetSimData/InDetSimData.h" #include "InDetSimData/InDetSimDataCollection.h" -#include "TRT_PAI_Process/ITRT_PAITool.h" -#include "TRT_Digitization/ITRT_SimDriftTimeTool.h" #include "InDetSimEvent/TRTHitIdHelper.h" #include "GeneratorObjects/HepMcParticleLink.h" @@ -49,7 +47,6 @@ // Gaudi includes #include "GaudiKernel/SmartDataPtr.h" -#include "TRT_ConditionsServices/ITRT_StrawNeighbourSvc.h" //CondDB #include "AthenaPoolUtilities/AthenaAttributeList.h" @@ -66,56 +63,12 @@ //_____________________________________________________________________________ TRTDigitizationTool::TRTDigitizationTool(const std::string& type, - const std::string& name, - const IInterface* parent) - : PileUpToolBase(type, name, parent), - m_TRTpaiToolXe("TRT_PAI_Process_Xe",this), - m_TRTpaiToolAr("TRT_PAI_Process_Ar",this), - m_TRTpaiToolKr("TRT_PAI_Process_Kr",this), - m_TRTsimdrifttimetool("TRT_SimDriftTimeTool"), - m_mergeSvc("PileUpMergeSvc",name), - m_pElectronicsProcessing(NULL), - m_pProcessingOfStraw(NULL), - m_pDigConditions(NULL), - m_pNoise(NULL), - m_TRTStrawNeighbourSvc("TRT_StrawNeighbourSvc",name), - m_manager(NULL), - m_trt_id(NULL), - m_thpctrt(NULL), - m_alreadyPrintedPDGcodeWarning(false), - m_minCrossingTimeSDO(0.0), - m_maxCrossingTimeSDO(0.0), - m_minpileuptruthEkin(0.0), - //m_ComTime(NULL), - m_particleTable(NULL), - m_dig_vers_from_condDB(-1), - m_digverscontainerkey("/TRT/Cond/DigVers"), - m_first_event(true), - m_condDBdigverfoldersexists(false), - m_HardScatterSplittingMode(0), - m_HardScatterSplittingSkipper(false), - m_UseGasMix(0), - m_cosmicEventPhase(0.0), - m_sumTool("TRT_StrawStatusSummaryTool",this) - + const std::string& name, + const IInterface* parent) + : PileUpToolBase(type, name, parent) { - - declareInterface<TRTDigitizationTool>(this); - declareProperty("PAI_Tool_Xe", m_TRTpaiToolXe, "The PAI model for ionisation in the TRT Xe gas" ); - declareProperty("PAI_Tool_Ar", m_TRTpaiToolAr, "The PAI model for ionisation in the TRT Ar gas" ); - declareProperty("PAI_Tool_Kr", m_TRTpaiToolKr, "The PAI model for ionisation in the TRT Kr gas" ); - declareProperty("SimDriftTimeTool", m_TRTsimdrifttimetool, "Drift time versus distance (r-t-relation) for TRT straws" ); - declareProperty("MergeSvc", m_mergeSvc, "Merge service" ); - declareProperty("DataObjectName", m_dataObjectName="TRTUncompressedHits", "Data Object Name" ); - declareProperty("PrintOverrideableSettings", m_printOverrideableSettings = false, "Print overrideable settings" ); - declareProperty("PrintDigSettings", m_printUsedDigSettings = true, "Print ditigization settings" ); m_settings = new TRTDigSettings(); m_settings->addPropertiesForOverrideableParameters(static_cast<AlgTool*>(this)); - declareProperty("TRT_StrawNeighbourSvc", m_TRTStrawNeighbourSvc); - declareProperty("InDetTRTStrawStatusSummaryTool", m_sumTool); - declareProperty("UseGasMix", m_UseGasMix); - declareProperty("HardScatterSplittingMode", m_HardScatterSplittingMode); - } //_____________________________________________________________________________ @@ -135,21 +88,13 @@ TRTDigitizationTool::~TRTDigitizationTool() { StatusCode TRTDigitizationTool::initialize() { - ATH_MSG_INFO ( "TRTDigitization::initialize() begin" ); - //ATH_MSG_DEBUG ( "TRTDigitization::initialize() begin" ); + ATH_MSG_DEBUG ( name()<<"::initialize() begin" ); // Get the TRT Detector Manager - if (StatusCode::SUCCESS != detStore()->retrieve(m_manager,"TRT") ) { - ATH_MSG_ERROR ( "Can't get TRT_DetectorManager " ); - return StatusCode::FAILURE; - } else { - ATH_MSG_DEBUG ( "Retrieved TRT_DetectorManager with version " << m_manager->getVersion().majorNum() ); - } + ATH_CHECK(detStore()->retrieve(m_manager,"TRT")); + ATH_MSG_DEBUG ( "Retrieved TRT_DetectorManager with version " << m_manager->getVersion().majorNum() ); - if (detStore()->retrieve(m_trt_id, "TRT_ID").isFailure()) { - ATH_MSG_ERROR ( "Could not get TRT ID helper" ); - return StatusCode::FAILURE; - } + ATH_CHECK(detStore()->retrieve(m_trt_id, "TRT_ID")); // Fill setting defaults and process joboption overrides: m_settings->initialize(m_manager); @@ -160,32 +105,18 @@ StatusCode TRTDigitizationTool::initialize() /// Get the PAI Tool for Xe, Ar, Kr gas mixtures: - if ( StatusCode::SUCCESS != m_TRTpaiToolXe.retrieve() ) { - ATH_MSG_ERROR ( "Can't get the Xe PAI Tool" ); - return StatusCode::FAILURE; - } else { - ATH_MSG_DEBUG ( "Retrieved the PAI Tool for Xe straws" ); - } + ATH_CHECK(m_TRTpaiToolXe.retrieve()); + ATH_MSG_DEBUG ( "Retrieved the PAI Tool for Xe straws" ); - if ( StatusCode::SUCCESS != m_TRTpaiToolAr.retrieve() ) { - ATH_MSG_WARNING ( "Can't get the Ar PAI Tool --> default PAI tool will be used for all straws (okay, if you don't use Argon straws)" ); - } else { - ATH_MSG_DEBUG ( "Retrieved the PAI Tool for Ar straws" ); - } + ATH_CHECK(m_TRTpaiToolAr.retrieve()); + ATH_MSG_DEBUG ( "Retrieved the PAI Tool for Ar straws" ); - if ( StatusCode::SUCCESS != m_TRTpaiToolKr.retrieve() ) { - ATH_MSG_WARNING ( "Can't get the Kr PAI Tool --> default PAI tool will be used for all straws (okay, if you don't use Krypton straws)" ); - } else { - ATH_MSG_DEBUG ( "Retrieved the PAI Tool for Kr straws" ); - } + ATH_CHECK(m_TRTpaiToolKr.retrieve()); + ATH_MSG_DEBUG ( "Retrieved the PAI Tool for Kr straws" ); /// Get the Sim-DriftTime Tool: - if ( StatusCode::SUCCESS != m_TRTsimdrifttimetool.retrieve() ) { - ATH_MSG_ERROR ( "Can't get the Sim. Drifttime Tool" ); - return StatusCode::FAILURE; - } else { - ATH_MSG_DEBUG ( "Retrieved the Sim. Drifttime Tool" ); - } + ATH_CHECK(m_TRTsimdrifttimetool.retrieve()); + ATH_MSG_DEBUG ( "Retrieved the Sim. Drifttime Tool" ); // Initialize ReadHandleKey if (!m_hitsContainerKey.key().empty()) { @@ -201,26 +132,16 @@ StatusCode TRTDigitizationTool::initialize() ATH_CHECK(m_rndmSvc.retrieve()); // Get the Particle Properties Service - IPartPropSvc* p_PartPropSvc = 0; + IPartPropSvc* p_PartPropSvc(nullptr); static const bool CREATEIFNOTTHERE(true); - StatusCode PartPropStatus = service("PartPropSvc", p_PartPropSvc, CREATEIFNOTTHERE); - if ( !PartPropStatus.isSuccess() || 0 == p_PartPropSvc ) { - ATH_MSG_ERROR ( "Could not initialize Particle Properties Service" ); - return PartPropStatus; - } + ATH_CHECK(service("PartPropSvc", p_PartPropSvc, CREATEIFNOTTHERE)); m_particleTable = p_PartPropSvc->PDT(); //locate the PileUpMergeSvc and initialize our local ptr - if (!m_mergeSvc.retrieve().isSuccess()) { - ATH_MSG_ERROR ( "Could not find PileUpMergeSvc" ); - return StatusCode::FAILURE; - } + ATH_CHECK(m_mergeSvc.retrieve()); //Retrieve TRT_StrawNeighbourService. - if (!m_TRTStrawNeighbourSvc.retrieve().isSuccess()) { - ATH_MSG_FATAL ( "Could not get StrawNeighbourSvc!" ); - return StatusCode::FAILURE; - } + ATH_CHECK(m_TRTStrawNeighbourSvc.retrieve()); // Check data object name if (m_dataObjectName == "") { @@ -272,8 +193,8 @@ StatusCode TRTDigitizationTool::prepareEvent(unsigned int) //_____________________________________________________________________________ StatusCode TRTDigitizationTool::processBunchXing(int bunchXing, - SubEventIterator bSubEvents, - SubEventIterator eSubEvents) { + SubEventIterator bSubEvents, + SubEventIterator eSubEvents) { m_seen.push_back(std::make_pair(std::distance(bSubEvents,eSubEvents), bunchXing)); //decide if this event will be processed depending on HardScatterSplittingMode & bunchXing @@ -338,7 +259,7 @@ StatusCode TRTDigitizationTool::lateInitialize(CLHEP::HepRandomEngine* noiseRndm //Resuming initialiazation. Section below had to be moved into event loop due to dependence on conditions data - TRTElectronicsNoise *electronicsNoise(NULL); + TRTElectronicsNoise *electronicsNoise(nullptr); if ( m_settings->noiseInUnhitStraws() || m_settings->noiseInSimhits() ) { electronicsNoise = new TRTElectronicsNoise(m_settings, elecNoiseRndmEngine); } @@ -376,7 +297,7 @@ StatusCode TRTDigitizationTool::lateInitialize(CLHEP::HepRandomEngine* noiseRndm ATH_MSG_DEBUG ( "Average straw noise level is " << m_pDigConditions->strawAverageNoiseLevel() ); } else { - m_pNoise = NULL; + m_pNoise = nullptr; } ITRT_PAITool *TRTpaiToolXe = &(* m_TRTpaiToolXe); @@ -767,7 +688,7 @@ StatusCode TRTDigitizationTool::createAndStoreRDOs() // for testing IdentifierHash IdHash; // default value is 0xFFFFFFFF IdentifierHash IdHashOld; // default value is 0xFFFFFFFF - TRT_RDO_Collection *RDOColl(NULL); + TRT_RDO_Collection *RDOColl(nullptr); Identifier idStraw; @@ -918,7 +839,7 @@ StatusCode TRTDigitizationTool::update( IOVSVC_CALLBACK_ARGS_P(I,keys) ) { ATH_MSG_INFO ("Updating condition settings TRT_Digitization! "); - const AthenaAttributeList* atrlist(NULL); + const AthenaAttributeList* atrlist(nullptr); if (StatusCode::SUCCESS == detStore()->retrieve(atrlist, m_digverscontainerkey ) && atrlist != 0) { std::list<std::string>::const_iterator itr; diff --git a/InnerDetector/InDetDigitization/TRT_Digitization/src/TRTDigitizationTool.h b/InnerDetector/InDetDigitization/TRT_Digitization/src/TRTDigitizationTool.h index c2df60fb43e41ee38239cdaaa3567a4dc69e4d2f..e51e9086867cdf10027cd7335484c15399afdd34 100644 --- a/InnerDetector/InDetDigitization/TRT_Digitization/src/TRTDigitizationTool.h +++ b/InnerDetector/InDetDigitization/TRT_Digitization/src/TRTDigitizationTool.h @@ -11,14 +11,19 @@ */ #include "xAODEventInfo/EventInfo.h" /*SubEvent*/ -#include "PileUpTools/PileUpToolBase.h" #include "AthenaKernel/IAthRNGSvc.h" +#include "PileUpTools/PileUpToolBase.h" #include "PileUpTools/PileUpMergeSvc.h" -#include "TRTDigit.h" #include "GaudiKernel/ServiceHandle.h" #include "GaudiKernel/ToolHandle.h" +#include "TRT_PAI_Process/ITRT_PAITool.h" +#include "TRT_Digitization/ITRT_SimDriftTimeTool.h" +#include "TRT_ConditionsServices/ITRT_StrawNeighbourSvc.h" +#include "TRT_ConditionsServices/ITRT_StrawStatusSummaryTool.h" + #include "InDetRawData/TRT_RDO_Container.h" #include "InDetSimData/InDetSimDataCollection.h" +#include "TRTDigit.h" #include "StoreGate/ReadHandleKey.h" #include "StoreGate/WriteHandleKey.h" @@ -28,15 +33,11 @@ #include <set> #include <utility> /* pair */ -class ITRT_PAITool; -class ITRT_SimDriftTimeTool; class TRT_ID; class TRTProcessingOfStraw; class TRTElectronicsProcessing; class TRTDigCondBase; class TRTNoise; -class ITRT_StrawNeighbourSvc; -class ITRT_StrawStatusSummaryTool; namespace CLHEP{ class HepRandomEngine; @@ -56,31 +57,31 @@ namespace InDetDD { class TRTDigSettings; -static const InterfaceID IID_ITRTDigitizationTool ("TRTDigitizationTool",1,0); - class TRTDigitizationTool : virtual public IPileUpTool, public PileUpToolBase { public: - static const InterfaceID& interfaceID(); TRTDigitizationTool( const std::string& type, const std::string& name, const IInterface* parent ); /** Destructor */ ~TRTDigitizationTool(); + /** Initialize */ + virtual StatusCode initialize() override final; + + /** Finalize */ + virtual StatusCode finalize() override final; + ///called at the end of the subevts loop. Not (necessarily) able to access SubEvents - StatusCode mergeEvent(); + virtual StatusCode mergeEvent() override final; ///called for each active bunch-crossing to process current SubEvents bunchXing is in ns - StatusCode processBunchXing( int bunchXing, - SubEventIterator bSubEvents, - SubEventIterator eSubEvents ); + virtual StatusCode processBunchXing( int bunchXing, + SubEventIterator bSubEvents, + SubEventIterator eSubEvents ) override final; /// return false if not interested in certain xing times (in ns) /// implemented by default in PileUpToolBase as FirstXing<=bunchXing<=LastXing // virtual bool toProcess(int bunchXing) const; - StatusCode prepareEvent( const unsigned int /*nInputEvents*/ ); - - /** Initialize */ - virtual StatusCode initialize(); + virtual StatusCode prepareEvent( const unsigned int /*nInputEvents*/ ) override final; /** * Perform digitization: @@ -89,18 +90,15 @@ public: * - Add noise * - Create RDO collection */ - virtual StatusCode processAllSubEvents(); - - /** Finalize */ - StatusCode finalize(); + virtual StatusCode processAllSubEvents() override final; private: CLHEP::HepRandomEngine* getRandomEngine(const std::string& streamName) const; Identifier getIdentifier( int hitID, - IdentifierHash& hashId, - Identifier& layerID, - bool& statusok ) const; + IdentifierHash& hashId, + Identifier& layerID, + bool& statusok ) const; StatusCode update( IOVSVC_CALLBACK_ARGS ); // Update of database entries. StatusCode ConditionsDependingInitialization(); @@ -123,61 +121,55 @@ private: unsigned int getRegion(int hitID); double getCosmicEventPhase(CLHEP::HepRandomEngine *rndmEngine); - std::vector<std::pair<unsigned int, int> > m_seen; - std::vector<TRTDigit> m_vDigits; /**< Vector of all digits */ - std::string m_dataObjectName; /**< Name of the hits collections */ + /// Configurable properties + ToolHandle<ITRT_PAITool> m_TRTpaiToolXe{this, "PAI_Tool_Xe", "TRT_PAI_Process_Xe", "The PAI model for ionisation in the TRT Xe gas"}; + ToolHandle<ITRT_PAITool> m_TRTpaiToolAr{this, "PAI_Tool_Ar", "TRT_PAI_Process_Ar", "The PAI model for ionisation in the TRT Ar gas"}; + ToolHandle<ITRT_PAITool> m_TRTpaiToolKr{this, "PAI_Tool_Kr", "TRT_PAI_Process_Kr", "The PAI model for ionisation in the TRT Kr gas"}; + ToolHandle<ITRT_SimDriftTimeTool> m_TRTsimdrifttimetool{this, "SimDriftTimeTool", "TRT_SimDriftTimeTool", "Drift time versus distance (r-t-relation) for TRT straws"}; + ToolHandle<ITRT_StrawStatusSummaryTool> m_sumTool{this, "InDetTRTStrawStatusSummaryTool", "TRT_StrawStatusSummaryTool", ""}; + ServiceHandle<PileUpMergeSvc> m_mergeSvc{this, "MergeSvc", "PileUpMergeSvc", "Merge service"}; + ServiceHandle<IAthRNGSvc> m_rndmSvc{this, "RndmSvc", "AthRNGSvc", ""}; //!< Random number service + ServiceHandle<ITRT_StrawNeighbourSvc> m_TRTStrawNeighbourSvc{this, "TRT_StrawNeighbourSvc", "TRT_StrawNeighbourSvc", ""}; + SG::ReadHandleKey<TRTUncompressedHitCollection> m_hitsContainerKey{this, "InputSingleHitsName", "", "Input Single HITS name"}; SG::WriteHandleKey<TRT_RDO_Container> m_outputRDOCollName{this,"OutputObjectName","TRT_RDOs","WHK Output Object name"}; /**< name of the output RDOs. */ SG::WriteHandleKey<InDetSimDataCollection> m_outputSDOCollName{this,"OutputSDOName","TRT_SDO_Map","WHK Output SDO container name"}; /**< name of the output SDOs. */ SG::WriteHandle<TRT_RDO_Container> m_trtrdo_container; //RDO container handle - bool m_printOverrideableSettings; - bool m_printUsedDigSettings; - ToolHandle<ITRT_PAITool> m_TRTpaiToolXe; - ToolHandle<ITRT_PAITool> m_TRTpaiToolAr; - ToolHandle<ITRT_PAITool> m_TRTpaiToolKr; - ToolHandle<ITRT_SimDriftTimeTool> m_TRTsimdrifttimetool; - ServiceHandle<PileUpMergeSvc> m_mergeSvc; /**< PileUp Merge service */ + Gaudi::Property<bool> m_printOverrideableSettings{this, "PrintOverrideableSettings", false, "Print overrideable settings"}; + Gaudi::Property<bool> m_printUsedDigSettings{this, "PrintDigSettings", true, "Print ditigization settings"}; + Gaudi::Property<std::string> m_dataObjectName{this, "DataObjectName", "TRTUncompressedHits", "Data Object Name"}; + Gaudi::Property<int> m_HardScatterSplittingMode{this, "HardScatterSplittingMode", 0, ""}; + Gaudi::Property<int> m_UseGasMix{this, "UseGasMix", 0, ""}; + IntegerProperty m_vetoThisBarcode{this, "ParticleBarcodeVeto", crazyParticleBarcode, "Barcode of particle to ignore"}; - TRTElectronicsProcessing * m_pElectronicsProcessing; - TRTProcessingOfStraw* m_pProcessingOfStraw; - TRTDigCondBase* m_pDigConditions; - TRTNoise* m_pNoise; + TRTDigSettings* m_settings{}; + std::vector<std::pair<unsigned int, int> > m_seen; + std::vector<TRTDigit> m_vDigits; /**< Vector of all digits */ + TRTElectronicsProcessing * m_pElectronicsProcessing{}; + TRTProcessingOfStraw* m_pProcessingOfStraw{}; + TRTDigCondBase* m_pDigConditions{}; + TRTNoise* m_pNoise{}; //unsigned int m_timer_eventcount; - ServiceHandle<IAthRNGSvc> m_rndmSvc{this, "RndmSvc", "AthRNGSvc", ""}; //!< Random number service - ServiceHandle<ITRT_StrawNeighbourSvc> m_TRTStrawNeighbourSvc; - - const InDetDD::TRT_DetectorManager* m_manager; - TRTDigSettings* m_settings; - const TRT_ID* m_trt_id; /**< TRT Id Helper */ + const InDetDD::TRT_DetectorManager* m_manager{}; + const TRT_ID* m_trt_id{}; /**< TRT Id Helper */ std::list<TRTUncompressedHitCollection*> m_trtHitCollList; - TimedHitCollection<TRTUncompressedHit>* m_thpctrt; - bool m_alreadyPrintedPDGcodeWarning; - double m_minCrossingTimeSDO; - double m_maxCrossingTimeSDO; - double m_minpileuptruthEkin; - - // const ComTime* m_ComTime; - - const HepPDT::ParticleDataTable* m_particleTable; - int m_dig_vers_from_condDB; - std::string m_digverscontainerkey; - bool m_first_event; - bool m_condDBdigverfoldersexists; - - int m_HardScatterSplittingMode; - bool m_HardScatterSplittingSkipper; - - int m_UseGasMix; - double m_cosmicEventPhase; // local replacement for the comTime service - ToolHandle<ITRT_StrawStatusSummaryTool> m_sumTool; + TimedHitCollection<TRTUncompressedHit>* m_thpctrt{}; + bool m_alreadyPrintedPDGcodeWarning{false}; + double m_minCrossingTimeSDO{0.0}; + double m_maxCrossingTimeSDO{0.0}; + double m_minpileuptruthEkin{0.0}; + // const ComTime* m_ComTime{}; + double m_cosmicEventPhase{0.0}; // local replacement for the comTime service + const HepPDT::ParticleDataTable* m_particleTable{}; + int m_dig_vers_from_condDB{-1}; + std::string m_digverscontainerkey{"/TRT/Cond/DigVers"}; + bool m_first_event{true}; + bool m_condDBdigverfoldersexists{false}; + + bool m_HardScatterSplittingSkipper{false}; }; -inline const InterfaceID& TRTDigitizationTool::interfaceID() -{ - return IID_ITRTDigitizationTool; -} - #endif diff --git a/MuonSpectrometer/MuonDigitization/CSC_Digitization/CSC_Digitization/CscDigitBuilder.h b/MuonSpectrometer/MuonDigitization/CSC_Digitization/CSC_Digitization/CscDigitBuilder.h index ff51b5755548adb5459eb4ace742881dfc311978..4e7aeaaaaf8214aed948ab0da7bb5319a0c6ca10 100644 --- a/MuonSpectrometer/MuonDigitization/CSC_Digitization/CSC_Digitization/CscDigitBuilder.h +++ b/MuonSpectrometer/MuonDigitization/CSC_Digitization/CSC_Digitization/CscDigitBuilder.h @@ -17,8 +17,7 @@ #include "GaudiKernel/ToolHandle.h" #include "AthenaBaseComps/AthAlgorithm.h" - -class IPileUpTool; +#include "PileUpTools/IPileUpTool.h" class CscDigitBuilder : public AthAlgorithm { diff --git a/MuonSpectrometer/MuonDigitization/CSC_Digitization/CSC_Digitization/CscDigitizationTool.h b/MuonSpectrometer/MuonDigitization/CSC_Digitization/CSC_Digitization/CscDigitizationTool.h index 52cc9a061f84940b26fffdc41921333c1b87215e..6f3f5aa4162c970fdaafdc44f20291e4c178481e 100644 --- a/MuonSpectrometer/MuonDigitization/CSC_Digitization/CSC_Digitization/CscDigitizationTool.h +++ b/MuonSpectrometer/MuonDigitization/CSC_Digitization/CSC_Digitization/CscDigitizationTool.h @@ -23,7 +23,7 @@ #include "PileUpTools/PileUpToolBase.h" -class PileUpMergeSvc; +#include "PileUpTools/PileUpMergeSvc.h" // Author: Ketevi A. Assamagan // BNL, October 27, 2003 @@ -78,6 +78,9 @@ public: //possibly these should be private? StatusCode CoreDigitization(CscDigitContainer* cscDigits,CscSimDataCollection* cscSimData, CLHEP::HepRandomEngine* rndmEngine); + // Get next event and extract collection of hit collections: + StatusCode getNextEvent(); + private: PublicToolHandle<ICscCalibTool> m_pcalib{this, "cscCalibTool", "CscCalibTool", ""}; @@ -92,40 +95,28 @@ private: const CscIdHelper * m_cscIdHelper{nullptr}; - double m_pedestal; - bool m_maskBadChannel; - double m_amplification; + Gaudi::Property<double> m_pedestal{this, "pedestal",0.0, ""}; + Gaudi::Property<bool> m_maskBadChannel{this, "maskBadChannels", true, ""}; + Gaudi::Property<double> m_amplification{this, "amplification", 0.58e5, ""}; //pile-up TimedHitCollection<CSCSimHit>* m_thpcCSC{nullptr}; // the hits std::list<CSCSimHitCollection*> m_cscHitCollList; // only for pileup events.. //pileup truth veto - bool m_includePileUpTruth; - - double m_timeWindowLowerOffset; - double m_timeWindowUpperOffset; - bool m_isPileUp; - bool m_newDigitEDM; - double m_driftVelocity; - double m_electronEnergy; - bool m_NInterFixed; - - /////////////////////////////////////////////////////////////////// - // Access to the event methods: - /////////////////////////////////////////////////////////////////// -private: - - // Get next event and extract collection of hit collections: - StatusCode getNextEvent(); + Gaudi::Property<bool> m_includePileUpTruth{this, "IncludePileUpTruth", true, "Include pile-up truth info"}; -protected: + Gaudi::Property<double> m_timeWindowLowerOffset{this, "WindowLowerOffset", -25., ""}; + Gaudi::Property<double> m_timeWindowUpperOffset{this, "WindowUpperOffset", +25., ""}; + Gaudi::Property<bool> m_isPileUp{this, "isPileUp", false, ""}; + Gaudi::Property<bool> m_newDigitEDM{this, "NewDigitEDM", true, ""}; + Gaudi::Property<double> m_driftVelocity{this, "DriftVelocity", 60, ""}; // 60 / (1e-6 * 1e9); // 6 cm/microsecond -> mm/ns // 0.06 + Gaudi::Property<double> m_electronEnergy{this, "ElectronEnergy", 66, ""}; // eV + Gaudi::Property<bool> m_NInterFixed{this, "NInterFixed", false, ""}; - PileUpMergeSvc *m_mergeSvc{nullptr}; // Pile up service - std::string m_inputObjectName{"CSC_Hits"}; // name of the input objects + ServiceHandle<PileUpMergeSvc> m_mergeSvc{this, "PileUpMergeSvc", "PileUpMergeSvc", ""}; // Pile up service + Gaudi::Property<std::string> m_inputObjectName{this, "InputObjectName", "CSC_Hits", "name of the input objects"}; // name of the input objects ServiceHandle <IAthRNGSvc> m_rndmSvc{this, "RndmSvc", "AthRNGSvc", ""}; // Random number service - CLHEP::HepRandomEngine *m_rndmEngine; // Random number engine used - not init in SiDigitization - std::string m_rndmEngineName;// name of random engine }; diff --git a/MuonSpectrometer/MuonDigitization/CSC_Digitization/src/CscDigitBuilder.cxx b/MuonSpectrometer/MuonDigitization/CSC_Digitization/src/CscDigitBuilder.cxx index cc1bae3dd5fa669a8339c59e6ce24f517bea4d78..4cf98725ceefe2fd91e002bc80fbef478bc770f7 100644 --- a/MuonSpectrometer/MuonDigitization/CSC_Digitization/src/CscDigitBuilder.cxx +++ b/MuonSpectrometer/MuonDigitization/CSC_Digitization/src/CscDigitBuilder.cxx @@ -8,7 +8,6 @@ // Digitization algorithm for the CSC hits #include "CSC_Digitization/CscDigitBuilder.h" -#include "PileUpTools/IPileUpTool.h" CscDigitBuilder::CscDigitBuilder(const std::string& name, ISvcLocator* pSvcLocator) diff --git a/MuonSpectrometer/MuonDigitization/CSC_Digitization/src/CscDigitizationTool.cxx b/MuonSpectrometer/MuonDigitization/CSC_Digitization/src/CscDigitizationTool.cxx index 64336ff639da03401ec283fbf3ad75f33f949538..78021330b02a6477daff986b5521d201832eed68 100644 --- a/MuonSpectrometer/MuonDigitization/CSC_Digitization/src/CscDigitizationTool.cxx +++ b/MuonSpectrometer/MuonDigitization/CSC_Digitization/src/CscDigitizationTool.cxx @@ -14,8 +14,6 @@ #include "StoreGate/StoreGateSvc.h" #include "StoreGate/DataHandle.h" -#include "PileUpTools/PileUpMergeSvc.h" - #include "CSC_Digitization/CscDigitizationTool.h" #include "AthenaKernel/RNGWrapper.h" @@ -26,22 +24,7 @@ using namespace MuonGM; CscDigitizationTool::CscDigitizationTool(const std::string& type,const std::string& name,const IInterface* pIID) : PileUpToolBase(type, name, pIID) { - - declareProperty("InputObjectName", m_inputObjectName = "CSC_Hits", "name of the input objects"); - declareProperty("pedestal",m_pedestal = 0.0); - declareProperty("WindowLowerOffset",m_timeWindowLowerOffset = -25.); - declareProperty("WindowUpperOffset",m_timeWindowUpperOffset = +25.); - declareProperty("isPileUp",m_isPileUp = false); - - declareProperty("maskBadChannels", m_maskBadChannel=true); - declareProperty("amplification", m_amplification=0.58e5); - - declareProperty("NewDigitEDM", m_newDigitEDM = true); - declareProperty("DriftVelocity", m_driftVelocity = 60); // 60 / (1e-6 * 1e9); // 6 cm/microsecond -> mm/ns // 0.06 - declareProperty("ElectronEnergy", m_electronEnergy = 66); // eV - declareProperty("NInterFixed", m_NInterFixed = false); - declareProperty("IncludePileUpTruth", m_includePileUpTruth = true, "Include pile-up truth info"); -} + } CscDigitizationTool::~CscDigitizationTool() { @@ -74,28 +57,17 @@ StatusCode CscDigitizationTool::initialize() { ATH_CHECK(m_cscSimDataCollectionWriteHandleKey.initialize()); // initialize transient detector store and MuonDetDescrManager - if ( detStore()->retrieve(m_geoMgr).isFailure() ) { - ATH_MSG_FATAL ( "Could not retrieve MuonDetectorManager!" ); - return StatusCode::FAILURE; - } - else - ATH_MSG_DEBUG ( "MuonDetectorManager retrieved from StoreGate."); - + ATH_CHECK(detStore()->retrieve(m_geoMgr)); + ATH_MSG_DEBUG ( "MuonDetectorManager retrieved from StoreGate."); - //locate the PileUpMergeSvc and initialize our local ptr - - const bool CREATEIF(true); - if (!(service("PileUpMergeSvc", m_mergeSvc, CREATEIF)).isSuccess() || - 0 == m_mergeSvc) { - ATH_MSG_ERROR ( "Could not find PileUpMergeSvc" ); - return StatusCode::FAILURE; - } + ATH_CHECK(m_mergeSvc.retrieve()); // check the input object name if (m_inputObjectName=="") { ATH_MSG_FATAL ( "Property InputObjectName not set !" ); return StatusCode::FAILURE; - } else { + } + else { ATH_MSG_DEBUG ( "Input objects: '" << m_inputObjectName << "'" ); } @@ -103,10 +75,7 @@ StatusCode CscDigitizationTool::initialize() { ATH_CHECK(m_rndmSvc.retrieve()); /** CSC calibratin tool for the Condtiions Data base access */ - if ( m_pcalib.retrieve().isFailure() ) { - ATH_MSG_ERROR ( "Can't get handle on CSC calibration tools" ); - return StatusCode::FAILURE; - } + ATH_CHECK(m_pcalib.retrieve()); ICscCalibTool * cscCalibTool = &*(m_pcalib); @@ -117,16 +86,12 @@ StatusCode CscDigitizationTool::initialize() { m_cscDigitizer->setDebug ( msgLvl(MSG::DEBUG) ); m_cscDigitizer->setDriftVelocity(m_driftVelocity); m_cscDigitizer->setElectronEnergy (m_electronEnergy); - if (m_NInterFixed) + if (m_NInterFixed) { m_cscDigitizer->setNInterFixed(); - - if ( m_cscDigitizer->initialize().isFailure() ) { - ATH_MSG_FATAL ( "Could not initialize CSC Digitizer!" ); - return StatusCode::FAILURE; } - m_cscIdHelper = m_geoMgr->cscIdHelper(); - // ATH_MSG_FATAL ( "Could not initialize CSC Digitizer!" ); + ATH_CHECK(m_cscDigitizer->initialize()); + m_cscIdHelper = m_geoMgr->cscIdHelper(); m_cscDigitizer->setWindow(m_timeWindowLowerOffset, m_timeWindowUpperOffset); diff --git a/MuonSpectrometer/MuonDigitization/RPC_Digitization/RPC_Digitization/RpcDigitizationTool.h b/MuonSpectrometer/MuonDigitization/RPC_Digitization/RPC_Digitization/RpcDigitizationTool.h index f21653e581683006fe8d7a7d116c9ca3f14addd5..fbe45c008327049d7709d75bf217d0157f0c9fdc 100644 --- a/MuonSpectrometer/MuonDigitization/RPC_Digitization/RPC_Digitization/RpcDigitizationTool.h +++ b/MuonSpectrometer/MuonDigitization/RPC_Digitization/RPC_Digitization/RpcDigitizationTool.h @@ -8,32 +8,32 @@ #define RPC_DIGITIZATIONTOOL_H /** @class RpcDigitizationTool -@section RPC_DigitizerDetails Class methods and properties - - -In the initialize() method, the PileUpMerge and StoreGate services are initialized, -and a pointer to an instance of the class MuonDetectorManager is retrieved from -the detector store and used to obtain an rpcIdHelper. -The ASCII file G4RPC_Digitizer.txt is read and its contents are used by the -algorithm in order to simulate clusters. -Random numbers are obtained in the code from a dedicated stream via -AtRndmSvc, which is also initialized in the initialize() method. -The execute() has responsibility for steering the digitization/cluster -simulation process. A loop over the RPCHits is performed, converting each SimID to OID. -The method PhysicalClusterSize -is hence called, which creates a cluster of size 1 or two according to the impact point -of the particle along the strip. The final size of the cluster is decided by the -method TurnOnStrips. -The last step in the creation of the digitization is the calculation of the -propagation time of the electrical signal along the strip length. This is done in -the PropagationTime method. -In the hit collections coming from the RPCSensitiveDetector, it sometimes happen that -many hits are produced by the same crossing particle, which are very close both in -space and time. This is related to ionization and production of secondaries in the gas, -and it is thus safe, and also recommended, to eliminate these multiple hits before -proceeding to reconstruction. The execute() method provides this functionality -using a dead time: once a hit is found on a given strip, every other hit coming from -the same strip before the dead time is ignored. + @section RPC_DigitizerDetails Class methods and properties + + + In the initialize() method, the PileUpMerge and StoreGate services are initialized, + and a pointer to an instance of the class MuonDetectorManager is retrieved from + the detector store and used to obtain an rpcIdHelper. + The ASCII file G4RPC_Digitizer.txt is read and its contents are used by the + algorithm in order to simulate clusters. + Random numbers are obtained in the code from a dedicated stream via + AtRndmSvc, which is also initialized in the initialize() method. + The execute() has responsibility for steering the digitization/cluster + simulation process. A loop over the RPCHits is performed, converting each SimID to OID. + The method PhysicalClusterSize + is hence called, which creates a cluster of size 1 or two according to the impact point + of the particle along the strip. The final size of the cluster is decided by the + method TurnOnStrips. + The last step in the creation of the digitization is the calculation of the + propagation time of the electrical signal along the strip length. This is done in + the PropagationTime method. + In the hit collections coming from the RPCSensitiveDetector, it sometimes happen that + many hits are produced by the same crossing particle, which are very close both in + space and time. This is related to ionization and production of secondaries in the gas, + and it is thus safe, and also recommended, to eliminate these multiple hits before + proceeding to reconstruction. The execute() method provides this functionality + using a dead time: once a hit is found on a given strip, every other hit coming from + the same strip before the dead time is ignored. */ @@ -42,6 +42,7 @@ the same strip before the dead time is ignored. #include "PileUpTools/PileUpToolBase.h" #include "AthenaKernel/IAthRNGSvc.h" +#include "PileUpTools/PileUpMergeSvc.h" #include "MuonSimEvent/RPCSimHit.h" #include "MuonSimEvent/RPCSimHitCollection.h" @@ -62,10 +63,8 @@ the same strip before the dead time is ignored. class RpcHitIdHelper; class RpcIdHelper; -class PileUpMergeSvc; -class IAtRndmGenSvc; class ITagInfoMgr; - + namespace MuonGM{ class MuonDetectorManager; } @@ -79,13 +78,13 @@ public: RpcDigitizationTool(const std::string& type, const std::string& name, const IInterface* pIID); /** Initialize */ - virtual StatusCode initialize() override final; + virtual StatusCode initialize() override final; - /** When being run from PileUpToolsAlgs, this method is called at the start of + /** When being run from PileUpToolsAlgs, this method is called at the start of the subevts loop. Not able to access SubEvents */ virtual StatusCode prepareEvent(const unsigned int /*nInputEvents*/) override final; - /** When being run from PileUpToolsAlgs, this method is called for each active + /** When being run from PileUpToolsAlgs, this method is called for each active bunch-crossing to process current SubEvents bunchXing is in ns */ virtual StatusCode processBunchXing( @@ -95,37 +94,16 @@ public: ) override final; - /** When being run from PileUpToolsAlgs, this method is called at the end of + /** When being run from PileUpToolsAlgs, this method is called at the end of the subevts loop. Not (necessarily) able to access SubEvents */ virtual StatusCode mergeEvent() override final; /** alternative interface which uses the PileUpMergeSvc to obtain - all the required SubEvents. */ + all the required SubEvents. */ virtual StatusCode processAllSubEvents() override final; private: - const MuonGM::MuonDetectorManager* m_GMmgr; - const RpcIdHelper* m_idHelper; - RpcHitIdHelper* m_muonHelper; - std::list<RPCSimHitCollection*> m_RPCHitCollList; - TimedHitCollection<RPCSimHit>* m_thpcRPC; - ServiceHandle<IRPCConditionsSvc> m_rSummarySvc; - std::map<Identifier,std::vector<MuonSimData::Deposit> > m_sdo_tmp_map; - int m_deadTime; - bool m_patch_for_rpc_time; - double m_rpc_time_shift ; - std::string m_paraFile; // ascii file with cluster simulation parameters - std::vector<double> m_csPara; // cluster simulation parameters - std::vector<double> m_rgausPara; - std::vector<double> m_fgausPara; - std::vector<double> m_constPara; - double m_cs3Para; - std::vector<double> m_cs4Para; - bool m_validationSetup; - //pileup truth veto - bool m_includePileUpTruth; - /** Get next event and extract collection of hit collections: */ StatusCode getNextEvent(); /** Digitization functionality shared with RPC_PileUpTool */ @@ -154,9 +132,9 @@ private: double PropagationTimeNew(const Identifier* id, const Amg::Vector3D globPos); /** Calculates the position of the hit wrt to the strip panel this transformation is needed since the impact point comes from the SD - int he gas gap's reference frame. */ - double m_UncorrJitter ; //time jitter uncorrelated between eta and phi - double m_CorrJitter ; //time jitter correlated between eta and phi + int he gas gap's reference frame. */ + Gaudi::Property<double> m_UncorrJitter {this, "UncorrJitter", 1.5 , "jitter uncorrelated between eta and phi"}; + Gaudi::Property<double> m_CorrJitter {this, "CorrJitter", 0.0 , "jitter correlated between eta and phi"}; Amg::Vector3D posInPanel(const Identifier* id, const Amg::Vector3D posInGap); /** adjust strip numbering according to standard OIDs **/ int adjustStripNumber(const Identifier* id,int nstrip); @@ -171,8 +149,8 @@ private: //pile-up bool outsideWindow(double time) const; - double m_timeWindowLowerOffset; - double m_timeWindowUpperOffset; + Gaudi::Property<double> m_timeWindowLowerOffset{this, "WindowLowerOffset", -100. , "digitization window lower limit"}; + Gaudi::Property<double> m_timeWindowUpperOffset{this, "WindowUpperOffset", +150. , "digitization window lower limit"}; /** Average calibration methods and parameters */ StatusCode PrintCalibrationVector(); @@ -182,72 +160,110 @@ private: int ClusterSizeEvaluation(const Identifier* id, float xstripnorm, CLHEP::HepRandomEngine* rndmEngine); /** CoolDB */ StatusCode DumpRPCCalibFromCoolDB(); - - bool m_turnON_efficiency ; - bool m_kill_deadstrips ;//gabriele - bool m_applyEffThreshold ;//stefania - float m_Minimum_efficiency ;//gabriele - bool m_turnON_clustersize ; - int m_testbeam_clustersize ; - int m_FirstClusterSizeInTail ; - - std::vector<float> m_PhiAndEtaEff_A; - std::vector<float> m_OnlyPhiEff_A ; - std::vector<float> m_OnlyEtaEff_A ; - - std::vector<float> m_PhiAndEtaEff_C; - std::vector<float> m_OnlyPhiEff_C ; - std::vector<float> m_OnlyEtaEff_C ; - - std::vector<double> m_FracClusterSize1_A ; - std::vector<double> m_FracClusterSize2_A ; - std::vector<double> m_FracClusterSizeTail_A; - std::vector<double> m_MeanClusterSizeTail_A; - - std::vector<double> m_FracClusterSize1_C ; - std::vector<double> m_FracClusterSize2_C ; - std::vector<double> m_FracClusterSizeTail_C; - std::vector<double> m_MeanClusterSizeTail_C; - - std::vector<Identifier> m_DeadStripPanel; - - bool m_SetPhiOn ; - bool m_SetEtaOn ; - bool m_muonOnlySDOs; -protected: - PileUpMergeSvc *m_mergeSvc; // Pile up service - std::string m_inputHitCollectionName; // name of the input objects - SG::WriteHandleKey<RpcDigitContainer> m_outputDigitCollectionKey{this,"OutputObjectName","RPC_DIGITS","WriteHandleKey for Output RpcDigitContainer"}; // name of the output digits - SG::WriteHandleKey<MuonSimDataCollection> m_outputSDO_CollectionKey{this,"OutputSDOName","RPC_SDO","WriteHandleKey for Output MuonSimDataCollection"}; // name of the output SDOs + + const MuonGM::MuonDetectorManager* m_GMmgr{}; + const RpcIdHelper* m_idHelper{}; + RpcHitIdHelper* m_muonHelper{}; + std::list<RPCSimHitCollection*> m_RPCHitCollList; + TimedHitCollection<RPCSimHit>* m_thpcRPC{}; + ServiceHandle<IRPCConditionsSvc> m_rSummarySvc{this, "RPCCondSummarySvc", "RPCCondSummarySvc", ""}; + std::map<Identifier,std::vector<MuonSimData::Deposit> > m_sdo_tmp_map; + Gaudi::Property<int> m_deadTime{this, "DeadTime", 100. , "dead time"}; + Gaudi::Property<bool> m_patch_for_rpc_time{this, "PatchForRpcTime", false, ""}; + Gaudi::Property<double> m_rpc_time_shift{this, "PatchForRpcTimeShift", 12.5, + "shift rpc digit time to match hardware time calibration: Zmumu muons are at the center of BC0, i.e. at 12.5ns+BC0shift w.r.t. RPC readout (BC0shift=2x3.125)"}; + Gaudi::Property<std::string> m_paraFile{this, "Parameters", "G4RPC_Digitizer.txt", + "ascii file with cluster simulation parameters"}; + std::vector<double> m_csPara; // cluster simulation parameters + std::vector<double> m_rgausPara; + std::vector<double> m_fgausPara; + std::vector<double> m_constPara; + double m_cs3Para{0}; + std::vector<double> m_cs4Para; + Gaudi::Property<bool> m_validationSetup{this, "ValidationSetup", false, ""}; + Gaudi::Property<bool> m_includePileUpTruth{this, "IncludePileUpTruth", true, "pileup truth veto"}; + + Gaudi::Property<bool> m_turnON_efficiency{this, "turnON_efficiency", true, ""}; + Gaudi::Property<bool> m_kill_deadstrips{this, "KillDeadStrips", false, ""};//gabriele + Gaudi::Property<bool> m_applyEffThreshold{this, "ApplyEfficiencyThreshold", false, ""};//stefania + Gaudi::Property<float> m_Minimum_efficiency{this, "Minimum_efficiency", 0.5, ""};//gabriele + Gaudi::Property<bool> m_turnON_clustersize{this, "turnON_clustersize", true, ""}; + Gaudi::Property<int> m_testbeam_clustersize{this, "testbeam_clustersize", 1, ""}; + Gaudi::Property<int> m_FirstClusterSizeInTail{this, "FirstClusterSizeInTail", 3, ""}; + + Gaudi::Property< std::vector<float> > m_PhiAndEtaEff_A{this, "PhiAndEtaEff_A", {} , ""}; + Gaudi::Property< std::vector<float> > m_OnlyPhiEff_A {this, "OnlyPhiEff_A" , {} , ""}; + Gaudi::Property< std::vector<float> > m_OnlyEtaEff_A {this, "OnlyEtaEff_A" , {} , ""}; + Gaudi::Property< std::vector<float> > m_PhiAndEtaEff_C{this, "PhiAndEtaEff_C", {} , ""}; + Gaudi::Property< std::vector<float> > m_OnlyPhiEff_C {this, "OnlyPhiEff_C" , {} , ""}; + Gaudi::Property< std::vector<float> > m_OnlyEtaEff_C {this, "OnlyEtaEff_C" , {} , ""}; + + Gaudi::Property< std::vector<double> > m_FracClusterSize1_A {this, "FracClusterSize1_A" , {} , ""}; + Gaudi::Property< std::vector<double> > m_FracClusterSize2_A {this, "FracClusterSize2_A" , {} , ""}; + Gaudi::Property< std::vector<double> > m_FracClusterSizeTail_A{this, "FracClusterSizeTail_A", {} , ""}; + Gaudi::Property< std::vector<double> > m_MeanClusterSizeTail_A{this, "MeanClusterSizeTail_A", {} , ""}; + + Gaudi::Property< std::vector<double> > m_FracClusterSize1_C {this, "FracClusterSize1_C" , {} , ""}; + Gaudi::Property< std::vector<double> > m_FracClusterSize2_C {this, "FracClusterSize2_C" , {} , ""}; + Gaudi::Property< std::vector<double> > m_FracClusterSizeTail_C{this, "FracClusterSizeTail_C", {} , ""}; + Gaudi::Property< std::vector<double> > m_MeanClusterSizeTail_C{this, "MeanClusterSizeTail_C", {} , ""}; + + std::vector<Identifier> m_DeadStripPanel; + + bool m_SetPhiOn{false}; + bool m_SetEtaOn{false}; + Gaudi::Property<bool> m_muonOnlySDOs{this, "MuonOnlySDOs", true, ""}; +protected: + ServiceHandle<PileUpMergeSvc> m_mergeSvc{this, "PileUpMergeSvc", "PileUpMergeSvc", + "Pile up service"}; + Gaudi::Property<std::string> m_inputHitCollectionName{this, "InputObjectName", "RPC_Hits", + "name of the input object"}; + SG::WriteHandleKey<RpcDigitContainer> m_outputDigitCollectionKey{this, "OutputObjectName", "RPC_DIGITS", + "WriteHandleKey for Output RpcDigitContainer"}; // name of the output digits + SG::WriteHandleKey<MuonSimDataCollection> m_outputSDO_CollectionKey{this, "OutputSDOName", "RPC_SDO", + "WriteHandleKey for Output MuonSimDataCollection"}; // name of the output SDOs ServiceHandle<IAthRNGSvc> m_rndmSvc{this, "RndmSvc", "AthRNGSvc", ""}; // Random number service - ITagInfoMgr *m_tagInfoMgr ; // Tag Info Manager - std::string m_RPC_TimeSchema ; // Tag info name of Rpc Time Info - bool m_sdoAreOnlyDigits ; // decide is SDO deposits are saved for all G4 hits or only for those accepted as digits - bool m_PrintCalibrationVector ; // Printout Eff and CS average parameters - bool m_Efficiency_fromCOOL ; // Read efficiency from CoolDB - bool m_EfficiencyPatchForBMShighEta ; // special patch to be true only when m_Efficiency_fromCOOL=true and /RPC/DQMF/ELEMENT_STATUS tag is RPCDQMFElementStatus_2012_Jaunuary_26 - bool m_ClusterSize_fromCOOL ; // Read cluster size from CoolDB - bool m_ClusterSize1_2uncorr ; // Cluster size 1 and 2 not correlated to track position - bool m_BOG_BOF_DoubletR2_OFF ; // Turn-off BOG and BOF with DoubletR=2 - bool m_ignoreRunDepConfig ; // true if we want to force the RUN1/RUN2 dependent options - bool m_PanelId_OFF_fromlist ; // Turn-off PanelId from file m_FileName_DeadPanels - std::string m_FileName_DeadPanels ; // File with Dead panel PanelId list - bool m_PanelId_OK_fromlist ; // Turn-on PanelId from file m_FileName_GoodPanels - std::string m_FileName_GoodPanels ; // File with Good panel PanelId list + ITagInfoMgr *m_tagInfoMgr{} ; // Tag Info Manager + Gaudi::Property<std::string> m_RPC_TimeSchema{this, "RPC_TimeSchema", "RPC_TimeSchema", + "Tag info name of Rpc Time Info"}; + Gaudi::Property<bool> m_sdoAreOnlyDigits{this, "RPCSDOareRPCDigits", true, + "decide is SDO deposits are saved for all G4 hits or only for those accepted as digits"}; + Gaudi::Property<bool> m_PrintCalibrationVector {this, "PrintCalibrationVector", false, + "Printout Eff and CS average parameters"}; + Gaudi::Property<bool> m_Efficiency_fromCOOL {this, "Efficiency_fromCOOL", false, + "Read efficiency from CoolDB"}; + Gaudi::Property<bool> m_EfficiencyPatchForBMShighEta{this, "EfficiencyPatchForBMShighEta", false, + "special patch to be true only when m_Efficiency_fromCOOL=true and /RPC/DQMF/ELEMENT_STATUS tag is RPCDQMFElementStatus_2012_Jaunuary_26"}; + Gaudi::Property<bool> m_ClusterSize_fromCOOL {this, "ClusterSize_fromCOOL", false, + "Read cluster size from CoolDB"}; + Gaudi::Property<bool> m_ClusterSize1_2uncorr {this, "ClusterSize1_2uncorr", false, + "Cluster size 1 and 2 not correlated to track position"}; + Gaudi::Property<bool> m_BOG_BOF_DoubletR2_OFF {this, "Force_BOG_BOF_DoubletR2_OFF", false, + "Turn-off BOG and BOF with DoubletR=2"}; + Gaudi::Property<bool> m_ignoreRunDepConfig {this, "IgnoreRunDependentConfig", false, + "true if we want to force the RUN1/RUN2 dependent options"}; + Gaudi::Property<bool> m_PanelId_OFF_fromlist {this, "PanelId_OFF_fromlist", false, + "Turn-off PanelId from file m_FileName_DeadPanels"}; + Gaudi::Property<std::string> m_FileName_DeadPanels {this, "FileName_DeadPanels", "PermanentDeadPanels.txt", + "File with Dead panel PanelId list"}; + Gaudi::Property<bool> m_PanelId_OK_fromlist {this, "PanelId_OK_fromlist", false, + "Turn-on PanelId from file m_FileName_GoodPanels"}; + Gaudi::Property<std::string> m_FileName_GoodPanels {this, "FileName_GoodPanels", "PermanentGoodPanels.txt", + " File with Good panel PanelId list"}; std::map<Identifier , int> m_DeadPanel_fromlist; std::map<Identifier , int> m_GoodPanel_fromlist; - bool m_RPCInfoFromDb ; - bool m_DumpFromDbFirst ; - float m_CutMaxClusterSize ; - int m_CutProjectedTracks; + Gaudi::Property<bool> m_RPCInfoFromDb {this, "RPCInfoFromDb", false, ""}; + Gaudi::Property<bool> m_DumpFromDbFirst {this, "DumpFromDbFirst", false, ""}; + Gaudi::Property<float> m_CutMaxClusterSize {this, "CutMaxClusterSize", 5.0, ""}; + Gaudi::Property<int> m_CutProjectedTracks{this, "CutProjectedTracks", 100, ""}; }; -inline +inline bool RpcDigitizationTool::outsideWindow(double time) const { return time < m_timeWindowLowerOffset || time > m_timeWindowUpperOffset; } diff --git a/MuonSpectrometer/MuonDigitization/RPC_Digitization/src/RpcDigitizationTool.cxx b/MuonSpectrometer/MuonDigitization/RPC_Digitization/src/RpcDigitizationTool.cxx index 2f7cfdb906745ce4db3633dd6edba3b9ca98c31d..f57c4cc2e13a47d9f1b37de17466419a1ad66ea1 100644 --- a/MuonSpectrometer/MuonDigitization/RPC_Digitization/src/RpcDigitizationTool.cxx +++ b/MuonSpectrometer/MuonDigitization/RPC_Digitization/src/RpcDigitizationTool.cxx @@ -13,7 +13,6 @@ //////////////////////////////////////////////////////////////////////////////// #include "RPC_Digitization/RpcDigitizationTool.h" -#include "PileUpTools/PileUpMergeSvc.h" //Inputs #include "MuonSimEvent/RPCSimHit.h" @@ -22,16 +21,15 @@ #include "MuonIdHelpers/RpcIdHelper.h" #include "MuonReadoutGeometry/RpcReadoutElement.h" #include "MuonReadoutGeometry/MuonDetectorManager.h" -#include "MuonCondInterface/IRPCConditionsSvc.h" #include "MuonSimEvent/RpcHitIdHelper.h" -//run n. from geometry DB -#include "GeoModelInterfaces/IGeoModelSvc.h" -#include "GeometryDBSvc/IGeometryDBSvc.h" -#include "RDBAccessSvc/IRDBAccessSvc.h" -#include "RDBAccessSvc/IRDBRecordset.h" -#include "RDBAccessSvc/IRDBRecord.h" +//run n. from geometry DB +#include "GeoModelInterfaces/IGeoModelSvc.h" +#include "GeometryDBSvc/IGeometryDBSvc.h" +#include "RDBAccessSvc/IRDBAccessSvc.h" +#include "RDBAccessSvc/IRDBRecordset.h" +#include "RDBAccessSvc/IRDBRecord.h" //Truth #include "GeneratorObjects/HepMcParticleLink.h" @@ -60,75 +58,10 @@ using namespace MuonGM; static double time_correction(double, double, double); RpcDigitizationTool::RpcDigitizationTool(const std::string& type, - const std::string& name, - const IInterface* pIID) + const std::string& name, + const IInterface* pIID) : PileUpToolBase(type, name, pIID) - , m_GMmgr(0) - , m_idHelper(0) - , m_muonHelper(0) - , m_thpcRPC(0) - , m_rSummarySvc("RPCCondSummarySvc", name) - , m_cs3Para(0) - , m_validationSetup(false) - , m_SetPhiOn(false) - , m_SetEtaOn(false) - , m_mergeSvc(0) - , m_inputHitCollectionName("RPC_Hits") - , m_tagInfoMgr(0) { - - declareProperty("Parameters" , m_paraFile = "G4RPC_Digitizer.txt"); // File with cluster distributions - declareProperty("InputObjectName" , m_inputHitCollectionName = "RPC_Hits", "name of the input object"); - declareProperty("WindowLowerOffset" , m_timeWindowLowerOffset = -100. , "digitization window lower limit"); - declareProperty("WindowUpperOffset" , m_timeWindowUpperOffset = +150. , "digitization window lower limit"); - declareProperty("DeadTime" , m_deadTime = 100. , "dead time" ); - declareProperty("UncorrJitter" , m_UncorrJitter = 1.5 , "jitter uncorrelated" ); - declareProperty("CorrJitter" , m_CorrJitter = 0.0 , "jitter correlated" ); - declareProperty("PatchForRpcTime" , m_patch_for_rpc_time = false ); - declareProperty("PatchForRpcTimeShift" , m_rpc_time_shift = 12.5 ); // shift rpc digit time to match hardware time calibration: Zmumu muons are at the center of BC0, i.e. at 12.5ns+BC0shift w.r.t. RPC readout (BC0shift=2x3.125) - declareProperty("RPC_TimeSchema" , m_RPC_TimeSchema = "RPC_TimeSchema"); // RPC time Info tag name - declareProperty("RPCSDOareRPCDigits" , m_sdoAreOnlyDigits = true ); - declareProperty("MuonOnlySDOs" , m_muonOnlySDOs = true ); - declareProperty("PanelId_OFF_fromlist" , m_PanelId_OFF_fromlist = false ); - declareProperty("FileName_DeadPanels" , m_FileName_DeadPanels= "PermanentDeadPanels.txt"); //File with deadpanel list - declareProperty("PanelId_OK_fromlist" , m_PanelId_OK_fromlist = false ); - declareProperty("FileName_GoodPanels" , m_FileName_GoodPanels= "PermanentGoodPanels.txt"); //File with goodpanel list - - declareProperty("PhiAndEtaEff_A" , m_PhiAndEtaEff_A ); - declareProperty("OnlyPhiEff_A" , m_OnlyPhiEff_A ); - declareProperty("OnlyEtaEff_A" , m_OnlyEtaEff_A ); - declareProperty("PhiAndEtaEff_C" , m_PhiAndEtaEff_C ); - declareProperty("OnlyPhiEff_C" , m_OnlyPhiEff_C ); - declareProperty("OnlyEtaEff_C" , m_OnlyEtaEff_C ); - declareProperty("FracClusterSize1_A" , m_FracClusterSize1_A ); - declareProperty("FracClusterSize2_A" , m_FracClusterSize2_A ); - declareProperty("FracClusterSizeTail_A" , m_FracClusterSizeTail_A ); - declareProperty("MeanClusterSizeTail_A" , m_MeanClusterSizeTail_A ); - declareProperty("FracClusterSize1_C" , m_FracClusterSize1_C ); - declareProperty("FracClusterSize2_C" , m_FracClusterSize2_C ); - declareProperty("FracClusterSizeTail_C" , m_FracClusterSizeTail_C ); - declareProperty("MeanClusterSizeTail_C" , m_MeanClusterSizeTail_C ); - declareProperty("turnON_efficiency" , m_turnON_efficiency = true ); - declareProperty("Minimum_efficiency" , m_Minimum_efficiency = 0.5 ); - declareProperty("ApplyEfficiencyThreshold" , m_applyEffThreshold = false ); - declareProperty("Efficiency_fromCOOL" , m_Efficiency_fromCOOL = false ); - declareProperty("KillDeadStrips" , m_kill_deadstrips = false ); - declareProperty("EfficiencyPatchForBMShighEta", m_EfficiencyPatchForBMShighEta = false ); - declareProperty("turnON_clustersize" , m_turnON_clustersize = true ); - declareProperty("ClusterSize_fromCOOL" , m_ClusterSize_fromCOOL = false ); - declareProperty("testbeam_clustersize" , m_testbeam_clustersize = 1 ); - declareProperty("ClusterSize1_2uncorr" , m_ClusterSize1_2uncorr = 0 ); - declareProperty("FirstClusterSizeInTail" , m_FirstClusterSizeInTail = 3 ); - declareProperty("PrintCalibrationVector" , m_PrintCalibrationVector = 0 ); - declareProperty("Force_BOG_BOF_DoubletR2_OFF", m_BOG_BOF_DoubletR2_OFF = false ); - declareProperty("IgnoreRunDependentConfig" , m_ignoreRunDepConfig = false ); - declareProperty("RPCInfoFromDb" , m_RPCInfoFromDb = false ); - declareProperty("DumpFromDbFirst" , m_DumpFromDbFirst = false ); - declareProperty("CutMaxClusterSize" , m_CutMaxClusterSize = 5.0 ); - declareProperty("CutProjectedTracks" , m_CutProjectedTracks = 100 ); - declareProperty("RPCCondSummarySvc" , m_rSummarySvc ); - declareProperty("ValidationSetup" , m_validationSetup = false ); - declareProperty("IncludePileUpTruth" , m_includePileUpTruth = true ); } // member function implementation @@ -152,7 +85,7 @@ StatusCode RpcDigitizationTool::initialize() { ATH_MSG_DEBUG ( "RPCSDOareRPCDigits " << m_sdoAreOnlyDigits ); - ATH_MSG_DEBUG ( "IgnoreRunDependentConfig "<< m_ignoreRunDepConfig ); + ATH_MSG_DEBUG ( "IgnoreRunDependentConfig "<< m_ignoreRunDepConfig ); ATH_MSG_DEBUG ( "turnON_efficiency " << m_turnON_efficiency ); ATH_MSG_DEBUG ( "Efficiency_fromCOOL " << m_Efficiency_fromCOOL ); ATH_MSG_DEBUG ( "turnON_clustersize " << m_turnON_clustersize ); @@ -175,20 +108,10 @@ StatusCode RpcDigitizationTool::initialize() { ATH_MSG_DEBUG ( "ParticleBarcodeVeto " << m_vetoThisBarcode ); - if (detStore()->retrieve( m_GMmgr,"Muon" ).isFailure()) { - return StatusCode::FAILURE; - } + ATH_CHECK(detStore()->retrieve( m_GMmgr,"Muon" )); ATH_MSG_DEBUG ( "Retrieved GeoModel from DetectorStore." ); - if(!m_mergeSvc) { - //locate the PileUpMergeSvc and initialize our local ptr - const bool CREATEIF(true); - if (!(service("PileUpMergeSvc", m_mergeSvc, CREATEIF)).isSuccess() || - 0 == m_mergeSvc) { - ATH_MSG_ERROR ("Could not find PileUpMergeSvc" ); - return StatusCode::FAILURE; - } - } + ATH_CHECK(m_mergeSvc.retrieve()); m_idHelper = m_GMmgr->rpcIdHelper(); if(!m_idHelper) { @@ -209,148 +132,120 @@ StatusCode RpcDigitizationTool::initialize() { ATH_MSG_DEBUG ( "Output digits: '" << m_outputDigitCollectionKey.key() << "'" ); //set the configuration based on run1/run2 - // Retrieve geometry config information from the database (RUN1, RUN2, etc...) - IRDBAccessSvc* rdbAccess = 0; - StatusCode result = service("RDBAccessSvc",rdbAccess); - - if(result.isFailure()) { - ATH_MSG_ERROR("Unable to get RDBAccessSvc"); - return result; - } + // Retrieve geometry config information from the database (RUN1, RUN2, etc...) + IRDBAccessSvc* rdbAccess(nullptr); + ATH_CHECK(service("RDBAccessSvc",rdbAccess)); bool run1 = true; std::string configVal = ""; - const IGeoModelSvc* geoModel = 0; - result = service("GeoModelSvc", geoModel); - if (result.isFailure()) { - ATH_MSG_ERROR( "Could not locate GeoModelSvc" ); - } - else { - // check the DetDescr version - std::string atlasVersion = geoModel->atlasVersion(); - - IRDBRecordset_ptr atlasCommonRec = rdbAccess->getRecordsetPtr("AtlasCommon",atlasVersion,"ATLAS"); - if(atlasCommonRec->size()==0) { - run1 = true; - } else { - configVal = (*atlasCommonRec)[0]->getString("CONFIG"); - ATH_MSG_INFO( "From DD Database, Configuration is "<< configVal ); - std::string MSgeoVersion = m_GMmgr->geometryVersion().substr(0,4); - ATH_MSG_INFO( "From DD Database, MuonSpectrometer geometry version is "<< MSgeoVersion ); - if(configVal=="RUN1" || MSgeoVersion=="R.06"){ - run1 = true; - } - else if(configVal=="RUN2" || configVal=="RUN3" || MSgeoVersion=="R.07") { - run1 = false; - } - else { - ATH_MSG_FATAL("Unexpected value for geometry config read from the database: " << configVal); - return StatusCode::FAILURE; - } - } - // - if (run1) ATH_MSG_INFO("From Geometry DB: MuonSpectrometer configuration is: RUN1 or MuonGeometry = R.06"); - else ATH_MSG_INFO("From Geometry DB: MuonSpectrometer configuration is: RUN2 or MuonGeometry = R.07"); + const IGeoModelSvc* geoModel(nullptr); + ATH_CHECK(service("GeoModelSvc", geoModel)); + // check the DetDescr version + std::string atlasVersion = geoModel->atlasVersion(); + + IRDBRecordset_ptr atlasCommonRec = rdbAccess->getRecordsetPtr("AtlasCommon",atlasVersion,"ATLAS"); + if (atlasCommonRec->size()==0) { + run1 = true; } - if (m_ignoreRunDepConfig==false) - { - m_BOG_BOF_DoubletR2_OFF = false; - m_Efficiency_fromCOOL = false; - m_ClusterSize_fromCOOL = false; - m_RPCInfoFromDb = false; - m_kill_deadstrips = false; - m_applyEffThreshold = false; - if (run1) - { - //m_BOG_BOF_DoubletR2_OFF = true - //m_Efficiency_fromCOOL = true - //m_ClusterSize_fromCOOL = true - m_BOG_BOF_DoubletR2_OFF = true; - if (configVal=="RUN1") - {// MC12 setup - m_Efficiency_fromCOOL = true; - m_ClusterSize_fromCOOL = true; - m_RPCInfoFromDb = true; - m_kill_deadstrips = true; - m_applyEffThreshold = false; - m_CutProjectedTracks = 50; - } - } - else - { - //m_BOG_BOF_DoubletR2_OFF = false # do not turn off at digitization the hits in the dbR=2 chambers in the feet - //m_Efficiency_fromCOOL = false # use common average values in python conf. - //m_ClusterSize_fromCOOL = false # use common average values in python conf. - m_BOG_BOF_DoubletR2_OFF = false; - if (configVal=="RUN2") - {// MC15c setup - m_Efficiency_fromCOOL = true; - m_ClusterSize_fromCOOL = true; - m_RPCInfoFromDb = true; - m_kill_deadstrips = false; - m_applyEffThreshold = false; //for MC16 [2015-2016]IoV will use measurements, [2017]IoV will use measurements with threshold at 50% already applied in the condition data ////// it was true (with threshold 50%) for MC15c; - m_CutProjectedTracks = 100; - } - } - ATH_MSG_DEBUG ( "Run1/Run2-dependent configuration is enforced; option setting reset for: " ); - ATH_MSG_DEBUG ( "......Efficiency_fromCOOL " << m_Efficiency_fromCOOL ); - ATH_MSG_DEBUG ( "......ClusterSize_fromCOOL " << m_ClusterSize_fromCOOL ); - ATH_MSG_DEBUG ( "......BOG_BOF_DoubletR2_OFF " << m_BOG_BOF_DoubletR2_OFF ); - ATH_MSG_DEBUG ( "......RPCInfoFromDb " << m_RPCInfoFromDb ); - ATH_MSG_DEBUG ( "......KillDeadStrips " << m_kill_deadstrips ); - ATH_MSG_DEBUG ( "......ApplyEffThreshold " << m_applyEffThreshold ); - ATH_MSG_DEBUG ( "......CutProjectedTracks " << m_CutProjectedTracks ); + else { + configVal = (*atlasCommonRec)[0]->getString("CONFIG"); + ATH_MSG_INFO( "From DD Database, Configuration is "<< configVal ); + std::string MSgeoVersion = m_GMmgr->geometryVersion().substr(0,4); + ATH_MSG_INFO( "From DD Database, MuonSpectrometer geometry version is "<< MSgeoVersion ); + if(configVal=="RUN1" || MSgeoVersion=="R.06"){ + run1 = true; } - else - { - ATH_MSG_WARNING ( "Run1/Run2-dependent configuration is bypassed; be careful with option settings" ); - ATH_MSG_DEBUG ( "......Efficiency_fromCOOL " << m_Efficiency_fromCOOL ); - ATH_MSG_DEBUG ( "......ClusterSize_fromCOOL " << m_ClusterSize_fromCOOL ); - ATH_MSG_DEBUG ( "......BOG_BOF_DoubletR2_OFF " << m_BOG_BOF_DoubletR2_OFF ); - ATH_MSG_DEBUG ( "......RPCInfoFromDb " << m_RPCInfoFromDb ); - ATH_MSG_DEBUG ( "......KillDeadStrips " << m_kill_deadstrips ); - ATH_MSG_DEBUG ( "......ApplyEffThreshold " << m_applyEffThreshold ); - ATH_MSG_DEBUG ( "......CutProjectedTracks " << m_CutProjectedTracks ); + else if (configVal=="RUN2" || configVal=="RUN3" || MSgeoVersion=="R.07") { + run1 = false; + } + else { + ATH_MSG_FATAL("Unexpected value for geometry config read from the database: " << configVal); + return StatusCode::FAILURE; + } + } + // + if (run1) ATH_MSG_INFO("From Geometry DB: MuonSpectrometer configuration is: RUN1 or MuonGeometry = R.06"); + else ATH_MSG_INFO("From Geometry DB: MuonSpectrometer configuration is: RUN2 or MuonGeometry = R.07"); + + if (m_ignoreRunDepConfig==false) { + m_BOG_BOF_DoubletR2_OFF = false; + m_Efficiency_fromCOOL = false; + m_ClusterSize_fromCOOL = false; + m_RPCInfoFromDb = false; + m_kill_deadstrips = false; + m_applyEffThreshold = false; + if (run1) { + //m_BOG_BOF_DoubletR2_OFF = true + //m_Efficiency_fromCOOL = true + //m_ClusterSize_fromCOOL = true + m_BOG_BOF_DoubletR2_OFF = true; + if (configVal=="RUN1") {// MC12 setup + m_Efficiency_fromCOOL = true; + m_ClusterSize_fromCOOL = true; + m_RPCInfoFromDb = true; + m_kill_deadstrips = true; + m_applyEffThreshold = false; + m_CutProjectedTracks = 50; + } } + else { + //m_BOG_BOF_DoubletR2_OFF = false # do not turn off at digitization the hits in the dbR=2 chambers in the feet + //m_Efficiency_fromCOOL = false # use common average values in python conf. + //m_ClusterSize_fromCOOL = false # use common average values in python conf. + m_BOG_BOF_DoubletR2_OFF = false; + if (configVal=="RUN2") {// MC15c setup + m_Efficiency_fromCOOL = true; + m_ClusterSize_fromCOOL = true; + m_RPCInfoFromDb = true; + m_kill_deadstrips = false; + m_applyEffThreshold = false; //for MC16 [2015-2016]IoV will use measurements, [2017]IoV will use measurements with threshold at 50% already applied in the condition data ////// it was true (with threshold 50%) for MC15c; + m_CutProjectedTracks = 100; + } + } + ATH_MSG_DEBUG ( "Run1/Run2-dependent configuration is enforced; option setting reset for: " ); + ATH_MSG_DEBUG ( "......Efficiency_fromCOOL " << m_Efficiency_fromCOOL ); + ATH_MSG_DEBUG ( "......ClusterSize_fromCOOL " << m_ClusterSize_fromCOOL ); + ATH_MSG_DEBUG ( "......BOG_BOF_DoubletR2_OFF " << m_BOG_BOF_DoubletR2_OFF ); + ATH_MSG_DEBUG ( "......RPCInfoFromDb " << m_RPCInfoFromDb ); + ATH_MSG_DEBUG ( "......KillDeadStrips " << m_kill_deadstrips ); + ATH_MSG_DEBUG ( "......ApplyEffThreshold " << m_applyEffThreshold ); + ATH_MSG_DEBUG ( "......CutProjectedTracks " << m_CutProjectedTracks ); + } + else { + ATH_MSG_WARNING ( "Run1/Run2-dependent configuration is bypassed; be careful with option settings" ); + ATH_MSG_DEBUG ( "......Efficiency_fromCOOL " << m_Efficiency_fromCOOL ); + ATH_MSG_DEBUG ( "......ClusterSize_fromCOOL " << m_ClusterSize_fromCOOL ); + ATH_MSG_DEBUG ( "......BOG_BOF_DoubletR2_OFF " << m_BOG_BOF_DoubletR2_OFF ); + ATH_MSG_DEBUG ( "......RPCInfoFromDb " << m_RPCInfoFromDb ); + ATH_MSG_DEBUG ( "......KillDeadStrips " << m_kill_deadstrips ); + ATH_MSG_DEBUG ( "......ApplyEffThreshold " << m_applyEffThreshold ); + ATH_MSG_DEBUG ( "......CutProjectedTracks " << m_CutProjectedTracks ); + } ATH_MSG_DEBUG ( "Ready to read parameters for cluster simulation from file" ); - if(StatusCode::SUCCESS != readParameters() ){ - ATH_MSG_ERROR ("Cannot read parameters for cluster simulation. Exiting."); - return StatusCode::FAILURE; - } + ATH_CHECK(readParameters()); ATH_CHECK(m_rndmSvc.retrieve()); // get TagInfoMgr - if ( service("TagInfoMgr", m_tagInfoMgr).isFailure() || m_tagInfoMgr==0) { - ATH_MSG_WARNING ( " Unable to locate TagInfoMgr service" ); - return StatusCode::FAILURE; - } + ATH_CHECK(service("TagInfoMgr", m_tagInfoMgr)); // fill the taginfo information - if (StatusCode::SUCCESS != fillTagInfo()) { - ATH_MSG_WARNING ( "Could not fill the tagInfo for RPC Timing" ); - return StatusCode::FAILURE; - } - if (m_RPCInfoFromDb){ - if (StatusCode::SUCCESS != m_rSummarySvc.retrieve()) { - ATH_MSG_WARNING ( "Could not retrieve RPC Info from Db" ); - return StatusCode::FAILURE; - } + ATH_CHECK(fillTagInfo()); + + if (m_RPCInfoFromDb) { + ATH_CHECK(m_rSummarySvc.retrieve()); } - if(m_PrintCalibrationVector!=0){ - if (StatusCode::SUCCESS != PrintCalibrationVector()) { - ATH_MSG_WARNING ( "Could not PrintCalibrationVector" ); - return StatusCode::FAILURE; - } + if(m_PrintCalibrationVector) { + ATH_CHECK(PrintCalibrationVector()); } m_DeadStripPanel.clear(); - //////////////////// special test + //////////////////// special test // m_turnON_clustersize=false; return StatusCode::SUCCESS; @@ -421,20 +316,8 @@ StatusCode RpcDigitizationTool::getNextEvent() ATH_MSG_DEBUG ( "RpcDigitizationTool::getNextEvent()" ); - if(!m_mergeSvc) { - //locate the PileUpMergeSvc and initialize our local ptr - const bool CREATEIF(true); - if (!(service("PileUpMergeSvc", m_mergeSvc, CREATEIF)).isSuccess() || - 0 == m_mergeSvc) { - ATH_MSG_ERROR ("Could not find PileUpMergeSvc" ); - return StatusCode::FAILURE; - } - - } - - // initialize pointer - m_thpcRPC = 0; + m_thpcRPC = nullptr; // get the container(s) typedef PileUpMergeSvc::TimedList<RPCSimHitCollection>::type TimedHitCollList; @@ -1682,7 +1565,7 @@ StatusCode RpcDigitizationTool::fillTagInfo() const { //-------------------------------------------- StatusCode RpcDigitizationTool::readParameters(){ - std::string fileName = m_paraFile.c_str(); + std::string fileName = m_paraFile.value().c_str(); std::string file = PathResolver::find_file (fileName, "DATAPATH"); std::ifstream filein(file.c_str(), std::ios::in); @@ -2342,60 +2225,60 @@ StatusCode RpcDigitizationTool::PrintCalibrationVector() { vec_size = m_PhiAndEtaEff_A.size() ; for(int i=0 ; i!= vec_size ; i++ ){ - ATH_MSG_INFO ( "size of RPC calib vector PhiAndEtaEff_A: " << m_PhiAndEtaEff_A.at(i) ); + ATH_MSG_INFO ( "size of RPC calib vector PhiAndEtaEff_A: " << m_PhiAndEtaEff_A.value().at(i) ); } vec_size = m_OnlyPhiEff_A.size() ; for(int i=0 ; i!= vec_size ; i++ ){ - ATH_MSG_INFO ( "size of RPC calib vector OnlyPhi_A: " << m_OnlyPhiEff_A.at(i) ); + ATH_MSG_INFO ( "size of RPC calib vector OnlyPhi_A: " << m_OnlyPhiEff_A.value().at(i) ); } vec_size = m_OnlyEtaEff_A.size() ; for(int i=0 ; i!= vec_size ; i++ ){ - ATH_MSG_INFO ( "size of RPC calib vector OnlyEta_A: " << m_OnlyEtaEff_A.at(i) ); + ATH_MSG_INFO ( "size of RPC calib vector OnlyEta_A: " << m_OnlyEtaEff_A.value().at(i) ); } vec_size = m_PhiAndEtaEff_C.size() ; for(int i=0 ; i!= vec_size ; i++ ){ - ATH_MSG_INFO ( "size of RPC calib vector PhiAndEtaEff_C: " << m_PhiAndEtaEff_C.at(i) ); + ATH_MSG_INFO ( "size of RPC calib vector PhiAndEtaEff_C: " << m_PhiAndEtaEff_C.value().at(i) ); } vec_size = m_OnlyPhiEff_C.size() ; for(int i=0 ; i!= vec_size ; i++ ){ - ATH_MSG_INFO ( "size of RPC calib vector OnlyPhi_C: " << m_OnlyPhiEff_C.at(i) ); + ATH_MSG_INFO ( "size of RPC calib vector OnlyPhi_C: " << m_OnlyPhiEff_C.value().at(i) ); } vec_size = m_OnlyEtaEff_C.size() ; for(int i=0 ; i!= vec_size ; i++ ){ - ATH_MSG_INFO ( "size of RPC calib vector OnlyEta_C: " << m_OnlyPhiEff_C.at(i) ); + ATH_MSG_INFO ( "size of RPC calib vector OnlyEta_C: " << m_OnlyPhiEff_C.value().at(i) ); } vec_size = m_FracClusterSize1_A.size() ; for(int i=0 ; i!= vec_size ; i++ ){ - ATH_MSG_INFO ( "size of RPC calib vector FracClusterSize1_A: " << m_FracClusterSize1_A.at(i) ); + ATH_MSG_INFO ( "size of RPC calib vector FracClusterSize1_A: " << m_FracClusterSize1_A.value().at(i) ); } vec_size = m_FracClusterSize2_A.size() ; for(int i=0 ; i!= vec_size ; i++ ){ - ATH_MSG_INFO ( "size of RPC calib vector FracClusterSize2_A: " << m_FracClusterSize2_A.at(i) ); + ATH_MSG_INFO ( "size of RPC calib vector FracClusterSize2_A: " << m_FracClusterSize2_A.value().at(i) ); } vec_size = m_FracClusterSizeTail_A.size() ; for(int i=0 ; i!= vec_size ; i++ ){ - ATH_MSG_INFO ( "size of RPC calib vector FracClusterSizeTail_A: " << m_FracClusterSizeTail_A.at(i) ); + ATH_MSG_INFO ( "size of RPC calib vector FracClusterSizeTail_A: " << m_FracClusterSizeTail_A.value().at(i) ); } vec_size = m_MeanClusterSizeTail_A.size() ; for(int i=0 ; i!= vec_size ; i++ ){ - ATH_MSG_INFO ( "size of RPC calib vector MeanClusterSizeTail_A: " << m_MeanClusterSizeTail_A.at(i) ); + ATH_MSG_INFO ( "size of RPC calib vector MeanClusterSizeTail_A: " << m_MeanClusterSizeTail_A.value().at(i) ); } vec_size = m_FracClusterSize1_C.size() ; for(int i=0 ; i!= vec_size ; i++ ){ - ATH_MSG_INFO ( "size of RPC calib vector FracClusterSize1_C: " << m_FracClusterSize1_C.at(i) ); + ATH_MSG_INFO ( "size of RPC calib vector FracClusterSize1_C: " << m_FracClusterSize1_C.value().at(i) ); } vec_size = m_FracClusterSize2_C.size() ; for(int i=0 ; i!= vec_size ; i++ ){ - ATH_MSG_INFO ( "size of RPC calib vector FracClusterSize2_C: " << m_FracClusterSize2_C.at(i) ); + ATH_MSG_INFO ( "size of RPC calib vector FracClusterSize2_C: " << m_FracClusterSize2_C.value().at(i) ); } vec_size = m_FracClusterSizeTail_C.size() ; for(int i=0 ; i!= vec_size ; i++ ){ - ATH_MSG_INFO ( "size of RPC calib vector FracClusterSizeTail_C: " << m_FracClusterSizeTail_C.at(i) ); + ATH_MSG_INFO ( "size of RPC calib vector FracClusterSizeTail_C: " << m_FracClusterSizeTail_C.value().at(i) ); } vec_size = m_MeanClusterSizeTail_C.size() ; for(int i=0 ; i!= vec_size ; i++ ){ - ATH_MSG_INFO ( "size of RPC calib vector MeanClusterSizeTail_C: " << m_MeanClusterSizeTail_C.at(i) ); + ATH_MSG_INFO ( "size of RPC calib vector MeanClusterSizeTail_C: " << m_MeanClusterSizeTail_C.value().at(i) ); } return sc; diff --git a/MuonSpectrometer/MuonDigitization/TGC_Digitization/src/TgcDigitizationTool.cxx b/MuonSpectrometer/MuonDigitization/TGC_Digitization/src/TgcDigitizationTool.cxx index 93df1dd3085ef888e6c35b6de4bfe27df80b3e35..9bd3f0e5788b9728616c2bdf7324c925e937e287 100644 --- a/MuonSpectrometer/MuonDigitization/TGC_Digitization/src/TgcDigitizationTool.cxx +++ b/MuonSpectrometer/MuonDigitization/TGC_Digitization/src/TgcDigitizationTool.cxx @@ -19,7 +19,6 @@ #include "MuonSimEvent/TgcHitIdHelper.h" #include "TgcDigitMaker.h" -#include "PileUpTools/PileUpMergeSvc.h" #include "PileUpTools/IPileUpTool.h" // for SubEventIterator #include "xAODEventInfo/EventInfo.h" @@ -29,20 +28,11 @@ #include "RDBAccessSvc/IRDBRecordset.h" #include "RDBAccessSvc/IRDBRecord.h" -TgcDigitizationTool::TgcDigitizationTool(const std::string& type, - const std::string& name, - const IInterface* parent) : - PileUpToolBase(type, name, parent), - m_mergeSvc(0), - m_hitIdHelper(0), - m_idHelper(0), - m_mdManager(0), - m_digitizer(0), - m_thpcTGC(0), - m_inputHitCollectionName("TGC_Hits") +TgcDigitizationTool::TgcDigitizationTool(const std::string& type, + const std::string& name, + const IInterface* parent) : + PileUpToolBase(type, name, parent) { - declareProperty("InputObjectName", m_inputHitCollectionName = "TGC_Hits", "name of the input object"); - declareProperty("IncludePileUpTruth", m_includePileUpTruth = true, "Include pile-up truth info"); } //-------------------------------------------- @@ -50,28 +40,18 @@ StatusCode TgcDigitizationTool::initialize() { // retrieve MuonDetctorManager from DetectorStore - if(detStore()->retrieve(m_mdManager).isFailure()) { - return StatusCode::FAILURE; - } + ATH_CHECK(detStore()->retrieve(m_mdManager)); ATH_MSG_DEBUG("Retrieved MuonDetectorManager from DetectorStore."); - if(!m_mergeSvc) { - //locate the PileUpMergeSvc - const bool CREATEIF = true; - if(!(service("PileUpMergeSvc", m_mergeSvc, CREATEIF)).isSuccess() || - !m_mergeSvc) { - ATH_MSG_FATAL("Could not find PileUpMergeSvc"); - return StatusCode::FAILURE; - } - } - + ATH_CHECK(m_mergeSvc.retrieve()); + //initialize the TgcIdHelper m_idHelper = m_mdManager->tgcIdHelper(); - if(!m_idHelper) { + if (!m_idHelper) { ATH_MSG_WARNING("tgcIdHelper could not be retrieved."); return StatusCode::FAILURE; } - + // TgcHitIdHelper m_hitIdHelper = TgcHitIdHelper::GetHelper(); @@ -79,9 +59,8 @@ StatusCode TgcDigitizationTool::initialize() if(m_inputHitCollectionName=="") { ATH_MSG_FATAL("Property InputObjectName not set !"); return StatusCode::FAILURE; - } else { - ATH_MSG_INFO("Input objects: '" << m_inputHitCollectionName << "'"); } + ATH_MSG_INFO("Input objects: '" << m_inputHitCollectionName << "'"); //initialize the output WriteHandleKeys ATH_CHECK(m_outputDigitCollectionKey.initialize()); @@ -100,23 +79,23 @@ StatusCode TgcDigitizationTool::initialize() IRDBRecordset_ptr atlasCommonRec = rdbAccess->getRecordsetPtr("AtlasCommon",atlasVersion,"ATLAS"); unsigned int runperiod = 1; - if(atlasCommonRec->size()==0) runperiod = 1; + if (atlasCommonRec->size()==0) runperiod = 1; else { std::string configVal = (*atlasCommonRec)[0]->getString("CONFIG"); if(configVal=="RUN1") runperiod = 1; - else if(configVal=="RUN2") runperiod = 2; - else if(configVal=="RUN3") runperiod = 3; // currently runperiod 3 means no masking => ok for upgrade - else if(configVal=="RUN4") runperiod = 3; // currently runperiod 3 means no masking => ok for upgrade + else if (configVal=="RUN2") runperiod = 2; + else if (configVal=="RUN3") runperiod = 3; // currently runperiod 3 means no masking => ok for upgrade + else if (configVal=="RUN4") runperiod = 3; // currently runperiod 3 means no masking => ok for upgrade else { - ATH_MSG_FATAL("Unexpected value for geometry config read from the database: " << configVal); + ATH_MSG_FATAL("Unexpected value for geometry config read from the database: " << configVal); return StatusCode::FAILURE; } } - // initialize class to execute digitization - m_digitizer = new TgcDigitMaker(m_hitIdHelper, - m_mdManager, - runperiod); + // initialize class to execute digitization + m_digitizer = new TgcDigitMaker(m_hitIdHelper, + m_mdManager, + runperiod); m_digitizer->setMessageLevel(static_cast<MSG::Level>(msgLevel())); ATH_CHECK(m_rndmSvc.retrieve()); @@ -224,18 +203,8 @@ StatusCode TgcDigitizationTool::finalize() { // Get next event and extract collection of hit collections: StatusCode TgcDigitizationTool::getNextEvent() { - if(!m_mergeSvc) { - //locate the PileUpMergeSvc - const bool CREATEIF = true; - if(!(service("PileUpMergeSvc", m_mergeSvc, CREATEIF)).isSuccess() || - !m_mergeSvc) { - ATH_MSG_FATAL("Could not find PileUpMergeSvc"); - return StatusCode::FAILURE; - } - } - // initialize pointer - m_thpcTGC = 0; + m_thpcTGC = nullptr; // get the container(s) typedef PileUpMergeSvc::TimedList<TGCSimHitCollection>::type TimedHitCollList; diff --git a/MuonSpectrometer/MuonDigitization/TGC_Digitization/src/TgcDigitizationTool.h b/MuonSpectrometer/MuonDigitization/TGC_Digitization/src/TgcDigitizationTool.h index da52b478137f72e16dff40802c1a3b0616cd1292..043db5cef363d1fd8a321f7333382d9eb83ceb11 100644 --- a/MuonSpectrometer/MuonDigitization/TGC_Digitization/src/TgcDigitizationTool.h +++ b/MuonSpectrometer/MuonDigitization/TGC_Digitization/src/TgcDigitizationTool.h @@ -4,8 +4,8 @@ Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ -#ifndef MUONDIGITIZATION_TGC_DIGITIZATIONTOOL_H -#define MUONDIGITIZATION_TGC_DIGITIZATIONTOOL_H +#ifndef MUONDIGITIZATION_TGC_DIGITIZATIONTOOL_H +#define MUONDIGITIZATION_TGC_DIGITIZATIONTOOL_H /** @file TgcDigitizationTool.h * @brief implementation of IPileUpTool to produce TgcDigit objects from TGCSimHit * @author John Chapman, Yoji Hasegawa, Susumu Oda @@ -15,6 +15,7 @@ #include "GaudiKernel/ServiceHandle.h" #include "AthenaKernel/IAthRNGSvc.h" +#include "PileUpTools/PileUpMergeSvc.h" #include "HitManagement/TimedHitCollection.h" #include "MuonSimEvent/TGCSimHit.h" @@ -37,14 +38,14 @@ namespace MuonGM{ class TgcDigitizationTool : public PileUpToolBase { public: - TgcDigitizationTool(const std::string& type, - const std::string& name, - const IInterface* parent); + TgcDigitizationTool(const std::string& type, + const std::string& name, + const IInterface* parent); /** Initialize */ virtual StatusCode initialize() override final; virtual StatusCode prepareEvent(unsigned int /*nInputEvents*/) override final; - + /** called for each active bunch-crossing to process current SubEvents bunchXing is in ns */ virtual StatusCode processBunchXing( @@ -52,8 +53,8 @@ public: SubEventIterator bSubEvents, SubEventIterator eSubEvents ) override final; - - /** called at the end of the subevts loop. Not (necessarily) able to access + + /** called at the end of the subevts loop. Not (necessarily) able to access SubEvents (IPileUpTool) */ virtual StatusCode mergeEvent() override final; @@ -75,25 +76,23 @@ private: /** Core part of digitization used by processAllSubEvents and mergeEvent */ StatusCode digitizeCore(); -protected: - PileUpMergeSvc *m_mergeSvc; // Pile up service +protected: + ServiceHandle<PileUpMergeSvc> m_mergeSvc{this, "PileUpMergeSvc", "PileUpMergeSvc", ""}; // Pile up service ServiceHandle<IAthRNGSvc> m_rndmSvc{this, "RndmSvc", "AthRNGSvc", ""}; // Random number service private: - TgcHitIdHelper* m_hitIdHelper; - //TgcDigitContainer* m_digitContainer; - const TgcIdHelper* m_idHelper; - const MuonGM::MuonDetectorManager* m_mdManager; - TgcDigitMaker* m_digitizer; - TimedHitCollection<TGCSimHit>* m_thpcTGC; - //MuonSimDataCollection* m_sdoContainer; + TgcHitIdHelper* m_hitIdHelper{}; + const TgcIdHelper* m_idHelper{}; + const MuonGM::MuonDetectorManager* m_mdManager{}; + TgcDigitMaker* m_digitizer{}; + TimedHitCollection<TGCSimHit>* m_thpcTGC{}; std::list<TGCSimHitCollection*> m_TGCHitCollList; - std::string m_inputHitCollectionName; // name of the input objects + Gaudi::Property<std::string> m_inputHitCollectionName{this, "InputObjectName", "TGC_Hits", "name of the input object"}; // name of the input objects SG::WriteHandleKey<TgcDigitContainer> m_outputDigitCollectionKey{this,"OutputObjectName","TGC_DIGITS","WriteHandleKey for Output TgcDigitContainer"}; // name of the output digits SG::WriteHandleKey<MuonSimDataCollection> m_outputSDO_CollectionKey{this,"OutputSDOName","TGC_SDO","WriteHandleKey for Output MuonSimDataCollection"}; // name of the output SDOs //pileup truth veto - bool m_includePileUpTruth; + Gaudi::Property<bool> m_includePileUpTruth{this, "IncludePileUpTruth", true, "Include pile-up truth info"}; }; #endif // MUONDIGITIZATION_TGC_DIGITIZATIONTOOL_H diff --git a/Simulation/Digitization/test/test_MC16a_Digi_tf_configuration.py b/Simulation/Digitization/test/test_MC16a_Digi_tf_configuration.py index 488995be966d5b9814096aa085eb5fb26e1a1811..390aa0ec9a49ea18c144b3e2f20492ed56f193f4 100755 --- a/Simulation/Digitization/test/test_MC16a_Digi_tf_configuration.py +++ b/Simulation/Digitization/test/test_MC16a_Digi_tf_configuration.py @@ -176,7 +176,7 @@ class TestDigitizationMC16a(unittest.TestCase): def test___MergeTruthJetsTool_properties(self): tested_configurable_name = 'StandardSignalOnlyTruthPileUpToolsAlg.MergeTruthJetsTool' - expected_property_list = ['DetStore', 'EvtStore', 'ExtraInputs', 'ExtraOutputs', 'FirstXing', 'InTimeOutputTruthJetCollKey', 'LastXing', 'OutOfTimeTruthJetCollKey'] + expected_property_list = ['DetStore', 'EvtStore', 'ExtraInputs', 'ExtraOutputs', 'FirstXing', 'InTimeOutputTruthJetCollKey', 'LastXing', 'OutOfTimeTruthJetCollKey', 'PileUpMergeSvc'] expected_nonstring_properties = {'LastXing': '100', 'FirstXing': '-500'} expected_string_properties = {} # Not checking any specific property values self._detailed_ConfigurablePropertiesCheck( @@ -188,7 +188,7 @@ class TestDigitizationMC16a(unittest.TestCase): def test___MergeMuonEntryLayerTool_properties(self): tested_configurable_name = 'StandardSignalOnlyTruthPileUpToolsAlg.MergeMuonEntryLayerTool' - expected_property_list = ['DetStore', 'EvtStore', 'ExtraInputs', 'ExtraOutputs', 'FirstXing', 'LastXing', 'TrackRecordCollKey', 'TrackRecordCollOutputKey'] + expected_property_list = ['DetStore', 'EvtStore', 'ExtraInputs', 'ExtraOutputs', 'FirstXing', 'LastXing', 'PileUpMergeSvc', 'TrackRecordCollKey', 'TrackRecordCollOutputKey'] expected_nonstring_properties = {'LastXing': '1', 'FirstXing': '-1'} expected_string_properties = {} # Not checking any specific property values self._detailed_ConfigurablePropertiesCheck( @@ -200,7 +200,7 @@ class TestDigitizationMC16a(unittest.TestCase): def test___MergeCalibHitsTool_properties(self): tested_configurable_name = 'StandardSignalOnlyTruthPileUpToolsAlg.MergeCalibHitsTool' - expected_property_list = ['DetStore', 'EvtStore', 'ExtraInputs', 'ExtraOutputs', 'FirstXing', 'LastXing'] + expected_property_list = ['DetStore', 'EvtStore', 'ExtraInputs', 'ExtraOutputs', 'FirstXing', 'LastXing', 'PileUpMergeSvc'] expected_nonstring_properties = {'LastXing': '1', 'FirstXing': '-1'} expected_string_properties = {} # Not checking any specific property values self._detailed_ConfigurablePropertiesCheck( @@ -224,7 +224,7 @@ class TestDigitizationMC16a(unittest.TestCase): def test___SignalOnlyMcEventCollTool_properties(self): tested_configurable_name = 'StandardSignalOnlyTruthPileUpToolsAlg.SignalOnlyMcEventCollTool' - expected_property_list = ['KeepUnstable', 'SaveInTimeMinBias', 'AddBackgroundCollisionVertices', 'zRange', 'TruthCollInputKey', 'TruthCollOutputKey', 'OnlySaveSignalTruth', 'OutOfTimeAbsEtaMax', 'rRange', 'CompressOutputCollection', 'ExtraOutputs', 'AbsEtaMax', 'LastXing', 'SaveOutOfTimeMinBias', 'ExtraInputs', 'DetStore', 'SaveCavernBackground', 'FirstXing', 'SaveRestOfMinBias', 'EvtStore', 'HighTimeToKeep', 'LowTimeToKeep'] + expected_property_list = ['KeepUnstable', 'SaveInTimeMinBias', 'AddBackgroundCollisionVertices', 'zRange', 'TruthCollInputKey', 'TruthCollOutputKey', 'OnlySaveSignalTruth', 'OutOfTimeAbsEtaMax', 'PileUpMergeSvc', 'rRange', 'CompressOutputCollection', 'ExtraOutputs', 'AbsEtaMax', 'LastXing', 'SaveOutOfTimeMinBias', 'ExtraInputs', 'DetStore', 'SaveCavernBackground', 'FirstXing', 'SaveRestOfMinBias', 'EvtStore', 'HighTimeToKeep', 'LowTimeToKeep'] expected_nonstring_properties = {'KeepUnstable': 'False', 'SaveInTimeMinBias': 'True', 'AddBackgroundCollisionVertices': 'True', 'zRange': '200.0', 'OnlySaveSignalTruth': 'True', 'OutOfTimeAbsEtaMax': '3.0', 'rRange': '20.0', 'CompressOutputCollection': 'False', 'ExtraOutputs': '[]', 'AbsEtaMax': '5.0', 'LastXing': '0', 'SaveOutOfTimeMinBias': 'True', 'ExtraInputs': '[]', 'SaveCavernBackground': 'True', 'FirstXing': '0', 'SaveRestOfMinBias': 'False', 'HighTimeToKeep': '50.5', 'LowTimeToKeep': '-50.5'} expected_string_properties = {'TruthCollInputKey': 'TruthEvent', 'TruthCollOutputKey': 'TruthEvent'} self._detailed_ConfigurablePropertiesCheck( @@ -236,7 +236,7 @@ class TestDigitizationMC16a(unittest.TestCase): def test___PixelDigitizationTool_properties(self): tested_configurable_name = 'StandardSignalOnlyTruthPileUpToolsAlg.PixelDigitizationTool' - expected_property_list = ['ChargeTools', 'DetStore', 'EnergyDepositionTool', 'EvtStore', 'ExtraInputs', 'ExtraOutputs', 'FirstXing', 'FrontEndSimTools', 'HardScatterSplittingMode', 'InputObjectName', 'LastXing', 'MergeSvc', 'RDOCollName', 'RndmSvc', 'SDOCollName'] + expected_property_list = ['ChargeTools', 'DetStore', 'EnergyDepositionTool', 'EvtStore', 'ExtraInputs', 'ExtraOutputs', 'FirstXing', 'FrontEndSimTools', 'HardScatterSplittingMode', 'InputObjectName', 'LastXing', 'PileUpMergeSvc', 'RDOCollName', 'RndmSvc', 'SDOCollName'] expected_nonstring_properties = {'LastXing': '25', 'FirstXing': '-25'} expected_string_properties = {'InputObjectName': 'PixelHits'} self._detailed_ConfigurablePropertiesCheck( @@ -284,7 +284,7 @@ class TestDigitizationMC16a(unittest.TestCase): def test___TileHitVecToCntTool_properties(self): tested_configurable_name = 'StandardSignalOnlyTruthPileUpToolsAlg.TileHitVecToCntTool' - expected_property_list = ['DetStore', 'DoHSTruthReconstruction', 'EvtStore', 'ExtraInputs', 'ExtraOutputs', 'FirstXing', 'LastXing', 'PileUp', 'RndmSvc', 'TileHitContainer', 'TileHitContainer_DigiHSTruth', 'TileHitVectors', 'TileInfoName', 'TriggerTimeTool'] + expected_property_list = ['DetStore', 'DoHSTruthReconstruction', 'EvtStore', 'ExtraInputs', 'ExtraOutputs', 'FirstXing', 'LastXing', 'PileUp', 'PileUpMergeSvc', 'RndmSvc', 'TileCablingSvc', 'TileHitContainer', 'TileHitContainer_DigiHSTruth', 'TileHitVectors', 'TileInfoName', 'TriggerTimeTool'] expected_nonstring_properties = {'LastXing': '150', 'FirstXing': '-200', 'TileHitVectors': '["TileHitVec", "MBTSHits"]'} expected_string_properties = {'TileHitContainer': 'TileHitCnt'} self._detailed_ConfigurablePropertiesCheck( @@ -296,7 +296,7 @@ class TestDigitizationMC16a(unittest.TestCase): def test___CscDigitizationTool_properties(self): tested_configurable_name = 'StandardSignalOnlyTruthPileUpToolsAlg.CscDigitizationTool' - expected_property_list = ['CSCSimDataCollectionOutputName', 'DetStore', 'DriftVelocity', 'ElectronEnergy', 'EvtStore', 'ExtraInputs', 'ExtraOutputs', 'FirstXing', 'InputObjectName', 'LastXing', 'NewDigitEDM', 'OutputObjectName', 'RndmSvc', 'WindowLowerOffset', 'WindowUpperOffset', 'amplification', 'cscCalibTool', 'isPileUp', 'pedestal'] + expected_property_list = ['CSCSimDataCollectionOutputName', 'DetStore', 'DriftVelocity', 'ElectronEnergy', 'EvtStore', 'ExtraInputs', 'ExtraOutputs', 'FirstXing', 'InputObjectName', 'LastXing', 'NewDigitEDM', 'OutputObjectName', 'PileUpMergeSvc', 'RndmSvc', 'WindowLowerOffset', 'WindowUpperOffset', 'amplification', 'cscCalibTool', 'isPileUp', 'pedestal'] expected_nonstring_properties = {'LastXing': '175', 'FirstXing': '-375'} expected_string_properties = {'InputObjectName': 'CSC_Hits', 'OutputObjectName': 'CSC_DIGITS'} self._detailed_ConfigurablePropertiesCheck( @@ -320,7 +320,7 @@ class TestDigitizationMC16a(unittest.TestCase): def test___RpcDigitizationTool_properties(self): tested_configurable_name = 'StandardSignalOnlyTruthPileUpToolsAlg.RpcDigitizationTool' - expected_property_list = ['ClusterSize1_2uncorr', 'ClusterSize_fromCOOL', 'CutProjectedTracks', 'DeadTime', 'DetStore', 'DumpFromDbFirst', 'EfficiencyPatchForBMShighEta', 'Efficiency_fromCOOL', 'EvtStore', 'ExtraInputs', 'ExtraOutputs', 'FirstXing', 'FracClusterSize1_A', 'FracClusterSize1_C', 'FracClusterSize2_A', 'FracClusterSize2_C', 'FracClusterSizeTail_A', 'FracClusterSizeTail_C', 'IgnoreRunDependentConfig', 'LastXing', 'MeanClusterSizeTail_A', 'MeanClusterSizeTail_C', 'OnlyEtaEff_A', 'OnlyEtaEff_C', 'OnlyPhiEff_A', 'OnlyPhiEff_C', 'OutputObjectName', 'OutputSDOName', 'PanelId_OFF_fromlist', 'PanelId_OK_fromlist', 'PatchForRpcTime', 'PatchForRpcTimeShift', 'PhiAndEtaEff_A', 'PhiAndEtaEff_C', 'PrintCalibrationVector', 'RPCCondSummarySvc', 'RPCInfoFromDb', 'RndmSvc', 'testbeam_clustersize', 'turnON_clustersize', 'turnON_efficiency'] + expected_property_list = ['ClusterSize1_2uncorr', 'ClusterSize_fromCOOL', 'CutProjectedTracks', 'DeadTime', 'DetStore', 'DumpFromDbFirst', 'EfficiencyPatchForBMShighEta', 'Efficiency_fromCOOL', 'EvtStore', 'ExtraInputs', 'ExtraOutputs', 'FirstXing', 'FracClusterSize1_A', 'FracClusterSize1_C', 'FracClusterSize2_A', 'FracClusterSize2_C', 'FracClusterSizeTail_A', 'FracClusterSizeTail_C', 'IgnoreRunDependentConfig', 'LastXing', 'MeanClusterSizeTail_A', 'MeanClusterSizeTail_C', 'OnlyEtaEff_A', 'OnlyEtaEff_C', 'OnlyPhiEff_A', 'OnlyPhiEff_C', 'OutputObjectName', 'OutputSDOName', 'PanelId_OFF_fromlist', 'PanelId_OK_fromlist', 'PatchForRpcTime', 'PatchForRpcTimeShift', 'PhiAndEtaEff_A', 'PhiAndEtaEff_C', 'PileUpMergeSvc', 'PrintCalibrationVector', 'RPCCondSummarySvc', 'RPCInfoFromDb', 'RndmSvc', 'testbeam_clustersize', 'turnON_clustersize', 'turnON_efficiency'] expected_nonstring_properties = {'LastXing': '125', 'FirstXing': '-150'} expected_string_properties = {} # Not checking any specific property values self._detailed_ConfigurablePropertiesCheck( @@ -332,7 +332,7 @@ class TestDigitizationMC16a(unittest.TestCase): def test___TgcDigitizationTool_properties(self): tested_configurable_name = 'StandardSignalOnlyTruthPileUpToolsAlg.TgcDigitizationTool' - expected_property_list = ['DetStore', 'EvtStore', 'ExtraInputs', 'ExtraOutputs', 'FirstXing', 'LastXing', 'OutputObjectName', 'OutputSDOName', 'RndmSvc'] + expected_property_list = ['DetStore', 'EvtStore', 'ExtraInputs', 'ExtraOutputs', 'FirstXing', 'LastXing', 'OutputObjectName', 'OutputSDOName', 'PileUpMergeSvc', 'RndmSvc'] expected_nonstring_properties = {'LastXing': '75', 'FirstXing': '-50'} expected_string_properties = {} # Not checking any specific property values self._detailed_ConfigurablePropertiesCheck( diff --git a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeCalibHitsTool.cxx b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeCalibHitsTool.cxx index 39430814e52bd68f2a688e819d13d1953d6eab48..c926864ea27e253bde99342b493ce0395e8114d1 100644 --- a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeCalibHitsTool.cxx +++ b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeCalibHitsTool.cxx @@ -1,27 +1,25 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "MergeCalibHitsTool.h" #include "CaloSimEvent/CaloCalibrationHit.h" #include "CaloSimEvent/CaloCalibrationHitContainer.h" -#include "PileUpTools/PileUpMergeSvc.h" #include "StoreGate/StoreGateSvc.h" MergeCalibHitsTool::MergeCalibHitsTool(const std::string& type, const std::string& name, const IInterface* parent) : - PileUpToolBase(type, name, parent), - m_firstSubEvent(true), - m_pMergeSvc("PileUpMergeSvc", name), - m_oldFormat(false) + PileUpToolBase(type, name, parent) { - declareProperty("OldFormat", m_oldFormat); } StatusCode MergeCalibHitsTool::initialize() { ATH_MSG_VERBOSE ( "initialize()" ); + + ATH_CHECK(m_pMergeSvc.retrieve()); + // list of CaloCalibrationHit containers if(m_oldFormat) { m_CalibrationHitContainer.reserve(5); @@ -58,8 +56,8 @@ StatusCode MergeCalibHitsTool::prepareEvent(unsigned int nInputEvents) { } StatusCode MergeCalibHitsTool::processBunchXing(int bunchXing, - SubEventIterator bSubEvents, - SubEventIterator eSubEvents) + SubEventIterator bSubEvents, + SubEventIterator eSubEvents) { SubEventIterator iEvt(bSubEvents); while (iEvt != eSubEvents) { @@ -126,12 +124,6 @@ StatusCode MergeCalibHitsTool::mergeEvent() { StatusCode MergeCalibHitsTool::processAllSubEvents() { ATH_MSG_VERBOSE ( "processAllSubEvents()" ); - if(!m_pMergeSvc) { - if (!(m_pMergeSvc.retrieve()).isSuccess()) { - ATH_MSG_FATAL ( "processAllSubEvents: Could not find PileUpMergeSvc" ); - return StatusCode::FAILURE; - } - } // loop over containers for (unsigned int iHitContainer=0;iHitContainer<m_CalibrationHitContainer.size();iHitContainer++) { diff --git a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeCalibHitsTool.h b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeCalibHitsTool.h index b32b4138dbe8052f731a381523c3b423f7fe2631..01b28e8c52bea0193bf3935ae2da456cb32116ff 100644 --- a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeCalibHitsTool.h +++ b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeCalibHitsTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef MCTRUTHSIMALGS_MERGECALIBHITSTOOL_H @@ -8,12 +8,12 @@ #include "PileUpTools/PileUpToolBase.h" #include "GaudiKernel/ServiceHandle.h" +#include "PileUpTools/PileUpMergeSvc.h" #include <vector> #include <string> class CaloCalibrationHitContainer; -class PileUpMergeSvc; /** @class MergeCalibHitsTool * @brief an algorithm to copy in the overlayed store the calib hits from the signal event @@ -50,10 +50,10 @@ public: virtual StatusCode processAllSubEvents() override final; private: - bool m_firstSubEvent; - ServiceHandle<PileUpMergeSvc> m_pMergeSvc; + Gaudi::Property<bool> m_oldFormat{this, "OldFormat", false, ""}; + ServiceHandle<PileUpMergeSvc> m_pMergeSvc{this, "PileUpMergeSvc", "PileUpMergeSvc", ""}; + bool m_firstSubEvent{true}; std::vector<CaloCalibrationHitContainer*> m_outputContainers;//FIXME hardcoded size - bool m_oldFormat; std::vector<std::string> m_CalibrationHitContainer; }; #endif //MCTRUTHSIMALGS_MERGECALIBHITSTOOL_H diff --git a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeHijingPars.h b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeHijingPars.h index 518410e6c49a3367b70a605ae1bfac2c3ca4223f..ee6f82ddea565a534e163a4ef4046185728928da 100644 --- a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeHijingPars.h +++ b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeHijingPars.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef MCTRUTHSIMALGS_MERGEHIJINGEVENTPARS_H @@ -10,7 +10,6 @@ class IPileUpTool; -class PileUpMergeSvc; /** @class MergeHijingPars * @brief an algorithm to copy in the overlayed store the HijingEventParams from the signal event diff --git a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeHijingParsTool.cxx b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeHijingParsTool.cxx index 2a14429a165ac2df98214457c4fb28a94d3dbf90..61d4a327624eda809a70c74a09e974c82eac5322 100644 --- a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeHijingParsTool.cxx +++ b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeHijingParsTool.cxx @@ -1,28 +1,27 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "MergeHijingParsTool.h" -#include "PileUpTools/PileUpMergeSvc.h" -#include "StoreGate/StoreGateSvc.h" -#include "CxxUtils/make_unique.h" - MergeHijingParsTool::MergeHijingParsTool(const std::string& type, const std::string& name, const IInterface* parent) : - PileUpToolBase(type, name, parent), - m_pMergeSvc("PileUpMergeSvc", name), - m_outputObject("Hijing_event_params"), - m_firstSubEvent(true) + PileUpToolBase(type, name, parent) { - declareProperty("HijingParamsKey", m_outputObject, ""); +} + +StatusCode MergeHijingParsTool::initialize() { + ATH_CHECK(m_pMergeSvc.retrieve()); + ATH_CHECK(m_outputObjectKey.initialize()); + return StatusCode::SUCCESS; } StatusCode MergeHijingParsTool::prepareEvent(unsigned int nInputEvents) { ATH_MSG_VERBOSE ( "Calling prepareEvent(): " << name() << " - package version " << PACKAGE_VERSION ); ATH_MSG_DEBUG( "prepareEvent: there are " << nInputEvents << " subevents in this event."); m_firstSubEvent=true; + m_outputObject = SG::makeHandle(m_outputObjectKey); return StatusCode::SUCCESS; } @@ -31,64 +30,55 @@ StatusCode MergeHijingParsTool::processBunchXing(int bunchXing, SubEventIterator eSubEvents) { ATH_MSG_VERBOSE ( "processBunchXing()" ); - if(m_outputObject.isValid()) - { - ATH_MSG_VERBOSE("Already written out a HijingEventParams for the current signal event."); - return StatusCode::SUCCESS; - } + if(m_outputObject.isValid()) { + ATH_MSG_VERBOSE("Already written out a HijingEventParams for the current signal event."); + return StatusCode::SUCCESS; + } SubEventIterator iEvt = bSubEvents; - for (; iEvt!=eSubEvents; iEvt++) - { - const HijingEventParams *hijing_pars(nullptr); - if (m_pMergeSvc->retrieveSingleSubEvtData(m_outputObject.name(), hijing_pars, - bunchXing, iEvt).isSuccess()){ - + for (; iEvt!=eSubEvents; iEvt++) { + const HijingEventParams *hijing_pars(nullptr); + if (m_pMergeSvc->retrieveSingleSubEvtData(m_outputObject.name(), hijing_pars, + bunchXing, iEvt).isSuccess()) { + ATH_CHECK(m_outputObject.record(std::make_unique<HijingEventParams>(hijing_pars->get_np(), + hijing_pars->get_nt(), + hijing_pars->get_n0(), + hijing_pars->get_n01(), + hijing_pars->get_n10(), + hijing_pars->get_n11(), + hijing_pars->get_natt(), + hijing_pars->get_jatt(), + hijing_pars->get_b(), + hijing_pars->get_bphi()))); + // FIXME Why is there no copy constructor for this class?! + // add in setting Psi angles manually. + for(int n=1;n<7;++n) { + m_outputObject->set_psi(n,hijing_pars->get_psi(n)); + } - m_outputObject = CxxUtils::make_unique<HijingEventParams>(hijing_pars->get_np(), - hijing_pars->get_nt(), - hijing_pars->get_n0(), - hijing_pars->get_n01(), - hijing_pars->get_n10(), - hijing_pars->get_n11(), - hijing_pars->get_natt(), - hijing_pars->get_jatt(), - hijing_pars->get_b(), - hijing_pars->get_bphi()); - // FIXME Why is there no copy constructor for this class?! - // add in setting Psi angles manually. - for(int n=1;n<7;++n) - { - m_outputObject->set_psi(n,hijing_pars->get_psi(n)); - } - - if(m_firstSubEvent) - { - ATH_MSG_DEBUG( "processBunchXing: copied original event HijingEventParams" ); - } - else - { - ATH_MSG_DEBUG( "processBunchXing: copied background event HijingEventParams" ); - } - return StatusCode::SUCCESS; + if(m_firstSubEvent) { + ATH_MSG_DEBUG( "processBunchXing: copied original event HijingEventParams" ); } + else { + ATH_MSG_DEBUG( "processBunchXing: copied background event HijingEventParams" ); + } + return StatusCode::SUCCESS; + } - if(m_firstSubEvent) - { - ATH_MSG_VERBOSE("processBunchXing: No HijingEventParams found in the signal eventStore." ); - m_firstSubEvent=false; - } + if(m_firstSubEvent) { + ATH_MSG_VERBOSE("processBunchXing: No HijingEventParams found in the signal eventStore." ); + m_firstSubEvent=false; } + } return StatusCode::SUCCESS; } StatusCode MergeHijingParsTool::mergeEvent() { //Double check that something was found. - if(!m_outputObject.isValid()) - { - ATH_MSG_ERROR ( "mergeEvent: No HijingEventParams found in the signal or background eventStores." ); - return StatusCode::FAILURE; - } + if(!m_outputObject.isValid()) { + ATH_MSG_ERROR ( "mergeEvent: No HijingEventParams found in the signal or background eventStores." ); + return StatusCode::FAILURE; + } return StatusCode::SUCCESS; } @@ -100,46 +90,40 @@ bool MergeHijingParsTool::toProcess(int bunchXing) const { StatusCode MergeHijingParsTool::processAllSubEvents() { ATH_MSG_VERBOSE ( "processAllSubEvents()" ); - if(!m_pMergeSvc) - { - ATH_CHECK(m_pMergeSvc.retrieve()); - } + m_outputObject = SG::makeHandle(m_outputObjectKey); typedef PileUpMergeSvc::TimedList<HijingEventParams>::type TimedHijingParamsList; TimedHijingParamsList HijingList; - const HijingEventParams *hijing_pars(0); + const HijingEventParams *hijing_pars(nullptr); if (!(m_pMergeSvc->retrieveSubEvtsData(m_outputObject.name(), HijingList).isSuccess()) || HijingList.size()==0) { ATH_MSG_INFO ( " Cannot find HijingEventParams from PileUp service " ); return StatusCode::SUCCESS; } ATH_MSG_DEBUG ( " HijingEventParams found from PileUp service " ); - for (const auto& hijingParams: HijingList) - { - hijing_pars = hijingParams.second; - // create new container for overlayed event - m_outputObject = CxxUtils::make_unique<HijingEventParams>(hijing_pars->get_np(), - hijing_pars->get_nt(), - hijing_pars->get_n0(), - hijing_pars->get_n01(), - hijing_pars->get_n10(), - hijing_pars->get_n11(), - hijing_pars->get_natt(), - hijing_pars->get_jatt(), - hijing_pars->get_b(), - hijing_pars->get_bphi()); - // FIXME Why is there no copy constructor for this class?! - // add in setting Psi angles manually. - for(int n=1;n<7;++n) - { - m_outputObject->set_psi(n,hijing_pars->get_psi(n)); - } - break; + for (const auto& hijingParams: HijingList) { + hijing_pars = hijingParams.second; + // create new container for overlayed event + ATH_CHECK(m_outputObject.record(std::make_unique<HijingEventParams>(hijing_pars->get_np(), + hijing_pars->get_nt(), + hijing_pars->get_n0(), + hijing_pars->get_n01(), + hijing_pars->get_n10(), + hijing_pars->get_n11(), + hijing_pars->get_natt(), + hijing_pars->get_jatt(), + hijing_pars->get_b(), + hijing_pars->get_bphi()))); + // FIXME Why is there no copy constructor for this class?! + // add in setting Psi angles manually. + for(int n=1;n<7;++n) { + m_outputObject->set_psi(n,hijing_pars->get_psi(n)); } + break; + } //Double check that something was found. - if(!m_outputObject.isValid()) - { - ATH_MSG_ERROR( "processAllSubEvents: No HijingEventParams found in the signal or background eventStores." ); - return StatusCode::FAILURE; - } + if(!m_outputObject.isValid()) { + ATH_MSG_ERROR( "processAllSubEvents: No HijingEventParams found in the signal or background eventStores." ); + return StatusCode::FAILURE; + } return StatusCode::SUCCESS; } diff --git a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeHijingParsTool.h b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeHijingParsTool.h index b1c526c8ee4922afe68dae9612d45c23aed49a9c..8a1c5008e4079b024c2b42e2cc2c1f127983e6b3 100644 --- a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeHijingParsTool.h +++ b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeHijingParsTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef MCTRUTHSIMALGS_MERGEHIJINGPARSTOOL_H @@ -9,13 +9,13 @@ #include "GeneratorObjects/HijingEventParams.h" #include "StoreGate/WriteHandle.h" +#include "StoreGate/WriteHandleKey.h" +#include "PileUpTools/PileUpMergeSvc.h" #include "GaudiKernel/ServiceHandle.h" #include <string> -class PileUpMergeSvc; - /** @class MergeHijingParsTool * @brief an algorithm to propagate HijingPars to the overlay store * @@ -28,6 +28,7 @@ public: MergeHijingParsTool(const std::string& type, const std::string& name, const IInterface* parent); + virtual StatusCode initialize() override final; ///called before the subevts loop. Not (necessarily) able to access ///SubEvents virtual StatusCode prepareEvent(unsigned int nInputEvents) override final; @@ -47,8 +48,9 @@ public: */ virtual StatusCode processAllSubEvents() override final; private: - ServiceHandle<PileUpMergeSvc> m_pMergeSvc; + ServiceHandle<PileUpMergeSvc> m_pMergeSvc{this, "PileUpMergeSvc", "PileUpMergeSvc", ""}; + SG::WriteHandleKey<HijingEventParams> m_outputObjectKey{this, "HijingParamsKey", "Hijing_event_params", ""}; SG::WriteHandle<HijingEventParams> m_outputObject; - bool m_firstSubEvent; + bool m_firstSubEvent{true}; }; #endif //MCTRUTHSIMALGS_MERGEHIJINGPARSTOOL_H diff --git a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeMcEventCollTool.cxx b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeMcEventCollTool.cxx index 88454c01922f45561eaced7b59cc9e36b0357453..0ec8c3e530f85c3fc700ce381b44fbf021be8dec 100644 --- a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeMcEventCollTool.cxx +++ b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeMcEventCollTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "MergeMcEventCollTool.h" @@ -125,37 +125,8 @@ namespace { MergeMcEventCollTool::MergeMcEventCollTool(const std::string& type, const std::string& name, const IInterface *parent) : - PileUpToolBase(type, name, parent), - m_pMergeSvc("PileUpMergeSvc", name), - m_pOvrlMcEvColl(0), - m_r2Range(400.0), - m_startingIndexForBackground(0), - m_newevent(true), - m_nInputMcEventColls(0), - m_nBkgEventsReadSoFar(0), - m_addBackgroundCollisionVertices(true), - m_signal_event_number(0) + PileUpToolBase(type, name, parent) { - declareProperty("TruthCollInputKey", m_truthCollInputKey=std::string("TruthEvent")); - declareProperty("TruthCollOutputKey", m_truthCollOutputKey=std::string("TruthEvent")); - declareProperty("KeepUnstable", m_keepUnstable=false, "do not cut unstable particles"); - declareProperty("AbsEtaMax", m_absEtaMax=5.0); - declareProperty("OutOfTimeAbsEtaMax", m_absEtaMax_outOfTime=3.0); - declareProperty("LowTimeToKeep", m_lowTimeToKeep=-51.0, "leading edge in ns of the time window to keep if SaveOutOfTimePileUp is true"); - declareProperty("HighTimeToKeep", m_highTimeToKeep=+51.0, "trailing edge in ns of the time window to keep if SaveOutOfTimePileUp is true"); - declareProperty("rRange", m_rRange = 20.0, "rRange of production vertex in mm"); - declareProperty("zRange", m_zRange = 200.0, "z range of production vertex in mm"); - declareProperty("ptMin", m_ptMin = 0.4*GeV, "in MeV"); - declareProperty("EKinMin", m_minKinE = 1.0*MeV, "in MeV"); - declareProperty("SaveCavernBackground", m_saveCavernBackground=true); - declareProperty("SaveInTimeMinBias", m_saveInTimePileup=true, "save min bias particles in the t0 xing"); - declareProperty("SaveOutOfTimeMinBias", m_saveOutOfTimePileup=true, "save out of time min bias particles in the [LowTimeToKeep:HighTimeToKeep] range"); - declareProperty("SaveRestOfMinBias", m_saveRestOfPileup=false, "save the rest of out of time min bias particles as well" ); - declareProperty("DoSlimming", m_doSlimming=true, "flag to do the slimming or save everything"); - declareProperty("AddBackgroundCollisionVertices", m_addBackgroundCollisionVertices=true, "ensure that the collision GenVertex objects of minbias background events are saved."); - declareProperty("CompressOutputCollection", m_compressOutputCollection=false, "Remove all empty GenEvents from the output McEventCollection"); - declareProperty("OnlySaveSignalTruth", m_onlySaveSignalTruth=false, "Just save the Signal GenEvent"); - } StatusCode MergeMcEventCollTool::initialize() { diff --git a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeMcEventCollTool.h b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeMcEventCollTool.h index feb2f44dd4055c792bfb5ab8d3ea140562923c2b..c3ca95e8fe4ff274b0dd8411b654c13227200518 100755 --- a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeMcEventCollTool.h +++ b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeMcEventCollTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef MCTRUTHSIMALGS_MERGEMCEVENTCOLLTOOL_H @@ -9,12 +9,12 @@ #include "GaudiKernel/Property.h" #include "GaudiKernel/ServiceHandle.h" +#include "GaudiKernel/PhysicalConstants.h" #include <utility> /* pair */ class McEventCollection; class StoreGateSvc; -class PileUpMergeSvc; namespace HepMC { class GenParticle; @@ -52,6 +52,9 @@ public: virtual StatusCode processAllSubEvents() override final; private: + //** The types used to classify the events. NOPUTYPE is used both as the number of types, and to flag a reject (no type) + typedef enum puType { INTIME, OUTOFTIME, RESTOFMB, CAVERN, NOPUTYPE } puType; + //** Add the required information from the current GenEvent to the output McEventCollection StatusCode processEvent(const McEventCollection *pMcEvtColl, const double currentEventTime, const int currentBkgEventIndex); //** Special case of processEvent for the first (signal) GenEvent @@ -66,73 +69,64 @@ private: void printDetailsOfMergedMcEventCollection() const; //** Ensure that any GenEvent::HeavyIon info is stored in the signal GenEvent. StatusCode saveHeavyIonInfo(const McEventCollection *pMcEvtColl); + //** Classify the current GenParticle according to the MC Truth Taskforce requirements + MergeMcEventCollTool::puType classifyVertex(const HepMC::GenParticle *pCurrentVertexParticle, const HepMC::GenVertex *pCurrentParticleProductionVertex, double currentEventTime); + //** Check if the current GenVertex contains beam particles + bool isInitialCollisionVertex(const HepMC::GenVertex *pCurrentVertex) const; + //** Check whether the current McEventCollection has already been truth-filtered + bool isTruthFiltertedMcEventCollection(const McEventCollection *pMcEvtColl) const; + //** Map from GenEvent to puType FIXME: Simpler to key the map on GenEvent* ? + typedef std::map<std::pair<int,int>, int> PileUpBackgroundMap; + PileUpBackgroundMap m_backgroundClassificationMap; + //** Update the map of GenEvent->puType + void updateClassificationMap(int signal_process_id, int event_number, int hack, int classification, bool firstUpdateForThisEvent); - //** Handle for the PileUpMergeSvc (provides input McEventCollections) - ServiceHandle<PileUpMergeSvc> m_pMergeSvc; + ServiceHandle<PileUpMergeSvc> m_pMergeSvc{this, "PileUpMergeSvc", "PileUpMergeSvc", "Handle for the PileUpMergeSvc (provides input McEventCollections)"}; //** New McEventCollection to be written out to file - McEventCollection* m_pOvrlMcEvColl; - //** Name of input McEventCollection - StringProperty m_truthCollInputKey; - //** Name of output McEventCollection - StringProperty m_truthCollOutputKey; - //** Should unstable particles should be kept? - BooleanProperty m_keepUnstable; - //** Eta cut-off for INTIME GenParticles - DoubleProperty m_absEtaMax; - //** Eta cut-off for OUTOFTIME GenParticles - DoubleProperty m_absEtaMax_outOfTime; - //** Define time range for OUTOFTIME GenParticles - DoubleProperty m_lowTimeToKeep, m_highTimeToKeep; + McEventCollection* m_pOvrlMcEvColl{}; + StringProperty m_truthCollInputKey{this, "TruthCollInputKey", "TruthEvent", "Name of input McEventCollection"}; + StringProperty m_truthCollOutputKey{this, "TruthCollOutputKey", "TruthEvent", "Name of output McEventCollection"}; + BooleanProperty m_keepUnstable{this, "KeepUnstable", false, "Do not cut unstable particles"}; + DoubleProperty m_absEtaMax{this, "AbsEtaMax", 5.0, "Eta cut-off for INTIME GenParticles"}; + DoubleProperty m_absEtaMax_outOfTime{this,"OutOfTimeAbsEtaMax", 3.0, "Eta cut-off for OUTOFTIME GenParticles"}; + DoubleProperty m_lowTimeToKeep{this, "LowTimeToKeep", -51.0, "leading edge in ns of the time window to keep if SaveOutOfTimePileUp is true"}; + DoubleProperty m_highTimeToKeep{this, "HighTimeToKeep", 51.0, "trailing edge in ns of the time window to keep if SaveOutOfTimePileUp is true"}; //** Radius acceptance cut on production vertex of all stable particles (in mm) - DoubleProperty m_rRange; + DoubleProperty m_rRange{this, "rRange", 20.0*Gaudi::Units::mm, "rRange of production vertex in mm"}; //** Radius acceptance squared to speed up cut - double m_r2Range; + double m_r2Range{400.0}; //** Cut on Z coordinate of production vertex in mm, to distinguish between minbias and cavern background categories - DoubleProperty m_zRange; - //** Minimum threshold for pT for selected pileup particles. - DoubleProperty m_ptMin; - //** Minimum threshold for Kinetic Energy of selected cavern events - DoubleProperty m_minKinE; + DoubleProperty m_zRange{this, "zRange", 200.0*Gaudi::Units::mm, "z range of production vertex in mm"}; + DoubleProperty m_ptMin{this, "ptMin", 0.4*Gaudi::Units::GeV, "Minimum threshold for pT for selected pileup particles in MeV"}; + DoubleProperty m_minKinE{this, "EKinMin", 1.0*Gaudi::Units::MeV, "Minimum threshold for Kinetic Energy of selected cavern events in MeV"}; //** save minimum bias events in the t0 bunch xing - BooleanProperty m_saveInTimePileup; + BooleanProperty m_saveInTimePileup{this, "SaveInTimeMinBias", true, "save min bias particles in the t0 xing"}; //** save minbias events which are "close" by (within [ m_lowTimeToKeep, m_highTimeToKeep ]) - BooleanProperty m_saveOutOfTimePileup; + BooleanProperty m_saveOutOfTimePileup{this, "SaveOutOfTimeMinBias", true, "save out of time min bias particles in the [LowTimeToKeep:HighTimeToKeep] range"}; //** save as well the rest of minbias - BooleanProperty m_saveRestOfPileup; + BooleanProperty m_saveRestOfPileup{this, "SaveRestOfMinBias", false, "save the rest of out of time min bias particles as well"}; //** save as well the cavern background - BooleanProperty m_saveCavernBackground; + BooleanProperty m_saveCavernBackground{this, "SaveCavernBackground", true, "save the cavern background as well"}; //** do the slimming - flag to do slimming or not - BooleanProperty m_doSlimming; - //** The types used to classify the events. NOPUTYPE is used both as the number of types, and to flag a reject (no type) - typedef enum puType { INTIME, OUTOFTIME, RESTOFMB, CAVERN, NOPUTYPE } puType; + BooleanProperty m_doSlimming{this, "DoSlimming", true, "flag to do the slimming or save everything"}; //** Should any details of GenEvents corresponding to each puType be saved? bool m_saveType[NOPUTYPE]; //** The index (before sorting) within the McEventCollection where the background events start - unsigned int m_startingIndexForBackground; + unsigned int m_startingIndexForBackground{0}; //** Bool to indicate that the next GenEvent is a new signal event - bool m_newevent; + bool m_newevent{true}; //** The total number of GenEvents that will be passed for the current signal event - unsigned int m_nInputMcEventColls; + unsigned int m_nInputMcEventColls{0}; //** How many background events have been read so far for this signal event - unsigned int m_nBkgEventsReadSoFar; + unsigned int m_nBkgEventsReadSoFar{0}; //** Ensure that the collision GenVertex objects of minbias background events are saved. - BooleanProperty m_addBackgroundCollisionVertices; + BooleanProperty m_addBackgroundCollisionVertices{this, "AddBackgroundCollisionVertices", true, "ensure that the collision GenVertex objects of minbias background events are saved."}; //** Should empty GenEvents be removed from the output McEventCollection? - BooleanProperty m_compressOutputCollection; + BooleanProperty m_compressOutputCollection{this, "CompressOutputCollection", false, "Remove all empty GenEvents from the output McEventCollection"}; //** Just save the Signal GenEvent - BooleanProperty m_onlySaveSignalTruth; + BooleanProperty m_onlySaveSignalTruth{this, "OnlySaveSignalTruth", false, "Just save the Signal GenEvent"}; //** Temporary store for the true signal event number - int m_signal_event_number; - //** Classify the current GenParticle according to the MC Truth Taskforce requirements - MergeMcEventCollTool::puType classifyVertex(const HepMC::GenParticle *pCurrentVertexParticle, const HepMC::GenVertex *pCurrentParticleProductionVertex, double currentEventTime); - //** Check if the current GenVertex contains beam particles - bool isInitialCollisionVertex(const HepMC::GenVertex *pCurrentVertex) const; - //** Check whether the current McEventCollection has already been truth-filtered - bool isTruthFiltertedMcEventCollection(const McEventCollection *pMcEvtColl) const; - //** Map from GenEvent to puType FIXME: Simpler to key the map on GenEvent* ? - typedef std::map<std::pair<int,int>, int> PileUpBackgroundMap; - PileUpBackgroundMap m_backgroundClassificationMap; - //** Update the map of GenEvent->puType - void updateClassificationMap(int signal_process_id, int event_number, int hack, int classification, bool firstUpdateForThisEvent); + int m_signal_event_number{0}; + }; #endif //MCTRUTHSIMALGS_MERGEMCEVENTCOLLTOOL_H diff --git a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeRecoTimingObjTool.cxx b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeRecoTimingObjTool.cxx index 4c14335f21ffa82c5371e563ea8b27237b11e47e..86ef97de7852d8d1db0bc01e200d5543ae0f7087 100644 --- a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeRecoTimingObjTool.cxx +++ b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeRecoTimingObjTool.cxx @@ -1,25 +1,24 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "MergeRecoTimingObjTool.h" #include "AthenaKernel/errorcheck.h" -#include "PileUpTools/PileUpMergeSvc.h" #include "RecEvent/RecoTimingObj.h" #include "StoreGate/StoreGateSvc.h" MergeRecoTimingObjTool::MergeRecoTimingObjTool(const std::string& type, const std::string& name, const IInterface* parent) : - PileUpToolBase(type, name, parent), - m_pMergeSvc("PileUpMergeSvc", name), - m_recTimingObjInputKey("EVNTtoHITS_timings"), - m_recTimingObjOutputKey("EVNTtoHITS_timings"), - m_firstSubEvent(true) + PileUpToolBase(type, name, parent) { - declareProperty("RecoTimingObjInputKey", m_recTimingObjInputKey); - declareProperty("RecoTimingObjOutputKey", m_recTimingObjOutputKey); +} + +StatusCode MergeRecoTimingObjTool::initialize() +{ + ATH_CHECK(m_pMergeSvc.retrieve()); + return StatusCode::SUCCESS; } StatusCode MergeRecoTimingObjTool::prepareEvent(unsigned int nInputEvents) @@ -35,27 +34,22 @@ StatusCode MergeRecoTimingObjTool::processBunchXing(int bunchXing, SubEventIterator eSubEvents) { ATH_MSG_VERBOSE ( "processBunchXing()" ); - if(m_firstSubEvent && bunchXing==0) - { - if (bSubEvents != eSubEvents) - { - const RecoTimingObj *oldColl(0); - if (m_pMergeSvc->retrieveSingleSubEvtData(m_recTimingObjInputKey.value(), oldColl, - bunchXing, bSubEvents).isSuccess()) - { - CHECK(processRecoTimingObj(oldColl)); - } - else - { - ATH_MSG_DEBUG ( "processBunchXing: No RecoTimingObj found." ); - } - } - else - { - ATH_MSG_DEBUG ( "processBunchXing: Central Bunch Crossing Empty?!" ); - } - m_firstSubEvent=false; + if(m_firstSubEvent && bunchXing==0) { + if (bSubEvents != eSubEvents) { + const RecoTimingObj *oldColl(nullptr); + if (m_pMergeSvc->retrieveSingleSubEvtData(m_recTimingObjInputKey.value(), oldColl, + bunchXing, bSubEvents).isSuccess()) { + ATH_CHECK(processRecoTimingObj(oldColl)); + } + else { + ATH_MSG_DEBUG ( "processBunchXing: No RecoTimingObj found." ); + } } + else { + ATH_MSG_DEBUG ( "processBunchXing: Central Bunch Crossing Empty?!" ); + } + m_firstSubEvent=false; + } return StatusCode::SUCCESS; } @@ -75,17 +69,11 @@ bool MergeRecoTimingObjTool::toProcess(int bunchXing) const StatusCode MergeRecoTimingObjTool::processAllSubEvents() { ATH_MSG_VERBOSE ( "processAllSubEvents()" ); - if(!m_pMergeSvc) - { - CHECK(m_pMergeSvc.retrieve()); - } - - const RecoTimingObj *oldColl(NULL); - if( !m_pMergeSvc->retrieveOriginal(m_recTimingObjInputKey.value(), oldColl).isSuccess() || !oldColl) - { - ATH_MSG_DEBUG ( "processAllSubEventss: Cannot find RecoTimingObj in input HITS file" ); - return StatusCode::SUCCESS; - } + const RecoTimingObj *oldColl(nullptr); + if( !m_pMergeSvc->retrieveOriginal(m_recTimingObjInputKey.value(), oldColl).isSuccess() || !oldColl) { + ATH_MSG_DEBUG ( "processAllSubEventss: Cannot find RecoTimingObj in input HITS file" ); + return StatusCode::SUCCESS; + } return this->processRecoTimingObj(oldColl); } @@ -93,7 +81,7 @@ StatusCode MergeRecoTimingObjTool::processAllSubEvents() StatusCode MergeRecoTimingObjTool::processRecoTimingObj(const RecoTimingObj* inputObj) { RecoTimingObj *outputRecoTimingObj = new RecoTimingObj(*inputObj); //CHECK copy constructor is OK!! - CHECK(evtStore()->record(outputRecoTimingObj, m_recTimingObjOutputKey.value())); + ATH_CHECK(evtStore()->record(outputRecoTimingObj, m_recTimingObjOutputKey.value())); ATH_MSG_DEBUG( "processRecoTimingObj: copied original event RecoTimingObj" ); return StatusCode::SUCCESS; } diff --git a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeRecoTimingObjTool.h b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeRecoTimingObjTool.h index d4d4671c9eb6d84cd01589f4900ef0553ef26dd7..dcabdac2760d04b9655a968be043cfae67c76b3c 100644 --- a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeRecoTimingObjTool.h +++ b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeRecoTimingObjTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef MCTRUTHSIMALGS_MERGERECTIMINGOBJTOOL_H @@ -9,10 +9,10 @@ #include "GaudiKernel/Property.h" #include "GaudiKernel/ServiceHandle.h" +#include "PileUpTools/PileUpMergeSvc.h" #include <string> -class PileUpMergeSvc; class RecoTimingObj; /** @class MergeRecoTimingObjTool * @brief an algorithm to merge MC track record collTool in the overlay store @@ -26,6 +26,8 @@ public: MergeRecoTimingObjTool(const std::string& type, const std::string& name, const IInterface* parent); + /// + virtual StatusCode initialize() override final; ///called before the subevts loop. Not (necessarily) able to access ///SubEvents virtual StatusCode prepareEvent(unsigned int nInputEvents) override final; @@ -45,9 +47,9 @@ public: private: /// share code between two approaches virtual StatusCode processRecoTimingObj(const RecoTimingObj *inputObj); - ServiceHandle<PileUpMergeSvc> m_pMergeSvc; - StringProperty m_recTimingObjInputKey; - StringProperty m_recTimingObjOutputKey; - bool m_firstSubEvent; + ServiceHandle<PileUpMergeSvc> m_pMergeSvc{this, "PileUpMergeSvc", "PileUpMergeSvc", ""}; + StringProperty m_recTimingObjInputKey{this, "RecoTimingObjInputKey", "EVNTtoHITS_timings", ""}; + StringProperty m_recTimingObjOutputKey{this, "RecoTimingObjOutputKey", "EVNTtoHITS_timings", ""}; + bool m_firstSubEvent{true}; }; #endif diff --git a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeTrackRecordCollTool.cxx b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeTrackRecordCollTool.cxx index 83ec5fe105a423a88f99000b862fffc799d612d1..e5e610c7ca071c485c554d7b3e5837cff109c037 100644 --- a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeTrackRecordCollTool.cxx +++ b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeTrackRecordCollTool.cxx @@ -5,22 +5,19 @@ #include "MergeTrackRecordCollTool.h" #include "AthenaKernel/errorcheck.h" -#include "PileUpTools/PileUpMergeSvc.h" #include "StoreGate/StoreGateSvc.h" MergeTrackRecordCollTool::MergeTrackRecordCollTool(const std::string& type, const std::string& name, const IInterface* parent) : - PileUpToolBase(type, name, parent), - m_pMergeSvc("PileUpMergeSvc", name), - m_firstSubEvent(true) + PileUpToolBase(type, name, parent) { - declareProperty("TrackRecordCollKey", m_trRecCollKey=std::string("MuonEntryLayer")); } StatusCode MergeTrackRecordCollTool::initialize() { ATH_MSG_DEBUG( "initialize()" ); + ATH_CHECK( m_pMergeSvc.retrieve() ); ATH_CHECK( m_outputKey.initialize() ); return StatusCode::SUCCESS; } @@ -39,14 +36,11 @@ StatusCode MergeTrackRecordCollTool::processBunchXing(int bunchXing, { ATH_MSG_VERBOSE ( "processBunchXing()" ); //We are only interested in the TrackRecordCollection for the original event - if(m_firstSubEvent && bunchXing==0) - { - if (bSubEvents != eSubEvents) - { - const TrackRecordCollection* oldColl(0); - if (m_pMergeSvc->retrieveSingleSubEvtData(m_trRecCollKey.value(), oldColl, - bunchXing, bSubEvents).isSuccess()) - { + if(m_firstSubEvent && bunchXing==0) { + if (bSubEvents != eSubEvents) { + const TrackRecordCollection* oldColl(nullptr); + if (m_pMergeSvc->retrieveSingleSubEvtData(m_trRecCollKey.value(), oldColl, + bunchXing, bSubEvents).isSuccess()) { SG::WriteHandle<TrackRecordCollection> outputCollection(m_outputKey); ATH_CHECK(outputCollection.record(std::make_unique<TrackRecordCollection>())); if (!outputCollection.isValid()) { @@ -54,23 +48,20 @@ StatusCode MergeTrackRecordCollTool::processBunchXing(int bunchXing, return StatusCode::FAILURE; } - for(auto trcit : *oldColl) - { + for(auto trcit : *oldColl) { outputCollection->push_back( TrackRecord(trcit) ); } - ATH_MSG_DEBUG( "processBunchXing: copied original event TrackRecordCollection" ); - m_firstSubEvent=false; - } - else - { - ATH_MSG_ERROR ( "processBunchXing: TimedTruthList is empty" ); - } + ATH_MSG_DEBUG( "processBunchXing: copied original event TrackRecordCollection" ); + m_firstSubEvent=false; } - else - { - ATH_MSG_ERROR ( "processBunchXing: Can not find TimedTruthList" ); + else { + ATH_MSG_ERROR ( "processBunchXing: TimedTruthList is empty" ); } } + else { + ATH_MSG_ERROR ( "processBunchXing: Can not find TimedTruthList" ); + } + } return StatusCode::SUCCESS; } @@ -91,42 +82,33 @@ bool MergeTrackRecordCollTool::toProcess(int bunchXing) const StatusCode MergeTrackRecordCollTool::processAllSubEvents() { ATH_MSG_VERBOSE ( "processAllSubEvents()" ); - if(!m_pMergeSvc) - { - CHECK(m_pMergeSvc.retrieve()); - } typedef PileUpMergeSvc::TimedList<TrackRecordCollection>::type TimedTruthList; TimedTruthList truthList; - if ( (m_pMergeSvc->retrieveSubEvtsData(m_trRecCollKey.value(), truthList)).isSuccess() ) - { - if (truthList.begin() != truthList.end()) - { - //FIXME we are forced to do a deep copy - const TrackRecordCollection &oldColl=*(truthList.begin())->second; + if ( (m_pMergeSvc->retrieveSubEvtsData(m_trRecCollKey.value(), truthList)).isSuccess() ) { + if (truthList.begin() != truthList.end()) { + //FIXME we are forced to do a deep copy + const TrackRecordCollection &oldColl=*(truthList.begin())->second; - SG::WriteHandle<TrackRecordCollection> outputCollection(m_outputKey); - ATH_CHECK(outputCollection.record(std::make_unique<TrackRecordCollection>())); - if (!outputCollection.isValid()) { - ATH_MSG_ERROR("Could not record output TrackRecordCollection " << outputCollection.name() << " to store " << outputCollection.store()); - return StatusCode::FAILURE; - } + SG::WriteHandle<TrackRecordCollection> outputCollection(m_outputKey); + ATH_CHECK(outputCollection.record(std::make_unique<TrackRecordCollection>())); + if (!outputCollection.isValid()) { + ATH_MSG_ERROR("Could not record output TrackRecordCollection " << outputCollection.name() << " to store " << outputCollection.store()); + return StatusCode::FAILURE; + } - for (auto trcit : oldColl) - { - outputCollection->push_back( TrackRecord(trcit) ); - } + for (auto trcit : oldColl) { + outputCollection->push_back( TrackRecord(trcit) ); + } - ATH_MSG_DEBUG ( "processAllSubEvents: copied original event TrackRecordCollection" ); - } - else - { - ATH_MSG_ERROR ( "processAllSubEvents: TimedTruthList is empty" ); - } + ATH_MSG_DEBUG ( "processAllSubEvents: copied original event TrackRecordCollection" ); } - else - { - ATH_MSG_ERROR ( "processAllSubEvents: Can not find TimedTruthList" ); + else { + ATH_MSG_ERROR ( "processAllSubEvents: TimedTruthList is empty" ); } + } + else { + ATH_MSG_ERROR ( "processAllSubEvents: Can not find TimedTruthList" ); + } return StatusCode::SUCCESS; } diff --git a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeTrackRecordCollTool.h b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeTrackRecordCollTool.h index 897af20837976107bd53111905858cbff766a1da..65f80d321c510ff972524b55acbc41a183461625 100644 --- a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeTrackRecordCollTool.h +++ b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeTrackRecordCollTool.h @@ -10,10 +10,10 @@ #include "GaudiKernel/Property.h" #include "GaudiKernel/ServiceHandle.h" +#include "PileUpTools/PileUpMergeSvc.h" #include <string> -class PileUpMergeSvc; /** @class MergeTrackRecordCollTool * @brief an algorithm to merge MC track record collTool in the overlay store * @@ -47,9 +47,9 @@ public: */ virtual StatusCode processAllSubEvents() override final; private: - ServiceHandle<PileUpMergeSvc> m_pMergeSvc; - StringProperty m_trRecCollKey; + ServiceHandle<PileUpMergeSvc> m_pMergeSvc{this, "PileUpMergeSvc", "PileUpMergeSvc", ""}; + StringProperty m_trRecCollKey{this, "TrackRecordCollKey", "MuonEntryLayer", ""}; SG::WriteHandleKey<TrackRecordCollection> m_outputKey{ this, "TrackRecordCollOutputKey", "MuonExitLayer", "" }; - bool m_firstSubEvent; + bool m_firstSubEvent{true}; }; #endif //MCTRUTHSIMALGS_MERGETRACKRECORDCOLLTOOL_H diff --git a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeTruthJetsTool.cxx b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeTruthJetsTool.cxx index a0dcbd754f4b6b8ad4706096361ee98c82d7c1f0..0880e0421752ccb3e92f9b860bffab8225262ffe 100644 --- a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeTruthJetsTool.cxx +++ b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeTruthJetsTool.cxx @@ -1,12 +1,11 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "MergeTruthJetsTool.h" #include "AthenaKernel/errorcheck.h" #include "xAODJet/JetAuxContainer.h" -#include "PileUpTools/PileUpMergeSvc.h" #include "StoreGate/StoreGateSvc.h" #include "GaudiKernel/SystemOfUnits.h" @@ -15,32 +14,13 @@ MergeTruthJetsTool::MergeTruthJetsTool(const std::string& type, const std::string& name, const IInterface* parent) : PileUpToolBase(type, name, parent) - , m_pMergeSvc("PileUpMergeSvc", name) - , m_inTimeOutputJetContainer(nullptr) - , m_outOfTimeOutputJetContainer(nullptr) - , m_inputJetCollKey("AntiKt4TruthJets") - , m_inTimeOutputJetCollKey("InTimeAntiKt4TruthJets") - , m_outOfTimeOutputJetCollKey("OutOfTimeAntiKt4TruthJets") - , m_inTimePtCut(10.0*Gaudi::Units::GeV) - , m_outOfTimePtCut(15.0*Gaudi::Units::GeV) - , m_activateFilter(false) - , m_includeSignalJets(false) - , m_first_event(true) - , m_signal_max_pT(-1.) - , m_pileup_max_pT(-1.) { - declareProperty("InputTruthJetCollKey", m_inputJetCollKey); - declareProperty("InTimeOutputTruthJetCollKey", m_inTimeOutputJetCollKey); - declareProperty("OutOfTimeTruthJetCollKey", m_outOfTimeOutputJetCollKey); - declareProperty("InTimePtCut", m_inTimePtCut); - declareProperty("OutOfTimePtCut", m_outOfTimePtCut); - declareProperty("ActivateFilter", m_activateFilter); - declareProperty("IncludeSignalJets", m_includeSignalJets, "Include signal jets in the pileup truth jet collections, if they exist"); } StatusCode MergeTruthJetsTool::initialize() { - ATH_MSG_DEBUG ( "Initializing " << name() << " - package version " << PACKAGE_VERSION ); + ATH_MSG_DEBUG ( "Initializing " << name()); + ATH_CHECK(m_pMergeSvc.retrieve()); return StatusCode::SUCCESS; } @@ -62,54 +42,45 @@ StatusCode MergeTruthJetsTool::processBunchXing(int bunchXing, { ATH_MSG_VERBOSE ( "processBunchXing()" ); SubEventIterator iEvt(bSubEvents); - while (iEvt != eSubEvents) - { - const xAOD::JetContainer* inputJetContainer = 0; - if (m_pMergeSvc->retrieveSingleSubEvtData(m_inputJetCollKey, inputJetContainer, - bunchXing, bSubEvents).isSuccess()) - { - ATH_MSG_VERBOSE("Found an xAOD::JetContainer in storeGate."); - if ( inputJetContainer==0 ) - { - ATH_MSG_ERROR("Unable to retrieve input jet container: " << m_inputJetCollKey); - return StatusCode::FAILURE; - } - ATH_MSG_DEBUG ( "processBunchXing: bunch Crossing = " << bunchXing << " JetContainer size = " << inputJetContainer->size()); - if (bunchXing==0) - { - if (m_first_event) - {//FIXME this may not be robust in the case that there is no TruthJet container from the signal event. - m_signal_max_pT = this->processJetContainer(&(*inputJetContainer), 0, 0.0, 0.0); - ATH_MSG_DEBUG ( "Setting m_signal_max_pT = " << m_signal_max_pT); - if(m_includeSignalJets) - { - (void)this->processJetContainer(&(*inputJetContainer), m_inTimeOutputJetContainer, m_inTimePtCut, 0.0); - } - else - { - ATH_MSG_VERBOSE ( "Don't include signal events in output Truth Jet Containers."); - } - m_first_event=false; - ++iEvt; - continue; - } - const double pileup_this_pT=this->processJetContainer(&(*inputJetContainer), m_inTimeOutputJetContainer, m_inTimePtCut, 0.0); - ATH_MSG_VERBOSE ( "highest jet pT in the current background event = " << pileup_this_pT); - if (pileup_this_pT>m_pileup_max_pT) m_pileup_max_pT=pileup_this_pT; - ATH_MSG_DEBUG ( "highest in-time background jet pT so far = " << m_pileup_max_pT); - } - else - { - const float timeOfBCID(static_cast<float>(iEvt->time())); - (void)this->processJetContainer(&(*inputJetContainer), m_outOfTimeOutputJetContainer, m_outOfTimePtCut, timeOfBCID); - } - } - else - { - ATH_MSG_DEBUG ( "processBunchXing: No JetContainers found." ); + while (iEvt != eSubEvents) { + const xAOD::JetContainer* inputJetContainer(nullptr); + if (m_pMergeSvc->retrieveSingleSubEvtData(m_inputJetCollKey, inputJetContainer, + bunchXing, bSubEvents).isSuccess()) { + ATH_MSG_VERBOSE("Found an xAOD::JetContainer in storeGate."); + if ( !inputJetContainer ) { + ATH_MSG_ERROR("Unable to retrieve input jet container: " << m_inputJetCollKey); + return StatusCode::FAILURE; + } + ATH_MSG_DEBUG ( "processBunchXing: bunch Crossing = " << bunchXing << " JetContainer size = " << inputJetContainer->size()); + if (bunchXing==0) { + if (m_first_event) {//FIXME this may not be robust in the case that there is no TruthJet container from the signal event. + m_signal_max_pT = this->processJetContainer(&(*inputJetContainer), 0, 0.0, 0.0); + ATH_MSG_DEBUG ( "Setting m_signal_max_pT = " << m_signal_max_pT); + if(m_includeSignalJets) { + (void)this->processJetContainer(&(*inputJetContainer), m_inTimeOutputJetContainer, m_inTimePtCut, 0.0); + } + else { + ATH_MSG_VERBOSE ( "Don't include signal events in output Truth Jet Containers."); + } + m_first_event=false; + ++iEvt; + continue; } - ++iEvt; + const double pileup_this_pT=this->processJetContainer(&(*inputJetContainer), m_inTimeOutputJetContainer, m_inTimePtCut, 0.0); + ATH_MSG_VERBOSE ( "highest jet pT in the current background event = " << pileup_this_pT); + if (pileup_this_pT>m_pileup_max_pT) m_pileup_max_pT=pileup_this_pT; + ATH_MSG_DEBUG ( "highest in-time background jet pT so far = " << m_pileup_max_pT); + } + else { + const float timeOfBCID(static_cast<float>(iEvt->time())); + (void)this->processJetContainer(&(*inputJetContainer), m_outOfTimeOutputJetContainer, m_outOfTimePtCut, timeOfBCID); + } } + else { + ATH_MSG_DEBUG ( "processBunchXing: No JetContainers found." ); + } + ++iEvt; + } //signal is always the first event, so even if we didn't see //anything should set this to false here. if(m_first_event) {m_first_event=false;} @@ -121,34 +92,29 @@ StatusCode MergeTruthJetsTool::mergeEvent() ATH_MSG_VERBOSE ( "mergeEvent" ); // Veto event when m_pileup_max_pT>m_signal_max_pT - if (m_activateFilter && m_pileup_max_pT>m_signal_max_pT) - { - ATH_MSG_INFO ( "Highest pT Jet in Hard-scatter event = " << m_signal_max_pT - << ", highest pT jet in a background event = " << m_pileup_max_pT - << ". Therefore filtering this hard-scatter event." ); - m_filterPassed = false; - } + if (m_activateFilter && m_pileup_max_pT>m_signal_max_pT) { + ATH_MSG_INFO ( "Highest pT Jet in Hard-scatter event = " << m_signal_max_pT + << ", highest pT jet in a background event = " << m_pileup_max_pT + << ". Therefore filtering this hard-scatter event." ); + m_filterPassed = false; + } - if(this->record(m_inTimeOutputJetContainer, m_inTimeOutputJetCollKey).isFailure()) - { //This call also records the xAOD::JetAuxContainer. - ATH_MSG_ERROR("mergeEvent: Failed to record InTimeOutputJetContainer"); - return StatusCode::FAILURE; - } - else - { - ATH_MSG_DEBUG ( "mergeEvent: Recorded " << m_inTimeOutputJetCollKey << " JetContainer with " - << m_inTimeOutputJetContainer->size() <<" entries." ); - } - if(this->record(m_outOfTimeOutputJetContainer, m_outOfTimeOutputJetCollKey).isFailure()) - { //This call also records the xAOD::JetAuxContainer. - ATH_MSG_ERROR("mergeEvent: Failed to record OutOfTimeOutputJetContainer"); - return StatusCode::FAILURE; - } - else - { - ATH_MSG_DEBUG ( "mergeEvent: Recorded " << m_outOfTimeOutputJetCollKey << " JetContainer with " - << m_outOfTimeOutputJetContainer->size() <<" entries." ); - } + if(this->record(m_inTimeOutputJetContainer, m_inTimeOutputJetCollKey).isFailure()) { //This call also records the xAOD::JetAuxContainer. + ATH_MSG_ERROR("mergeEvent: Failed to record InTimeOutputJetContainer"); + return StatusCode::FAILURE; + } + else { + ATH_MSG_DEBUG ( "mergeEvent: Recorded " << m_inTimeOutputJetCollKey << " JetContainer with " + << m_inTimeOutputJetContainer->size() <<" entries." ); + } + if(this->record(m_outOfTimeOutputJetContainer, m_outOfTimeOutputJetCollKey).isFailure()) { //This call also records the xAOD::JetAuxContainer. + ATH_MSG_ERROR("mergeEvent: Failed to record OutOfTimeOutputJetContainer"); + return StatusCode::FAILURE; + } + else { + ATH_MSG_DEBUG ( "mergeEvent: Recorded " << m_outOfTimeOutputJetCollKey << " JetContainer with " + << m_outOfTimeOutputJetContainer->size() <<" entries." ); + } return StatusCode::SUCCESS; } @@ -157,23 +123,20 @@ StatusCode MergeTruthJetsTool::record(const xAOD::JetContainer* pjets, std::stri const xAOD::JetAuxContainer* pjetsaux = dynamic_cast<const xAOD::JetAuxContainer*>(pjets->getConstStore()); ATH_MSG_DEBUG("Check Aux store: " << pjets << " ... " << &pjets->auxbase() << " ... " << pjetsaux ); - if ( pjetsaux == 0 ) - { - ATH_MSG_ERROR("Unable to retrieve Aux container"); - return StatusCode::FAILURE; - } + if ( !pjetsaux ) { + ATH_MSG_ERROR("Unable to retrieve Aux container"); + return StatusCode::FAILURE; + } ATH_MSG_VERBOSE("Recording new Jet Aux container."); - if ( evtStore()->record(pjetsaux, jetcontainername+"Aux.").isFailure() ) - { - ATH_MSG_ERROR("Unable to write new Aux Jet collection to event store: " << jetcontainername); - return StatusCode::FAILURE; - } + if ( evtStore()->record(pjetsaux, jetcontainername+"Aux.").isFailure() ) { + ATH_MSG_ERROR("Unable to write new Aux Jet collection to event store: " << jetcontainername); + return StatusCode::FAILURE; + } ATH_MSG_VERBOSE("Recording new Jet container."); - if ( evtStore()->record(pjets, jetcontainername).isFailure() ) - { - ATH_MSG_ERROR("Unable to write new Jet collection to event store: " << jetcontainername); - return StatusCode::FAILURE; - } + if ( evtStore()->record(pjets, jetcontainername).isFailure() ) { + ATH_MSG_ERROR("Unable to write new Jet collection to event store: " << jetcontainername); + return StatusCode::FAILURE; + } ATH_MSG_DEBUG("Created new Jet collection in event store: " << jetcontainername); return StatusCode::SUCCESS; } @@ -182,14 +145,6 @@ StatusCode MergeTruthJetsTool::record(const xAOD::JetContainer* pjets, std::stri StatusCode MergeTruthJetsTool::processAllSubEvents() { ATH_MSG_VERBOSE ( "processAllSubEvents()" ); - if(!m_pMergeSvc) - { - if (!(m_pMergeSvc.retrieve()).isSuccess()) - { - ATH_MSG_FATAL ( "processAllSubEvents: Could not find PileUpMergeSvc" ); - return StatusCode::FAILURE; - } - } m_first_event = true; m_inTimeOutputJetContainer = new xAOD::JetContainer(); @@ -199,90 +154,74 @@ StatusCode MergeTruthJetsTool::processAllSubEvents() typedef PileUpMergeSvc::TimedList<xAOD::JetContainer>::type TruthJetList; TruthJetList truthList; - if ( (m_pMergeSvc->retrieveSubEvtsData(m_inputJetCollKey, truthList)).isSuccess() ) - { - if (!truthList.empty()) - { - - //now merge all collections into one - TruthJetList::const_iterator jetColl_iter(truthList.begin()); - const TruthJetList::const_iterator endOfJetColls(truthList.end()); - while (jetColl_iter!=endOfJetColls) - { - //FIXME we are forced to do a deep copy - if (static_cast<int>((jetColl_iter)->first.time())==0) - { - if (m_first_event) - {//FIXME this may not be robust in the case that there is no TruthJet container from the signal event. - m_signal_max_pT = this->processJetContainer(&(*((jetColl_iter)->second)), 0, 0.0, 0.0); - if(m_includeSignalJets) - { - (void)this->processJetContainer(&(*((jetColl_iter)->second)), m_inTimeOutputJetContainer, m_inTimePtCut, 0.0); - } - else - { - ATH_MSG_VERBOSE ( "Don't include signal events in output Truth Jet Containers."); - } - m_first_event=false; - ++jetColl_iter; - continue; - } - const double pileup_this_pT=this->processJetContainer(&(*((jetColl_iter)->second)), m_inTimeOutputJetContainer, m_inTimePtCut, 0.0); - ATH_MSG_VERBOSE ( "highest jet pT in the current background event = " << pileup_this_pT); - if (pileup_this_pT>m_pileup_max_pT) m_pileup_max_pT=pileup_this_pT; - ATH_MSG_DEBUG ( "highest in-time background jet pT so far = " << m_pileup_max_pT); - } - else - { - const float timeOfBCID(static_cast<float>((jetColl_iter)->first.time())); - (void)this->processJetContainer(&(*((jetColl_iter)->second)), m_outOfTimeOutputJetContainer, m_outOfTimePtCut, timeOfBCID); - } - //signal is always the first event, so if the first event - //wasn't in-time, then the signal collection was missing and - //we should skip further checks. - if(m_first_event) {m_first_event=false;} - ++jetColl_iter; + if ( (m_pMergeSvc->retrieveSubEvtsData(m_inputJetCollKey, truthList)).isSuccess() ) { + if (!truthList.empty()) { + //now merge all collections into one + TruthJetList::const_iterator jetColl_iter(truthList.begin()); + const TruthJetList::const_iterator endOfJetColls(truthList.end()); + while (jetColl_iter!=endOfJetColls) { + //FIXME we are forced to do a deep copy + if (static_cast<int>((jetColl_iter)->first.time())==0) { + if (m_first_event) { + //FIXME this may not be robust in the case that there is no TruthJet container from the signal event. + m_signal_max_pT = this->processJetContainer(&(*((jetColl_iter)->second)), 0, 0.0, 0.0); + if(m_includeSignalJets) { + (void)this->processJetContainer(&(*((jetColl_iter)->second)), m_inTimeOutputJetContainer, m_inTimePtCut, 0.0); } - + else { + ATH_MSG_VERBOSE ( "Don't include signal events in output Truth Jet Containers."); + } + m_first_event=false; + ++jetColl_iter; + continue; + } + const double pileup_this_pT=this->processJetContainer(&(*((jetColl_iter)->second)), m_inTimeOutputJetContainer, m_inTimePtCut, 0.0); + ATH_MSG_VERBOSE ( "highest jet pT in the current background event = " << pileup_this_pT); + if (pileup_this_pT>m_pileup_max_pT) m_pileup_max_pT=pileup_this_pT; + ATH_MSG_DEBUG ( "highest in-time background jet pT so far = " << m_pileup_max_pT); } - else - { - ATH_MSG_DEBUG ( "processAllSubEvents: TruthJetList is empty" ); + else { + const float timeOfBCID(static_cast<float>((jetColl_iter)->first.time())); + (void)this->processJetContainer(&(*((jetColl_iter)->second)), m_outOfTimeOutputJetContainer, m_outOfTimePtCut, timeOfBCID); } + //signal is always the first event, so if the first event + //wasn't in-time, then the signal collection was missing and + //we should skip further checks. + if(m_first_event) {m_first_event=false;} + ++jetColl_iter; + } } - else - { - ATH_MSG_ERROR ( "processAllSubEvents: Can not find TruthJetList" ); + else { + ATH_MSG_DEBUG ( "processAllSubEvents: TruthJetList is empty" ); } + } + else { + ATH_MSG_ERROR ( "processAllSubEvents: Can not find TruthJetList" ); + } // Veto event when m_pileup_max_pT>m_signal_max_pT - if (m_activateFilter && m_pileup_max_pT>m_signal_max_pT) - { - ATH_MSG_INFO ( "Highest pT Jet in Hard-scatter event = " << m_signal_max_pT - << ", highest pT jet in a background event = " << m_pileup_max_pT - << ". Therefore filtering this hard-scatter event." ); - m_filterPassed = false; - } - if(this->record(m_inTimeOutputJetContainer, m_inTimeOutputJetCollKey).isFailure()) - { //This call also records the JetMomentMap. - ATH_MSG_ERROR ( "processAllSubEvents: Failed to record InTimeOutputJetContainer" ); - return StatusCode::FAILURE; - } - else - { - ATH_MSG_DEBUG ( "processAllSubEvents: Recorded " << m_inTimeOutputJetCollKey << " JetContainer with " - << m_inTimeOutputJetContainer->size() <<" entries." ); - } + if (m_activateFilter && m_pileup_max_pT>m_signal_max_pT) { + ATH_MSG_INFO ( "Highest pT Jet in Hard-scatter event = " << m_signal_max_pT + << ", highest pT jet in a background event = " << m_pileup_max_pT + << ". Therefore filtering this hard-scatter event." ); + m_filterPassed = false; + } + if(this->record(m_inTimeOutputJetContainer, m_inTimeOutputJetCollKey).isFailure()) { //This call also records the JetMomentMap. + ATH_MSG_ERROR ( "processAllSubEvents: Failed to record InTimeOutputJetContainer" ); + return StatusCode::FAILURE; + } + else { + ATH_MSG_DEBUG ( "processAllSubEvents: Recorded " << m_inTimeOutputJetCollKey << " JetContainer with " + << m_inTimeOutputJetContainer->size() <<" entries." ); + } - if(this->record(m_outOfTimeOutputJetContainer, m_outOfTimeOutputJetCollKey).isFailure()) - { //This call also records the JetMomentMap. - ATH_MSG_ERROR ( "processAllSubEvents: Failed to record OutOfTimeOutputJetContainer" ); - return StatusCode::FAILURE; - } - else - { - ATH_MSG_DEBUG ( "processAllSubEvents: Recorded " << m_outOfTimeOutputJetCollKey << " JetContainer with " - << m_outOfTimeOutputJetContainer->size() <<" entries." ); - } + if(this->record(m_outOfTimeOutputJetContainer, m_outOfTimeOutputJetCollKey).isFailure()) { //This call also records the JetMomentMap. + ATH_MSG_ERROR ( "processAllSubEvents: Failed to record OutOfTimeOutputJetContainer" ); + return StatusCode::FAILURE; + } + else { + ATH_MSG_DEBUG ( "processAllSubEvents: Recorded " << m_outOfTimeOutputJetCollKey << " JetContainer with " + << m_outOfTimeOutputJetContainer->size() <<" entries." ); + } return StatusCode::SUCCESS; } @@ -292,31 +231,27 @@ double MergeTruthJetsTool::processJetContainer(const xAOD::JetContainer* inputJe { double max_pT=-1.; const xAOD::JetContainer::const_iterator endOfJets(inputJetContainer->end()); - for (xAOD::JetContainer::const_iterator jetIter(inputJetContainer->begin()); jetIter != endOfJets; ++jetIter) - { - try - { - if (!(*jetIter) || (*jetIter)->pt()<ptCut) - { - ATH_MSG_VERBOSE( "processJetContainer: Jet with pT = " << (*jetIter)->pt() << " GeV failed ptCut of " << ptCut << "GeV." ); - continue; - } - if (max_pT<(*jetIter)->pt()) max_pT=(*jetIter)->pt(); - if (!outputJetContainer) continue; - ATH_MSG_VERBOSE( "processJetContainer: Jet with pT = " << (*jetIter)->pt() << " GeV passed ptCut of " << ptCut << "GeV." ); - } - catch (...) - { - ATH_MSG_ERROR ( "Failed to find Truth jet pT for Jet in a BCID at time = " << timeOfBCID ); - } - xAOD::Jet* pjet = new xAOD::Jet(); - outputJetContainer->push_back(pjet); - *pjet = **jetIter; - //FIXME: Would be nice to check if the Timing attribute is already - //set and add that time to the BCID time, but I can't see a way of - //doing that which doesn't involve lots of string comparison, so - //we will have to live without it. - outputJetContainer->back()->setAttribute("Timing", timeOfBCID); + for (xAOD::JetContainer::const_iterator jetIter(inputJetContainer->begin()); jetIter != endOfJets; ++jetIter) { + try { + if (!(*jetIter) || (*jetIter)->pt()<ptCut) { + ATH_MSG_VERBOSE( "processJetContainer: Jet with pT = " << (*jetIter)->pt() << " GeV failed ptCut of " << ptCut << "GeV." ); + continue; + } + if (max_pT<(*jetIter)->pt()) max_pT=(*jetIter)->pt(); + if (!outputJetContainer) continue; + ATH_MSG_VERBOSE( "processJetContainer: Jet with pT = " << (*jetIter)->pt() << " GeV passed ptCut of " << ptCut << "GeV." ); + } + catch (...) { + ATH_MSG_ERROR ( "Failed to find Truth jet pT for Jet in a BCID at time = " << timeOfBCID ); } + xAOD::Jet* pjet = new xAOD::Jet(); + outputJetContainer->push_back(pjet); + *pjet = **jetIter; + //FIXME: Would be nice to check if the Timing attribute is already + //set and add that time to the BCID time, but I can't see a way of + //doing that which doesn't involve lots of string comparison, so + //we will have to live without it. + outputJetContainer->back()->setAttribute("Timing", timeOfBCID); + } return max_pT; } diff --git a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeTruthJetsTool.h b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeTruthJetsTool.h index 3e8957a684f99514f378bc17b2b3f6ff7e34548d..d0aece1ff4582128cdc387039ca265c40428bed3 100644 --- a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeTruthJetsTool.h +++ b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeTruthJetsTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef MCTRUTHSIMALGS_MERGETRUTHJETSTOOL_H @@ -12,10 +12,11 @@ #include "GaudiKernel/Property.h" #include "GaudiKernel/ServiceHandle.h" #include "GaudiKernel/ToolHandle.h" +#include "PileUpTools/PileUpMergeSvc.h" +#include "GaudiKernel/SystemOfUnits.h" #include <string> -class PileUpMergeSvc; /** @class MergeTruthJetsTool * @brief an algorithm to merge truth jet collections in the overlay store */ @@ -50,18 +51,18 @@ private: /// JetContainer Loop virtual double processJetContainer(const xAOD::JetContainer* inputJetContainer, xAOD::JetContainer *outputJetContainer, const double& ptCut, const float& timeOfBCID); StatusCode record(const xAOD::JetContainer* pjets, std::string jetcontainername) const; - ServiceHandle<PileUpMergeSvc> m_pMergeSvc; - xAOD::JetContainer *m_inTimeOutputJetContainer; - xAOD::JetContainer *m_outOfTimeOutputJetContainer; - std::string m_inputJetCollKey; - std::string m_inTimeOutputJetCollKey; - std::string m_outOfTimeOutputJetCollKey; - double m_inTimePtCut; - double m_outOfTimePtCut; - bool m_activateFilter; - bool m_includeSignalJets; - bool m_first_event; - double m_signal_max_pT; - double m_pileup_max_pT; + ServiceHandle<PileUpMergeSvc> m_pMergeSvc{this, "PileUpMergeSvc", "PileUpMergeSvc", ""}; + Gaudi::Property<std::string> m_inputJetCollKey{this, "InputTruthJetCollKey", "AntiKt4TruthJets", ""}; + Gaudi::Property<std::string> m_inTimeOutputJetCollKey{this, "InTimeOutputTruthJetCollKey", "InTimeAntiKt4TruthJets", ""}; + Gaudi::Property<std::string> m_outOfTimeOutputJetCollKey{this, "OutOfTimeTruthJetCollKey", "OutOfTimeAntiKt4TruthJets", ""}; + Gaudi::Property<double> m_inTimePtCut{this, "InTimePtCut", 10.0*Gaudi::Units::GeV, ""}; + Gaudi::Property<double> m_outOfTimePtCut{this, "OutOfTimePtCut", 15.0*Gaudi::Units::GeV, ""}; + Gaudi::Property<bool> m_activateFilter{this, "ActivateFilter", false, ""}; + Gaudi::Property<bool> m_includeSignalJets{this, "IncludeSignalJets", false, ""}; + xAOD::JetContainer *m_inTimeOutputJetContainer{}; + xAOD::JetContainer *m_outOfTimeOutputJetContainer{}; + bool m_first_event{true}; + double m_signal_max_pT{-1.0}; + double m_pileup_max_pT{-1.0}; }; #endif //MCTRUTHSIMALGS_MERGETRUTHJETSTOOL_H diff --git a/Simulation/G4Utilities/MCTruthSimAlgs/src/NewMergeMcEventCollTool.cxx b/Simulation/G4Utilities/MCTruthSimAlgs/src/NewMergeMcEventCollTool.cxx index b9009cb480388f2fd0576c4060502d98a47d6caf..6a3cbc09102802577e33973c1b1cf54ee1bb7fe1 100644 --- a/Simulation/G4Utilities/MCTruthSimAlgs/src/NewMergeMcEventCollTool.cxx +++ b/Simulation/G4Utilities/MCTruthSimAlgs/src/NewMergeMcEventCollTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "NewMergeMcEventCollTool.h" @@ -12,16 +12,11 @@ NewMergeMcEventCollTool::NewMergeMcEventCollTool(const std::string& type, const IInterface *parent) : PileUpToolBase(type, name, parent) { - declareProperty("TruthCollInputKey", m_truthCollInputKey); - declareProperty("PileUpType", m_pileUpType); } StatusCode NewMergeMcEventCollTool::initialize() { - if(!m_pMergeSvc.empty()) - { - ATH_CHECK(m_pMergeSvc.retrieve()); - } + ATH_CHECK(m_pMergeSvc.retrieve()); ATH_CHECK( m_truthCollOutputKey.initialize() ); return StatusCode::SUCCESS; @@ -33,12 +28,11 @@ StatusCode NewMergeMcEventCollTool::prepareEvent(unsigned int nInputEvents) ATH_MSG_VERBOSE( this->name()<<"::prepareEvent()" ); //Check we are getting at least one event - if (0 == nInputEvents) - { - ATH_MSG_ERROR("prepareEvent: TimedTruthList with key " - << m_truthCollInputKey.value() << " is empty"); - return StatusCode::RECOVERABLE; - } + if (0 == nInputEvents) { + ATH_MSG_ERROR("prepareEvent: TimedTruthList with key " + << m_truthCollInputKey.value() << " is empty"); + return StatusCode::RECOVERABLE; + } ATH_MSG_VERBOSE( this->name()<<"::prepareEvent: there are " << nInputEvents << " subevents in this event."); if (!m_outputMcEventCollection.isValid()) { @@ -63,17 +57,16 @@ StatusCode NewMergeMcEventCollTool::processBunchXing(int /*bunchXing*/, { SubEventIterator iEvt(bSubEvents); //loop over the McEventCollections (each one assumed to containing exactly one GenEvent) of the various input events - while (iEvt != eSubEvents) - { - StoreGateSvc& seStore(*iEvt->ptr()->evtStore()); - const McEventCollection *pMEC(nullptr); - ATH_CHECK(seStore.retrieve(pMEC, m_truthCollInputKey.value())); - ATH_MSG_VERBOSE( this->name()<<"::processBunchXing: SubEvt McEventCollection from StoreGate " << seStore.name() << " of PileUpType " << iEvt->type() ); - if(m_pileUpType==iEvt->type()) { - ATH_CHECK(this->processEvent(pMEC, m_outputMcEventCollection.ptr(), iEvt->time())); - } - ++iEvt; + while (iEvt != eSubEvents){ + StoreGateSvc& seStore(*iEvt->ptr()->evtStore()); + const McEventCollection *pMEC(nullptr); + ATH_CHECK(seStore.retrieve(pMEC, m_truthCollInputKey.value())); + ATH_MSG_VERBOSE( this->name()<<"::processBunchXing: SubEvt McEventCollection from StoreGate " << seStore.name() << " of PileUpType " << iEvt->type() ); + if(m_pileUpType==iEvt->type()) { + ATH_CHECK(this->processEvent(pMEC, m_outputMcEventCollection.ptr(), iEvt->time())); } + ++iEvt; + } return StatusCode::SUCCESS; } @@ -98,25 +91,23 @@ StatusCode NewMergeMcEventCollTool::processAllSubEvents() //Check we are getting at least one event const unsigned int nInputMcEventColls=truthList.size(); - if (0 == nInputMcEventColls) - { - ATH_MSG_WARNING("TimedTruthList with key " << m_truthCollInputKey.value() << " is empty."); - return StatusCode::SUCCESS; - } + if (0 == nInputMcEventColls) { + ATH_MSG_WARNING("TimedTruthList with key " << m_truthCollInputKey.value() << " is empty."); + return StatusCode::SUCCESS; + } ATH_MSG_DEBUG( "execute: there are " << nInputMcEventColls << " subevents in this event."); //TODO can we make this into an auto for loop? TimedTruthList::iterator timedTruthListIter(truthList.begin()), endOfTimedTruthList(truthList.end()); //loop over the McEventCollections (each one assumed to containing exactly one GenEvent) of the various input events - while (timedTruthListIter != endOfTimedTruthList) - { - ATH_MSG_VERBOSE( this->name()<<"::processBunchXing: SubEvt McEventCollection of PileUpType " << timedTruthListIter->first.type() ); - if(m_pileUpType==timedTruthListIter->first.type()) { - const McEventCollection *pBackgroundMcEvtColl(&*(timedTruthListIter->second)); - ATH_CHECK(this->processEvent(pBackgroundMcEvtColl,outputMcEventCollection.ptr(),timedTruthListIter->first.time())); - } - ++timedTruthListIter; - } //timed colls + while (timedTruthListIter != endOfTimedTruthList) { + ATH_MSG_VERBOSE( this->name()<<"::processBunchXing: SubEvt McEventCollection of PileUpType " << timedTruthListIter->first.type() ); + if(m_pileUpType==timedTruthListIter->first.type()) { + const McEventCollection *pBackgroundMcEvtColl(&*(timedTruthListIter->second)); + ATH_CHECK(this->processEvent(pBackgroundMcEvtColl,outputMcEventCollection.ptr(),timedTruthListIter->first.time())); + } + ++timedTruthListIter; + } //timed colls if(msgLvl(MSG::VERBOSE)) { this->printDetailsOfMergedMcEventCollection(outputMcEventCollection.ptr()); } return StatusCode::SUCCESS; @@ -155,23 +146,22 @@ void NewMergeMcEventCollTool::printDetailsOfMergedMcEventCollection(McEventColle ATH_MSG_INFO ( "pileUpType: " << m_pileUpType); ATH_MSG_INFO ( "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" ); ATH_MSG_INFO ( "Current OUTPUT GenEvent: " ); - while(outputEventItr!=endOfEvents) - { - const int signal_process_id((*outputEventItr)->signal_process_id()); - const int event_number((*outputEventItr)->event_number()); - ATH_MSG_INFO ( "GenEvent #"<<event_number<<", signal_process_id="<<signal_process_id<</*", category="<<event->second<<*/", number of Vertices="<<(*outputEventItr)->vertices_size() ); - char fname[80]; - sprintf(fname,"%s.event%d.txt",m_truthCollInputKey.value().c_str(),event_number); - std::ofstream of(fname); - (*outputEventItr)->print(of); // verbose output - of.close(); - // HepMC::GenEvent& currentSignalEvent(**(outputEventItr)); - // currentSignalEvent.print(); - // ATH_MSG_INFO ( "Current signal_process_vertex: " ); - // if(0!=currentSignalEvent.signal_process_vertex()) currentSignalEvent.signal_process_vertex()->print(); - // else ATH_MSG_INFO ( "signal_process_vertex is NULL" ); - ++outputEventItr; - } + while(outputEventItr!=endOfEvents) { + const int signal_process_id((*outputEventItr)->signal_process_id()); + const int event_number((*outputEventItr)->event_number()); + ATH_MSG_INFO ( "GenEvent #"<<event_number<<", signal_process_id="<<signal_process_id<</*", category="<<event->second<<*/", number of Vertices="<<(*outputEventItr)->vertices_size() ); + char fname[80]; + sprintf(fname,"%s.event%d.txt",m_truthCollInputKey.value().c_str(),event_number); + std::ofstream of(fname); + (*outputEventItr)->print(of); // verbose output + of.close(); + // HepMC::GenEvent& currentSignalEvent(**(outputEventItr)); + // currentSignalEvent.print(); + // ATH_MSG_INFO ( "Current signal_process_vertex: " ); + // if(0!=currentSignalEvent.signal_process_vertex()) currentSignalEvent.signal_process_vertex()->print(); + // else ATH_MSG_INFO ( "signal_process_vertex is NULL" ); + ++outputEventItr; + } ATH_MSG_INFO ( "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" ); return; } diff --git a/Simulation/G4Utilities/MCTruthSimAlgs/src/NewMergeMcEventCollTool.h b/Simulation/G4Utilities/MCTruthSimAlgs/src/NewMergeMcEventCollTool.h index e79bea3abe1c360271884bdf7750d805e066b079..5054b130bedf74733638ae354d45dcbc51007825 100644 --- a/Simulation/G4Utilities/MCTruthSimAlgs/src/NewMergeMcEventCollTool.h +++ b/Simulation/G4Utilities/MCTruthSimAlgs/src/NewMergeMcEventCollTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef MCTRUTHSIMALGS_NEWMERGEMCEVENTCOLLTOOL_H @@ -50,9 +50,9 @@ private: //** Handle for the PileUpMergeSvc (provides input McEventCollections) ServiceHandle<PileUpMergeSvc> m_pMergeSvc{this, "PileUpMergeSvc", "PileUpMergeSvc", ""}; //** Name of input McEventCollection - StringProperty m_truthCollInputKey{"TruthEvent"}; + StringProperty m_truthCollInputKey{this,"TruthCollInputKey", "TruthEvent", ""}; //** Depends on PileUpTimeEventIndex::PileUpType; provide one instance of this tool for each type - int m_pileUpType{-1}; // initialise to PileUpTimeEventIndex::PileUpType::Unknown + Gaudi::Property<int> m_pileUpType{this, "PileUpType", -1, ""}; // initialise to PileUpTimeEventIndex::PileUpType::Unknown //** Writing to StoreGate safely in MT SG::WriteHandle<McEventCollection> m_outputMcEventCollection{}; //** Writing to StoreGate safely in MT diff --git a/Simulation/G4Utilities/MCTruthSimAlgs/src/SimpleMergeMcEventCollTool.cxx b/Simulation/G4Utilities/MCTruthSimAlgs/src/SimpleMergeMcEventCollTool.cxx index 37e3a3edc75e596540228d35ba652bb6e2a8882d..f90ff2380098be0c6395fc02455d04b3ce0ab5ae 100644 --- a/Simulation/G4Utilities/MCTruthSimAlgs/src/SimpleMergeMcEventCollTool.cxx +++ b/Simulation/G4Utilities/MCTruthSimAlgs/src/SimpleMergeMcEventCollTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "SimpleMergeMcEventCollTool.h" @@ -13,7 +13,6 @@ SimpleMergeMcEventCollTool::SimpleMergeMcEventCollTool(const std::string& type, const IInterface *parent) : PileUpToolBase(type, name, parent) { - declareProperty("TruthCollInputKey", m_truthCollInputKey); } StatusCode SimpleMergeMcEventCollTool::initialize() @@ -36,7 +35,7 @@ StatusCode SimpleMergeMcEventCollTool::prepareEvent(unsigned int nInputEvents) if (0 == m_nInputMcEventColls) { ATH_MSG_ERROR("prepareEvent: TimedTruthList with key " - << m_truthCollInputKey.value() << " is empty"); + << m_truthCollInputKey << " is empty"); return StatusCode::RECOVERABLE; } ATH_MSG_DEBUG( "prepareEvent: there are " << m_nInputMcEventColls << " subevents in this event."); @@ -67,7 +66,7 @@ StatusCode SimpleMergeMcEventCollTool::processBunchXing(int /*bunchXing*/, { StoreGateSvc& seStore(*iEvt->ptr()->evtStore()); const McEventCollection *pMEC(nullptr); - ATH_CHECK(seStore.retrieve(pMEC, m_truthCollInputKey.value())); + ATH_CHECK(seStore.retrieve(pMEC, m_truthCollInputKey)); ATH_MSG_DEBUG ("processBunchXing: SubEvt McEventCollection from StoreGate " << seStore.name() ); ATH_CHECK(this->processEvent(pMEC, m_outputMcEventCollection.ptr())); ++iEvt; @@ -97,7 +96,7 @@ StatusCode SimpleMergeMcEventCollTool::processAllSubEvents() //first get the list of McEventCollections typedef PileUpMergeSvc::TimedList<McEventCollection>::type TimedTruthList; TimedTruthList truthList; - ATH_CHECK(m_pMergeSvc->retrieveSubEvtsData(m_truthCollInputKey.value(), truthList)); + ATH_CHECK(m_pMergeSvc->retrieveSubEvtsData(m_truthCollInputKey, truthList)); m_nBkgEventsReadSoFar=0; @@ -105,7 +104,7 @@ StatusCode SimpleMergeMcEventCollTool::processAllSubEvents() m_nInputMcEventColls=truthList.size(); if (0 == m_nInputMcEventColls) { - ATH_MSG_ERROR("TimedTruthList with key " << m_truthCollInputKey.value() << " is empty."); + ATH_MSG_ERROR("TimedTruthList with key " << m_truthCollInputKey << " is empty."); return StatusCode::RECOVERABLE; } diff --git a/Simulation/G4Utilities/MCTruthSimAlgs/src/SimpleMergeMcEventCollTool.h b/Simulation/G4Utilities/MCTruthSimAlgs/src/SimpleMergeMcEventCollTool.h index aed3d18c1d3619b27dc615d95ed250b832c1555d..c580ad404947471c5421ff712e07cf10580d4636 100644 --- a/Simulation/G4Utilities/MCTruthSimAlgs/src/SimpleMergeMcEventCollTool.h +++ b/Simulation/G4Utilities/MCTruthSimAlgs/src/SimpleMergeMcEventCollTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef MCTRUTHSIMALGS_SIMPLEMERGEMCEVENTCOLLTOOL_H @@ -14,7 +14,6 @@ class McEventCollection; class StoreGateSvc; -class PileUpMergeSvc; namespace HepMC { class GenParticle; @@ -65,7 +64,7 @@ private: //** Writing to StoreGate safely in MT SG::WriteHandleKey<McEventCollection> m_truthCollOutputKey{this, "TruthCollOutputKey","TruthEvent",""}; //** Name of input McEventCollection - StringProperty m_truthCollInputKey{"TruthEvent"}; + Gaudi::Property<std::string> m_truthCollInputKey{this, "TruthCollInputKey", "TruthEvent", ""}; //** The total number of GenEvents that will be passed for the current signal event unsigned int m_nInputMcEventColls{0}; //** How many background events have been read so far for this signal event diff --git a/TileCalorimeter/TileSimAlgs/TileSimAlgs/TileHitVecToCntTool.h b/TileCalorimeter/TileSimAlgs/TileSimAlgs/TileHitVecToCntTool.h index c2d2086b54f7d594e12eb5e850d9ed9c6439a78d..1d70f7c0d18e4ab5e3a49f854b06c422c80caec7 100644 --- a/TileCalorimeter/TileSimAlgs/TileSimAlgs/TileHitVecToCntTool.h +++ b/TileCalorimeter/TileSimAlgs/TileSimAlgs/TileHitVecToCntTool.h @@ -8,13 +8,13 @@ // Created : Dec. 2009 // // DESCRIPTION -// +// // TileHitVecToCnt copies all TileHits from TileHitVector (AthenaHitsVector) // to TileHitContainer (identifiable container) without any corrections. // If pileup option is set, all hits are merged. The pileup is done bunchXing // by bunchXing (main difference from TileHitVecToCnt). If several hits have // the same ID, energy and time from all of them is stored in vectors -// inside single TileHit. +// inside single TileHit. // // Properties (JobOption Parameters): // @@ -38,12 +38,14 @@ #include "PileUpTools/PileUpToolBase.h" #include "StoreGate/WriteHandleKey.h" #include "AthenaKernel/IAthRNGSvc.h" +// Pile up +#include "PileUpTools/PileUpMergeSvc.h" #include "AthenaKernel/ITriggerTime.h" // Gaudi includes #include "GaudiKernel/ServiceHandle.h" - +#include "GaudiKernel/SystemOfUnits.h" // Avoid pushing dependencies into clients- just fwd declare the following: @@ -53,7 +55,6 @@ class TileHit; class TileInfo; class TileHitNonConstContainer; class TileDetDescrManager; -class PileUpMergeSvc; class Identifier; class TileCablingService; class TileHitCollection; @@ -67,101 +68,115 @@ namespace CLHEP { #include <string> #include <vector> -/** - @class TileHitVecToCntTool - @brief This AlgTool merges TileHits from different AthenaHitVectors and stores the result in a TileHitContainer +/** + @class TileHitVecToCntTool + @brief This AlgTool merges TileHits from different AthenaHitVectors and stores the result in a TileHitContainer - TileHitVecToCntTool copies all TileHits from TileHitVector (AthenaHitsVector) - to TileHitContainer (identifiable container) without any corrections - If pileup option is set, all hits are merged, if several hits have - the same ID, energy and time from all of them is stored in vectors - inside single TileHit - */ + TileHitVecToCntTool copies all TileHits from TileHitVector (AthenaHitsVector) + to TileHitContainer (identifiable container) without any corrections + If pileup option is set, all hits are merged, if several hits have + the same ID, energy and time from all of them is stored in vectors + inside single TileHit +*/ class TileHitVecToCntTool: public PileUpToolBase { - public: - TileHitVecToCntTool(const std::string& type, const std::string& name, const IInterface* parent); //!< Constructor - StatusCode initialize() override final; - virtual StatusCode prepareEvent(unsigned int /*nInputEvents*/) override final; - virtual StatusCode mergeEvent() override final; - virtual StatusCode processBunchXing(int bunchXing, - SubEventIterator bSubEvents, - SubEventIterator eSubEvents) override final; - virtual StatusCode processAllSubEvents() override final; - StatusCode finalize() override final; - - private: - StatusCode createContainers(); - void processHitVectorForOverlay(const TileHitVector* inputHits, int& nHit, double& eHitTot); - void processHitVectorForPileUp(const TileHitVector* inputHits, double SubEvtTimOffset, int& nHit, double& eHitTot, bool isSignal = false); - void processHitVectorWithoutPileUp(const TileHitVector* inputHits, int& nHit, double& eHitTot, TileHitNonConstContainer* &hitCont, CLHEP::HepRandomEngine * engine); - double applyPhotoStatistics(double energy, Identifier pmt_id, CLHEP::HepRandomEngine * engine); //!< Method to apply photostatistics effect - void findAndMergeE1(TileHitCollection* coll, int frag_id, TileHitNonConstContainer* &hitCont); - void findAndMergeMBTS(TileHitCollection* coll, int frag_id, TileHitNonConstContainer* &hitCont); - - std::vector<std::string> m_hitVectorNames; //!< vector with the names of TileHitVectors to use - - SG::WriteHandleKey<TileHitContainer> m_hitContainerKey{this,"TileHitContainer","TileHitCnt", - "Output Tile hit container key"}; - - SG::WriteHandleKey<TileHitContainer> m_hitContainer_DigiHSTruthKey{this,"TileHitContainer_DigiHSTruth","TileHitCnt_DigiHSTruth", - "Output DigiHSTruth Tile hit container key"}; - - - std::string m_infoName; //!< name of TileInfo object in TES - bool m_run2; //!< if true => RUN2 geometry with E4' and merged E1 - bool m_run2plus; //!< if true => RUN2+ geometry with merged E1 (and E4' in RUN2) - bool m_pileUp; //!< if true => pileup mode is activated - double m_deltaT; //!< minimal time granularity for TileHit - int m_timeFlag; //!< specail options to deal with times of hits for cosmics and TB - double m_triggerTime; //!< fixed trigger time value (default=0) - double m_maxHitTime; //!< all sub-hits with time above m_maxHitTime will be ignored - double m_photoStatisticsWindow; //!< sum up energy in [-m_photoStatWindow,+m_photoStatWindow] and use it for photostatistics - int m_photoElectronStatistics; //!< photoelectron statistics type: 0 - Poisson, 1 - "new" Poisson + Gauss, 2 - Poisson->Gauss - bool m_skipNoHit; //!< if true => skip events with no Tile hits - bool m_rndmEvtOverlay; //!< If true => overlay with random event (zero-luminosity pile-up) - bool m_useTriggerTime; //!< if true => take trigger time from external tool or from m_triggerTime - bool m_doDigiTruth; //! - ToolHandle<ITriggerTime> m_triggerTimeTool; //!< tool to take the time from - - PileUpMergeSvc* m_mergeSvc; //!< Pointer to PileUpMergeService - - const TileID* m_tileID; //!< Pointer to TileID helper - const TileTBID* m_tileTBID; //!< Pointer to TileID helper - const TileInfo* m_tileInfo; //!< Pointer to TileInfo - const TileDetDescrManager* m_tileMgr; //!< Pointer to TileDetDescrManager - float m_nPhotoElectrons[7]; //!< number of photo electrons per GeV in samplings - - ServiceHandle<IAthRNGSvc> m_rndmSvc{this, "RndmSvc", "AthRNGSvc", ""}; //!< Random number generator engine to use - - std::vector<TileHit*> m_allHits; //!< vector for all TileHits - std::vector<TileHit*> m_allHits_DigiHSTruth; //!< vector for all TileHits - TileHitNonConstContainer* m_hits; //!< pointer to hits container - TileHitNonConstContainer* m_hits_DigiHSTruth; //!< pointer to hits container - - int m_mbtsOffset; //<! index of first MBTS hit in m_allHits vector - static const int N_SIDE = 2; - static const int N_PHI = 8; - static const int N_ETA = 2; - static const int N_MBTS_CELLS = N_SIDE * N_PHI * N_ETA; - inline int mbts_index(int side, int phi, int eta) const { - return (side * N_PHI + phi) * N_ETA + eta + m_mbtsOffset; - } - static const int E4_SIDE = -1; - static const int E4_ETA = 2; - static const int E4_N_PHI = 4; - static const int N_E4PRIME_CELLS = E4_N_PHI; - inline int e4pr_index(int phi) const { - return phi + N_MBTS_CELLS + m_mbtsOffset; - } - - ServiceHandle<TileCablingSvc> m_cablingSvc; - const TileCablingService* m_cabling; - TileFragHash m_fragHashFunc; - std::vector<bool> m_E1merged; - std::vector<bool> m_MBTSmerged; - enum CELL_TOWER{E1_TOWER = 10}; +public: + TileHitVecToCntTool(const std::string& type, const std::string& name, const IInterface* parent); //!< Constructor + StatusCode initialize() override final; + virtual StatusCode prepareEvent(unsigned int /*nInputEvents*/) override final; + virtual StatusCode mergeEvent() override final; + virtual StatusCode processBunchXing(int bunchXing, + SubEventIterator bSubEvents, + SubEventIterator eSubEvents) override final; + virtual StatusCode processAllSubEvents() override final; + StatusCode finalize() override final; + +private: + StatusCode createContainers(); + void processHitVectorForOverlay(const TileHitVector* inputHits, int& nHit, double& eHitTot); + void processHitVectorForPileUp(const TileHitVector* inputHits, double SubEvtTimOffset, int& nHit, double& eHitTot, bool isSignal = false); + void processHitVectorWithoutPileUp(const TileHitVector* inputHits, int& nHit, double& eHitTot, TileHitNonConstContainer* &hitCont, CLHEP::HepRandomEngine * engine); + double applyPhotoStatistics(double energy, Identifier pmt_id, CLHEP::HepRandomEngine * engine); //!< Method to apply photostatistics effect + void findAndMergeE1(TileHitCollection* coll, int frag_id, TileHitNonConstContainer* &hitCont); + void findAndMergeMBTS(TileHitCollection* coll, int frag_id, TileHitNonConstContainer* &hitCont); + + Gaudi::Property< std::vector<std::string> > m_hitVectorNames{this, "TileHitVectors", {"TileHitVec"}, + "Name of input hit vectors (default=TileHitVec)" }; //!< vector with the names of TileHitVectors to use + + SG::WriteHandleKey<TileHitContainer> m_hitContainerKey{this,"TileHitContainer","TileHitCnt", + "Output Tile hit container key"}; + + SG::WriteHandleKey<TileHitContainer> m_hitContainer_DigiHSTruthKey{this,"TileHitContainer_DigiHSTruth","TileHitCnt_DigiHSTruth", + "Output DigiHSTruth Tile hit container key"}; + + + Gaudi::Property<std::string> m_infoName{this, "TileInfoName", "TileInfo", + "Name of TileInfo store (default=TileInfo)"}; //!< name of TileInfo object in TES + bool m_run2{false}; //!< if true => RUN2 geometry with E4' and merged E1 + bool m_run2plus{false}; //!< if true => RUN2+ geometry with merged E1 (and E4' in RUN2) + Gaudi::Property<bool> m_pileUp{this, "PileUp", false, + "To switch on pileup (default=false)"}; //!< if true => pileup mode is activated + Gaudi::Property<double> m_deltaT{this, "DeltaT", 1.0*Gaudi::Units::nanosecond, + "Minimal Time granularity in TileHit (default=1ns)"}; //!< minimal time granularity for TileHit + Gaudi::Property<int> m_timeFlag{this, "HitTimeFlag", 0, + "Special options to deal with times of hits for cosmics and TB (default=0)"}; //!< special options to deal with times of hits for cosmics and TB + Gaudi::Property<double> m_triggerTime{this, "TriggerTime", 0.0, + "Fixed trigger time value (default=0)"}; //!< fixed trigger time value (default=0) + Gaudi::Property<double> m_maxHitTime{this, "MaxHitTime", 150.5*Gaudi::Units::nanosecond, + "All sub-hits with time above m_maxHitTime will be ignored"}; //!< all sub-hits with time above m_maxHitTime will be ignored + Gaudi::Property<double> m_photoStatisticsWindow{this, "PhotostatWindow", 62.5*Gaudi::Units::nanosecond, + "Sum up energy in [-m_photoStatWindow,+m_photoStatWindow] and use it for photostatistics"}; //!< sum up energy in [-m_photoStatWindow,+m_photoStatWindow] and use it for photostatistics + Gaudi::Property<int> m_photoElectronStatistics{this, "PhotostatType", 2, + "Method to apply photostatistics (default=2)"}; //!< photoelectron statistics type: 0 - Poisson, 1 - "new" Poisson + Gauss, 2 - Poisson->Gauss + Gaudi::Property<bool> m_skipNoHit{this, "SkipNoHit", false, + "Skip events with no Tile hits (default=false)"}; //!< if true => skip events with no Tile hits + Gaudi::Property<bool> m_rndmEvtOverlay{this, "RndmEvtOverlay", false, + "Pileup and/or noise added by overlaying random events (default=false)"}; //!< If true => overlay with random event (zero-luminosity pile-up) + Gaudi::Property<bool> m_useTriggerTime{this, "UseTriggerTime", false, + "Take trigger time from external tool (default=false)"}; //!< if true => take trigger time from external tool or from m_triggerTime + Gaudi::Property<bool> m_doDigiTruth{this, "DoHSTruthReconstruction", true, + "DigiTruth reconstruction"}; //! + PublicToolHandle<ITriggerTime> m_triggerTimeTool{this, "TriggerTimeTool", "", + "Name of trigger time tool (default='')"}; //!< tool to take the time from + + ServiceHandle<PileUpMergeSvc> m_mergeSvc{this, "PileUpMergeSvc", "PileUpMergeSvc", ""}; + + const TileID* m_tileID{}; //!< Pointer to TileID helper + const TileTBID* m_tileTBID{}; //!< Pointer to TileID helper + const TileInfo* m_tileInfo{}; //!< Pointer to TileInfo + const TileDetDescrManager* m_tileMgr{}; //!< Pointer to TileDetDescrManager + float m_nPhotoElectrons[7]; //!< number of photo electrons per GeV in samplings + + ServiceHandle<IAthRNGSvc> m_rndmSvc{this, "RndmSvc", "AthRNGSvc", ""}; //!< Random number generator engine to use + + std::vector<TileHit*> m_allHits; //!< vector for all TileHits + std::vector<TileHit*> m_allHits_DigiHSTruth; //!< vector for all TileHits + TileHitNonConstContainer* m_hits{}; //!< pointer to hits container + TileHitNonConstContainer* m_hits_DigiHSTruth{}; //!< pointer to hits container + + int m_mbtsOffset{0}; //<! index of first MBTS hit in m_allHits vector + static const int N_SIDE = 2; + static const int N_PHI = 8; + static const int N_ETA = 2; + static const int N_MBTS_CELLS = N_SIDE * N_PHI * N_ETA; + inline int mbts_index(int side, int phi, int eta) const { + return (side * N_PHI + phi) * N_ETA + eta + m_mbtsOffset; + } + static const int E4_SIDE = -1; + static const int E4_ETA = 2; + static const int E4_N_PHI = 4; + static const int N_E4PRIME_CELLS = E4_N_PHI; + inline int e4pr_index(int phi) const { + return phi + N_MBTS_CELLS + m_mbtsOffset; + } + + ServiceHandle<TileCablingSvc> m_cablingSvc{this, "TileCablingSvc", "TileCablingSvc", ""}; + const TileCablingService* m_cabling{}; + TileFragHash m_fragHashFunc; + std::vector<bool> m_E1merged; + std::vector<bool> m_MBTSmerged; + enum CELL_TOWER{E1_TOWER = 10}; }; #endif // TILESIMALGS_TILEHITVECTOCNTTOOL_H diff --git a/TileCalorimeter/TileSimAlgs/src/TileHitVecToCntTool.cxx b/TileCalorimeter/TileSimAlgs/src/TileHitVecToCntTool.cxx index 9eaf670ee10690b18ab9be1806e0e344c94c43ec..39ef353f22e7b2c0f8ec3f06029f91c09c459819 100644 --- a/TileCalorimeter/TileSimAlgs/src/TileHitVecToCntTool.cxx +++ b/TileCalorimeter/TileSimAlgs/src/TileHitVecToCntTool.cxx @@ -15,7 +15,6 @@ #include "TileEvent/TileHitNonConstContainer.h" #include "TileConditions/TileInfo.h" #include "TileConditions/TileCablingService.h" -#include "TileConditions/TileCablingSvc.h" // Calo includes #include "CaloIdentifier/TileID.h" @@ -25,8 +24,6 @@ #include "AthenaBaseComps/AthMsgStreamMacros.h" #include "StoreGate/WriteHandle.h" -// Pile up -#include "PileUpTools/PileUpMergeSvc.h" // Trigger time #include "AthenaKernel/ITriggerTime.h" #include "AthenaKernel/errorcheck.h" @@ -35,10 +32,6 @@ #include "AthenaKernel/RNGWrapper.h" #include "CLHEP/Random/RandomEngine.h" -// Gaudi includes -#include "GaudiKernel/SystemOfUnits.h" - - #include "CLHEP/Random/Randomize.h" #include "CLHEP/Random/RandomEngine.h" @@ -53,49 +46,7 @@ TileHitVecToCntTool::TileHitVecToCntTool(const std::string& type, const std::string& name, const IInterface* parent) : PileUpToolBase(type,name,parent) - , m_infoName("TileInfo") - , m_run2(false) - , m_run2plus(false) - , m_pileUp(false) - , m_deltaT(1.0 * Gaudi::Units::nanosecond) - , m_timeFlag(0) - , m_triggerTime(0.0) - , m_maxHitTime(150.5 * Gaudi::Units::nanosecond) - , m_photoStatisticsWindow(62.5 * Gaudi::Units::nanosecond) - , m_photoElectronStatistics(2) - , m_skipNoHit(false) - , m_rndmEvtOverlay(false) - , m_useTriggerTime(false) - , m_triggerTimeTool("") - , m_mergeSvc(0) - , m_tileID(0) - , m_tileTBID(0) - , m_tileInfo(0) - , m_tileMgr(0) - , m_hits(0) - , m_hits_DigiHSTruth(0) - , m_mbtsOffset(0) - , m_cablingSvc("TileCablingSvc", name) - , m_cabling(0) { - - m_hitVectorNames.push_back("TileHitVec"); - - declareProperty("TileHitVectors", m_hitVectorNames, "Name of input hit vectors (default=TileHitVec)" ); - declareProperty("TileInfoName", m_infoName, "Name of TileInfo store (default=TileInfo"); - declareProperty("PileUp",m_pileUp, "To switch on pileup (default=false)"); - declareProperty("DeltaT",m_deltaT, "Minimal Time granularity in TileHit (default=1ns)"); - declareProperty("HitTimeFlag",m_timeFlag, "Specail options to deal with times of hits for cosmics and TB (default=0)"); - declareProperty("TriggerTime",m_triggerTime, "Fixed trigger time value (default=0)"); - declareProperty("UseTriggerTime",m_useTriggerTime, "Take trigger time from external tool (default=false)"); - declareProperty("TriggerTimeTool",m_triggerTimeTool, "Name of trigger time tool (default='')"); - declareProperty("MaxHitTime", m_maxHitTime, "All sub-hits with time above m_maxHitTime will be ignored"); - declareProperty("PhotostatWindow", m_photoStatisticsWindow, "Sum up energy in [-m_photoStatWindow,+m_photoStatWindow] and use it for photostatistics"); - declareProperty("PhotostatType", m_photoElectronStatistics, "Method to apply photostatistics (default=2)"); - declareProperty("SkipNoHit",m_skipNoHit, "Skip events with no Tile hits (default=false)"); - declareProperty("RndmEvtOverlay",m_rndmEvtOverlay = false, "Pileup and/or noise added by overlaying random events (default=false)"); - declareProperty("DoHSTruthReconstruction",m_doDigiTruth = true, "DigiTruth reconstruction"); - m_doDigiTruth = true; } StatusCode TileHitVecToCntTool::initialize() { @@ -177,17 +128,7 @@ StatusCode TileHitVecToCntTool::initialize() { if (m_pileUp || m_rndmEvtOverlay) { ATH_MSG_INFO("take events from PileUp service"); - // - // locate the PileUpMergeSvc and initialize our local ptr - // - if (service("PileUpMergeSvc", m_mergeSvc).isFailure()) { - error = true; - ATH_MSG_ERROR("Can not retrive PileUpMergeSvc"); - ATH_MSG_ERROR("Setting PileUp and RndmOverlay flags to FALSE "); - m_pileUp = m_rndmEvtOverlay = false; - } else { - ATH_MSG_INFO("PileUpMergeSvc successfully initialized"); - } + ATH_CHECK(m_mergeSvc.retrieve()); if (m_useTriggerTime) { ATH_MSG_INFO(" In case of pileup, the trigger time subtraction is done in PileUpSvc");