CMS 3D CMS Logo

Functions
genutils Namespace Reference

Functions

def allDaughters (particle, daughters, rank)
 
def bosonToX (particles, bosonType, xType)
 
def findStatus1Leptons (particle)
 
def isNotFromHadronicShower (l)
 
def isNotHadronicId (pdgId, includeSMLeptons=True)
 
def isPromptLepton (lepton, beforeFSR, includeMotherless=True, includeTauDecays=False)
 
def lastGenCopy (gp)
 
def realGenDaughters (gp, excludeRadiation=True)
 
def realGenMothers (gp)
 

Function Documentation

◆ allDaughters()

def genutils.allDaughters (   particle,
  daughters,
  rank 
)
Fills daughters with all the daughters of particle.
Recursive function.

Definition at line 20 of file genutils.py.

20 def allDaughters(particle, daughters, rank ):
21  '''Fills daughters with all the daughters of particle.
22  Recursive function.'''
23  rank += 1
24  for i in range( particle.numberOfDaughters() ):
25  dau = GenParticle(particle.daughter(i))
26  dau.rank = rank
27  daughters.append( dau )
28  daughters = allDaughters( dau, daughters, rank )
29  return daughters
30 
31 

References FastTimerService_cff.range.

Referenced by bosonToX().

◆ bosonToX()

def genutils.bosonToX (   particles,
  bosonType,
  xType 
)

Definition at line 32 of file genutils.py.

32 def bosonToX(particles, bosonType, xType):
33  bosons = [x for x in particles if x.status()==3 and x.pdgId()==bosonType]
34  daughters = []
35  if len(bosons)==0:
36  return [], False
37  boson = bosons[0]
38  daus = []
39  allDaughters( boson, daus, 0)
40  xDaus = [x for x in daus if x.status()==3 and abs(x.pdgId())==xType]
41  # print printOut(xDaus)
42  return xDaus, True
43 

References funct.abs(), and allDaughters().

◆ findStatus1Leptons()

def genutils.findStatus1Leptons (   particle)
Returns status 1 e and mu among the particle daughters

Definition at line 5 of file genutils.py.

5 def findStatus1Leptons(particle):
6  '''Returns status 1 e and mu among the particle daughters'''
7  leptons = []
8  for i in range( particle.numberOfDaughters() ):
9  dau = particle.daughter(i)
10  if dau.status() == 1:
11  if abs(dau.pdgId())==11 or abs(dau.pdgId())==13:
12  leptons.append( dau )
13  else:
14  continue
15  else:
16  leptons = findStatus1Leptons( dau, leptons )
17  return leptons
18 
19 

References funct.abs(), and FastTimerService_cff.range.

◆ isNotFromHadronicShower()

def genutils.isNotFromHadronicShower (   l)

Definition at line 66 of file genutils.py.

67  for x in range(l.numberOfMothers()):
68  mom = l.mother(x)
69  if mom.status() > 2: return True
70  id = abs(mom.pdgId())
71  if id > 1000000: return True
72  if id > 100: return False
73  if id < 6: return False
74  if id == 21: return False
75  if id in [11,12,13,14,15,16]:
76  if l.status() > 2: return True
77  return isNotFromHadronicShower(mom)
78  if id >= 22 and id <= 39: return True
79  return True
80 

References funct.abs(), and FastTimerService_cff.range.

Referenced by gen.GeneratorAnalyzer.GeneratorAnalyzer.makeMCInfo().

◆ isNotHadronicId()

def genutils.isNotHadronicId (   pdgId,
  includeSMLeptons = True 
)

Definition at line 44 of file genutils.py.

44 def isNotHadronicId(pdgId,includeSMLeptons=True):
45  if abs(pdgId) in [11,12,13,14,15,16]:
46  return includeSMLeptons
47  i = (abs(pdgId) % 1000)
48  return i > 10 and i != 21 and i < 100
49 

References funct.abs().

Referenced by isPromptLepton().

◆ isPromptLepton()

def genutils.isPromptLepton (   lepton,
  beforeFSR,
  includeMotherless = True,
  includeTauDecays = False 
)

Definition at line 50 of file genutils.py.

