From ae93508fdc0dd1552e950ffa5190f8bcb62c51a1 Mon Sep 17 00:00:00 2001 From: Zachary Louis Marshall <zach.marshall@cern.ch> Date: Thu, 30 Oct 2014 15:09:32 +0100 Subject: [PATCH] Warning prior to removing VertexTimeOffset (G4AtlasApps-00-07-86) * Tagging: G4AtlasApps-00-07-86 * Warning prior to removing VertexTimeOffset 2014-10-21 Zach Marshall <ZLMarshall@lbl.gov> * Tagging: G4AtlasApps-00-07-85 * Protection for forward sim jobs running single particles. Fixes ATLASSIM-1646 2014-10-16 John Chapman <John.Chapman@cern.ch> * Tagging: G4AtlasApps-00-07-84 * python/PyG4Atlas.py: Adding a line for the pass-through of a truth xAODJet::JetContainer from EVNT to HITS. ATLASSIM-1636. Whitespace clean-up. ... (Long ChangeLog diff - truncated) --- .../G4Atlas/G4AtlasApps/python/PyG4Atlas.py | 32 +- .../G4AtlasApps/python/SimAtlasKernel.py | 13 + .../G4Atlas/G4AtlasApps/python/SimFlags.py | 139 ++------- .../G4AtlasApps/python/atlas_common.py | 68 ++-- .../G4Atlas/G4AtlasApps/python/atlas_flags.py | 58 ++++ .../G4AtlasApps/python/atlas_forward.py | 291 +++++++++++++----- .../G4Atlas/G4AtlasApps/python/callbacks.py | 6 + .../G4AtlasApps/share/jobOptions.G4Atlas.py | 6 +- .../share/jobOptions.G4Atlas_ReadEvgen.py | 6 +- .../G4AtlasApps/share/jobOptions.G4Cosmic.py | 4 +- 10 files changed, 364 insertions(+), 259 deletions(-) diff --git a/Simulation/G4Atlas/G4AtlasApps/python/PyG4Atlas.py b/Simulation/G4Atlas/G4AtlasApps/python/PyG4Atlas.py index 8447b20f892..078d0ef7376 100644 --- a/Simulation/G4Atlas/G4AtlasApps/python/PyG4Atlas.py +++ b/Simulation/G4Atlas/G4AtlasApps/python/PyG4Atlas.py @@ -1866,7 +1866,7 @@ class RecEnvelope: self.Dict_Volumes = dict() self.Dict_Volumes[volume_name] = volume_level self._AllowMods=allowMods - + def _construct(self): if not self._Built: for i in self.Dict_Volumes.keys(): @@ -1874,7 +1874,7 @@ class RecEnvelope: #Temporary protection to avoid branching for MC12 if hasattr(G4AtlasEngine._ctrl.sendetectorMenu, 'setAllowMods'): G4AtlasEngine._ctrl.sendetectorMenu.setAllowMods(self.Name,self._AllowMods) - + G4AtlasEngine.log.debug(' RecEnvelope:'+ '_construct: '+self.Name+' and store at the exit of volume '+i) self._Built = True @@ -2137,13 +2137,15 @@ class SimSkeleton(object): stream1 = AthenaPoolOutputStream("StreamHITS", athenaCommonFlags.PoolHitsOutput()) ## Write geometry tag info - move to main method - #import EventInfoMgt.EventInfoMgtInit + #import EventInfoMgt.EventInfoMgtInit ## EventInfo & TruthEvent always written by default stream1.ForceRead=True stream1.ItemList = ["EventInfo#*", "McEventCollection#TruthEvent", - "JetCollection#*"] + "JetCollection#*", + "xAOD::JetContainer_v1#*", + "xAOD::JetAuxContainer_v1#*"] ## Make stream aware of aborted events stream1.AcceptAlgs = ["G4AtlasAlg"] @@ -2177,7 +2179,7 @@ class SimSkeleton(object): stream1.ItemList += ["LUCID_SimHitCollection#*"] ## FwdRegion - checkFwdRegion = getattr(DetFlags, 'FwdRegion_on', None) #back-compatibility + checkFwdRegion = getattr(DetFlags, 'FwdRegion_on', None) #back-compatibility if checkFwdRegion is not None: #back-compatibility if checkFwdRegion(): stream1.ItemList += ["SimulationHitCollection#*"] @@ -2351,7 +2353,7 @@ class SimSkeleton(object): svcMgr.AthenaPoolCnvSvc.PoolAttributes += ["DEFAULT_BUFFERSIZE = '2048'"] ## Write geometry tag info - import EventInfoMgt.EventInfoMgtInit + import EventInfoMgt.EventInfoMgtInit ## Instantiate StreamHITS if athenaCommonFlags.PoolHitsOutput.statusOn: @@ -2404,7 +2406,7 @@ class SimSkeleton(object): import PyUtils.AthFile as af hitfile = athenaCommonFlags.PoolEvgenInput.get_Value()[0] f = af.fopen(hitfile) - + ## Check that event type is SIMULATION (as it must be) if "evt_type" in f.infos.keys(): evttypes = f.infos["evt_type"] @@ -2456,19 +2458,19 @@ class SimSkeleton(object): ## Save the fast simulation job.G4AtlasAlg.IncludeParentsInG4Event = simFlags.IncludeParentsInG4Event.get_Value() - if hasattr(simFlags, 'KillAbortedEvents') and simFlags.KillAbortedEvents.statusOn: - ## default true - job.G4AtlasAlg.KillAbortedEvents = simFlags.KillAbortedEvents.get_Value() + if hasattr(simFlags, 'KillAbortedEvents') and simFlags.KillAbortedEvents.statusOn: + ## default true + job.G4AtlasAlg.KillAbortedEvents = simFlags.KillAbortedEvents.get_Value() - if hasattr(simFlags, 'FlagAbortedEvents') and simFlags.FlagAbortedEvents.statusOn: - ## default false - job.G4AtlasAlg.FlagAbortedEvents = simFlags.FlagAbortedEvents.get_Value() + if hasattr(simFlags, 'FlagAbortedEvents') and simFlags.FlagAbortedEvents.statusOn: + ## default false + job.G4AtlasAlg.FlagAbortedEvents = simFlags.FlagAbortedEvents.get_Value() if simFlags.FlagAbortedEvents.get_Value() and simFlags.KillAbortedEvents.get_Value(): G4AtlasEngine.log.warning('When G4AtlasAlg.FlagAbortedEvents is True G4AtlasAlg.KillAbortedEvents should be False!!! Setting G4AtlasAlg.KillAbortedEvents = False now!') job.G4AtlasAlg.KillAbortedEvents = False - + if hasattr(simFlags, 'RandomSvc') and simFlags.RandomSvc.statusOn: - ## default true + ## default true job.G4AtlasAlg.AtRndmGenSvc = simFlags.RandomSvc.get_Value() ## G4AtlasAlg verbosities (available domains = Navigator, Propagator, Tracking, Stepping, Stacking, Event) diff --git a/Simulation/G4Atlas/G4AtlasApps/python/SimAtlasKernel.py b/Simulation/G4Atlas/G4AtlasApps/python/SimAtlasKernel.py index 7d1665790f4..16af788d75f 100644 --- a/Simulation/G4Atlas/G4AtlasApps/python/SimAtlasKernel.py +++ b/Simulation/G4Atlas/G4AtlasApps/python/SimAtlasKernel.py @@ -443,6 +443,16 @@ class AtlasSimSkeleton(SimSkeleton): if simFlags.ForwardDetectors.statusOn: from atlas_forward import ForwardRegion atlasForwardRegion = ForwardRegion() + + # Set up Twiss Files + atlasForwardRegion.setupTwissFiles() + + # Set up the field + if simFlags.FwdStepLimitation.statusOn: + atlasForwardRegion.add_field(simFlags.FwdStepLimitation()) + else: + atlasForwardRegion.add_field() + fwdRegionEnvelope = atlasForwardRegion.atlas_ForwardRegion AtlasG4Eng.G4Eng.add_DetFacility(fwdRegionEnvelope, atlas) @@ -846,6 +856,9 @@ class AtlasSimSkeleton(SimSkeleton): exec( 'new_value = beFilter.Get_'+opt+'()' ) AtlasG4Eng.G4Eng.log.info('Set BeamEffectTransformation option '+opt+' to '+str( new_value ) ) + if simFlags.VertexTimeOffset.statusOn and simFlags.VertexTimeOffset.get_Value() != 0: + raise RuntimeError( 'Vertex time offset should not be used!' ) + if hasattr(simFlags, 'RandomSvc') and simFlags.RandomSvc.statusOn: AtlasG4Eng.G4Eng._ctrl.physicsMenu.SetRandomNumberService( simFlags.RandomSvc() ) if simFlags.VertexOverrideFile.statusOn: diff --git a/Simulation/G4Atlas/G4AtlasApps/python/SimFlags.py b/Simulation/G4Atlas/G4AtlasApps/python/SimFlags.py index 6541438f0ec..448fb28ade1 100644 --- a/Simulation/G4Atlas/G4AtlasApps/python/SimFlags.py +++ b/Simulation/G4Atlas/G4AtlasApps/python/SimFlags.py @@ -199,38 +199,12 @@ class PhysicsList(JobProperty): """ statusOn = True allowedTypes = ["str"] - allowedValues = ["ExN01", + allowedValues = ["FTFP_BERT", "QGSP_BERT", - "QGSP_BERT_CHIPS", - "QGSP_FTFP_BERT", "QGSP_BERT_HP", - "QGSP_BERT_TRV", - "QGSP_BERT_EMV", - "QGSP_BERT_EMX", - "QGSP_BERT_NOLEP", - "QGS_BIC", "QGSP_BIC", - "QGSP_BIC_HP", - "QGSP_BIC_EMY", - "QGSC_BERT", - "QGSC_CHIPS", - "FTFP_BERT", - "FTFP_BERT_TRV", - "FTFP_BERT_EMV", - "FTFP_BERT_EMX", - "FTF_BIC", - "QGSP", - "LHEP", - "LHEP_EMV", - "CHIPS", - "QBBC", - "QGSP_BERT_Msc95", - "QGSP_BERT_Conv95", - "QGSP_BERT_Brem95", - "QGSP_BERT_95", - "QGSP_BERT_95NoMsc", ] - StoredValue = "QGSP_BERT" + StoredValue = "FTFP_BERT" def __setattr__(self, name, n_value): """ @@ -257,8 +231,11 @@ class SimLayout(JobProperty): unless you definitely know what you are doing! For more info see: - https://twiki.cern.ch/twiki/bin/view/Atlas/AtlasGeomDBTags + https://twiki.cern.ch/twiki/bin/view/AtlasComputing/AtlasGeomDBTags + https://twiki.cern.ch/twiki/bin/view/AtlasComputing/AtlasGeomDBTagsNew http://atlas.web.cern.ch/Atlas/GROUPS/OPERATIONS/dataBases/DDDB/tag_hierarchy_browser.php + And for more on the "new" naming conventions, see: + [ No note yet... ] The allowed values are as follows: @@ -378,95 +355,20 @@ class SimLayout(JobProperty): statusOn = True allowedTypes = ['str'] - StoredValue = 'ATLAS-GEO-20-00-01' - allowedValues = ['ATLAS-GEO-06-00-00', - 'ATLAS-GEO-06-01-00', - 'ATLAS-GEO-06-02-00', - 'ATLAS-GEO-06-03-00', - 'ATLAS-GEO-06-04-00', - 'ATLAS-GEO-06-05-00', - 'ATLAS-GEO-06-06-00', - 'ATLAS-GEO-06-07-00', - 'ATLAS-GEO-06-08-00', - 'ATLAS-GEO-06-09-00', - 'ATLAS-GEO-06-10-00', - 'ATLAS-GEO-06-11-00', - 'ATLAS-GEO-06-12-00', - 'ATLAS-GEO-06-13-00', - 'ATLAS-GEO-06-14-00', - 'ATLAS-GEO-06-15-00', - 'ATLAS-GEO-06-16-00', - 'ATLAS-GEO-06-17-00', - 'ATLAS-GEO-06-18-00', - 'ATLAS-GEO-06-19-00', - 'ATLAS-GEO-06-20-00', - 'ATLAS-GEO-06-21-00', - 'ATLAS-GEO-06-22-00', - 'ATLAS-GEO-07-00-00', - 'ATLAS-GEONSF-07-00-00', - 'ATLAS-GEONTF-07-00-00', - 'ATLAS-GEONF-07-00-00', - 'ATLAS-GEO-08-00-00', - 'ATLAS-GEO-08-00-01', - 'ATLAS-GEO-08-00-02', - 'ATLAS-GEONSF-08-00-00', - 'ATLAS-GEONTF-08-00-00', - 'ATLAS-GEONF-08-00-00', - 'ATLAS-GEOHNSF-08-00-02', - 'ATLAS-GEOHF-08-00-02', - 'ATLAS-GEONSF-08-00-02', - 'ATLAS-GEONTF-08-00-02', - 'ATLAS-GEONF-08-00-02', - 'ATLAS-GEO-08-01-00', - 'ATLAS-GEO-08-02-00', - 'ATLAS-GEO-08-03-00', - 'ATLAS-GEO-08-04-00', - 'ATLAS-GEO-08-05-00', - 'ATLAS-GEO-09-00-00', - 'ATLAS-GEO-10-00-00', - 'ATLAS-GEO-10-00-01', - 'ATLAS-GEO-10-00-02', - 'ATLAS-GEONTF-10-00-01', - 'ATLAS-GEO-10-01-00', - 'ATLAS-GEO-10-02-00', - 'ATLAS-GEO-10-03-00', - 'ATLAS-GEO-10-04-00', - 'ATLAS-GEO-10-05-00', - 'ATLAS-GEO-10-06-00', - 'ATLAS-GEO-10-07-00', - 'ATLAS-GEO-10-08-00', - 'ATLAS-GEO-10-09-00', - 'ATLAS-GEO-10-10-00', - 'ATLAS-GEO-10-11-00', - 'ATLAS-GEO-10-12-00', - 'ATLAS-GEO-10-13-00', - 'ATLAS-GEO-11-00-00', - 'ATLAS-GEO-11-00-01', - 'ATLAS-GEO-11-01-00', - 'ATLAS-GEO-11-01-01', - 'ATLAS-GEO-11-02-00', - 'ATLAS-GEO-11-02-01', - 'ATLAS-GEO-11-03-00', - 'ATLAS-GEO-11-03-01', - 'ATLAS-GEO-11-04-00', - 'ATLAS-GEO-11-04-01', - 'ATLAS-GEO-12-00-00', - 'ATLAS-GEO-13-00-00', - 'ATLAS-GEO-13-00-01', - 'ATLAS-GEO-13-01-00', - 'ATLAS-GEO-14-00-01', - 'ATLAS-GEO-14-01-01', - 'ATLAS-GEO-14-02-01', - 'ATLAS-GEO-16-00-00', - 'ATLAS-GEONSF-16-00-00', - 'ATLAS-GEO-16-01-00', - 'ATLAS-GEO-18-01-00', - 'ATLAS-GEO-18-01-03', - 'ATLAS-GEO-20-00-00', - 'ATLAS-GEO-20-00-01', - 'ATLAS-IBL-00-00-00', - 'ATLAS-IBL-01-00-00', - 'ATLAS-SLHC-00-00-00', + StoredValue = 'ATLAS-R2-2015-01-01-00' + allowedValues = [ + 'ATLAS-GEO-16-00-00', # Default for MC10 + 'ATLAS-GEO-18-01-00', # Used in MC11a, MC11b, MC11c + 'ATLAS-GEO-18-01-01', # Used in MC11a, MC11b, MC11c + 'ATLAS-GEO-18-01-03', # Used in MC11a, MC11b, MC11c + 'ATLAS-GEO-20-00-01', # Default for MC12a, MC12b + 'ATLAS-GEO-21-02-02', # Used in MC11d, MC12c + 'ATLAS-IBL-03-00-00', # Used in MC12 Upgrade + 'ATLAS-SLHC-02-00-00', # Used in MC12 Upgrade + 'ATLAS-R1-2010-02-00-00', # Used in MC14a + 'ATLAS-R1-2011-02-00-00', # Used in MC14a + 'ATLAS-R1-2012-02-00-00', # Used in MC14a + 'ATLAS-R2-2015-01-01-00', # Used in MC14a 'ctbh8_combined', 'ctbh8_photon', 'ctbh8_lar-material', @@ -479,7 +381,6 @@ class SimLayout(JobProperty): 'tb_LArH6EC_2002', 'tb_LArH6_2004'] - def __setattr__(self, name, n_value): """ Ensure that _VALIDATION layout tags get through the first level of checking. diff --git a/Simulation/G4Atlas/G4AtlasApps/python/atlas_common.py b/Simulation/G4Atlas/G4AtlasApps/python/atlas_common.py index 935a2ea7311..259fcea9797 100644 --- a/Simulation/G4Atlas/G4AtlasApps/python/atlas_common.py +++ b/Simulation/G4Atlas/G4AtlasApps/python/atlas_common.py @@ -202,14 +202,14 @@ class CaloEnvelope(object): ( 41., 3795., -6735.), ( 41., 3795., -6530.), ( 41., 4251., -6530.), - ( 41., 4251., -4185.), - ( 120., 4251., -4185.), + ( 41., 4251., -4587.), + ( 120., 4251., -4587.), ( 120., 4251., -3475.), (1148., 4251., -3475.), (1148., 4251., 3475.), ( 120., 4251., 3475.), - ( 120., 4251., 4185.), - ( 41., 4251., 4185.), + ( 120., 4251., 4587.), + ( 41., 4251., 4587.), ( 41., 4251., 6530.), ( 41., 3795., 6530.), ( 41., 3795., 6735.), @@ -240,36 +240,36 @@ class MuonEnvelope(object): AtlasG4Eng.G4Eng.log.debug('Creating Muon envelope') self.muonq02 = PyG4Atlas.DetFacility("GenericPCON", "MUONQ02") ri_ro_z_list = [ - (1050., 1500., -26046.), - (1050., 1500., -23001.), - (1050., 2750., -23001.), - (1050., 2750., -22030.), - ( 436., 12650., -22030.), - ( 436., 12650., -18650.), - ( 279., 13400., -18650.), - ( 279., 13400., -12900.), - ( 70., 13910., -12900.), - ( 70., 13910., -6783.), - ( 420., 13910., -6783.), - ( 420., 13910., -6736.), - (3800., 13910., -6736.), - (3800., 13910., -6550.), - (4255., 13000., -6550.), - (4255., 13000., 6550.), - (3800., 13910., 6550.), - (3800., 13910., 6736.), - ( 420., 13910., 6736.), - ( 420., 13910., 6783.), - ( 70., 13910., 6783.), - ( 70., 13910., 12900.), - ( 279., 13400., 12900.), - ( 279., 13400., 18650.), - ( 436., 12650., 18650.), - ( 436., 12650., 22030.), - (1050., 2750., 22030.), - (1050., 2750., 23001.), - (1050., 1500., 23001.), - (1050., 1500., 26046.)] + (1050., 1500., -26046.), + (1050., 1500., -23001.), + (1050., 2750., -23001.), + (1050., 2750., -22030.), + ( 436.7, 12650., -22030.), + ( 436.7, 12650., -18650.), + ( 279., 13400., -18650.), + ( 279., 13400., -12900.), + ( 70., 13910., -12900.), + ( 70., 13910., -6783.), + ( 420., 13910., -6783.), + ( 420., 13910., -6736.), + (3800., 13910., -6736.), + (3800., 13910., -6550.), + (4255., 13000., -6550.), + (4255., 13000., 6550.), + (3800., 13910., 6550.), + (3800., 13910., 6736.), + ( 420., 13910., 6736.), + ( 420., 13910., 6783.), + ( 70., 13910., 6783.), + ( 70., 13910., 12900.), + ( 279., 13400., 12900.), + ( 279., 13400., 18650.), + ( 436.7, 12650., 18650.), + ( 436.7, 12650., 22030.), + (1050., 2750., 22030.), + (1050., 2750., 23001.), + (1050., 1500., 23001.), + (1050., 1500., 26046.)] self.muonq02.df.SetPhiMin(math.radians(0)) self.muonq02.df.SetDeltaPhi(math.radians(360)) diff --git a/Simulation/G4Atlas/G4AtlasApps/python/atlas_flags.py b/Simulation/G4Atlas/G4AtlasApps/python/atlas_flags.py index ac450676270..405bf1b9cb1 100644 --- a/Simulation/G4Atlas/G4AtlasApps/python/atlas_flags.py +++ b/Simulation/G4Atlas/G4AtlasApps/python/atlas_flags.py @@ -363,3 +363,61 @@ class BeamEffectOptions(JobProperty): allowedTypes = ['dict'] StoredValue = {} +class FwdStepLimitation(JobProperty): + """ + Forward step limitation option + """ + statusOn = False + allowedTypes = ['float'] + StoredValue = 1000. + +class TwissFileBeam1(JobProperty): + """ + Twiss file full path for beam 1 + """ + statusOn = False + allowedTypes = ['str'] + StoredValue = None + +class TwissFileBeam2(JobProperty): + """ + Twiss file full path for beam 2 + """ + statusOn = False + allowedTypes = ['str'] + StoredValue = None + +class TwissEnergy(JobProperty): + """ + Twiss file center of mass energy, in ATLAS units. + Use 'None' for autoconfiguration based on input file. + """ + statusOn = False + allowedTypes = ['float'] + StoredValue = 8000000. + +class TwissFileBeta(JobProperty): + """ + Twiss file beta, in ATLAS units + """ + statusOn = True + allowedTypes = ['float'] + StoredValue = 550. + +class TwissFileNomReal(JobProperty): + """ + Twiss file: nominal or real optics? + """ + statusOn = False + allowedTypes = ['str'] + allowedValues = ['nominal','real'] + StoredValue = None + +class TwissFileVersion(JobProperty): + """ + Twiss file version string + """ + statusOn = True + allowedTypes = ['str'] + StoredValue = 'v01' + diff --git a/Simulation/G4Atlas/G4AtlasApps/python/atlas_forward.py b/Simulation/G4Atlas/G4AtlasApps/python/atlas_forward.py index b060acb0978..5dec39db322 100644 --- a/Simulation/G4Atlas/G4AtlasApps/python/atlas_forward.py +++ b/Simulation/G4Atlas/G4AtlasApps/python/atlas_forward.py @@ -8,114 +8,239 @@ __author__ = 'A. Dell`Acqua' import PyG4Atlas, AtlasG4Eng from PyG4Atlas import DetConfigurator -from SimFlags import SimFlags +from SimFlags import simFlags class ForwardRegion(object): - """Describes the whole forward region (outside the ATLAS boundaries)""" + """Describes the whole forward region (outside the ATLAS boundaries)""" + + def __init__(self): + """Describes the geometry.""" + self.atlas_ForwardRegion = PyG4Atlas.DetFacility("GeoDetector", "ForDetEnvelope:ForDetEnvelope") + + # Custom magnetic field + def add_field( self , step_limitation = None ): + from G4AtlasApps import AtlasG4Eng + + AtlasG4Eng.G4Eng._ctrl.load('ForwardRegionMgField') + + fieldVolumes = [] + fieldVolumes += ['Q1', 'FwdRegion::LQXAA.1R1MagQ1'] + fieldVolumes += ['Q2', 'FwdRegion::LQXBA.2R1MagQ2a'] + fieldVolumes += ['Q2', 'FwdRegion::LQXBA.2R1MagQ2b'] + fieldVolumes += ['Q3', 'FwdRegion::LQXAG.3R1MagQ3'] + fieldVolumes += ['D1', 'FwdRegion::MBXW.A4R1MagD1a'] + fieldVolumes += ['D1', 'FwdRegion::MBXW.B4R1MagD1b'] + fieldVolumes += ['D1', 'FwdRegion::MBXW.C4R1MagD1c'] + fieldVolumes += ['D1', 'FwdRegion::MBXW.D4R1MagD1d'] + fieldVolumes += ['D1', 'FwdRegion::MBXW.E4R1MagD1e'] + fieldVolumes += ['D1', 'FwdRegion::MBXW.F4R1MagD1f'] + fieldVolumes += ['D2', 'FwdRegion::LBRCD.4R1MagD2'] + fieldVolumes += ['Q4', 'FwdRegion::LQYCH.4R1MagQ4'] + fieldVolumes += ['Q5', 'FwdRegion::LQNDC.5R1MagQ5'] + fieldVolumes += ['Q6', 'FwdRegion::LQNDD.6R1MagQ6'] + fieldVolumes += ['Q7', 'FwdRegion::LQNFD.7R1MagQ7a'] + fieldVolumes += ['Q7', 'FwdRegion::LQNFD.7R1MagQ7b'] + fieldVolumes += ['Q1HKick', 'FwdRegion::LQXAA.1R1MagQ1HKick'] + fieldVolumes += ['Q1VKick', 'FwdRegion::LQXAA.1R1MagQ1VKick'] + fieldVolumes += ['Q2HKick', 'FwdRegion::LQXBA.2R1MagQ2HKick'] + fieldVolumes += ['Q2VKick', 'FwdRegion::LQXBA.2R1MagQ2VKick'] + fieldVolumes += ['Q3HKick', 'FwdRegion::LQXAG.3R1MagQ3HKick'] + fieldVolumes += ['Q3VKick', 'FwdRegion::LQXAG.3R1MagQ3VKick'] + fieldVolumes += ['Q4VKickA', 'FwdRegion::LQYCH.4R1MagQ4VKickA'] + fieldVolumes += ['Q4HKick', 'FwdRegion::LQYCH.4R1MagQ4HKick'] + fieldVolumes += ['Q4VKickB', 'FwdRegion::LQYCH.4R1MagQ4VKickB'] + fieldVolumes += ['Q5HKick', 'FwdRegion::LQNDC.5R1MagQ5HKick'] + fieldVolumes += ['Q6VKick', 'FwdRegion::LQNDD.6R1MagQ6VKick'] + + epsMin = 1e-9 + epsMax = 1e-8 + deltaIntersection = 1e-9 + deltaOneStep = 1e-8 + + for i in range(len(fieldVolumes)/2): + AtlasG4Eng.G4Eng._ctrl.fldMenu.assign(fieldVolumes[2*i], '*', fieldVolumes[2*i+1]) # assign fields to volumes + + # demand higher precision + AtlasG4Eng.G4Eng._ctrl.fldMenu.setMinimumEpsilonStep(fieldVolumes[2*i+1],epsMin) + AtlasG4Eng.G4Eng._ctrl.fldMenu.setMaximumEpsilonStep(fieldVolumes[2*i+1],epsMax) + AtlasG4Eng.G4Eng._ctrl.fldMenu.setDeltaIntersection(fieldVolumes[2*i+1],deltaIntersection) + AtlasG4Eng.G4Eng._ctrl.fldMenu.setDeltaOneStep(fieldVolumes[2*i+1],deltaOneStep) + + # limit step length + if step_limitation is not None: + AtlasG4Eng.G4Eng._ctrl.geometryMenu.SetMaxStep(fieldVolumes[2*i+1], step_limitation) + if step_limitation is not None: + AtlasG4Eng.G4Eng._ctrl.geometryMenu.SetMaxStep('FwdRegion::ForwardRegionGeoModel', step_limitation) + + def setupTwissFiles(self): + # Settings of optics to be used + import os + twiss_path = os.getenv('TwissFilesPATH') + twiss_beam1 = None + twiss_beam2 = None + twiss_momentum = -1. + + if simFlags.TwissFileBeam1.statusOn: + if os.access(simFlags.TwissFileBeam1(),os.R_OK): twiss_beam1 = simFlags.TwissFileBeam1() + elif os.access(twiss_path+simFlags.TwissFileBeam1(),os.R_OK): twiss_beam1 = twiss_path+simFlags.TwissFileBeam1() + if simFlags.TwissFileBeam2.statusOn: + if os.access(simFlags.TwissFileBeam2(),os.R_OK): twiss_beam2 = simFlags.TwissFileBeam2() + elif os.access(twiss_path+simFlags.TwissFileBeam2(),os.R_OK): twiss_beam2 = twiss_path+simFlags.TwissFileBeam2() + if twiss_beam1 is None or twiss_beam2 is None: + twiss_energy = '7.0TeV' + if simFlags.TwissEnergy.statusOn: + twiss_energy = twiss_energy = '%1.1fTeV'%(simFlags.TwissEnergy()*0.000001) + else: + from AthenaCommon.AthenaCommonFlags import athenaCommonFlags + if athenaCommonFlags.PoolEvgenInput.statusOn and len(athenaCommonFlags.PoolEvgenInput.get_Value())>0: + inputfile = athenaCommonFlags.PoolEvgenInput.get_Value()[0] + import PyUtils.AthFile as af + try: + f = af.fopen(inputfile) + if 'beam_energy' in f.infos and 'N/A' not in f.infos['beam_energy']: + if type(f.infos['beam_energy']) is list and float(f.infos['beam_energy'][0])>100.: + twiss_energy = '%1.1fTeV'%(float(f.infos['beam_energy'])*0.000001) + elif float(f.infos['beam_energy'])>100.: + twiss_energy = '%1.1fTeV'%(float(f.infos['beam_energy'])*0.000001) + except AssertionError: + AtlasG4Eng.G4Eng.log.error("Failed to open input file: %s", inputfile) + pass + twiss_beta = '%07.2fm'%(0.001*simFlags.TwissFileBeta()) + if not (simFlags.TwissFileNomReal.statusOn and simFlags.TwissFileVersion.statusOn): + AtlasG4Eng.G4Eng.log.error('Need to either provide file names or set file name and file version flags') + raise Exception('Not enough information to locate Twiss files') + twiss_nomreal = simFlags.TwissFileNomReal() + twiss_version = simFlags.TwissFileVersion() + + # Getting paths to the twiss files, momentum calculation; you can switch to local files + import re + import math + twiss_beam1 = os.path.join(twiss_path, twiss_energy, twiss_beta, twiss_nomreal, twiss_version, 'beam1.tfs') + twiss_beam2 = os.path.join(twiss_path, twiss_energy, twiss_beta, twiss_nomreal, twiss_version, 'beam2.tfs') + twiss_momentum = math.sqrt(float(re.findall("\d+.\d+", twiss_energy)[0])**2 - (0.938e-3)**2)*1e3 + else: + # Have to sort out twiss momentum based on file name + tmp = twiss_beam1.split('TeV')[0] + tmp_spot = len(tmp) + while True: + try: + tmp_energy = float( tmp[tmp_spot:] ) + tmp_spot -= 1 + except ValueError: + twiss_energy = float( tmp[tmp_spot+1:] ) + break + pass + twiss_momentum = math.sqrt(float(re.findall("\d+.\d+", twiss_energy)[0])**2 - (0.938e-3)**2)*1e3 + + # properties of the field set according to the optics settings above + from ForwardRegionProperties.ForwardRegionPropertiesConf import ForwardRegionProperties + fwdProperties = ForwardRegionProperties("ForwardRegionProperties") + fwdProperties.twissFileB1 = twiss_beam1 + fwdProperties.twissFileB2 = twiss_beam2 + fwdProperties.momentum = twiss_momentum + from AthenaCommon.AppMgr import ToolSvc + ToolSvc += fwdProperties - def __init__(self): - """Describes the geometry.""" - self.atlas_ForwardRegion = PyG4Atlas.DetFacility("GeoDetector", "ForDetEnvelope:ForDetEnvelope") class ZDC(object): - """Describes the ATLAS ZDC detector.""" + """Describes the ATLAS ZDC detector.""" - def __init__(self): - """Describes the geometry.""" - AtlasG4Eng.G4Eng.log.debug("ZDC Simulation :: ZDC atlas_ZDC.py :: __init__ about to make DetFacility") - self.atlas_ZDC = PyG4Atlas.DetFacility("GeoDetector", "ZDC:ZDC") - AtlasG4Eng.G4Eng.log.debug("ZDC Simulation :: ZDC atlas_ZDC.py :: __init__ DetFacility Done") + def __init__(self): + """Describes the geometry.""" + AtlasG4Eng.G4Eng.log.debug("ZDC Simulation :: ZDC atlas_ZDC.py :: __init__ about to make DetFacility") + self.atlas_ZDC = PyG4Atlas.DetFacility("GeoDetector", "ZDC:ZDC") + AtlasG4Eng.G4Eng.log.debug("ZDC Simulation :: ZDC atlas_ZDC.py :: __init__ DetFacility Done") - def _initSD(self): - """Describes the sensitive detector.""" - AtlasG4Eng.G4Eng.log.debug("ZDC Simulation :: atlas_ZDC.py :: _initSD about to make SenDetector") - self.atlas_ZDC.add_SenDetector('ZDC_SD', 'ZDCPixelSD', 'ZDCPixelSD', 'ZDC::Pixel_Logical') - self.atlas_ZDC.add_SenDetector('ZDC_SD', 'ZDCStripSD', 'ZDCStripSD', 'ZDC::Strip_Logical') - AtlasG4Eng.G4Eng.log.debug("ZDC Simulation :: atlas_ZDC.py :: _initSD SenDetector Done") + def _initSD(self): + """Describes the sensitive detector.""" + AtlasG4Eng.G4Eng.log.debug("ZDC Simulation :: atlas_ZDC.py :: _initSD about to make SenDetector") + self.atlas_ZDC.add_SenDetector('ZDC_SD', 'ZDCPixelSD', 'ZDCPixelSD', 'ZDC::Pixel_Logical') + self.atlas_ZDC.add_SenDetector('ZDC_SD', 'ZDCStripSD', 'ZDCStripSD', 'ZDC::Strip_Logical') + AtlasG4Eng.G4Eng.log.debug("ZDC Simulation :: atlas_ZDC.py :: _initSD SenDetector Done") - def _initPR(self): - """Describes the physics regions.""" + def _initPR(self): + """Describes the physics regions.""" class ALFA(object): - """Describes the ATLAS ALFA detector.""" - - def __init__(self): - """Describes the geometry.""" - self.alfa = PyG4Atlas.DetFacility("GeoDetector", "ALFA:ALFA") - - def _initSD(self): - """Describes the sensitive detector.""" - self.alfa.add_SenDetector('ALFA_G4_SD','ALFA_SensitiveDetector', 'ALFA_SensitiveDetector','ALFA::logALFA_FiberU') - self.alfa.add_SenDetector('ALFA_G4_SD','ALFA_SensitiveDetector', 'ALFA_SensitiveDetector','ALFA::logALFA_FiberV') - for i_alfa_fiber in xrange(64): - self.alfa.add_SenDetector('ALFA_G4_SD', 'ALFA_SensitiveDetector', - 'ALFA_SensitiveDetector', 'ALFA::logALFA_FiberU[%d]' % i_alfa_fiber) - self.alfa.add_SenDetector('ALFA_G4_SD', 'ALFA_SensitiveDetector', - 'ALFA_SensitiveDetector', 'ALFA::logALFA_FiberV[%d]' % i_alfa_fiber) - self.alfa.add_SenDetector('ALFA_G4_SD','ALFA_SensitiveDetector', 'ALFA_SensitiveDetector', 'ALFA::logOD_FiberActive') - #print 'fiber %d' % i_alfa_fiber - - # ALFA global vacuum sensors - self.alfa.add_SenDetector('ALFA_G4_SD','ALFA_SensitiveDetector', 'ALFA_SensitiveDetector','ALFA::B7L1_GVS') - self.alfa.add_SenDetector('ALFA_G4_SD','ALFA_SensitiveDetector', 'ALFA_SensitiveDetector','ALFA::A7L1_GVS') - self.alfa.add_SenDetector('ALFA_G4_SD','ALFA_SensitiveDetector', 'ALFA_SensitiveDetector','ALFA::A7R1_GVS') - self.alfa.add_SenDetector('ALFA_G4_SD','ALFA_SensitiveDetector', 'ALFA_SensitiveDetector','ALFA::B7R1_GVS') + """Describes the ATLAS ALFA detector.""" + + def __init__(self): + """Describes the geometry.""" + self.alfa = PyG4Atlas.DetFacility("GeoDetector", "ALFA:ALFA") + + def _initSD(self): + """Describes the sensitive detector.""" + self.alfa.add_SenDetector('ALFA_G4_SD','ALFA_SensitiveDetector', 'ALFA_SensitiveDetector','ALFA::logALFA_FiberU') + self.alfa.add_SenDetector('ALFA_G4_SD','ALFA_SensitiveDetector', 'ALFA_SensitiveDetector','ALFA::logALFA_FiberV') + for i_alfa_fiber in xrange(64): + self.alfa.add_SenDetector('ALFA_G4_SD', 'ALFA_SensitiveDetector', + 'ALFA_SensitiveDetector', 'ALFA::logALFA_FiberU[%d]' % i_alfa_fiber) + self.alfa.add_SenDetector('ALFA_G4_SD', 'ALFA_SensitiveDetector', + 'ALFA_SensitiveDetector', 'ALFA::logALFA_FiberV[%d]' % i_alfa_fiber) + self.alfa.add_SenDetector('ALFA_G4_SD','ALFA_SensitiveDetector', 'ALFA_SensitiveDetector', 'ALFA::logOD_FiberActive') + #print 'fiber %d' % i_alfa_fiber + + # ALFA global vacuum sensors + self.alfa.add_SenDetector('ALFA_G4_SD','ALFA_SensitiveDetector', 'ALFA_SensitiveDetector','ALFA::B7L1_GVS') + self.alfa.add_SenDetector('ALFA_G4_SD','ALFA_SensitiveDetector', 'ALFA_SensitiveDetector','ALFA::A7L1_GVS') + self.alfa.add_SenDetector('ALFA_G4_SD','ALFA_SensitiveDetector', 'ALFA_SensitiveDetector','ALFA::A7R1_GVS') + self.alfa.add_SenDetector('ALFA_G4_SD','ALFA_SensitiveDetector', 'ALFA_SensitiveDetector','ALFA::B7R1_GVS') class Lucid(object): - """Describes Lucid.""" + """Describes Lucid.""" - def __init__(self): - """Describes the geometry.""" - self.lucid = PyG4Atlas.DetFacility("GeoDetector", "LUCID:LUCID") + def __init__(self): + """Describes the geometry.""" + self.lucid = PyG4Atlas.DetFacility("GeoDetector", "LUCID:LUCID") - def _initSD(self): - """Describes the sensitive detector.""" - self.lucid.add_SenDetector('LUCID_G4_SD', 'LUCID_SensitiveDetector', 'LUCID_SensitiveDetector', 'LUCID::lvPmt') + def _initSD(self): + """Describes the sensitive detector.""" + self.lucid.add_SenDetector('LUCID_G4_SD', 'LUCID_SensitiveDetector', 'LUCID_SensitiveDetector', 'LUCID::lvPmt') - def _initOpProcess(self): - """Activates the optical process.""" - AtlasG4Eng.G4Eng.load_Lib("LUCID_OpProcess") + def _initOpProcess(self): + """Activates the optical process.""" + AtlasG4Eng.G4Eng.load_Lib("LUCID_OpProcess") class AFP(object): - """Describes AFP.""" - - def __init__(self): - """Describes the geometry.""" - self.AFP = PyG4Atlas.DetFacility("GeoDetector", "AFP:AFP_GeoModel") + """Describes AFP.""" - def _initSD(self): - """Describes the SI sensitive detector.""" - self.AFP.add_SenDetector('AFP_G4_SD','AFP_SensitiveDetector', 'AFP_SensitiveDetector','AFP::AFP*_LogSIDSensor*') - self.AFP.add_SenDetector('AFP_G4_SD','AFP_SensitiveDetector', 'AFP_SensitiveDetector','AFP::AFP*_LogSIDVacuumSensor*') + def __init__(self): + """Describes the geometry.""" + self.AFP = PyG4Atlas.DetFacility("GeoDetector", "AFP:AFP_GeoModel") - """Describes the T sensitive detector.""" - self.AFP.add_SenDetector('AFP_G4_SD','AFP_SensitiveDetector', 'AFP_SensitiveDetector','AFP::AFP*_LogTDSensor*') - #self.AFP.add_SenDetector('AFP_G4_SD','AFP_SensitiveDetector', 'AFP_SensitiveDetector','AFP::AFP*_LogRadiator*') - #self.AFP.add_SenDetector('AFP_G4_SD','AFP_SensitiveDetector', 'AFP_SensitiveDetector','AFP::AFP*_LogVertBar*') - #self.AFP.add_SenDetector('AFP_G4_SD','AFP_SensitiveDetector', 'AFP_SensitiveDetector','AFP::AFP*_LogHorzBar*') + def _initSD(self): + """Describes the SI sensitive detector.""" + self.AFP.add_SenDetector('AFP_G4_SD','AFP_SensitiveDetector', 'AFP_SensitiveDetector','AFP::AFP*_LogSIDSensor*') + self.AFP.add_SenDetector('AFP_G4_SD','AFP_SensitiveDetector', 'AFP_SensitiveDetector','AFP::AFP*_LogSIDVacuumSensor*') - def _initOpProcess(self): - """Activates the optical process.""" - AtlasG4Eng.G4Eng.load_Lib("LUCID_OpProcess") + """Describes the T sensitive detector.""" + self.AFP.add_SenDetector('AFP_G4_SD','AFP_SensitiveDetector', 'AFP_SensitiveDetector','AFP::AFP*_LogTDSensor*') + #self.AFP.add_SenDetector('AFP_G4_SD','AFP_SensitiveDetector', 'AFP_SensitiveDetector','AFP::AFP*_LogRadiator*') + #self.AFP.add_SenDetector('AFP_G4_SD','AFP_SensitiveDetector', 'AFP_SensitiveDetector','AFP::AFP*_LogVertBar*') + #self.AFP.add_SenDetector('AFP_G4_SD','AFP_SensitiveDetector', 'AFP_SensitiveDetector','AFP::AFP*_LogHorzBar*') -class FwdRegion(object): - """Describes beam pipe in the Forward Region""" + def _initOpProcess(self): + """Activates the optical process.""" + AtlasG4Eng.G4Eng.load_Lib("LUCID_OpProcess") - def __init__(self): - """Describes the geometry.""" - self.atlas_FwdRegion = PyG4Atlas.DetFacility("GeoDetector", "FwdRegion:ForwardRegionGeoModel") - - def _initPR(self): - """Describes the physics regions.""" - self.atlas_FwdRegion_PhysReg=PyG4Atlas.PhysicsReg('FwdRegion') - self.atlas_FwdRegion_PhysReg.add_Volumes('FwdRegion::ForwardRegionGeoModel') - self.atlas_FwdRegion_PhysReg.add_Cuts('e-',200.) - self.atlas_FwdRegion_PhysReg.add_Cuts('e+',200.) - self.atlas_FwdRegion_PhysReg.add_Cuts('gamma',200.) - self.atlas_FwdRegion.add_PhysicsReg(self.atlas_FwdRegion_PhysReg) +class FwdRegion(object): + """Describes beam pipe in the Forward Region""" + + def __init__(self): + """Describes the geometry.""" + self.atlas_FwdRegion = PyG4Atlas.DetFacility("GeoDetector", "FwdRegion:ForwardRegionGeoModel") + + def _initPR(self): + """Describes the physics regions.""" + self.atlas_FwdRegion_PhysReg=PyG4Atlas.PhysicsReg('FwdRegion') + self.atlas_FwdRegion_PhysReg.add_Volumes('FwdRegion::ForwardRegionGeoModel') + self.atlas_FwdRegion_PhysReg.add_Cuts('e-',200.) + self.atlas_FwdRegion_PhysReg.add_Cuts('e+',200.) + self.atlas_FwdRegion_PhysReg.add_Cuts('gamma',200.) + self.atlas_FwdRegion.add_PhysicsReg(self.atlas_FwdRegion_PhysReg) diff --git a/Simulation/G4Atlas/G4AtlasApps/python/callbacks.py b/Simulation/G4Atlas/G4AtlasApps/python/callbacks.py index 6ba2e436597..9fbbe8f2bc4 100644 --- a/Simulation/G4Atlas/G4AtlasApps/python/callbacks.py +++ b/Simulation/G4Atlas/G4AtlasApps/python/callbacks.py @@ -35,3 +35,9 @@ def add_LLP_truth_strategies(): mcTruthMenu=PyG4Atlas.G4AtlasEngine.menu_MCTruth() mcTruthMenu.add_McTruthStrategy(astrategy) +def add_EnergyConservationTest(): + from G4AtlasApps import PyG4Atlas,AtlasG4Eng + # Enable the energy conservation test action + MyAction = PyG4Atlas.UserAction('G4UserActions','EnergyConservationTest', ['BeginOfEvent','EndOfEvent','Step']) + AtlasG4Eng.G4Eng.menu_UserActions.add_UserAction(MyAction) + diff --git a/Simulation/G4Atlas/G4AtlasApps/share/jobOptions.G4Atlas.py b/Simulation/G4Atlas/G4AtlasApps/share/jobOptions.G4Atlas.py index 3357274d4cd..3f7c1193bf2 100644 --- a/Simulation/G4Atlas/G4AtlasApps/share/jobOptions.G4Atlas.py +++ b/Simulation/G4Atlas/G4AtlasApps/share/jobOptions.G4Atlas.py @@ -17,7 +17,7 @@ DetFlags.Truth_setOn() ## Global conditions tag from AthenaCommon.GlobalFlags import jobproperties -jobproperties.Global.ConditionsTag = "OFLCOND-MC12-SIM-00" +jobproperties.Global.ConditionsTag = "OFLCOND-RUN12-SDR-01" ## AthenaCommon flags from AthenaCommon.AthenaCommonFlags import athenaCommonFlags @@ -34,9 +34,9 @@ simFlags.RandomSvc = 'AtDSFMTGenSvc' ## Use the default layout: simFlags.SimLayout.set_On() ## Set a specific layout tag: -#simFlags.SimLayout='ATLAS-GEO-20-00-01' +#simFlags.SimLayout='ATLAS-R2-2015-01-01-00' ## Set a specific non-officially-supported layout tag using the _VALIDATION suffix: -#simFlags.SimLayout = 'ATLAS-GEO-20-00-01_VALIDATION' +#simFlags.SimLayout = 'ATLAS-R2-2015-01-01-00_VALIDATION' ## Set the EtaPhi, VertexSpread and VertexRange checks on simFlags.EventFilter.set_On() diff --git a/Simulation/G4Atlas/G4AtlasApps/share/jobOptions.G4Atlas_ReadEvgen.py b/Simulation/G4Atlas/G4AtlasApps/share/jobOptions.G4Atlas_ReadEvgen.py index fca609c7fa5..ab0324b51e2 100644 --- a/Simulation/G4Atlas/G4AtlasApps/share/jobOptions.G4Atlas_ReadEvgen.py +++ b/Simulation/G4Atlas/G4AtlasApps/share/jobOptions.G4Atlas_ReadEvgen.py @@ -17,7 +17,7 @@ DetFlags.Truth_setOn() ## Global conditions tag from AthenaCommon.GlobalFlags import jobproperties -jobproperties.Global.ConditionsTag = "OFLCOND-MC12-SIM-00" +jobproperties.Global.ConditionsTag = "OFLCOND-RUN12-SDR-01" ## AthenaCommon flags from AthenaCommon.AthenaCommonFlags import athenaCommonFlags @@ -34,9 +34,9 @@ simFlags.load_atlas_flags() ## Use the default layout: simFlags.SimLayout.set_On() ## Set a specific layout tag: -#simFlags.SimLayout='ATLAS-GEO-18-01-00' +#simFlags.SimLayout='ATLAS-R2-2015-01-01-00' ## Set a specific non-officially-supported layout tag using the _VALIDATION suffix: -#simFlags.SimLayout = 'ATLAS-GEO-18-01-00_VALIDATION' +#simFlags.SimLayout = 'ATLAS-R2-2015-01-01-00_VALIDATION' ## Set the EtaPhi, VertexSpread and VertexRange checks on simFlags.EventFilter.set_On() diff --git a/Simulation/G4Atlas/G4AtlasApps/share/jobOptions.G4Cosmic.py b/Simulation/G4Atlas/G4AtlasApps/share/jobOptions.G4Cosmic.py index b0f07a448b1..0b041cb0d56 100644 --- a/Simulation/G4Atlas/G4AtlasApps/share/jobOptions.G4Cosmic.py +++ b/Simulation/G4Atlas/G4AtlasApps/share/jobOptions.G4Cosmic.py @@ -15,7 +15,7 @@ DetFlags.Truth_setOn() ## Global conditions tag (set for global MC12 sim) from AthenaCommon.GlobalFlags import globalflags -globalflags.ConditionsTag = "OFLCOND-MC12-SIM-00" # Probably want a different conditions tag for cosmics running +globalflags.ConditionsTag = "OFLCOND-RUN12-SDR-01" # Probably want a different conditions tag for cosmics running ## AthenaCommon flags from AthenaCommon.AthenaCommonFlags import athenaCommonFlags @@ -34,7 +34,7 @@ simFlags.RandomSvc = 'AtDSFMTGenSvc' ## Use the default layout: simFlags.SimLayout.set_On() ## Set a specific layout tag: -#simFlags.SimLayout='ATLAS-GEO-20-00-01' +#simFlags.SimLayout='ATLAS-R2-2015-01-01-00' ## There are three ways to run cosmics sim: ## 1) Generate and simulate directly without intermediates: -- GitLab