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

Fix DIF decay position and typo in Calo code

parent 175be27d
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
......@@ -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).
......@@ -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)
......
......@@ -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
......
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