From f98719ea498f9deabedd1e956c63b53c4d9aa83a Mon Sep 17 00:00:00 2001 From: Carl Gwilliam <gwilliam@hep.ph.liv.ac.uk> Date: Mon, 16 May 2022 17:40:16 +0100 Subject: [PATCH] Fix to make shift LOS work with different seqs --- Generators/GeneratorUtils/python/ShiftLOS.py | 8 ++++---- Generators/GeneratorUtils/python/ShiftLOSConfig.py | 10 ++++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Generators/GeneratorUtils/python/ShiftLOS.py b/Generators/GeneratorUtils/python/ShiftLOS.py index f1010367..fb6180b4 100644 --- a/Generators/GeneratorUtils/python/ShiftLOS.py +++ b/Generators/GeneratorUtils/python/ShiftLOS.py @@ -40,17 +40,17 @@ class ShiftLOS(PyAthena.Alg): # Shift x or y by appropriate crossing angle if self.xcross: x += dz * self.xcross - self.msg.debug(f"Shifting x by {self.xcross} over {dz}: {pos.x()} -> {x} ") + self.msg.debug(f"Shifting x by {self.xcross} urad over {dz}: {pos.x()} -> {x} ") elif self.ycross: y += dz * self.ycross - self.msg.debug(f"Shifting y by {self.ycross} over {dz}: {pos.y()} -> {y} ") + self.msg.debug(f"Shifting y by {self.ycross} urad over {dz}: {pos.y()} -> {y} ") if self.xshift: x += self.xshift - self.msg.debug(f"Shifting x by {self.xshift}: {pos.x()} -> {x} ") + self.msg.debug(f"Shifting x by {self.xshift} mm: {pos.x()} -> {x} ") elif self.yshift: y += self.yshift - self.msg.debug(f"Shifting x by {self.yshift}: {pos.y()} -> {y} ") + self.msg.debug(f"Shifting x by {self.yshift} mm: {pos.y()} -> {y} ") v.set_position(HepMC.FourVector(x, y, z, pos.t())) diff --git a/Generators/GeneratorUtils/python/ShiftLOSConfig.py b/Generators/GeneratorUtils/python/ShiftLOSConfig.py index 5aece64b..4d7f02d5 100644 --- a/Generators/GeneratorUtils/python/ShiftLOSConfig.py +++ b/Generators/GeneratorUtils/python/ShiftLOSConfig.py @@ -4,7 +4,7 @@ # import sys from AthenaConfiguration.MainServicesConfig import AthSequencer -from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator, ConfigurationError from AthenaConfiguration.ComponentFactory import CompFactory from GeneratorUtils.ShiftLOS import ShiftLOS @@ -21,6 +21,12 @@ def ShiftLOSCfg(ConfigFlags, **kwargs) : shift.ycross = kwargs.setdefault("ycross", 0) shift.xshift = kwargs.setdefault("xshift", 0) shift.yshift = kwargs.setdefault("yshift", 0) - cfg.addEventAlgo(shift, sequenceName = "AthBeginSeq", primary = True) # to run *before* G4 + try: + # Run for PG + cfg.addEventAlgo(shift, sequenceName = "AthBeginSeq", primary = True) # to run *before* G4 + except ConfigurationError: + # Run for pool or hepmc + cfg.addEventAlgo(shift, sequenceName = "AthAlgSeq", primary = True) # to run *before* G4 + return cfg -- GitLab