Skip to content
Snippets Groups Projects
Commit 6a36c53a authored by Carl Gwilliam's avatar Carl Gwilliam
Browse files

Fix LOS dealing with ATLAS vs FASER coords

parent a40f55b9
No related branches found
No related tags found
No related merge requests found
...@@ -7,8 +7,6 @@ from AthenaConfiguration.MainServicesConfig import AthSequencer ...@@ -7,8 +7,6 @@ from AthenaConfiguration.MainServicesConfig import AthSequencer
from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator, ConfigurationError from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator, ConfigurationError
from AthenaConfiguration.ComponentFactory import CompFactory from AthenaConfiguration.ComponentFactory import CompFactory
from SGComps.AddressRemappingConfig import InputOverwriteCfg
from GeneratorUtils.ShiftLOS import ShiftLOS from GeneratorUtils.ShiftLOS import ShiftLOS
...@@ -17,9 +15,6 @@ def ShiftLOSCfg(ConfigFlags, **kwargs) : ...@@ -17,9 +15,6 @@ def ShiftLOSCfg(ConfigFlags, **kwargs) :
cfg = ComponentAccumulator() cfg = ComponentAccumulator()
# Rename old truth collection to add ATLAS coord to can still use BeamTruthEvent for the one in FASER Coords
cfg.merge(InputOverwriteCfg("McEventCollection", "BeamTruthEvent", "McEventCollection", "BeamTruthEvent_ATLASCoord"))
shift = ShiftLOS(name = kwargs.setdefault("name", "ShiftLOS")) shift = ShiftLOS(name = kwargs.setdefault("name", "ShiftLOS"))
shift.InputMCEventKey = kwargs.setdefault("InputMCEventKey", "BeamTruthEvent_ATLASCoord") shift.InputMCEventKey = kwargs.setdefault("InputMCEventKey", "BeamTruthEvent_ATLASCoord")
shift.OutputMCEventKey = kwargs.setdefault("OutputMCEventKey", "BeamTruthEvent") shift.OutputMCEventKey = kwargs.setdefault("OutputMCEventKey", "BeamTruthEvent")
......
...@@ -58,11 +58,21 @@ if __name__ == '__main__': ...@@ -58,11 +58,21 @@ if __name__ == '__main__':
import sys import sys
ConfigFlags.fillFromArgs(sys.argv[1:]) ConfigFlags.fillFromArgs(sys.argv[1:])
# from math import atan doShiftLOS = (ConfigFlags.Sim.Beam.xangle or ConfigFlags.Sim.Beam.yangle or
# from AthenaCommon.SystemOfUnits import GeV, TeV, cm, m ConfigFlags.Sim.Beam.xshift or ConfigFlags.Sim.Beam.yshift)
# from AthenaCommon.PhysicalConstants import pi
# import ParticleGun as PG from math import atan
# ConfigFlags.Sim.Gun = {"Generator" : "SingleParticle", "pid" : 11, "energy" : PG.LogSampler(10*GeV, 1*TeV), "theta" : PG.GaussianSampler(0, atan((10*cm)/(7*m)), oneside = True), "phi" : [0, 2*pi], "mass" : 0.511, "radius" : -10*cm, "randomSeed" : 12345} from AthenaCommon.SystemOfUnits import GeV, TeV, cm, m
from AthenaCommon.PhysicalConstants import pi
import ParticleGun as PG
ConfigFlags.Sim.Gun = {"Generator" : "SingleParticle", "pid" : 11, "energy" : PG.LogSampler(10*GeV, 1*TeV), "theta" :
PG.GaussianSampler(0, atan((10*cm)/(7*m)), oneside = True), "phi" : [0, 2*pi], "mass" : 0.511, "radius" : -10*cm, "randomSeed" : 12345}
if doShiftLOS:
pgConfig = ConfigFlags.Sim.Gun
pgConfig["McEventKey"] = "BeamTruthEvent_ATLASCoord"
ConfigFlags.Sim.Gun = pgConfig
# #
# By being a little clever, we can steer the geometry setup from the command line using GeoModel.FaserVersion # By being a little clever, we can steer the geometry setup from the command line using GeoModel.FaserVersion
...@@ -97,12 +107,16 @@ if __name__ == '__main__': ...@@ -97,12 +107,16 @@ if __name__ == '__main__':
print("Input.Files = ",ConfigFlags.Input.Files) print("Input.Files = ",ConfigFlags.Input.Files)
# #
# If so, and only one file that ends in .events read as HepMC # If so, and only one file that ends in .events or .hepmc read as HepMC
# #
if len(ConfigFlags.Input.Files) == 1 and (ConfigFlags.Input.Files[0].endswith(".events") or ConfigFlags.Input.Files[0].endswith(".hepmc")): if len(ConfigFlags.Input.Files) == 1 and (ConfigFlags.Input.Files[0].endswith(".events") or ConfigFlags.Input.Files[0].endswith(".hepmc")):
from HEPMCReader.HepMCReaderConfig import HepMCReaderCfg from HEPMCReader.HepMCReaderConfig import HepMCReaderCfg
cfg.merge(HepMCReaderCfg(ConfigFlags))
if doShiftLOS:
cfg.merge(HepMCReaderCfg(ConfigFlags, McEventKey = "BeamTruthEvent_ATLASCoord"))
else:
cfg.merge(HepMCReaderCfg(ConfigFlags))
from McEventSelector.McEventSelectorConfig import McEventSelectorCfg from McEventSelector.McEventSelectorConfig import McEventSelectorCfg
cfg.merge(McEventSelectorCfg(ConfigFlags)) cfg.merge(McEventSelectorCfg(ConfigFlags))
...@@ -113,6 +127,12 @@ if __name__ == '__main__': ...@@ -113,6 +127,12 @@ if __name__ == '__main__':
else: else:
from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
cfg.merge(PoolReadCfg(ConfigFlags)) cfg.merge(PoolReadCfg(ConfigFlags))
if doShiftLOS:
from SGComps.AddressRemappingConfig import InputOverwriteCfg
# Rename old truth collection to add ATLAS coord to can still use BeamTruthEvent for the one in FASER Coords
cfg.merge(InputOverwriteCfg("McEventCollection", "BeamTruthEvent", "McEventCollection", "BeamTruthEvent_ATLASCoord"))
# #
# If not, configure the particle gun as requested, or using defaults # If not, configure the particle gun as requested, or using defaults
# #
...@@ -122,6 +142,7 @@ if __name__ == '__main__': ...@@ -122,6 +142,7 @@ if __name__ == '__main__':
# #
from FaserParticleGun.FaserParticleGunConfig import FaserParticleGunCfg from FaserParticleGun.FaserParticleGunConfig import FaserParticleGunCfg
cfg.merge(FaserParticleGunCfg(ConfigFlags)) cfg.merge(FaserParticleGunCfg(ConfigFlags))
from McEventSelector.McEventSelectorConfig import McEventSelectorCfg from McEventSelector.McEventSelectorConfig import McEventSelectorCfg
cfg.merge(McEventSelectorCfg(ConfigFlags)) cfg.merge(McEventSelectorCfg(ConfigFlags))
...@@ -135,8 +156,7 @@ if __name__ == '__main__': ...@@ -135,8 +156,7 @@ if __name__ == '__main__':
# Shift LOS # Shift LOS
# #
if (ConfigFlags.Sim.Beam.xangle or ConfigFlags.Sim.Beam.yangle or if doShiftLOS:
ConfigFlags.Sim.Beam.xshift or ConfigFlags.Sim.Beam.yshift):
import McParticleEvent.Pythonizations import McParticleEvent.Pythonizations
from GeneratorUtils.ShiftLOSConfig import ShiftLOSCfg from GeneratorUtils.ShiftLOSConfig import ShiftLOSCfg
...@@ -150,7 +170,7 @@ if __name__ == '__main__': ...@@ -150,7 +170,7 @@ if __name__ == '__main__':
from G4FaserAlg.G4FaserAlgConfigNew import G4FaserAlgCfg from G4FaserAlg.G4FaserAlgConfigNew import G4FaserAlgCfg
cfg.merge(G4FaserAlgCfg(ConfigFlags)) cfg.merge(G4FaserAlgCfg(ConfigFlags))
###cfg.getEventAlgo("OutputStreamHITS").ItemList += ["McEventCollection#BeamTruthEvent_ATLASCoord"] #cfg.getEventAlgo("OutputStreamHITS").ItemList += ["McEventCollection#BeamTruthEvent_ATLASCoord"]
# #
# Dump config # Dump config
# #
......
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