CMS 3D CMS Logo

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

Functions

def allDaughters
 
def bosonToX
 
def findStatus1Leptons
 
def isNotFromHadronicShower
 
def isNotHadronicId
 
def isPromptLepton
 
def lastGenCopy
 
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 20 of file genutils.py.

References sistrip::SpyUtilities.range().

Referenced by bosonToX().

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

Definition at line 32 of file genutils.py.

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

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

Definition at line 5 of file genutils.py.

References funct.abs(), and sistrip::SpyUtilities.range().

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

Definition at line 66 of file genutils.py.

References funct.abs(), and sistrip::SpyUtilities.range().

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

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

Definition at line 44 of file genutils.py.

References funct.abs().

Referenced by isPromptLepton().

44 
45 def isNotHadronicId(pdgId,includeSMLeptons=True):
46  if abs(pdgId) in [11,12,13,14,15,16]:
47  return includeSMLeptons
48  i = (abs(pdgId) % 1000)
49  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:44
def genutils.isPromptLepton (   lepton,
  beforeFSR,
  includeMotherless = True,
  includeTauDecays = False 
)

Definition at line 50 of file genutils.py.

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

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

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

Definition at line 112 of file genutils.py.

References sistrip::SpyUtilities.range().

113 def lastGenCopy(gp):
114  me = gp.pdgId();
115  for i in range(gp.numberOfDaughters()):
116  if gp.daughter(i).pdgId() == me:
117  return False
118  return True
119 
120 
def lastGenCopy
Definition: genutils.py:112
const uint16_t range(const Frame &aFrame)
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.

References sistrip::SpyUtilities.range().

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

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

References sistrip::SpyUtilities.range().

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

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