Skip to content

Commit

Permalink
Merge pull request #12 from arizzi/vhbbHeppy722patch2
Browse files Browse the repository at this point in the history
new VHbb stuff
  • Loading branch information
arizzi committed Feb 28, 2015
2 parents 0f4003a + 79c7176 commit 4342cdf
Show file tree
Hide file tree
Showing 6 changed files with 11,917 additions and 233 deletions.
27 changes: 26 additions & 1 deletion VHbbAnalysis/Heppy/python/AdditionalBTag.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,28 @@
from math import *
import itertools
import ROOT
import array
class AdditionalBTag( Analyzer ):

def declareHandles(self):
super(AdditionalBTag, self).declareHandles()
self.handles['btag'] = AutoHandle( ("combinedInclusiveSecondaryVertexV2BJetTags","","EX"), "edm::AssociationVector<edm::RefToBaseProd<reco::Jet>,vector<float>,edm::RefToBase<reco::Jet>,unsigned int,edm::helper::AssociationIdenticalKeyReference>")
self.handles['btagcsv'] = AutoHandle( ("combinedSecondaryVertexBJetTags","","EX"), "edm::AssociationVector<edm::RefToBaseProd<reco::Jet>,vector<float>,edm::RefToBase<reco::Jet>,unsigned int,edm::helper::AssociationIdenticalKeyReference>")

reader = ROOT.TMVA.Reader()
self.Jet_btagCSV = array.array('f',[0])
self.Jet_btagCMVA = array.array('f',[0])
self.Jet_btagProb = array.array('f',[0])
self.Jet_btagBProb = array.array('f',[0])
self.Jet_pt = array.array('f',[0])
self.Jet_eta = array.array('f',[0])
reader.AddVariable("Jet_btagCSV",self.Jet_btagCSV)
reader.AddVariable("Jet_btagCMVA",self.Jet_btagCMVA)
reader.AddVariable("Jet_btagProb",self.Jet_btagProb)
reader.AddVariable("Jet_btagBProb",self.Jet_btagBProb)
reader.AddSpectator("Jet_pt",self.Jet_pt)
reader.AddSpectator("Jet_eta",self.Jet_eta)
reader.BookMVA("BDT","TMVAClassification_BDT.weights.xml")
self.reader=reader
def addNewBTag(self,event):
newtags = self.handles['btag'].product()
for i in xrange(0,len(newtags)) :
Expand All @@ -26,8 +41,18 @@ def addNewBTag(self,event):


def process(self, event):

self.readCollections( event.input )
self.addNewBTag(event)
for j in event.cleanJets :
self.Jet_btagCSV[0]=j.btag('combinedInclusiveSecondaryVertexV2BJetTags')
self.Jet_btagCMVA[0]=j.btag('combinedMVABJetTags')
self.Jet_btagProb[0]=j.btag('jetProbabilityBJetTags')
self.Jet_btagBProb[0]=j.btag('jetBProbabilityBJetTags')
self.Jet_pt[0] = j.pt()
self.Jet_eta[0] = j.eta()
j.btagBDT = self.reader.EvaluateMVA("BDT")
# print self.Jet_btagCSV, self.Jet_btagCMVA, self.Jet_btagProb, self.Jet_btagBProb, self.Jet_pt, self.Jet_eta,j.btagBDT
return True


12 changes: 7 additions & 5 deletions VHbbAnalysis/Heppy/python/vhbbobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import ROOT
#from CMGTools.TTHAnalysis.signedSip import *
from PhysicsTools.Heppy.analyzers.objects.autophobj import *

import copy


leptonTypeVHbb = NTupleObjectType("leptonTypeVHbb", baseObjectTypes = [ leptonType ], variables = [
Expand Down Expand Up @@ -47,8 +47,9 @@

jetTypeVHbb = NTupleObjectType("jet", baseObjectTypes = [ jetType ], variables = [
NTupleVariable("hadronFlavour", lambda x : x.mcFlavour, int, mcOnly=True, help="match to heavy hadrons"),
NTupleVariable("btagProb", lambda x : x.btag('jetProbabilityBJetTags') , help="btag of nearest jet"),
NTupleVariable("btagBProb", lambda x : x.btag('jetBProbabilityBJetTags') , help="btag of nearest jet"),
NTupleVariable("btagBDT", lambda x : getattr(x,"btagBDT",-99), help="btag"),
NTupleVariable("btagProb", lambda x : x.btag('jetProbabilityBJetTags') , help="btag"),
NTupleVariable("btagBProb", lambda x : x.btag('jetBProbabilityBJetTags') , help="btag"),
NTupleVariable("btagnew", lambda x : getattr(x,"btagnew",-2), help="newest btag discriminator"),
NTupleVariable("btagCSVV0", lambda x : getattr(x,"btagcsv",-2), help="should be the old CSV discriminator"),
# NTupleVariable("mcMatchId", lambda x : x.mcMatchId, int, mcOnly=True, help="Match to source from hard scatter (25 for H, 6 for t, 23/24 for W/Z)"),
Expand Down Expand Up @@ -121,8 +122,9 @@
NTupleVariable("jetPt", lambda x : x.jet.pt() if x.jet != None else 0, help="Jet: pT"),
NTupleVariable("jetBTag", lambda x : x.jet.btag('combinedSecondaryVertexBJetTags') if x.jet != None else -99, help="CSV b-tag of associated jet"),
])


shiftedMetType= NTupleObjectType("shiftedMetType", baseObjectTypes=[twoVectorType], variables=[
NTupleVariable("sumEt", lambda x : x.sumEt() ),
])

def ptRel(p4,axis):
a=ROOT.TVector3(axis.Vect().X(),axis.Vect().Y(),axis.Vect().Z())
Expand Down
Loading

0 comments on commit 4342cdf

Please sign in to comment.