50 def isPromptLepton(lepton, beforeFSR, includeMotherless=True, includeTauDecays=False):
51  if abs(lepton.pdgId()) not in [11,13,15]:
52  return False
53  if lepton.numberOfMothers() == 0:
54  return includeMotherless;
55  mom = lepton.mother()
56  if mom.pdgId() == lepton.pdgId():
57  if beforeFSR: return False
58  return isPromptLepton(mom, beforeFSR, includeMotherless, includeTauDecays)
59  elif abs(mom.pdgId()) == 15:
60  if not includeTauDecays: return False
61  return isPromptLepton(mom, beforeFSR, includeMotherless, includeTauDecays)
62  else:
63  return isNotHadronicId(mom.pdgId(), includeSMLeptons=False)
64 
65 

References funct.abs(), and isNotHadronicId().

Referenced by objects.LeptonAnalyzer.LeptonAnalyzer.matchAnyLeptons().

◆ lastGenCopy()

def genutils.lastGenCopy (   gp)

Definition at line 112 of file genutils.py.

112 def lastGenCopy(gp):
113  me = gp.pdgId();
114  for i in range(gp.numberOfDaughters()):
115  if gp.daughter(i).pdgId() == me:
116  return False
117  return True
118 
119 

References EgammaValidation_cff.pdgId, and FastTimerService_cff.range.

◆ realGenDaughters()

def genutils.realGenDaughters (   gp,
  excludeRadiation = True 
)
Get the daughters of a particle, going through radiative X -> X' + a
   decays, either including or excluding the radiation among the daughters
   e.g. for  
              X -> X' + a, X' -> b c 
       realGenDaughters(X, excludeRadiation=True)  = { b, c }
       realGenDaughters(X, excludeRadiation=False) = { a, b, c }

Definition at line 81 of file genutils.py.

81 def realGenDaughters(gp,excludeRadiation=True):
82  """Get the daughters of a particle, going through radiative X -> X' + a
83  decays, either including or excluding the radiation among the daughters
84  e.g. for
85  X -> X' + a, X' -> b c
86  realGenDaughters(X, excludeRadiation=True) = { b, c }
87  realGenDaughters(X, excludeRadiation=False) = { a, b, c }"""
88  ret = []
89  for i in range(gp.numberOfDaughters()):
90  dau = gp.daughter(i)
91  if dau.pdgId() == gp.pdgId():
92  if excludeRadiation:
93  return realGenDaughters(dau)
94  else:
95  ret += realGenDaughters(dau)
96  else:
97  ret.append(dau)
98  return ret
99 

References FastTimerService_cff.range.

Referenced by gen.GeneratorAnalyzer.GeneratorAnalyzer.makeMCInfo().

◆ realGenMothers()

def genutils.realGenMothers (   gp)
Get the mothers of a particle X going through intermediate X -> X' chains.
   e.g. if Y -> X, X -> X' realGenMothers(X') = Y

Definition at line 100 of file genutils.py.

100 def realGenMothers(gp):
101  """Get the mothers of a particle X going through intermediate X -> X' chains.
102  e.g. if Y -> X, X -> X' realGenMothers(X') = Y"""
103  ret = []
104  for i in range(gp.numberOfMothers()):
105  mom = gp.mother(i)
106  if mom.pdgId() == gp.pdgId():
107  ret += realGenMothers(mom)
108  else:
109  ret.append(mom)
110  return ret
111 

References FastTimerService_cff.range.

Referenced by gen.GeneratorAnalyzer.GeneratorAnalyzer.makeMCInfo().

genutils.bosonToX
def bosonToX(particles, bosonType, xType)
Definition: genutils.py:32
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
genutils.lastGenCopy
def lastGenCopy(gp)
Definition: genutils.py:112
GenParticle
Definition: GenParticle.py:1
genutils.realGenMothers
def realGenMothers(gp)
Definition: genutils.py:100
genutils.findStatus1Leptons
def findStatus1Leptons(particle)
Definition: genutils.py:5
EgammaValidation_cff.pdgId
pdgId
Definition: EgammaValidation_cff.py:118
genutils.allDaughters
def allDaughters(particle, daughters, rank)
Definition: genutils.py:20
genutils.isNotFromHadronicShower
def isNotFromHadronicShower(l)
Definition: genutils.py:66
genutils.realGenDaughters
def realGenDaughters(gp, excludeRadiation=True)
Definition: genutils.py:81
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
genutils.isPromptLepton
def isPromptLepton(lepton, beforeFSR, includeMotherless=True, includeTauDecays=False)
Definition: genutils.py:50
genutils.isNotHadronicId
def isNotHadronicId(pdgId, includeSMLeptons=True)
Definition: genutils.py:44