diff --git a/Control/CalypsoConfiguration/python/AllConfigFlags.py b/Control/CalypsoConfiguration/python/AllConfigFlags.py index cf26c40c3229ededad7f96a8080896e990cc30ef..3fd0a09b8d1ceedfdde7c1e83e2c75815c25fbe3 100644 --- a/Control/CalypsoConfiguration/python/AllConfigFlags.py +++ b/Control/CalypsoConfiguration/python/AllConfigFlags.py @@ -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 diff --git a/Generators/FaserParticleGun/python/FaserParticleGunConfig.py b/Generators/FaserParticleGun/python/FaserParticleGunConfig.py index 7409c81ae6d65b3b3b4a0dfabc077f2d2e2c973f..f5ba68bcba67791b3d7fa6792518ba74b90d1bb6 100644 --- a/Generators/FaserParticleGun/python/FaserParticleGunConfig.py +++ b/Generators/FaserParticleGun/python/FaserParticleGunConfig.py @@ -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 ) diff --git a/Simulation/G4Faser/G4FaserAlg/test/G4FaserAlgConfigNew_Test.py b/Simulation/G4Faser/G4FaserAlg/test/G4FaserAlgConfigNew_Test.py index 3421ae83f53992751c8e9ec5961a234529cd3177..709797ae28bec863f565eba2aa662d8bcefc0e2e 100644 --- a/Simulation/G4Faser/G4FaserAlg/test/G4FaserAlgConfigNew_Test.py +++ b/Simulation/G4Faser/G4FaserAlg/test/G4FaserAlgConfigNew_Test.py @@ -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 #