ATLAS Offline Software
ParticleGun_FastCalo_ChargeFlip_Config.py
Go to the documentation of this file.
1 #! -*- python -*-
2 evgenConfig.description = "Single particle gun for FastCaloSim event generation"
3 evgenConfig.keywords = ["singleParticle",]
4 evgenConfig.generators = ["ParticleGun"]
5 evgenConfig.contact = ["david.sosa@cern.ch"]
6 
7 import ParticleGun as PG
8 import ROOT
9 
10 class MyParticleSampler(PG.ParticleSampler):
11  def __init__(self,energy,eta,pid,shift_z=0):
12  self.pid = pid
13  self.shift_z = shift_z
14  pdg_table = ROOT.TDatabasePDG.Instance() #Gives values in GeV
15  mass = pdg_table.GetParticle(self.pid()).Mass()*1000.
16  self.mom1 = PG.EEtaMPhiSampler(energy=energy,eta=eta,mass=mass)
17 
18  def shoot(self):
19  pid = self.pid()
20 
21  shift_z = self.shift_z
22 
23  mom = self.mom1.shoot()
24  pos_temp = mom.Vect().Unit()
25 
26  # Would it hit the barrel, or the endcap?
27  if abs(pos_temp.Z())/3550.<pos_temp.Perp()/1148.: # Hit the barrel!
28  pos_temp *= 1148./pos_temp.Perp()
29  else: # Hit the endcap!
30  pos_temp *= 3550./abs(pos_temp.Z())
31 
32  # Shift position of vector in the Z direction
33  pos_temp_2 = ROOT.TVector3()
34  pos_temp_2.SetXYZ(pos_temp.X(), pos_temp.Y(), pos_temp.Z()+shift_z)
35  pos_temp_2 *= 1. / pos_temp_2.Mag(); # reduce magnitude of vector
36 
37  # recalculate; Would it hit the barrel, or the endcap?
38  if abs(pos_temp_2.Z())/3550.<pos_temp_2.Perp()/1148.:
39  pos_temp_2 *= 1148./pos_temp_2.Perp()
40  else:
41  pos_temp_2 *= 3550./abs(pos_temp_2.Z())
42 
43  pos = ROOT.TLorentzVector(pos_temp_2.X(),pos_temp_2.Y(),pos_temp_2.Z(), pos_temp_2.Mag())
44 
45  #print "pid ",pid
46 
47  return [ PG.SampledParticle( pid , mom , pos ) ]
48 
49 myE = float(jofile.split('_E')[1].split('_')[0])
50 myZV = float(jofile.split('_')[-1].split('.py')[0].replace("m","-"))
51 
52 myPDGID = jofile.split('_pid')[1].split('_')[0].replace('n','-')
53 myPDGID = int(float(myPDGID.replace('p','')))
54 
55 eta_li = []
56 
57 if "disj" in jofile:
58  myLowEta1 = 0.01*float(jofile.split('eta_')[1].split('_')[0].replace('m','-'))
59  myLowEta2 = 0.01*float(jofile.split('eta_')[1].split('_')[1].replace('m','-'))
60  myHighEta1 = 0.01*float(jofile.split('eta_')[1].split('_')[2].replace('m','-'))
61  myHighEta2 = 0.01*float(jofile.split('eta_')[1].split('_')[3].replace('m','-'))
62  eta_li.extend([myLowEta1,myLowEta2,myHighEta1,myHighEta2])
63 
64 else:
65  myLowEta = 0.01*float(jofile.split('eta')[1].split('_')[0].replace('m','-'))
66  myHighEta = 0.01*float(jofile.split('eta')[1].split('_')[1].replace('m','-'))
67  eta_li.extend([myLowEta,myHighEta])
68 
69 
70 print "================ SETTTINGS ================="
71 print ("energy = ", myE)
72 print ("eta = ", eta_li)
73 print ("pid = ", myPDGID)
74 print ("shift_z = ", myZV)
75 print "============================================"
76 
77 genSeq += PG.ParticleGun()
78 genSeq.ParticleGun.sampler = MyParticleSampler(energy=myE,eta=eta_li,pid=(myPDGID,myPDGID),shift_z=myZV) #unmixed
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
ParticleGun_FastCalo_ChargeFlip_Config.MyParticleSampler.__init__
def __init__(self, energy, eta, pid, shift_z=0)
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:11
ParticleGun_FastCalo_ChargeFlip_Config.MyParticleSampler.mom1
mom1
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:16
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
ParticleGun_FastCalo_ChargeFlip_Config.MyParticleSampler.shift_z
shift_z
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:13
ParticleGun_FastCalo_ChargeFlip_Config.MyParticleSampler.shoot
def shoot(self)
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:18
ParticleGun_FastCalo_ChargeFlip_Config.MyParticleSampler.pid
pid
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:12
ParticleGun_FastCalo_ChargeFlip_Config.MyParticleSampler
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:10
readCCLHist.float
float
Definition: readCCLHist.py:83
Trk::split
@ split
Definition: LayerMaterialProperties.h:38