From 0c64964c8677697f81d82ed3ea26f4b59bca25de Mon Sep 17 00:00:00 2001 From: Atlas-Software Librarian <Atlas-Software.Librarian@cern.ch> Date: Fri, 8 Apr 2016 18:56:23 +0200 Subject: [PATCH] 'CMakeLists.txt' (LArG4FastSimulation-05-00-04) * Tagging: LArG4FastSimulation-05-00-04 * share/LArG4FastSimulation_setupTimer_jobOptions.py, share/LArG4FastSimulation_VPTimer_EHist_jobOptions.py - update to use migrated UserActions. Should be back-compatible. ATLASSIM-2388 2015-09-13 Zach Marshall <ZLMarshall@lbl.gov> * Tagging: LArG4FastSimulation-05-00-03 * Making sure to add the damned SD to the SD manager - otherwise nobody else is going to be able to find it when they look for it, obviously! * Make sure to use the existing SD if it was already created 2015-09-13 Zach Marshall <ZLMarshall@lbl.gov> * Tagging: LArG4FastSimulation-05-00-02 * Fixing checkreq warning (doh) 2015-09-12 Zach Marshall <ZLMarshall@lbl.gov> ... (Long ChangeLog diff - truncated) --- .../LArG4/LArG4FastSimulation/CMakeLists.txt | 42 +++++++++++ .../LArG4FastSimulation/cmt/requirements | 4 +- .../python/LArG4FastSimulationConfig.py | 12 ---- .../python/LArG4FastSimulationConfigDb.py | 4 -- ...FastSimulation_VPTimer_EHist_jobOptions.py | 32 ++++++--- ...rG4FastSimulation_setupTimer_jobOptions.py | 19 +++-- .../src/BarrelFastSimDedicatedSD.cxx | 71 +++---------------- .../src/BarrelFastSimDedicatedSD.h | 20 +----- .../src/EndcapFastSimDedicatedSD.cxx | 66 +++-------------- .../src/EndcapFastSimDedicatedSD.h | 20 +----- .../src/FCALFastSimDedicatedSD.cxx | 66 +++-------------- .../src/FCALFastSimDedicatedSD.h | 20 +----- .../src/IFastSimDedicatedSD.h | 18 +++-- .../src/LArFastShowerTool.cxx | 26 +++++-- .../src/LArFastShowerTool.h | 4 +- .../LArG4FastSimulation_entries.cxx | 9 --- 16 files changed, 147 insertions(+), 286 deletions(-) create mode 100644 LArCalorimeter/LArG4/LArG4FastSimulation/CMakeLists.txt diff --git a/LArCalorimeter/LArG4/LArG4FastSimulation/CMakeLists.txt b/LArCalorimeter/LArG4/LArG4FastSimulation/CMakeLists.txt new file mode 100644 index 00000000000..ad1415072a1 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4FastSimulation/CMakeLists.txt @@ -0,0 +1,42 @@ +################################################################################ +# Package: LArG4FastSimulation +################################################################################ + +# Declare the package name: +atlas_subdir( LArG4FastSimulation ) + +# Declare the package's dependencies: +atlas_depends_on_subdirs( PUBLIC + GaudiKernel + PRIVATE + Control/StoreGate + DetectorDescription/GeoModel/GeoModelKernel + DetectorDescription/GeoModel/GeoSpecialShapes + LArCalorimeter/LArG4/LArG4Code + LArCalorimeter/LArG4/LArG4ShowerLibSvc + LArCalorimeter/LArGeoModel/LArReadoutGeometry + LArCalorimeter/LArSimEvent + Simulation/G4Atlas/G4AtlasTools ) + +# External dependencies: +find_package( CLHEP ) +find_package( Geant4 ) +find_package( HepMC ) +find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread Table MathMore Minuit Minuit2 Matrix Physics HistPainter Rint Graf Graf3d Gpad Html Postscript Gui GX11TTF GX11 ) +find_package( XercesC ) + +# tag ROOTBasicLibs was not recognized in automatic conversion in cmt2cmake + +# tag ROOTSTLDictLibs was not recognized in automatic conversion in cmt2cmake + +# Component(s) in the package: +atlas_add_component( LArG4FastSimulation + src/*.cxx + src/components/*.cxx + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${XERCESC_INCLUDE_DIRS} ${GEANT4_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} ${HEPMC_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} ${XERCESC_LIBRARIES} ${GEANT4_LIBRARIES} ${CLHEP_LIBRARIES} ${HEPMC_LIBRARIES} GaudiKernel StoreGateLib SGtests GeoModelKernel GeoSpecialShapes LArG4Code LArReadoutGeometry LArSimEvent G4AtlasToolsLib ) + +# Install files from the package: +atlas_install_python_modules( python/*.py ) +atlas_install_joboptions( share/*.py ) + diff --git a/LArCalorimeter/LArG4/LArG4FastSimulation/cmt/requirements b/LArCalorimeter/LArG4/LArG4FastSimulation/cmt/requirements index 51b8cc10663..c42b709c99e 100644 --- a/LArCalorimeter/LArG4/LArG4FastSimulation/cmt/requirements +++ b/LArCalorimeter/LArG4/LArG4FastSimulation/cmt/requirements @@ -14,9 +14,11 @@ use GeoModelKernel GeoModelKernel-* DetectorDescription/GeoModel use GeoSpecialShapes GeoSpecialShapes-* DetectorDescription/GeoModel use LArG4Code LArG4Code-* LArCalorimeter/LArG4 use LArG4ShowerLibSvc LArG4ShowerLibSvc-* LArCalorimeter/LArG4 -use LArG4SD LArG4SD-* LArCalorimeter/LArG4 +#use LArG4SD LArG4SD-* LArCalorimeter/LArG4 use LArReadoutGeometry LArReadoutGeometry-* LArCalorimeter/LArGeoModel use LArSimEvent LArSimEvent-* LArCalorimeter +use StoreGate StoreGate-* Control +#use CaloIdentifier CaloIdentifier-* Calorimeter end_private apply_tag ROOTBasicLibs diff --git a/LArCalorimeter/LArG4/LArG4FastSimulation/python/LArG4FastSimulationConfig.py b/LArCalorimeter/LArG4/LArG4FastSimulation/python/LArG4FastSimulationConfig.py index f6b7a772a22..d68ab43046f 100644 --- a/LArCalorimeter/LArG4/LArG4FastSimulation/python/LArG4FastSimulationConfig.py +++ b/LArCalorimeter/LArG4/LArG4FastSimulation/python/LArG4FastSimulationConfig.py @@ -2,18 +2,6 @@ from AthenaCommon import CfgMgr -def getBarrelFastSimDedicatedSD(name="BarrelFastSimDedicatedSD", **kwargs): - return CfgMgr.BarrelFastSimDedicatedSD(name, **kwargs) - -def getEndcapFastSimDedicatedSD(name="EndcapFastSimDedicatedSD", **kwargs): - return CfgMgr.EndcapFastSimDedicatedSD(name, **kwargs) - -def getFCALFastSimDedicatedSD(name="FCALFastSimDedicatedSD", **kwargs): - return CfgMgr.FCALFastSimDedicatedSD(name, **kwargs) - -def getFCAL2FastSimDedicatedSD(name="FCAL2FastSimDedicatedSD", **kwargs): - return CfgMgr.FCALFastSimDedicatedSD(name, **kwargs) - #def getDeadMaterialShower(name="DeadMaterialShower", **kwargs): # return CfgMgr.DeadMaterialShower(name, **kwargs) diff --git a/LArCalorimeter/LArG4/LArG4FastSimulation/python/LArG4FastSimulationConfigDb.py b/LArCalorimeter/LArG4/LArG4FastSimulation/python/LArG4FastSimulationConfigDb.py index c931b801b19..b0687a0b07d 100644 --- a/LArCalorimeter/LArG4/LArG4FastSimulation/python/LArG4FastSimulationConfigDb.py +++ b/LArCalorimeter/LArG4/LArG4FastSimulation/python/LArG4FastSimulationConfigDb.py @@ -1,10 +1,6 @@ # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration from AthenaCommon.CfgGetter import addTool -addTool("LArG4FastSimulation.LArG4FastSimulationConfig.getBarrelFastSimDedicatedSD","BarrelFastSimDedicatedSD") -addTool("LArG4FastSimulation.LArG4FastSimulationConfig.getEndcapFastSimDedicatedSD","EndcapFastSimDedicatedSD") -addTool("LArG4FastSimulation.LArG4FastSimulationConfig.getFCALFastSimDedicatedSD", "FCALFastSimDedicatedSD") -addTool("LArG4FastSimulation.LArG4FastSimulationConfig.getFCAL2FastSimDedicatedSD", "FCAL2FastSimDedicatedSD") #addTool("LArG4FastSimulation.LArG4FastSimulationConfig.getDeadMaterialShower", "DeadMaterialShower") addTool("LArG4FastSimulation.LArG4FastSimulationConfig.getEMBFastShower", "EMBFastShower") diff --git a/LArCalorimeter/LArG4/LArG4FastSimulation/share/LArG4FastSimulation_VPTimer_EHist_jobOptions.py b/LArCalorimeter/LArG4/LArG4FastSimulation/share/LArG4FastSimulation_VPTimer_EHist_jobOptions.py index fb0ec58b20d..9cdf0bb7d4f 100755 --- a/LArCalorimeter/LArG4/LArG4FastSimulation/share/LArG4FastSimulation_VPTimer_EHist_jobOptions.py +++ b/LArCalorimeter/LArG4/LArG4FastSimulation/share/LArG4FastSimulation_VPTimer_EHist_jobOptions.py @@ -1,5 +1,5 @@ ## -## # $Id: LArG4FastSimulation_VPTimer_EHist_jobOptions.py 662012 2015-04-21 14:32:22Z jchapman $ +## # $Id: LArG4FastSimulation_VPTimer_EHist_jobOptions.py 708108 2015-11-16 12:34:05Z jchapman $ ## ## # jobOptions file for preparing detailed program timer and histogramming of ## # MC-level energy by particle and volume @@ -27,17 +27,31 @@ actionProperties={ ## # volume/particle timing - prints cpu time spent per particle, per volume to outfile ## # DO NOT USE SIMULTANEOUSLY WITH EHistAction! -TimerAction = PyG4Atlas.UserAction('G4ProfilingTools','TestActionVPTimer', - ['BeginOfRun','EndOfRun','BeginOfEvent','EndOfEvent','Step']) -TimerAction.set_Properties(actionProperties) -AtlasG4Eng.G4Eng.menu_UserActions.add_UserAction(TimerAction) +try: + # Post UserAction Migration (ATLASSIM-1752) + from G4AtlasServices.G4AtlasUserActionConfig import UAStore + from AthenaCommon.CfgGetter import getPublicTool + UAStore.addAction(getPublicTool('TestActionVPTimer'),['BeginOfRun','EndOfRun','BeginOfEvent','EndOfEvent','Step']) +except: + # Pre UserAction Migration + TimerAction = PyG4Atlas.UserAction('G4ProfilingTools','TestActionVPTimer', + ['BeginOfRun','EndOfRun','BeginOfEvent','EndOfEvent','Step']) + TimerAction.set_Properties(actionProperties) + AtlasG4Eng.G4Eng.menu_UserActions.add_UserAction(TimerAction) print "volume/particle timing ON (see stdout)" ## # energy histogramming - creates ROOT file with histograms of kinetic energy by particle, by volume -#EHistAction = PyG4Atlas.UserAction('G4ProfilingTools','TestActionEHist', -# ['BeginOfRun','EndOfRun','Step']) -#EHistAction.set_Properties(actionProperties) -#AtlasG4Eng.G4Eng.menu_UserActions.add_UserAction(EHistAction) +#try: +# # Post UserAction Migration (ATLASSIM-1752) +# from G4AtlasServices.G4AtlasUserActionConfig import UAStore +# from AthenaCommon.CfgGetter import getPublicTool +# UAStore.addAction(getPublicTool('TestActionEHist'),['BeginOfRun','EndOfRun','Step']) +#except: +# # Pre UserAction Migration +# EHistAction = PyG4Atlas.UserAction('G4ProfilingTools','TestActionEHist', +# ['BeginOfRun','EndOfRun','Step']) +# EHistAction.set_Properties(actionProperties) +# AtlasG4Eng.G4Eng.menu_UserActions.add_UserAction(EHistAction) #print "energy histogramming ON (outfile:",actionProperties['ROOTFileName'],")" ## # must be imported prior to the commands: diff --git a/LArCalorimeter/LArG4/LArG4FastSimulation/share/LArG4FastSimulation_setupTimer_jobOptions.py b/LArCalorimeter/LArG4/LArG4FastSimulation/share/LArG4FastSimulation_setupTimer_jobOptions.py index d84861844bc..e51c2c4a201 100755 --- a/LArCalorimeter/LArG4/LArG4FastSimulation/share/LArG4FastSimulation_setupTimer_jobOptions.py +++ b/LArCalorimeter/LArG4/LArG4FastSimulation/share/LArG4FastSimulation_setupTimer_jobOptions.py @@ -1,5 +1,5 @@ # -# $Id: LArG4FastSimulation_setupTimer_jobOptions.py 662012 2015-04-21 14:32:22Z jchapman $ +# $Id: LArG4FastSimulation_setupTimer_jobOptions.py 708108 2015-11-16 12:34:05Z jchapman $ # # job options for calculating timing information # @@ -8,11 +8,18 @@ # Include this file in your simulation job options to apply the timer # -def LArG4Timer_preG4Init(): - from G4AtlasApps import PyG4Atlas,AtlasG4Eng - MyAction = PyG4Atlas.UserAction('G4ProfilingTools','TestActionTimer',['BeginOfRun','EndOfRun','BeginOfEvent','EndOfEvent','Step']) - AtlasG4Eng.G4Eng.menu_UserActions.add_UserAction(MyAction) -simFlags.InitFunctions.add_function("preInitG4", LArG4Timer_preG4Init) +try: + # Post UserAction Migration (ATLASSIM-1752) + from G4AtlasServices.G4AtlasUserActionConfig import UAStore + from AthenaCommon.CfgGetter import getPublicTool + UAStore.addAction(getPublicTool('TestActionTimer'),['BeginOfRun','EndOfRun','BeginOfEvent','EndOfEvent','Step']) +except: + # Pre UserAction Migration + def LArG4Timer_preG4Init(): + from G4AtlasApps import PyG4Atlas,AtlasG4Eng + MyAction = PyG4Atlas.UserAction('G4ProfilingTools','TestActionTimer',['BeginOfRun','EndOfRun','BeginOfEvent','EndOfEvent','Step']) + AtlasG4Eng.G4Eng.menu_UserActions.add_UserAction(MyAction) + simFlags.InitFunctions.add_function("preInitG4", LArG4Timer_preG4Init) from AthenaCommon.AppMgr import ServiceMgr from GaudiSvc.GaudiSvcConf import THistSvc diff --git a/LArCalorimeter/LArG4/LArG4FastSimulation/src/BarrelFastSimDedicatedSD.cxx b/LArCalorimeter/LArG4/LArG4FastSimulation/src/BarrelFastSimDedicatedSD.cxx index 69382cf2a37..8c38939f999 100644 --- a/LArCalorimeter/LArG4/LArG4FastSimulation/src/BarrelFastSimDedicatedSD.cxx +++ b/LArCalorimeter/LArG4/LArG4FastSimulation/src/BarrelFastSimDedicatedSD.cxx @@ -10,68 +10,26 @@ #include "LArReadoutGeometry/EMBAccordionDetails.h" #include "LArReadoutGeometry/GeoStraightAccSection.h" #include "LArG4Code/EnergySpot.h" -#include "LArG4SD/LArG4SD.h" -#include "LArG4Code/LArVHitMerger.h" -#include "LArG4Code/LArVHitMergerFactory.h" #include "LArG4Code/LArG4Identifier.h" +#include "StoreGate/StoreGateSvc.h" using HepGeom::Point3D; using HepGeom::Transform3D; using CLHEP::Hep3Vector; // Constructor: -BarrelFastSimDedicatedSD::BarrelFastSimDedicatedSD(const std::string& type, const std::string& name, const IInterface *parent) - : SensitiveDetectorBase(type,name,parent) - , m_hitMerger(0) +BarrelFastSimDedicatedSD::BarrelFastSimDedicatedSD(StoreGateSvc* detStore) + : IFastSimDedicatedSD("BarrelFastSimDedicatedSD", detStore) , m_embManager(nullptr) , m_accordionDetails(nullptr) , m_absorberSections(nullptr) { - m_noVolumes=true; - declareInterface<IFastSimDedicatedSD>(this); -} - -StatusCode BarrelFastSimDedicatedSD::initialize() -{ - ATH_MSG_VERBOSE( name() << "::initialize()"); - CHECK( detStore()->retrieve( m_embManager ) ); + G4cout << GetName() << "::initialize()" << G4endl; + if ( detStore->retrieve( m_embManager ).isFailure() ){ + throw std::runtime_error("Could not retrieve EMB manager"); + } m_accordionDetails=m_embManager->getAccordionDetails(); m_absorberSections=m_accordionDetails->getAbsorberSections(); - return SensitiveDetectorBase::initialize(); -} - -StatusCode BarrelFastSimDedicatedSD::retrieveLArHitMerger() -{ - // At the beginning of first event initialize m_hitMerger pointer - // 1. Get Hit Merger factory from DS - // 2. Query Hit Merger factory for Hit Merger pointer - const DataHandle<LArVHitMergerFactory> _factory; - CHECK( detStore()->retrieve(_factory,"LArHitMergerFactory") ); - - m_hitMerger = _factory->getHitMerger(); - - if(m_hitMerger==0){ - ATH_MSG_ERROR("0 pointer to the Hit Merger"); - return StatusCode::FAILURE; - } - m_hitMerger->BeginOfEvent(); //FIXME lazy init hack - return StatusCode::SUCCESS; -} - -// End each event (do hit merger here) -StatusCode BarrelFastSimDedicatedSD::EndOfAthenaEvent() { - if(m_hitMerger) m_hitMerger->EndOfEvent(); - return StatusCode::SUCCESS; -} - -StatusCode -BarrelFastSimDedicatedSD::queryInterface(const InterfaceID& riid, void** ppvIf) { - if ( riid == IFastSimDedicatedSD::interfaceID() ) { - *ppvIf = (IFastSimDedicatedSD*)this; - addRef(); - return StatusCode::SUCCESS; - } - return SensitiveDetectorBase::queryInterface( riid, ppvIf ); } // ProcessHitsMethod @@ -143,7 +101,7 @@ void BarrelFastSimDedicatedSD::ProcessSpot(const EnergySpot & spot){ int stackIndex=int(A1.dot(P0)/A1.mag2()*22.0 + 3.0)/2 ; if (stackIndex<0 || stackIndex>13) { - ATH_MSG_WARNING( "Warning, bad stack index " << stackIndex << ' ' << rmin << ' ' << r << ' ' << A0.perp() << ' ' << A0 << ' ' << A1 << ' ' << P0 ); + G4cout << "Warning, bad stack index " << stackIndex << ' ' << rmin << ' ' << r << ' ' << A0.perp() << ' ' << A0 << ' ' << A1 << ' ' << P0 << G4endl; if (implementWaves) return; } else { double xcent = m_absorberSections->XCent (accordionIndexLower,stackIndex); @@ -189,17 +147,8 @@ void BarrelFastSimDedicatedSD::ProcessSpot(const EnergySpot & spot){ << regionIndex << etaIndex << phiIndex; - //FIXME temporary hack for lazy initialization for LArHitMerger - if (!m_hitMerger) - { - if(retrieveLArHitMerger().isFailure()) - { - ATH_MSG_FATAL("Could not retrieve the LArHitMerger! Will crash now."); - //throw; - } - } - // call process with dummy first argument - m_hitMerger->process(0,id, spot.GetTime(), spot.GetEnergy()); + // call process to add this to the collection + SimpleHit(id, spot.GetTime(), spot.GetEnergy()); return; } diff --git a/LArCalorimeter/LArG4/LArG4FastSimulation/src/BarrelFastSimDedicatedSD.h b/LArCalorimeter/LArG4/LArG4FastSimulation/src/BarrelFastSimDedicatedSD.h index 43a75a37c09..010a4ca226b 100644 --- a/LArCalorimeter/LArG4/LArG4FastSimulation/src/BarrelFastSimDedicatedSD.h +++ b/LArCalorimeter/LArG4/LArG4FastSimulation/src/BarrelFastSimDedicatedSD.h @@ -9,7 +9,6 @@ // sensitive detector does. We give this to the framework, sort // of: we DO want it to execute it's end- -#include "G4AtlasTools/SensitiveDetectorBase.h" #include "IFastSimDedicatedSD.h" class EnergySpot; @@ -18,35 +17,22 @@ class LArVHitMerger; class EMBDetectorManager; class EMBAccordionDetails; class GeoStraightAccSection; +class StoreGateSvc; -class BarrelFastSimDedicatedSD : public SensitiveDetectorBase, virtual public IFastSimDedicatedSD +class BarrelFastSimDedicatedSD : public IFastSimDedicatedSD { public: // Constructor: - BarrelFastSimDedicatedSD(const std::string& type, const std::string& name, const IInterface *parent); + BarrelFastSimDedicatedSD(StoreGateSvc*); // Destructor: ~BarrelFastSimDedicatedSD() {} - StatusCode initialize() override final; - - virtual G4VSensitiveDetector* makeSD() override final { return (G4VSensitiveDetector*)NULL; }; - // ProcessHitsMethod void ProcessSpot(const EnergySpot & spot) override final; - // End each event (do hit merger here) - /** End of event collection of hits. Merging is done in this method.*/ - virtual StatusCode EndOfAthenaEvent() override final; - - virtual StatusCode queryInterface(const InterfaceID& riid, void** ppvIf) override; - -protected: - virtual StatusCode retrieveLArHitMerger() final; //!< Method for lazy initialization of LArHitMerger. Temporary solution FIXME - LArVHitMerger *m_hitMerger; //!< Hit merger for the combination of hits within a single detector area - private: const EMBDetectorManager *m_embManager; diff --git a/LArCalorimeter/LArG4/LArG4FastSimulation/src/EndcapFastSimDedicatedSD.cxx b/LArCalorimeter/LArG4/LArG4FastSimulation/src/EndcapFastSimDedicatedSD.cxx index 1454cdbb1e2..76163a30848 100644 --- a/LArCalorimeter/LArG4/LArG4FastSimulation/src/EndcapFastSimDedicatedSD.cxx +++ b/LArCalorimeter/LArG4/LArG4FastSimulation/src/EndcapFastSimDedicatedSD.cxx @@ -8,73 +8,31 @@ #include "LArReadoutGeometry/EMECDetectorManager.h" #include "LArReadoutGeometry/EMECDetectorRegion.h" #include "LArG4Code/EnergySpot.h" -#include "LArG4SD/LArG4SD.h" #include "LArSimEvent/LArHitContainer.h" #include "LArG4Code/LArG4Identifier.h" -#include "LArG4Code/LArVHitMerger.h" -#include "LArG4Code/LArVHitMergerFactory.h" #include "GeoSpecialShapes/LArWheelCalculator.h" +#include "StoreGate/StoreGateSvc.h" using HepGeom::Point3D; using HepGeom::Transform3D; // Constructor: -EndcapFastSimDedicatedSD::EndcapFastSimDedicatedSD(const std::string& type, const std::string& name, const IInterface *parent) - : SensitiveDetectorBase(type,name,parent) - , m_hitMerger(0) +EndcapFastSimDedicatedSD::EndcapFastSimDedicatedSD(StoreGateSvc* detStore) + : IFastSimDedicatedSD("EndcapFastSimDedicatedSD", detStore) , m_emecManager(nullptr) , m_innerWheelCalculatorPos(nullptr) , m_innerWheelCalculatorNeg(nullptr) , m_outerWheelCalculatorPos(nullptr) , m_outerWheelCalculatorNeg(nullptr) { - m_noVolumes=true; - declareInterface<IFastSimDedicatedSD>(this); -} - -StatusCode EndcapFastSimDedicatedSD::initialize() -{ - ATH_MSG_VERBOSE( name() << "::initialize()"); - CHECK( detStore()->retrieve( m_emecManager ) ); + G4cout << GetName() << "::initialize()" << G4endl; + if ( detStore->retrieve( m_emecManager ).isFailure() ){ + throw std::runtime_error("Could not retrieve EMEC manager"); + } m_innerWheelCalculatorPos = new LArWheelCalculator(LArWheelCalculator::InnerAbsorberWheel,+1); m_innerWheelCalculatorNeg = new LArWheelCalculator(LArWheelCalculator::InnerAbsorberWheel,-1); m_outerWheelCalculatorPos = new LArWheelCalculator(LArWheelCalculator::OuterAbsorberWheel,+1); m_outerWheelCalculatorNeg = new LArWheelCalculator(LArWheelCalculator::OuterAbsorberWheel,-1); - return SensitiveDetectorBase::initialize(); -} - -StatusCode EndcapFastSimDedicatedSD::retrieveLArHitMerger() -{ - // At the beginning of first event initialize m_hitMerger pointer - // 1. Get Hit Merger factory from DS - // 2. Query Hit Merger factory for Hit Merger pointer - const DataHandle<LArVHitMergerFactory> _factory; - CHECK( detStore()->retrieve(_factory,"LArHitMergerFactory") ); - - m_hitMerger = _factory->getHitMerger(); - - if(m_hitMerger==0){ - ATH_MSG_ERROR("0 pointer to the Hit Merger"); - return StatusCode::FAILURE; - } - m_hitMerger->BeginOfEvent(); //FIXME lazy init hack - return StatusCode::SUCCESS; -} - -// End each event (do hit merger here) -StatusCode EndcapFastSimDedicatedSD::EndOfAthenaEvent() { - if(m_hitMerger) m_hitMerger->EndOfEvent(); - return StatusCode::SUCCESS; -} - -StatusCode -EndcapFastSimDedicatedSD::queryInterface(const InterfaceID& riid, void** ppvIf) { - if ( riid == IFastSimDedicatedSD::interfaceID() ) { - *ppvIf = (IFastSimDedicatedSD*)this; - addRef(); - return StatusCode::SUCCESS; - } - return SensitiveDetectorBase::queryInterface( riid, ppvIf ); } // ProcessHitsMethod @@ -164,14 +122,8 @@ void EndcapFastSimDedicatedSD::ProcessSpot(const EnergySpot & spot){ << regionIndex << etaIndex << phiBin; - //FIXME temporary hack for lazy initialization for LArHitMerger - if (!m_hitMerger && retrieveLArHitMerger().isFailure()) - { - ATH_MSG_FATAL("Could not retrieve the LArHitMerger! Will crash now."); - throw; - } - // call process with dummy first argument - m_hitMerger->process(0,id, spot.GetTime(), spot.GetEnergy()); + // call process to add this to the collection + SimpleHit(id, spot.GetTime(), spot.GetEnergy()); return; } } diff --git a/LArCalorimeter/LArG4/LArG4FastSimulation/src/EndcapFastSimDedicatedSD.h b/LArCalorimeter/LArG4/LArG4FastSimulation/src/EndcapFastSimDedicatedSD.h index bf6d8e90e48..18c7c4fe197 100644 --- a/LArCalorimeter/LArG4/LArG4FastSimulation/src/EndcapFastSimDedicatedSD.h +++ b/LArCalorimeter/LArG4/LArG4FastSimulation/src/EndcapFastSimDedicatedSD.h @@ -9,7 +9,6 @@ // sensitive detector does. We give this to the framework, sort // of: we DO want it to execute it's end- -#include "G4AtlasTools/SensitiveDetectorBase.h" #include "IFastSimDedicatedSD.h" class EnergySpot; @@ -17,35 +16,22 @@ class G4HCofThisEvent; class LArVHitMerger; class EMECDetectorManager; class LArWheelCalculator; +class StoreGateSvc; -class EndcapFastSimDedicatedSD : public SensitiveDetectorBase, virtual public IFastSimDedicatedSD +class EndcapFastSimDedicatedSD : public IFastSimDedicatedSD { public: // Constructor: - EndcapFastSimDedicatedSD(const std::string& type, const std::string& name, const IInterface *parent); + EndcapFastSimDedicatedSD(StoreGateSvc*); // Destructor: ~EndcapFastSimDedicatedSD() {} - StatusCode initialize() override final; - - virtual G4VSensitiveDetector* makeSD() override final { return (G4VSensitiveDetector*)NULL; }; - // ProcessHitsMethod void ProcessSpot(const EnergySpot & spot) override final; - // End each event (do hit merger here) - /** End of event collection of hits. Merging is done in this method.*/ - virtual StatusCode EndOfAthenaEvent() override final; - - virtual StatusCode queryInterface(const InterfaceID& riid, void** ppvIf) override; - -protected: - virtual StatusCode retrieveLArHitMerger() final; //!< Method for lazy initialization of LArHitMerger. Temporary solution FIXME - LArVHitMerger *m_hitMerger; //!< Hit merger for the combination of hits within a single detector area - private: EMECDetectorManager * m_emecManager; diff --git a/LArCalorimeter/LArG4/LArG4FastSimulation/src/FCALFastSimDedicatedSD.cxx b/LArCalorimeter/LArG4/LArG4FastSimulation/src/FCALFastSimDedicatedSD.cxx index f4a2d95d890..25e007b2056 100644 --- a/LArCalorimeter/LArG4/LArG4FastSimulation/src/FCALFastSimDedicatedSD.cxx +++ b/LArCalorimeter/LArG4/LArG4FastSimulation/src/FCALFastSimDedicatedSD.cxx @@ -8,65 +8,23 @@ #include "LArReadoutGeometry/FCALDetectorManager.h" #include "LArReadoutGeometry/FCALModule.h" #include "LArG4Code/EnergySpot.h" -#include "LArG4SD/LArG4SD.h" #include "LArSimEvent/LArHitContainer.h" #include "LArG4Code/LArG4Identifier.h" -#include "LArG4Code/LArVHitMerger.h" -#include "LArG4Code/LArVHitMergerFactory.h" #include "GeoModelKernel/GeoTubs.h" +#include "StoreGate/StoreGateSvc.h" using HepGeom::Transform3D; using HepGeom::Point3D; // Constructor: -FCALFastSimDedicatedSD::FCALFastSimDedicatedSD(const std::string& type, const std::string& name, const IInterface *parent) - : SensitiveDetectorBase(type,name,parent) - , m_hitMerger(0) +FCALFastSimDedicatedSD::FCALFastSimDedicatedSD(StoreGateSvc* detStore) + : IFastSimDedicatedSD("FCALFastSimDedicatedSD", detStore) , m_fcalManager(nullptr) { - m_noVolumes=true; - declareInterface<IFastSimDedicatedSD>(this); -} - -StatusCode FCALFastSimDedicatedSD::initialize() -{ - ATH_MSG_VERBOSE( name() << "::initialize()"); - CHECK( detStore()->retrieve(m_fcalManager) ); - return SensitiveDetectorBase::initialize(); -} - -StatusCode FCALFastSimDedicatedSD::retrieveLArHitMerger() -{ - // At the beginning of first event initialize m_hitMerger pointer - // 1. Get Hit Merger factory from DS - // 2. Query Hit Merger factory for Hit Merger pointer - const DataHandle<LArVHitMergerFactory> _factory; - CHECK( detStore()->retrieve(_factory,"LArHitMergerFactory") ); - - m_hitMerger = _factory->getHitMerger(); - - if(m_hitMerger==0){ - ATH_MSG_ERROR("0 pointer to the Hit Merger"); - return StatusCode::FAILURE; + G4cout << GetName() << "::initialize()" << G4endl; + if ( detStore->retrieve(m_fcalManager).isFailure() ){ + throw std::runtime_error("Could not retrieve FCAL manager"); } - m_hitMerger->BeginOfEvent(); //FIXME lazy init hack - return StatusCode::SUCCESS; -} - -// End each event (do hit merger here) -StatusCode FCALFastSimDedicatedSD::EndOfAthenaEvent() { - if(m_hitMerger) m_hitMerger->EndOfEvent(); - return StatusCode::SUCCESS; -} - -StatusCode -FCALFastSimDedicatedSD::queryInterface(const InterfaceID& riid, void** ppvIf) { - if ( riid == IFastSimDedicatedSD::interfaceID() ) { - *ppvIf = (IFastSimDedicatedSD*)this; - addRef(); - return StatusCode::SUCCESS; - } - return SensitiveDetectorBase::queryInterface( riid, ppvIf ); } // ProcessHitsMethod @@ -138,15 +96,7 @@ void FCALFastSimDedicatedSD::ProcessSpot(const EnergySpot & spot){ return; } - //FIXME temporary hack for lazy initialization for LArHitMerger - if (!m_hitMerger && retrieveLArHitMerger().isFailure()) - { - ATH_MSG_FATAL("Could not retrieve the LArHitMerger! Will crash now."); - throw; - } - // call process with dummy first argument - m_hitMerger->process(0,id, spot.GetTime(), spot.GetEnergy()); + // call process to add this to the collection + SimpleHit(id, spot.GetTime(), spot.GetEnergy()); return; - - } diff --git a/LArCalorimeter/LArG4/LArG4FastSimulation/src/FCALFastSimDedicatedSD.h b/LArCalorimeter/LArG4/LArG4FastSimulation/src/FCALFastSimDedicatedSD.h index ab5df03f599..43f542e1e32 100644 --- a/LArCalorimeter/LArG4/LArG4FastSimulation/src/FCALFastSimDedicatedSD.h +++ b/LArCalorimeter/LArG4/LArG4FastSimulation/src/FCALFastSimDedicatedSD.h @@ -9,40 +9,26 @@ // sensitive detector does. We give this to the framework, sort // of: we DO want it to execute it's end- -#include "G4AtlasTools/SensitiveDetectorBase.h" #include "IFastSimDedicatedSD.h" class EnergySpot; class LArVHitMerger; class FCALDetectorManager; +class StoreGateSvc; -class FCALFastSimDedicatedSD : public SensitiveDetectorBase, virtual public IFastSimDedicatedSD +class FCALFastSimDedicatedSD : public IFastSimDedicatedSD { public: // Constructor: - FCALFastSimDedicatedSD(const std::string& type, const std::string& name, const IInterface *parent); + FCALFastSimDedicatedSD(StoreGateSvc*); // Destructor: ~FCALFastSimDedicatedSD() {} - StatusCode initialize() override final; - - virtual G4VSensitiveDetector* makeSD() override final { return (G4VSensitiveDetector*)NULL; }; - // ProcessHitsMethod virtual void ProcessSpot(const EnergySpot & spot) override final; - // End each event (do hit merger here) - /** End of event collection of hits. Merging is done in this method.*/ - virtual StatusCode EndOfAthenaEvent() override final; - - virtual StatusCode queryInterface(const InterfaceID& riid, void** ppvIf) override; - -protected: - virtual StatusCode retrieveLArHitMerger() final; //!< Method for lazy initialization of LArHitMerger. Temporary solution FIXME - LArVHitMerger *m_hitMerger; //!< Hit merger for the combination of hits within a single detector area - private: FCALDetectorManager * m_fcalManager; diff --git a/LArCalorimeter/LArG4/LArG4FastSimulation/src/IFastSimDedicatedSD.h b/LArCalorimeter/LArG4/LArG4FastSimulation/src/IFastSimDedicatedSD.h index 2471fbc91ec..64652804b18 100644 --- a/LArCalorimeter/LArG4/LArG4FastSimulation/src/IFastSimDedicatedSD.h +++ b/LArCalorimeter/LArG4/LArG4FastSimulation/src/IFastSimDedicatedSD.h @@ -6,25 +6,23 @@ #define LARG4FASTSIMULATION_IFASTSIMDEDICATEDSD_H // This is the interface for the fast simulation dedicated sensitive detector. -#include "GaudiKernel/IAlgTool.h" +#include "LArG4Code/LArG4SimpleSD.h" class EnergySpot; +class StoreGateSvc; -class IFastSimDedicatedSD : virtual public IAlgTool { +class IFastSimDedicatedSD : public LArG4SimpleSD { public: + // Simple constructor and destructor + IFastSimDedicatedSD( std::string name , StoreGateSvc * detStore ) : LArG4SimpleSD( name , detStore ) {} + + ~IFastSimDedicatedSD() {} + // ProcessHitsMethod /** Process a single energy spot from a frozen shower. The appropriate region of the sensitive detector is calculated and a LArIdentifier is constructed*/ virtual void ProcessSpot(const EnergySpot & spot) = 0; - // End each event (do hit merger here) - /** End of event collection of hits. Merging is done in this method.*/ - virtual StatusCode EndOfAthenaEvent() = 0; - - static const InterfaceID& interfaceID() { - static const InterfaceID IID_IFastSimDedicatedSD( "IFastSimDedicatedSD" , 1 , 0 ) ; - return IID_IFastSimDedicatedSD; - } }; #endif //LARG4FASTSIMULATION_IFASTSIMDEDICATEDSD_H diff --git a/LArCalorimeter/LArG4/LArG4FastSimulation/src/LArFastShowerTool.cxx b/LArCalorimeter/LArG4/LArG4FastSimulation/src/LArFastShowerTool.cxx index 36baa8fc1f3..9f91b326887 100644 --- a/LArCalorimeter/LArG4/LArG4FastSimulation/src/LArFastShowerTool.cxx +++ b/LArCalorimeter/LArG4/LArG4FastSimulation/src/LArFastShowerTool.cxx @@ -3,8 +3,11 @@ */ #include "LArFastShowerTool.h" - +#include "BarrelFastSimDedicatedSD.h" +#include "EndcapFastSimDedicatedSD.h" +#include "FCALFastSimDedicatedSD.h" #include "LArFastShower.h" +#include "G4SDManager.hh" LArFastShowerTool::LArFastShowerTool(const std::string& type, const std::string& name, const IInterface *parent): FastSimulationBase(type,name,parent), @@ -43,7 +46,7 @@ LArFastShowerTool::LArFastShowerTool(const std::string& type, const std::string& declareProperty("SensitiveDetector" , m_FastSimDedicatedSD , "Fast sim dedicated SD for this setup"); declareProperty("ShowerLibSvc" , m_showerLibSvc, "Handle on the shower library service"); m_configuration.m_showerLibSvcName=m_showerLibSvc.name(); - if(!m_FastSimDedicatedSD.empty()) {m_configuration.m_SensitiveDetectorName=m_FastSimDedicatedSD.name();} + declareInterface<IFastSimulation>(this); } @@ -51,20 +54,33 @@ StatusCode LArFastShowerTool::initialize() { ATH_MSG_VERBOSE( name() << "::initialize()"); CHECK( m_showerLibSvc.retrieve() ); - CHECK( m_FastSimDedicatedSD.retrieve() ); return FastSimulationBase::initialize(); } G4VFastSimulationModel* LArFastShowerTool::makeFastSimModel() { ATH_MSG_DEBUG( "Initializing Fast Sim Model" ); + IFastSimDedicatedSD * fastSD = dynamic_cast<IFastSimDedicatedSD*>(G4SDManager::GetSDMpointer()->FindSensitiveDetector(m_FastSimDedicatedSD,false)); + if (fastSD){ + ATH_MSG_INFO( "SD " << m_FastSimDedicatedSD << " already created." ); + } else if ("BarrelFastSimDedicatedSD"==m_FastSimDedicatedSD){ + fastSD = new BarrelFastSimDedicatedSD( &*detStore() ); + } else if ("EndcapFastSimDedicatedSD"==m_FastSimDedicatedSD){ + fastSD = new EndcapFastSimDedicatedSD( &*detStore() ); + } else if ("FCALFastSimDedicatedSD"==m_FastSimDedicatedSD){ + fastSD = new FCALFastSimDedicatedSD( &*detStore() ); + } else { + ATH_MSG_FATAL( "Fast sim SD type " << m_FastSimDedicatedSD << " not found!" ); + throw std::runtime_error("Bad SD name"); + } + G4SDManager::GetSDMpointer()->AddNewDetector(fastSD); // Create a fresh Fast Sim Model - return new LArFastShower(name(),m_configuration, &(*m_FastSimDedicatedSD)); + return new LArFastShower(name(),m_configuration, fastSD); } StatusCode LArFastShowerTool::EndOfAthenaEvent() { - CHECK(m_FastSimDedicatedSD->EndOfAthenaEvent()); + // SD is taken care of by the SD tools return StatusCode::SUCCESS; } diff --git a/LArCalorimeter/LArG4/LArG4FastSimulation/src/LArFastShowerTool.h b/LArCalorimeter/LArG4/LArG4FastSimulation/src/LArFastShowerTool.h index 12c5b4f48be..bbc2c4a5652 100644 --- a/LArCalorimeter/LArG4/LArG4FastSimulation/src/LArFastShowerTool.h +++ b/LArCalorimeter/LArG4/LArG4FastSimulation/src/LArFastShowerTool.h @@ -10,9 +10,7 @@ // Member variable headers #include "GaudiKernel/ServiceHandle.h" -#include "GaudiKernel/ToolHandle.h" #include "LArG4ShowerLibSvc/ILArG4ShowerLibSvc.h" -#include "IFastSimDedicatedSD.h" #include "FastShowerConfigStruct.h" // STL headers @@ -39,7 +37,7 @@ protected: virtual G4VFastSimulationModel* makeFastSimModel() override final; private: - ToolHandle<IFastSimDedicatedSD> m_FastSimDedicatedSD; //!< Shower library sensitive detector for this shower + std::string m_FastSimDedicatedSD; //!< Shower library sensitive detector for this shower ServiceHandle<ILArG4ShowerLibSvc> m_showerLibSvc; //!< Pointer to the shower library service FastShowerConfigStruct m_configuration; }; diff --git a/LArCalorimeter/LArG4/LArG4FastSimulation/src/components/LArG4FastSimulation_entries.cxx b/LArCalorimeter/LArG4/LArG4FastSimulation/src/components/LArG4FastSimulation_entries.cxx index a9451121cc0..69189307ac8 100644 --- a/LArCalorimeter/LArG4/LArG4FastSimulation/src/components/LArG4FastSimulation_entries.cxx +++ b/LArCalorimeter/LArG4/LArG4FastSimulation/src/components/LArG4FastSimulation_entries.cxx @@ -1,21 +1,12 @@ #include "GaudiKernel/DeclareFactoryEntries.h" -#include "../BarrelFastSimDedicatedSD.h" // #include "../DeadMaterialShower.h" -#include "../EndcapFastSimDedicatedSD.h" -#include "../FCALFastSimDedicatedSD.h" #include "../LArFastShowerTool.h" -DECLARE_TOOL_FACTORY( BarrelFastSimDedicatedSD ) // DECLARE_TOOL_FACTORY( DeadMaterialShower ) -DECLARE_TOOL_FACTORY( EndcapFastSimDedicatedSD ) -DECLARE_TOOL_FACTORY( FCALFastSimDedicatedSD ) DECLARE_TOOL_FACTORY( LArFastShowerTool ) DECLARE_FACTORY_ENTRIES( LArG4FastSimulation ) { - DECLARE_TOOL( BarrelFastSimDedicatedSD ) // DECLARE_TOOL( DeadMaterialShower ) - DECLARE_TOOL( EndcapFastSimDedicatedSD ) - DECLARE_TOOL( FCALFastSimDedicatedSD ) DECLARE_TOOL( LArFastShowerTool ) } -- GitLab