Skip to content
Snippets Groups Projects
Commit aab6c341 authored by Dave Casper's avatar Dave Casper
Browse files

Merge branch 'master-generator-steering' into 'master'

Allow simulation to be fully steered by command line arguments

See merge request faser/calypso!151
parents fc7088e3 f7920c0f
No related branches found
No related tags found
No related merge requests found
...@@ -32,7 +32,7 @@ def _createCfgFlags(): ...@@ -32,7 +32,7 @@ def _createCfgFlags():
# acf=AthConfigFlags() # acf=AthConfigFlags()
fcf = athenaConfigFlags fcf = athenaConfigFlags
fcf.Input.Files = ["_FASER_GENERIC_INPUTFILE_NAME_",] # former global.InputFiles fcf.Input.Files = ["_CALYPSO_GENERIC_INPUTFILE_NAME_",] # former global.InputFiles
# acf.addFlag('Input.SecondaryFiles', []) # secondary input files for DoubleEventSelector # acf.addFlag('Input.SecondaryFiles', []) # secondary input files for DoubleEventSelector
# acf.addFlag('Input.isMC', lambda prevFlags : "IS_SIMULATION" in GetFileMD(prevFlags.Input.Files).get("eventTypes",[]) ) # former global.isMC # acf.addFlag('Input.isMC', lambda prevFlags : "IS_SIMULATION" in GetFileMD(prevFlags.Input.Files).get("eventTypes",[]) ) # former global.isMC
# acf.addFlag('Input.RunNumber', lambda prevFlags : list(GetFileMD(prevFlags.Input.Files).get("runNumbers",[]))) # former global.RunNumber # acf.addFlag('Input.RunNumber', lambda prevFlags : list(GetFileMD(prevFlags.Input.Files).get("runNumbers",[]))) # former global.RunNumber
......
...@@ -108,3 +108,15 @@ def FaserParticleGunDecayInFlightCfg(ConfigFlags, **kwargs) : ...@@ -108,3 +108,15 @@ def FaserParticleGunDecayInFlightCfg(ConfigFlags, **kwargs) :
pg.sampler = DIFSampler(**kwargs) pg.sampler = DIFSampler(**kwargs)
return cfg return cfg
def FaserParticleGunCfg(ConfigFlags) :
generator = ConfigFlags.Sim.Gun.setdefault("Generator", "SingleParticle")
kwargs = ConfigFlags.Sim.Gun
if generator == "SingleEcalParticle" :
return FaserParticleGunSingleEcalParticleCfg(ConfigFlags, **kwargs)
elif generator == "Cosmics" :
return FaserParticleGunCosmicsCfg(ConfigFlags, **kwargs)
elif generator == "DecayInFlight" :
return FaserParticleGunDecayInFlightCfg(ConfigFlags, **kwargs)
else :
return FaserParticleGunSingleParticleCfg(ConfigFlags, **kwargs )
...@@ -32,16 +32,9 @@ if __name__ == '__main__': ...@@ -32,16 +32,9 @@ if __name__ == '__main__':
ConfigFlags.Input.LumiBlockNumber = [1] ConfigFlags.Input.LumiBlockNumber = [1]
ConfigFlags.Input.isMC = True ConfigFlags.Input.isMC = True
# #
# Input source if reading generator file
#
# from AthenaConfiguration.TestDefaults import defaultTestFiles
# inputDir = defaultTestFiles.d
# ConfigFlags.Input.Files = ['/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/SimCoreTests/valid1.410000.PowhegPythiaEvtGen_P2012_ttbar_hdamp172p5_nonallhad.evgen.EVNT.e4993.EVNT.08166201._000012.pool.root.1'] #defaultTestFiles.EVNT
#
# Output file name # Output file name
# #
ConfigFlags.Output.HITSFileName = "my.HITS.pool.root" # can be overridden from command line with Output.HITSFileName=<name> ConfigFlags.Output.HITSFileName = "my.HITS.pool.root" # can be overridden from command line with Output.HITSFileName=<name>
# #
# Sim ConfigFlags # Sim ConfigFlags
# #
...@@ -49,6 +42,7 @@ if __name__ == '__main__': ...@@ -49,6 +42,7 @@ if __name__ == '__main__':
ConfigFlags.Sim.PhysicsList = "FTFP_BERT" ConfigFlags.Sim.PhysicsList = "FTFP_BERT"
ConfigFlags.Sim.ReleaseGeoModel = False ConfigFlags.Sim.ReleaseGeoModel = False
ConfigFlags.Sim.IncludeParentsInG4Event = True # Controls whether BeamTruthEvent is written to output HITS file ConfigFlags.Sim.IncludeParentsInG4Event = True # Controls whether BeamTruthEvent is written to output HITS file
ConfigFlags.addFlag("Sim.Gun",{"Generator" : "SingleParticle"}) # Property bag for particle gun keyword:argument pairs
ConfigFlags.GeoModel.FaserVersion = "FASERNU-02" # Geometry set-up ConfigFlags.GeoModel.FaserVersion = "FASERNU-02" # Geometry set-up
ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-02" # Conditions set-up ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-02" # Conditions set-up
...@@ -65,13 +59,10 @@ if __name__ == '__main__': ...@@ -65,13 +59,10 @@ if __name__ == '__main__':
# Start with minimal configuration for Testbeam # Start with minimal configuration for Testbeam
# #
detectors = ['Veto', 'Preshower', 'FaserSCT', 'Ecal'] detectors = ['Veto', 'Preshower', 'FaserSCT', 'Ecal']
zStart = -200
if ConfigFlags.GeoModel.FaserVersion.count("TB") == 0 : if ConfigFlags.GeoModel.FaserVersion.count("TB") == 0 :
detectors += ['Trigger', 'Dipole'] detectors += ['Trigger', 'Dipole']
zStart = -1800
if ConfigFlags.GeoModel.FaserVersion.count("FASERNU") > 0 : if ConfigFlags.GeoModel.FaserVersion.count("FASERNU") > 0 :
detectors += ['Emulsion'] detectors += ['Emulsion']
zStart = -3750
# #
# Setup detector flags # Setup detector flags
# #
...@@ -87,30 +78,26 @@ if __name__ == '__main__': ...@@ -87,30 +78,26 @@ if __name__ == '__main__':
from CalypsoConfiguration.MainServicesConfig import MainServicesCfg from CalypsoConfiguration.MainServicesConfig import MainServicesCfg
cfg = MainServicesCfg(ConfigFlags) cfg = MainServicesCfg(ConfigFlags)
# #
# Particle gun generators - the energy, angle, particle type, position, etc can be modified by passing keyword arguments # Check whether a real input file was specified
# #
from FaserParticleGun.FaserParticleGunConfig import FaserParticleGunSingleParticleCfg if ConfigFlags.Input.Files and ConfigFlags.Input.Files != ["_CALYPSO_GENERIC_INPUTFILE_NAME_"] :
cfg.merge(FaserParticleGunSingleParticleCfg(ConfigFlags, theta = 0.001, z = zStart)) print("Input.Files = ",ConfigFlags.Input.Files)
# #
# from FaserParticleGun.FaserParticleGunConfig import FaserParticleGunSingleEcalParticleCfg # If so, set up to read it
# cfg.merge(FaserParticleGunSingleEcalParticleCfg(ConfigFlags)) #
# from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
# from FaserParticleGun.FaserParticleGunConfig import FaserParticleGunCosmicsCfg cfg.merge(PoolReadCfg(ConfigFlags))
# cfg.merge(FaserParticleGunCosmicsCfg(ConfigFlags)) #
# # If not, configure the particle gun as requested, or using defaults
# from FaserParticleGun.FaserParticleGunConfig import FaserParticleGunDecayInFlightCfg #
# cfg.merge(FaserParticleGunDecayInFlightCfg(ConfigFlags)) else :
# #
# # Particle gun generators - the generator, energy, angle, particle type, position, etc can be modified by passing keyword arguments
# Only one of these two should be used in a given job #
# MCEventSelectorCfg for generating events with no input file from FaserParticleGun.FaserParticleGunConfig import FaserParticleGunCfg
# PoolReadCfg when reading generator data from an input file cfg.merge(FaserParticleGunCfg(ConfigFlags))
# from McEventSelector.McEventSelectorConfig import McEventSelectorCfg
from McEventSelector.McEventSelectorConfig import McEventSelectorCfg cfg.merge(McEventSelectorCfg(ConfigFlags))
cfg.merge(McEventSelectorCfg(ConfigFlags))
# from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
# cfg.merge(PoolReadCfg(ConfigFlags))
# #
# Output file # Output file
# #
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment