ATLAS Offline Software
ParticleGun_egammaET.py
Go to the documentation of this file.
1 __doc__ = "Holds a 4-momentum sampler according to the egamma Et spectrum"
2 
3 import ParticleGun as PG
4 from GaudiKernel.SystemOfUnits import GeV
5 
6 def dbnFermiDirac(x,mu,kT):
7  import math
8  arg = (x-mu)/kT
9  if arg < -20 : # avoid numerical underflows
10  result = 1
11  elif arg > 20 : # avoid numerical overflows
12  result = 0
13  else :
14  div = math.exp(arg)+1
15  result = 1/div
16  return result
17 
18 class egammaETSampler(PG.PtEtaMPhiSampler):
19  "4-momentum sampler according to the egamma Et spectrum."
20  def __init__(self, pid, eta=[-2.5, 2.5], phi=[0, PG.TWOPI],
21  mu1 = 0.5, kT1 = 0.1, mu2 = 200, kT2 = 20, y0 = 0.005, PtMin = 0 , PtMax = 3e3, nBins=None):
22  """
23  Parameters for the MVA-shaped spectrum : higher density in the < 100 GeV range
24  PtMin = 0 # minimum Pt
25  PtMax = 3000 # maximum Pt (3 TeV)
26  nBins # number of bins (one every 100 MeV by default)
27  mu1 = 0.5 # mu1,kT1 : smooth but steep ramp-up from 0 to 1 GeV (requested by TauCP)
28  kT1 = 0.1
29  mu2 = 200 # mu2,kT2 : smooth, slow ramp-down in the 100-300 GeV range
30  kT2 = 20
31  y0 = 0.005 # y0 : baseline for low-density at high ET up to PtMax
32  """
33  self.m = PG.MASSES[abs(pid)]
34  self.eta = eta
35  self.phi = phi
36 
37  # Create and fill a very fine-grained histogram
38  from ROOT import TH1D
39  etSpectrumFullRange = TH1D("ETSpectrumFullRange",
40  "Reference ET spectrum for egamma MVA calib",
41  int(nBins or (PtMax - PtMin)*10), PtMin , PtMax)
42  for i in xrange(etSpectrumFullRange.GetNbinsX()):
43  x = etSpectrumFullRange.GetBinCenter(i+1)
44  y1 = dbnFermiDirac(x,mu1,kT1)
45  y2 = dbnFermiDirac(x,mu2,kT2)
46  y = y0 - y1 + y2
47  etSpectrumFullRange.SetBinContent(i+1,y)
48  self.hist = PG.TH1(etSpectrumFullRange) #< wrap *after* populating
49 
50  def pt(self):
51  return self.hist.GetRandom() * GeV
xrange
void xrange(TH1 *h, bool symmetric)
Definition: computils.cxx:516
ParticleGun_egammaET.egammaETSampler.__init__
def __init__(self, pid, eta=[-2.5, 2.5], phi=[0, PG.TWOPI], mu1=0.5, kT1=0.1, mu2=200, kT2=20, y0=0.005, PtMin=0, PtMax=3e3, nBins=None)
Definition: ParticleGun_egammaET.py:20
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
ParticleGun_egammaET.egammaETSampler.hist
hist
Definition: ParticleGun_egammaET.py:47
ParticleGun_egammaET.egammaETSampler
Definition: ParticleGun_egammaET.py:18
ParticleGun_egammaET.egammaETSampler.eta
eta
Definition: ParticleGun_egammaET.py:33
ParticleGun_egammaET.egammaETSampler.phi
phi
Definition: ParticleGun_egammaET.py:34
ParticleGun_egammaET.egammaETSampler.m
m
Definition: ParticleGun_egammaET.py:32
ParticleGun_egammaET.dbnFermiDirac
def dbnFermiDirac(x, mu, kT)
Definition: ParticleGun_egammaET.py:6
ParticleGun_egammaET.egammaETSampler.pt
def pt(self)
Definition: ParticleGun_egammaET.py:50