forked from cms-sw/cmssw
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request cms-sw#50 from arizzi/tauvhbb
Tauvhbb
- Loading branch information
Showing
9 changed files
with
244 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
|
||
from PhysicsTools.Heppy.analyzers.core.Analyzer import Analyzer | ||
from PhysicsTools.HeppyCore.framework.event import Event | ||
from PhysicsTools.Heppy.analyzers.core.AutoHandle import AutoHandle | ||
from PhysicsTools.Heppy.physicsobjects.PhysicsObjects import GenParticle | ||
|
||
from PhysicsTools.Heppy.physicsutils.genutils import * | ||
import PhysicsTools.HeppyCore.framework.config as cfg | ||
|
||
from VHbbAnalysis.Heppy.genTauDecayMode import genTauDecayMode | ||
|
||
class TauGenJetAnalyzer( Analyzer ): | ||
"""Determine generator level tau decay mode.""" | ||
|
||
def __init__(self, cfg_ana, cfg_comp, looperName ): | ||
super(TauGenJetAnalyzer,self).__init__(cfg_ana,cfg_comp,looperName) | ||
|
||
#--------------------------------------------- | ||
# DECLARATION OF HANDLES OF GEN LEVEL OBJECTS | ||
#--------------------------------------------- | ||
|
||
def declareHandles(self): | ||
super(TauGenJetAnalyzer, self).declareHandles() | ||
|
||
#mc information | ||
self.mchandles['tauGenJetsSelectorAllHadrons'] = AutoHandle( 'tauGenJetsSelectorAllHadrons', | ||
'vector<reco::GenJet>' ) | ||
|
||
def beginLoop(self,setup): | ||
super(TauGenJetAnalyzer,self).beginLoop(setup) | ||
|
||
def makeMCInfo(self, event): | ||
event.tauGenJets = [] | ||
tauGenJets = list(self.mchandles['tauGenJetsSelectorAllHadrons'].product() ) | ||
for tauGenJet in tauGenJets: | ||
tauGenJet.decayMode = genTauDecayMode(tauGenJet)[0] | ||
event.tauGenJets.append(tauGenJet) | ||
|
||
def process(self, event): | ||
self.readCollections(event.input) | ||
|
||
# if not MC, nothing to do | ||
if not self.cfg_comp.isMC: | ||
return True | ||
|
||
# do MC level analysis | ||
self.makeMCInfo(event) | ||
|
||
return True | ||
|
||
setattr(TauGenJetAnalyzer, "defaultConfig", cfg.Analyzer( | ||
class_object = TauGenJetAnalyzer, | ||
verbose = False, | ||
)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
|
||
#-------------------------------------------------------------------------------- | ||
# Auxiliary function to determine generator level tau decay mode. | ||
# | ||
# The function corresponds to a translation of | ||
# PhysicsTools/JetMCUtils/src/JetMCTag.cc | ||
# to python. | ||
# | ||
# author: Christian Veelken, NICPB Tallinn | ||
#-------------------------------------------------------------------------------- | ||
|
||
def genTauDecayMode(tau): | ||
|
||
numElectrons = 0 | ||
numMuons = 0 | ||
numChargedHadrons = 0 | ||
numNeutralHadrons = 0 | ||
numPhotons = 0 | ||
|
||
daughters = tau.daughterPtrVector(); | ||
for daughter in daughters: | ||
pdg_id = abs(daughter.pdgId()) | ||
if pdg_id == 22: | ||
numPhotons = numPhotons + 1 | ||
elif pdg_id == 11: | ||
numElectrons = numElectrons + 1 | ||
elif pdg_id == 13: | ||
numMuons = numMuons + 1 | ||
elif abs(daughter.charge()) > 0.5: | ||
numChargedHadrons = numChargedHadrons + 1 | ||
else: | ||
numNeutralHadrons = numNeutralHadrons + 1 | ||
|
||
##print "<genTauDecayMode>: numChargedHadrons = %i, numNeutralHadrons = %i, numPhotons = %i" % (numChargedHadrons, numNeutralHadrons, numPhotons) | ||
|
||
if numElectrons == 1: | ||
return ( 0, "electron" ) | ||
elif numMuons == 1: | ||
return ( 1, "muon" ) | ||
elif numChargedHadrons == 1: | ||
if numNeutralHadrons != 0: | ||
return ( 5, "oneProngOther" ) | ||
elif numPhotons == 0: | ||
return ( 2, "oneProng0Pi0" ) | ||
elif numPhotons == 2: | ||
return ( 3, "oneProng1Pi0" ) | ||
elif numPhotons == 4: | ||
return ( 4, "oneProng2Pi0" ) | ||
else: | ||
return ( 5, "oneProngOther" ) | ||
elif numChargedHadrons == 3: | ||
if numNeutralHadrons != 0: | ||
return ( 8, "threeProngOther" ) | ||
elif numPhotons == 0: | ||
return ( 6, "threeProng0Pi0" ) | ||
elif numPhotons == 2: | ||
return ( 7, "threeProng1Pi0" ) | ||
else: | ||
return ( 8, "threeProngOther" ) | ||
return ( 9, "rare" ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.