Skip to content

Commit

Permalink
Merge pull request cms-sw#313 from jstupak/genVbosonFix2
Browse files Browse the repository at this point in the history
Gen vboson fix2
  • Loading branch information
arizzi committed Jan 29, 2016
2 parents 0054feb + ac1a6c5 commit 1eb40c6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
30 changes: 23 additions & 7 deletions VHbbAnalysis/Heppy/python/VHGeneratorAnalyzer.py
Expand Up @@ -73,7 +73,7 @@ def declareHandles(self):
def beginLoop(self,setup):
super(GeneratorAnalyzer,self).beginLoop(setup)

def fillGenLeptons(self, event, particle, isTau=False, sourceId=25):
def fillGenLeptons(self, event, particle, isTau=False, recovered=False, sourceId=25):
"""Get the gen level light leptons (prompt and/or from tau decays)"""

for i in xrange( particle.numberOfDaughters() ):
Expand All @@ -83,14 +83,24 @@ def fillGenLeptons(self, event, particle, isTau=False, sourceId=25):
id = abs(dau.pdgId())
moid = abs(dau.mother().pdgId()) if dau.mother() else 2212 #if no mom, let say it is a proton (consistent with CMSSW < 74X)
if id in [11,13]:
if isTau: event.gentauleps.append(dau)
else: event.genleps.append(dau)
if not recovered:
if isTau: event.gentauleps.append(dau)
else: event.genleps.append(dau)
else:
if isTau: event.gentaulepsRecovered.append(dau)
else: event.genlepsRecovered.append(dau)
elif id == 15:
if moid in [22,23,24]:
event.gentaus.append(dau)
self.fillGenLeptons(event, dau, True, sourceId)
if not recovered:
if moid in [22,23,24]:
event.gentaus.append(dau)
self.fillGenLeptons(event, dau, True, sourceId)
else:
if moid in [22,23,24]:
event.gentausRecovered.append(dau)
self.fillGenLeptons(event, dau, True, True, sourceId)
elif id in [22,23,24]:
self.fillGenLeptons(event, dau, False, sourceId)
if not recovered: self.fillGenLeptons(event, dau, False, sourceId)
else: self.fillGenLeptons(event, dau, False, True, sourceId)

def fillWZQuarks(self, event, particle, isWZ=False, sourceId=25):
"""Descend daughters of 'particle', and add quarks from W,Z to event.genwzquarks
Expand Down Expand Up @@ -175,6 +185,9 @@ def makeMCInfo(self, event):
event.genleps = []
event.gentauleps = []
event.gentaus = []
event.genlepsRecovered = []
event.gentaulepsRecovered = []
event.gentausRecovered = []
event.genbquarksFromTop = []
event.genbquarksFromH = []
event.genbquarksFromHafterISR = []
Expand Down Expand Up @@ -211,6 +224,9 @@ def makeMCInfo(self, event):
self.fillGenLeptons(event, b, sourceId=abs(b.pdgId())) #selezione su leptoni fatta dentro la funzione stessa
self.fillWZQuarks(event, b, isWZ=True, sourceId=abs(b.pdgId()))

for b in event.genvbosonsRecovered:
if b.numberOfDaughters()>0 :
self.fillGenLeptons(event, b, recovered=True, sourceId=abs(b.pdgId()))


higgsBosons = [ p for p in event.genParticles if (p.pdgId() == 25) and p.numberOfDaughters() > 0 and abs(p.daughter(0).pdgId()) != 25 ]
Expand Down
5 changes: 4 additions & 1 deletion VHbbAnalysis/Heppy/test/vhbb.py
Expand Up @@ -124,9 +124,12 @@
"genbquarksFromHafterISR" : NTupleCollection("GenBQuarkFromHafterISR", genParticleType, 4, help="Generated bottom quarks from Higgs decays"),
"genwzquarks" : NTupleCollection("GenWZQuark", genParticleType, 6, help="Generated quarks from W/Z decays"),
"genleps" : NTupleCollection("GenLep", genParticleType, 4, help="Generated leptons from W/Z decays"),
"gentauleps" : NTupleCollection("GenTaus", genParticleType, 4, help="Generated taus"),
"gentaus" : NTupleCollection("GenTaus", genParticleType, 4, help="Generated taus"),
"genlepsRecovered" : NTupleCollection("GenLepRecovered", genParticleType, 4, help="Generated leptons from recovered W/Z decays"),
"gentausRecovered" : NTupleCollection("GenTausRecovered", genParticleType, 4, help="Generated taus from recovered W/Z decays"),
"genlepsFromTop" : NTupleCollection("GenLepFromTop", genParticleType, 4, help="Generated leptons from t->W decays"),
"gentauleps" : NTupleCollection("GenLepFromTau", genParticleType, 6, help="Generated leptons from decays of taus from W/Z decays"),
"gentaulepsRecovered" : NTupleCollection("GenLepFromTauRecovered", genParticleType, 6, help="Generated leptons from decays of taus from recovered W/Z decays"),
"genHiggsBosons" : NTupleCollection("GenHiggsBoson", genParticleType, 4, help="Generated Higgs boson "),
#"genZbosonsToLL" : NTupleCollection("GenZbosonsToLL", genParticleType, 6, help="Generated W or Z bosons decaying to LL"),
#"genWbosonsToLL" : NTupleCollection("GenWbosonsToLL", genParticleType, 6, help="Generated W or Z bosons decaying to LL"),
Expand Down

0 comments on commit 1eb40c6

Please sign in to comment.