CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
genutils Namespace Reference

Functions

def allDaughters
 
def bosonToX
 
def findStatus1Leptons
 
def isNotFromHadronicShower
 
def isNotHadronicId
 
def isPromptLepton
 
def realGenDaughters
 
def realGenMothers
 

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 
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 
def allDaughters
Definition: genutils.py:19
def genutils.bosonToX (   particles,
  bosonType,
  xType 
)

Definition at line 31 of file genutils.py.

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

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

65 
67  for x in xrange(l.numberOfMothers()):
68  mom = l.mother(x)
69  if mom.status() > 2: return True
70  id = abs(mom.pdgId())
71  if id > 100: return False
72  if id < 6: return False
73  if id == 21: return False
74  if id in [11,13,15]: return isNotFromHadronicShower(mom)
75  if id >= 22 and id <= 39: return True
76  return True
def isNotFromHadronicShower
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 
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
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
def isNotHadronicId
Definition: genutils.py:43
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 
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 
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
def isNotHadronicId
Definition: genutils.py:43
def isPromptLepton
Definition: genutils.py:49
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 77 of file genutils.py.

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

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

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

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