diff --git a/Calorimeter/FaserCaloSimEvent/src/CaloHitIdHelper.cxx b/Calorimeter/FaserCaloSimEvent/src/CaloHitIdHelper.cxx index 128ced42480147abbcc3e95eeb4bf167e0419971..cdf4d186395589cc2f7b025201afc3e487028334 100644 --- a/Calorimeter/FaserCaloSimEvent/src/CaloHitIdHelper.cxx +++ b/Calorimeter/FaserCaloSimEvent/src/CaloHitIdHelper.cxx @@ -45,7 +45,7 @@ void CaloHitIdHelper::Initialize() { const EcalID* pix; ServiceHandle<StoreGateSvc> detStore ("DetectorStore", "CaloHitIdHelper"); if (detStore.retrieve().isSuccess()) { - if (detStore->retrieve(pix, "Ecal_ID").isFailure()) { pix = 0; } + if (detStore->retrieve(pix, "EcalID").isFailure()) { pix = 0; } } InitializeField("Row", 0, 1); diff --git a/Generators/DIFGenerator/README.md b/Generators/DIFGenerator/README.md index 34dbc557986ed9b4e3f025b787375ace36c69cd3..9a1bd97251403f38fae218200eab8b27db0c8a65 100644 --- a/Generators/DIFGenerator/README.md +++ b/Generators/DIFGenerator/README.md @@ -12,7 +12,7 @@ Options available through the `DIFSampler` constructor include: * daughter2_pid - The pid of the second decay particle. The default valid pids are listed [here](https://gitlab.cern.ch/atlas/athena/-/blob/master/Generators/ParticleGun/python/samplers.py#L825). (default: -11) * mother_pid - The pid of the mother particle. Only set this if you need to get the mother's pid from the mother_sampler property (default: None) * mother_mom - A momentum sampler representing the mother particle's momentum. (default: PG.EThetaMPhiSampler(sqrt((1 * TeV)**2 + (10 * MeV)**2),0,10*MeV,0)) -* mother_pos - A position sampler representing the mother particle's position. (default: PG.PosSampler(0,0,[-1500,0],0)) +* mother_pos - A position sampler representing the mother particle's position. (default: DIFGenerator.CylinderSampler(rsq = [0, (100*mm)**2], phi = [0,2*pi], z = [-1500*mm,0])) The pid, momentum sampler, and position sampler of the mother particle can be modified after initialization by setting the `mother_sampler` property of the `DIFSampler`. The `mother_sampler` property should be a [ParticleSampler](https://gitlab.cern.ch/atlas/athena/-/blob/master/Generators/ParticleGun/python/samplers.py#L858). diff --git a/Generators/DIFGenerator/python/DIFSampler.py b/Generators/DIFGenerator/python/DIFSampler.py index 835d0f1ec82c849799e62b74cdd57020773be0e6..18f9156b4c385cc11614ac0937897ac813b34583 100644 --- a/Generators/DIFGenerator/python/DIFSampler.py +++ b/Generators/DIFGenerator/python/DIFSampler.py @@ -7,6 +7,58 @@ from math import sqrt, sin, cos, acos from random import uniform from AthenaCommon.SystemOfUnits import TeV, MeV from AthenaCommon.PhysicalConstants import pi +from ROOT import TLorentzVector + +class CylinderSampler(PG.Sampler): + """ + Sampler of position 4-vectors within a cylindrical volume. + """ + + def __init__(self, rsq, phi, z, t=0): + self.rsq = rsq + self.phi = phi + self.z = z + self.t = t + + @property + def rsq(self): + "rsq position sampler" + return self._rsq + @rsq.setter + def rsq(self, rsq): + self._rsq = PG.mksampler(rsq) + + @property + def phi(self): + "phi position sampler" + return self._phi + @phi.setter + def phi(self, phi): + self._phi = PG.mksampler(phi) + + @property + def z(self): + "z position sampler" + return self._z + @z.setter + def z(self, z): + self._z = PG.mksampler(z) + + @property + def t(self): + "Time sampler" + return self._t + @t.setter + def t(self, t): + self._t = PG.mksampler(t) + + def shoot(self): + r = sqrt(self.rsq()) + phi = self.phi() + z = self.z() + t = self.t() + #print "POS =", x, y, z, t + return TLorentzVector(r * cos(phi), r * sin(phi), z, t) class DIFSampler(PG.ParticleSampler): """ @@ -38,8 +90,8 @@ class DIFSampler(PG.ParticleSampler): else: self.mom = None - def __init__(self, daughter1_pid = 11, daughter2_pid = -11, mother_pid = None, mother_mom = PG.EThetaMPhiSampler(sqrt((1*TeV)**2 + (10*MeV)**2),0,10*MeV,0),mother_pos = PG.PosSampler(0,0,[-1500,0],0)): - self._mother_sampler = PG.ParticleSampler(mother_pid,mother_mom,mother_pos) + def __init__(self, daughter1_pid = 11, daughter2_pid = -11, mother_pid = None, mother_mom = PG.EThetaMPhiSampler(sqrt((1*TeV)**2 + (10*MeV)**2),0,10*MeV,0),mother_pos = CylinderSampler([0, 100**2],[0, 2*pi],[-1500, 0],0)): + self._mother_sampler = PG.ParticleSampler(pid = mother_pid, mom = mother_mom, pos = mother_pos) self.daughter1 = self.particle(daughter1_pid) self.daughter2 = self.particle(daughter2_pid) diff --git a/Simulation/G4Faser/G4FaserAlg/test/runG4DecayInFlight.py b/Simulation/G4Faser/G4FaserAlg/test/runG4DecayInFlight.py index 88401cafb3bbc781cec50291656b824931e5953e..e11ee6d1624cca27a23eb454af21d5a5f2e633dd 100644 --- a/Simulation/G4Faser/G4FaserAlg/test/runG4DecayInFlight.py +++ b/Simulation/G4Faser/G4FaserAlg/test/runG4DecayInFlight.py @@ -66,6 +66,8 @@ if __name__ == "__main__": ConfigFlags.Detector.GeometryPreshower = True ConfigFlags.Detector.SimulateFaserSCT = True ConfigFlags.Detector.GeometryFaserSCT = True + ConfigFlags.Detector.SimulateEcal = True + ConfigFlags.Detector.GeometryEcal = True ConfigFlags.Detector.SimulateUpstreamDipole = True ConfigFlags.Detector.SimulateCentralDipole = True ConfigFlags.Detector.SimulateDownstreamDipole = True @@ -74,6 +76,12 @@ if __name__ == "__main__": ConfigFlags.Detector.GeometryDownstreamDipole = True ConfigFlags.GeoModel.Align.Dynamic = False ConfigFlags.Sim.ReleaseGeoModel = False + +# +# Physics list +# + + ConfigFlags.Sim.PhysicsList = "FTFP_BERT" # # All flags should be set before calling lock # @@ -89,8 +97,13 @@ if __name__ == "__main__": pg = PG.ParticleGun() pg.McEventKey = "GEN_EVENT" pg.randomSeed = 123456 - pg.sampler = DIFSampler() +# Next line sets the range of mother particle energies to [0.1 TeV, 0.2 TeV] (default is 1 TeV) +# pg.sampler.mother_sampler.mom.energy = [0.1*TeV, 0.2*TeV] +# Next line sets the range of cylindrical radii to [90 mm, 100 mm] (default is [0, 100 mm]) +# pg.sampler.mother_sampler.pos.rsq = [90**2, 100**2] +# Next line changes the range of z vertex positions to [-1000 mm, -500 mm] (default is [-1500 mm, 0]) +# pg.sampler.mother_sampler.pos.z = [-1000, -500] acc.addEventAlgo(pg, "AthBeginSeq") # to run *before* G4 # # Only one of these two should be used in a given job @@ -108,7 +121,8 @@ if __name__ == "__main__": "McEventCollection#TruthEvent", "McEventCollection#GEN_EVENT", "ScintHitCollection#*", - "FaserSiHitCollection#*" + "FaserSiHitCollection#*", + "CaloHitCollection#*" ], disableEventTag=True)) acc.getEventAlgo("OutputStreamHITS").AcceptAlgs = ["G4FaserAlg"] # optional acc.getEventAlgo("OutputStreamHITS").WritingTool.ProcessingTag = "StreamHITS" # required