CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

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

Definition at line 19 of file genutils.py.

Referenced by bosonToX().

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

Definition at line 31 of file genutils.py.

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

31 def bosonToX(particles, bosonType, xType):
32  bosons = filter(lambda x: x.status()==3 and x.pdgId()==bosonType, particles)
33  daughters = []
34  if len(bosons)==0:
35  return [], False
36  boson = bosons[0]
37  daus = []
38  allDaughters( boson, daus, 0)
39  xDaus = filter(lambda x: x.status()==3 and abs(x.pdgId())==xType, daus)
40  # print printOut(xDaus)
41  return xDaus, True
42 
def bosonToX(particles, bosonType, xType)
Definition: genutils.py:31
def allDaughters(particle, daughters, rank)
Definition: genutils.py:19
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
def genutils.findStatus1Leptons (   particle)
Returns status 1 e and mu among the particle daughters

Definition at line 4 of file genutils.py.

References funct.abs().

4 def findStatus1Leptons(particle):
5  '''Returns status 1 e and mu among the particle daughters'''
6  leptons = []
7  for i in range( particle.numberOfDaughters() ):
8  dau = particle.daughter(i)
9  if dau.status() == 1:
10  if abs(dau.pdgId())==11 or abs(dau.pdgId())==13:
11  leptons.append( dau )
12  else:
13  continue
14  else:
15  leptons = findStatus1Leptons( dau, leptons )
16  return leptons
17 
18 
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
def findStatus1Leptons(particle)
Definition: genutils.py:4
def genutils.isNotFromHadronicShower (   l)

Definition at line 65 of file genutils.py.

References funct.abs().

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

66  for x in xrange(l.numberOfMothers()):
67  mom = l.mother(x)
68  if mom.status() > 2: return True
69  id = abs(mom.pdgId())
70  if id > 1000000: return True
71  if id > 100: return False
72  if id < 6: return False
73  if id == 21: return False
74  if id in [11,12,13,14,15,16]:
75  if l.status() > 2: return True
76  return isNotFromHadronicShower(mom)
77  if id >= 22 and id <= 39: return True
78  return True
79 
def isNotFromHadronicShower(l)
Definition: genutils.py:65
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
def genutils.isNotHadronicId (   pdgId,
  includeSMLeptons = True 
)

Definition at line 43 of file genutils.py.

References funct.abs().

Referenced by isPromptLepton().

43 def isNotHadronicId(pdgId,includeSMLeptons=True):
44  if abs(pdgId) in [11,12,13,14,15,16]:
45  return includeSMLeptons
46  i = (abs(pdgId) % 1000)
47  return i > 10 and i != 21 and i < 100
48 
def isNotHadronicId(pdgId, includeSMLeptons=True)
Definition: genutils.py:43
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
def genutils.isPromptLepton (   lepton,
  beforeFSR,
  includeMotherless = True,
  includeTauDecays = False 
)

Definition at line 49 of file genutils.py.

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

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

49 def isPromptLepton(lepton, beforeFSR, includeMotherless=True, includeTauDecays=False):
50  if abs(lepton.pdgId()) not in [11,13,15]:
51  return False
52  if lepton.numberOfMothers() == 0:
53  return includeMotherless;
54  mom = lepton.mother()
55  if mom.pdgId() == lepton.pdgId():
56  if beforeFSR: return False
57  return isPromptLepton(mom, beforeFSR, includeMotherless, includeTauDecays)
58  elif abs(mom.pdgId()) == 15:
59  if not includeTauDecays: return False
60  return isPromptLepton(mom, beforeFSR, includeMotherless, includeTauDecays)
61  else:
62  return isNotHadronicId(mom.pdgId(), includeSMLeptons=False)
63 
64 
def isPromptLepton(lepton, beforeFSR, includeMotherless=True, includeTauDecays=False)
Definition: genutils.py:49
def isNotHadronicId(pdgId, includeSMLeptons=True)
Definition: genutils.py:43
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
def genutils.lastGenCopy (   gp)

Definition at line 111 of file genutils.py.

References common_cff.pdgId.

111 def lastGenCopy(gp):
112  me = gp.pdgId();
113  for i in xrange(gp.numberOfDaughters()):
114  if gp.daughter(i).pdgId() == me:
115  return False
116  return True
117 
118 
119 
def lastGenCopy(gp)
Definition: genutils.py:111
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 80 of file genutils.py.

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

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

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

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