From 1f38ad30e8202b0a04f4293cb987ab23decbd49b Mon Sep 17 00:00:00 2001 From: Daniel Louis Noel <daniel.louis.noel@cern.ch> Date: Thu, 25 Jul 2019 16:50:24 +0000 Subject: [PATCH] Rewriting the GeoIDSvc to new config --- .../python/SubDetectorEnvelopesConfig.py | 2 + .../python/SubDetectorEnvelopesConfigNew.py | 170 ++++++++++++++++++ .../G4AtlasAlg/python/G4AtlasAlgConfigNew.py | 6 +- .../python/ISF_ServicesConfigNew.py | 23 ++- .../test/ISF_ServicesConfigNew_test.py | 3 +- 5 files changed, 193 insertions(+), 11 deletions(-) create mode 100644 AtlasGeometryCommon/SubDetectorEnvelopes/python/SubDetectorEnvelopesConfigNew.py diff --git a/AtlasGeometryCommon/SubDetectorEnvelopes/python/SubDetectorEnvelopesConfig.py b/AtlasGeometryCommon/SubDetectorEnvelopes/python/SubDetectorEnvelopesConfig.py index d1b0ae658d6..1ef5aae53aa 100644 --- a/AtlasGeometryCommon/SubDetectorEnvelopes/python/SubDetectorEnvelopesConfig.py +++ b/AtlasGeometryCommon/SubDetectorEnvelopes/python/SubDetectorEnvelopesConfig.py @@ -167,6 +167,8 @@ class Volume: # For new configuration - doesn't have access to DetFlags as of writing, so all HGTD stuff is missing. # Just copied from above. + +#New configuration in SubDetectorEnvelopesConfigNew.py def EnvelopeDefSvc(flags, **kwargs): kwargs.setdefault("DBInDetNode" , 'InDetEnvelope' ) kwargs.setdefault("DBBeamPipeNode" , 'BeamPipeEnvelope' ) diff --git a/AtlasGeometryCommon/SubDetectorEnvelopes/python/SubDetectorEnvelopesConfigNew.py b/AtlasGeometryCommon/SubDetectorEnvelopes/python/SubDetectorEnvelopesConfigNew.py new file mode 100644 index 00000000000..2d035a98176 --- /dev/null +++ b/AtlasGeometryCommon/SubDetectorEnvelopes/python/SubDetectorEnvelopesConfigNew.py @@ -0,0 +1,170 @@ +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + +""" +SubDetectorEnvelopes configurations for AtlasGeometryCommon +Elmar Ritsch, 27/09/2013 +""" + +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator + +from SubDetectorEnvelopes.SubDetectorEnvelopesConf import DetDescrDBEnvelopeSvc + +def EnvelopeDefSvcCfg(ConfigFlags, name="AtlasGeometry_EnvelopeDefSvc", **kwargs): + result = ComponentAccumulator() + + kwargs.setdefault("DBInDetNode" , 'InDetEnvelope' ) + kwargs.setdefault("DBBeamPipeNode" , 'BeamPipeEnvelope' ) + kwargs.setdefault("DBCaloNode" , 'CaloEnvelope' ) + kwargs.setdefault("DBMSNode" , 'MuonEnvelope' ) + kwargs.setdefault("DBCavernNode" , 'CavernEnvelope' ) + + # allow for python-based envelope definitions (see below) + # -> TODO: set this to False once the envelope definitions are tagged in the DDDB + kwargs.setdefault("EnableFallback" , True ) + + # setup fallback BeamPipeEnvelope + BeamPipe = Volume() + BeamPipe.addRZ( 34.3, 3475.0 ) + + if ConfigFlags.Detector.SimulateHGTD: + BeamPipe.addRZ( 47.0, 3475.0 ) + BeamPipe.addRZ( 47.0, 3535.0 ) + BeamPipe.addRZ( 120.0, 3535.0 ) + else: + BeamPipe.addRZ( 120.0, 3475.0 ) + BeamPipe.addRZ( 120.0, 4185.0 ) + BeamPipe.addRZ( 41.0, 4185.0 ) + BeamPipe.addRZ( 41.0, 6783.0 ) + BeamPipe.addRZ( 70.0, 6783.0 ) + BeamPipe.addRZ( 70.0, 12900.0 ) + BeamPipe.addRZ( 279.0, 12900.0 ) + BeamPipe.addRZ( 279.0, 18650.0 ) + BeamPipe.addRZ( 436.0, 18650.0 ) + BeamPipe.addRZ( 436.0, 22030.0 ) + BeamPipe.addRZ( 1050.0, 22030.0 ) + BeamPipe.addRZ( 1050.0, 26046.0 ) + BeamPipe.addRZ( 0.0, 26046.0 ) + + kwargs.setdefault("FallbackBeamPipeR" , BeamPipe.getRs() ) + kwargs.setdefault("FallbackBeamPipeZ" , BeamPipe.getZs() ) + + + # setup fallback IDEnvelope + InDet = Volume() + InDet.addRZ( 1148., 3475. ) + InDet.addRZ( 34.3, 3475. ) + kwargs.setdefault("FallbackInDetR" , InDet.getRs() ) + kwargs.setdefault("FallbackInDetZ" , InDet.getZs() ) + + + # setup fallback CaloEnvelope + Calo = Volume() + Calo.addRZ( 1148.0, 3475.0 ) + + if ConfigFlags.Detector.SimulateHGTD: + Calo.addRZ( 47.0, 3475.0 ) + Calo.addRZ( 47.0, 3535.0 ) + Calo.addRZ( 120.0, 3535.0 ) + else: + Calo.addRZ( 120.0, 3475.0 ) + Calo.addRZ( 120.0, 4185.0 ) + Calo.addRZ( 41.0, 4185.0 ) + Calo.addRZ( 41.0, 6783.0 ) + Calo.addRZ( 420.0, 6783.0 ) + Calo.addRZ( 420.0, 6736.0 ) + Calo.addRZ( 3800.0, 6736.0 ) + Calo.addRZ( 3800.0, 6550.0 ) + Calo.addRZ( 4255.0, 6550.0 ) + + kwargs.setdefault("FallbackCaloR" , Calo.getRs() ) + kwargs.setdefault("FallbackCaloZ" , Calo.getZs() ) + + + # setup fallback MuonEnvelope + Muon = Volume() + Muon.addRZ( 4255.0 , 4000.0 ) + Muon.addRZ( 4255.0 , 6550.0 ) + Muon.addRZ( 3800.0 , 6550.0 ) + Muon.addRZ( 3800.0 , 6736.0 ) + Muon.addRZ( 420.0 , 6736.0 ) + Muon.addRZ( 420.0 , 6783.0 ) + Muon.addRZ( 70.0 , 6783.0 ) + Muon.addRZ( 70.0 , 12900.0 ) + Muon.addRZ( 279.0 , 12900.0 ) + Muon.addRZ( 279.0 , 18650.0 ) + Muon.addRZ( 436.7 , 18650.0 ) + Muon.addRZ( 436.7 , 22030.0 ) + Muon.addRZ( 1050.0 , 22030.0 ) + Muon.addRZ( 1050.0 , 26046.0 ) + Muon.addRZ( 1500.0 , 26046.0 ) + Muon.addRZ( 1500.0 , 23001.0 ) + Muon.addRZ( 2750.0 , 23001.0 ) + Muon.addRZ( 2750.0 , 22030.0 ) + Muon.addRZ( 12650.0 , 22030.0 ) + Muon.addRZ( 12650.0 , 18650.0 ) + Muon.addRZ( 13400.0 , 18650.0 ) + Muon.addRZ( 13400.0 , 12900.0 ) + Muon.addRZ( 14200.0 , 12900.0 ) + Muon.addRZ( 14200.0 , 4000.0 ) + Muon.addRZ( 13000.0 , 4000.0 ) + kwargs.setdefault("FallbackMuonR" , Muon.getRs() ) + kwargs.setdefault("FallbackMuonZ" , Muon.getZs() ) + + + # setup fallback CavernEnvelope + Cavern = Volume() + Cavern.addRZ( 13000.0 , 4000.0 ) + Cavern.addRZ( 14200.0 , 4000.0 ) + Cavern.addRZ( 14200.0 , 12900.0 ) # boundary with MS + Cavern.addRZ( 13400.0 , 12900.0 ) # boundary with MS + Cavern.addRZ( 13400.0 , 18650.0 ) # boundary with MS + Cavern.addRZ( 12650.0 , 18650.0 ) # boundary with MS + Cavern.addRZ( 12650.0 , 22030.0 ) # boundary with MS + Cavern.addRZ( 2750.0 , 22030.0 ) # boundary with MS + Cavern.addRZ( 2750.0 , 23001.0 ) # boundary with MS + Cavern.addRZ( 1500.0 , 23001.0 ) # boundary with MS + Cavern.addRZ( 1500.0 , 26046.0 ) # boundary with MS + Cavern.addRZ( 0.0 , 26046.0 ) # + + # the outer dimesions differ between collision and cosmics jobs + if ConfigFlags.Beam.Type != 'cosmics': + # -> for collision jobs the 'cavern' envelope is much smaller + Cavern.addRZ( 0.0 , 500000.0 ) # z= +500m + Cavern.addRZ( 500000.0 , 500000.0 ) # r= 500m + else: + # -> for cosmics simulation the 'cavern' envelope spans much further + kwargs.setdefault("DBCavernNode" , 'CavernEnvelopeNONE' ) + kwargs.setdefault("EnableFallback" , True ) + Cavern.addRZ( 0.0 , 3000000.0 ) # z= +3km + Cavern.addRZ( 3000000.0 , 3000000.0 ) # r= 3km + kwargs.setdefault("FallbackCavernR" , Cavern.getRs() ) + kwargs.setdefault("FallbackCavernZ" , Cavern.getZs() ) + + #set the GeoModelSvc + from AtlasGeoModel.GeoModelConfig import GeoModelCfg + acc = GeoModelCfg(ConfigFlags) + kwargs.setdefault("GeoModelSvc", acc.getService("GeoModelSvc")) + result.merge(acc) + + result.addService(DetDescrDBEnvelopeSvc(name, **kwargs)) + return result + + +# class used for more readable definitions of envelope volumes +# -> create new volume boundary definitions +# -> return the coordinate vectors in R and Z and VolumeID +class Volume: + # initialize empy + def __init__(self): + self.r = [ ] + self.z = [ ] + + def addRZ(self, r, z): + self.r += [ r ] + self.z += [ z ] + + def getRs(self): + return self.r + + def getZs(self): + return self.z \ No newline at end of file diff --git a/Simulation/G4Atlas/G4AtlasAlg/python/G4AtlasAlgConfigNew.py b/Simulation/G4Atlas/G4AtlasAlg/python/G4AtlasAlgConfigNew.py index ae353281317..61539f6f23d 100644 --- a/Simulation/G4Atlas/G4AtlasAlg/python/G4AtlasAlgConfigNew.py +++ b/Simulation/G4Atlas/G4AtlasAlg/python/G4AtlasAlgConfigNew.py @@ -2,7 +2,7 @@ from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator #from AthenaCommon import CfgMgr from G4AtlasServices.G4AtlasServicesConfigNew import DetectorGeometrySvcCfg -from ISF_Services.ISF_ServicesConfigNew import MC15aPlusTruthServiceCfg +from ISF_Services.ISF_ServicesConfigNew import MC15aPlusTruthServiceCfg, GeoIDSvcCfg #todo - think about the flow, do we need if statements?! @@ -91,7 +91,9 @@ def G4AtlasAlgCfg(ConfigFlags, name='G4AtlasAlg', **kwargs): kwargs.setdefault('TruthRecordService', result.getService("ISF_MC15aPlusTruthService")) #kwargs.setdefault('TruthRecordService', ConfigFlags.Sim.TruthStrategy) # TODO need to have manual override (simFlags.TruthStrategy.TruthServiceName()) - kwargs.setdefault('GeoIDSvc', 'ISF_GeoIDSvc') + accGeoID = GeoIDSvcCfg(ConfigFlags) + result.merge(accGeoID) + kwargs.setdefault('GeoIDSvc', result.getService('ISF_GeoIDSvc')) ## G4AtlasAlg verbosities (available domains = Navigator, Propagator, Tracking, Stepping, Stacking, Event) ## Set stepper verbose = 1 if the Athena logging level is <= DEBUG diff --git a/Simulation/ISF/ISF_Core/ISF_Services/python/ISF_ServicesConfigNew.py b/Simulation/ISF/ISF_Core/ISF_Services/python/ISF_ServicesConfigNew.py index 82397c903af..9f63e6bcb6c 100644 --- a/Simulation/ISF/ISF_Core/ISF_Services/python/ISF_ServicesConfigNew.py +++ b/Simulation/ISF/ISF_Core/ISF_Services/python/ISF_ServicesConfigNew.py @@ -9,11 +9,13 @@ from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator from BarcodeServices.BarcodeServicesConfigNew import MC15aPlusBarcodeSvcCfg from ISF_HepMC_Tools.ISF_HepMC_ToolsConfigNew import TruthStrategyGroupID_MC15Cfg, TruthStrategyGroupCaloMuBremCfg, TruthStrategyGroupCaloDecay_MC15Cfg, TruthStrategyGroupIDHadInt_MC15Cfg +from SubDetectorEnvelopes.SubDetectorEnvelopesConfigNew import EnvelopeDefSvcCfg -from ISF_Services.ISF_ServicesConf import ISF__TruthSvc + +from ISF_Services.ISF_ServicesConf import ISF__TruthSvc, ISF__GeoIDSvc, ISF__ISFEnvelopeDefSvc #Functions yet to be migrated: -#getParticleBrokerSvcNoOrdering, getParticleBrokerSvc, getAFIIParticleBrokerSvc, getISFEnvelopeDefSvc, getAFIIEnvelopeDefSvc, getGeoIDSvc, getAFIIGeoIDSvc +#getParticleBrokerSvcNoOrdering, getParticleBrokerSvc, getAFIIParticleBrokerSvc, getAFIIEnvelopeDefSvc, getAFIIGeoIDSvc #getGenParticleFilters, getInputConverter, getLongLivedInputConverter, getValidationTruthService, getMC12BeamPipeTruthStrategies, getMC12IDTruthStrategies #getMC12CaloTruthStrategies, getMC12MSTruthStrategies, getMC12TruthService, getTruthService, getMC12LLPTruthService, getMC12PlusTruthService, getMC15IDTruthStrategies #getMC15CaloTruthStrategies @@ -42,10 +44,13 @@ def getAFIIParticleBrokerSvc(name="ISF_AFIIParticleBrokerSvc", **kwargs): return getParticleBrokerSvc(name, **kwargs) -def getISFEnvelopeDefSvc(name="ISF_ISFEnvelopeDefSvc", **kwargs): +def ISFEnvelopeDefSvcCfg(ConfigFlags, name="ISF_ISFEnvelopeDefSvc", **kwargs): + result = EnvelopeDefSvcCfg(ConfigFlags) # ATLAS common envlope definitions - kwargs.setdefault("ATLASEnvelopeDefSvc", "AtlasGeometry_EnvelopeDefSvc") - return CfgMgr.ISF__ISFEnvelopeDefSvc(name, **kwargs) + kwargs.setdefault("ATLASEnvelopeDefSvc", result.getService("AtlasGeometry_EnvelopeDefSvc")) + + result.addService(ISF__ISFEnvelopeDefSvc(name, **kwargs)) + return result def getAFIIEnvelopeDefSvc(name="ISF_AFIIEnvelopeDefSvc", **kwargs): @@ -56,10 +61,12 @@ def getAFIIEnvelopeDefSvc(name="ISF_AFIIEnvelopeDefSvc", **kwargs): return CfgMgr.ISF__AFIIEnvelopeDefSvc(name, **kwargs) -def getGeoIDSvc(name="ISF_GeoIDSvc", **kwargs): +def GeoIDSvcCfg(ConfigFlags, name="ISF_GeoIDSvc", **kwargs): + result = ISFEnvelopeDefSvcCfg(ConfigFlags) # with ISF volume definitions - kwargs.setdefault("EnvelopeDefSvc", "ISF_ISFEnvelopeDefSvc") - return CfgMgr.ISF__GeoIDSvc(name, **kwargs) + kwargs.setdefault("EnvelopeDefSvc", result.getService("ISF_ISFEnvelopeDefSvc")) + result.addService(ISF__GeoIDSvc(name, **kwargs)) + return result def getAFIIGeoIDSvc(name="ISF_AFIIGeoIDSvc", **kwargs): diff --git a/Simulation/ISF/ISF_Core/ISF_Services/test/ISF_ServicesConfigNew_test.py b/Simulation/ISF/ISF_Core/ISF_Services/test/ISF_ServicesConfigNew_test.py index 1efd162270a..056406fa007 100755 --- a/Simulation/ISF/ISF_Core/ISF_Services/test/ISF_ServicesConfigNew_test.py +++ b/Simulation/ISF/ISF_Core/ISF_Services/test/ISF_ServicesConfigNew_test.py @@ -28,13 +28,14 @@ if __name__ == '__main__': # Finalize ConfigFlags.lock() - from ISF_Services.ISF_ServicesConfigNew import MC15aPlusTruthServiceCfg + from ISF_Services.ISF_ServicesConfigNew import MC15aPlusTruthServiceCfg, GeoIDSvcCfg ## Initialize a new component accumulator cfg = MainServicesSerialCfg() #add the algorithm cfg.merge(MC15aPlusTruthServiceCfg(ConfigFlags)) + cfg.merge(GeoIDSvcCfg(ConfigFlags)) # Dump config cfg.printConfig(withDetails=True, summariseProps = True) -- GitLab