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

Allow simulation to be fully steered by command line arguments

parent fc7088e3
No related branches found
No related tags found
1 merge request!151Allow simulation to be fully steered by command line arguments
......@@ -32,7 +32,7 @@ def _createCfgFlags():
# acf=AthConfigFlags()
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.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
......
......@@ -108,3 +108,15 @@ def FaserParticleGunDecayInFlightCfg(ConfigFlags, **kwargs) :
pg.sampler = DIFSampler(**kwargs)
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__':
ConfigFlags.Input.LumiBlockNumber = [1]
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
#
ConfigFlags.Output.HITSFileName = "my.HITS.pool.root" # can be overridden from command line with Output.HITSFileName=<name>
#
# Sim ConfigFlags
#
......@@ -49,6 +42,7 @@ if __name__ == '__main__':
ConfigFlags.Sim.PhysicsList = "FTFP_BERT"
ConfigFlags.Sim.ReleaseGeoModel = False
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.IOVDb.GlobalTag = "OFLCOND-FASER-02" # Conditions set-up
......@@ -65,13 +59,10 @@ if __name__ == '__main__':
# Start with minimal configuration for Testbeam
#
detectors = ['Veto', 'Preshower', 'FaserSCT', 'Ecal']
zStart = -200
if ConfigFlags.GeoModel.FaserVersion.count("TB") == 0 :
detectors += ['Trigger', 'Dipole']
zStart = -1800
if ConfigFlags.GeoModel.FaserVersion.count("FASERNU") > 0 :
detectors += ['Emulsion']
zStart = -3750
#
# Setup detector flags
#
......@@ -87,30 +78,26 @@ if __name__ == '__main__':
from CalypsoConfiguration.MainServicesConfig import MainServicesCfg
cfg = MainServicesCfg(ConfigFlags)
#
# Particle gun generators - the energy, angle, particle type, position, etc can be modified by passing keyword arguments
#
from FaserParticleGun.FaserParticleGunConfig import FaserParticleGunSingleParticleCfg
cfg.merge(FaserParticleGunSingleParticleCfg(ConfigFlags, theta = 0.001, z = zStart))
#
# from FaserParticleGun.FaserParticleGunConfig import FaserParticleGunSingleEcalParticleCfg
# cfg.merge(FaserParticleGunSingleEcalParticleCfg(ConfigFlags))
#
# from FaserParticleGun.FaserParticleGunConfig import FaserParticleGunCosmicsCfg
# cfg.merge(FaserParticleGunCosmicsCfg(ConfigFlags))
#
# from FaserParticleGun.FaserParticleGunConfig import FaserParticleGunDecayInFlightCfg
# cfg.merge(FaserParticleGunDecayInFlightCfg(ConfigFlags))
#
#
# Only one of these two should be used in a given job
# MCEventSelectorCfg for generating events with no input file
# PoolReadCfg when reading generator data from an input file
#
from McEventSelector.McEventSelectorConfig import McEventSelectorCfg
cfg.merge(McEventSelectorCfg(ConfigFlags))
# from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
# cfg.merge(PoolReadCfg(ConfigFlags))
# Check whether a real input file was specified
#
if ConfigFlags.Input.Files and ConfigFlags.Input.Files != ["_CALYPSO_GENERIC_INPUTFILE_NAME_"] :
print("Input.Files = ",ConfigFlags.Input.Files)
#
# If so, set up to read it
#
from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
cfg.merge(PoolReadCfg(ConfigFlags))
#
# If not, configure the particle gun as requested, or using defaults
#
else :
#
# Particle gun generators - the generator, energy, angle, particle type, position, etc can be modified by passing keyword arguments
#
from FaserParticleGun.FaserParticleGunConfig import FaserParticleGunCfg
cfg.merge(FaserParticleGunCfg(ConfigFlags))
from McEventSelector.McEventSelectorConfig import McEventSelectorCfg
cfg.merge(McEventSelectorCfg(ConfigFlags))
#
# 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