Skip to content

Commit

Permalink
Merge pull request cms-sw#26 from arizzi/vhbbHeppy722patch2-qgl
Browse files Browse the repository at this point in the history
Adding QGL and (disabled) softactivity for VBF
  • Loading branch information
arizzi committed Mar 2, 2015
2 parents 818ca3d + 3e0ddd4 commit d79bfb6
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 11 deletions.
3 changes: 2 additions & 1 deletion PhysicsTools/Heppy/python/analyzers/objects/JetAnalyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ def __init__(self, cfg_ana, cfg_comp, looperName):
self.lepPtMin = getattr(self.cfg_ana, 'minLepPt', -1)
self.jetGammaDR = getattr(self.cfg_ana, 'jetGammaDR', 0.4)
if(self.cfg_ana.doQG):
self.qglcalc = QGLikelihoodCalculator("/afs/cern.ch/user/t/tomc/public/qgTagger/QGLikelihoodDBFiles/QGL_v1a/pdfQG_AK4chs_antib_13TeV_v1.root")
qgdefname="/afs/cern.ch/user/t/tomc/public/qgTagger/QGLikelihoodDBFiles/QGL_v1a/pdfQG_AK4chs_antib_13TeV_v1.root"
self.qglcalc = QGLikelihoodCalculator(getattr(self.cfg_ana,"QGpath",qgdefname))

def declareHandles(self):
super(JetAnalyzer, self).declareHandles()
Expand Down
29 changes: 25 additions & 4 deletions VHbbAnalysis/Heppy/python/VHbbAnalyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class VHbbAnalyzer( Analyzer ):

def declareHandles(self):
super(VHbbAnalyzer, self).declareHandles()
# self.handles['pfCands'] = AutoHandle( 'packedPFCandidates', 'std::vector<pat::PackedCandidate>' )
if getattr(self.cfg_ana,"doSoftActivity", False) :
self.handles['pfCands'] = AutoHandle( 'packedPFCandidates', 'std::vector<pat::PackedCandidate>' )
# self.handles['jee'] = AutoHandle( 'ak5PFJetsCHS', 'std::vector<reco::PFJet>' )
#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>")
Expand All @@ -47,7 +48,26 @@ def beginLoop(self,setup):
if "outputfile" in setup.services :
setup.services["outputfile"].file.cd()
self.inputCounter = ROOT.TH1F("Count","Count",1,0,2)


def doSoftActivity(self,event) :
event.pfCands = list(self.handles['pfCands'].product())
inputs=ROOT.std.vector(ROOT.heppy.ReclusterJets.LorentzVector)()
used=[]
for j in event.jetsForHiggs :
used.extend(j.daughterPtrVector())
#print "used",len(used)
remainingPF = [x for x in event.pfCands if x.charge() != 0 and x.fromPV() >=2 and x not in used]
#print "remain",len(remainingPF)
etaMin = min(event.jetsForHiggs,key=lambda x:x.eta()).eta()+0.4
etaMax = max(event.jetsForHiggs,key=lambda x:x.eta()).eta()-0.4
for pf in remainingPF :
#FIXME: add ellipses veto
if pf.eta() > etaMin and pf.eta() < etaMax:
inputs.push_back(pf.p4())
clusterizer=ROOT.heppy.ReclusterJets(inputs,-1,0.1)
event.softActivityJets = list(clusterizer.getGrouping(1))[:5]
for j in event.softActivityJets :
print j.eta(),j.pt()
def makeJets(self,event,b):
inputs=ROOT.std.vector(ROOT.heppy.ReclusterJets.LorentzVector)()
event.pfCands = list(self.handles['pfCands'].product())
Expand Down Expand Up @@ -257,7 +277,7 @@ def initOutputs (self,event) :
event.minDr3=-1
event.V.goodMt=0
event.hjidxDiJetPtByCSV = []

event.softActivityJets=[]
def process(self, event):
self.readCollections( event.input )
self.inputCounter.Fill(1)
Expand All @@ -282,7 +302,8 @@ def process(self, event):
self.doHiggsHighPt(event)
self.doHiggs3cj(event)
self.fillTauIndices(event)

if getattr(self.cfg_ana,"doSoftActivity", False) :
self.doSoftActivity(event)

# event.jee = list(self.handles['jee'].product())
#for j in list(jets)[0:3]:
Expand Down
7 changes: 6 additions & 1 deletion VHbbAnalysis/Heppy/python/vhbbobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,13 @@
NTupleVariable("vtx3DSig", lambda x : x.userFloat("vtx3DSig"), mcOnly=False, help="decay len significance of vertex from btag"),
NTupleVariable("vtx3DVal", lambda x : x.userFloat("vtx3DVal"), mcOnly=False, help="decay len of vertex from btag"),
NTupleVariable("vtxPosX", lambda x : x.userFloat("vtxPosX"), mcOnly=False, help="X coord of vertex from btag"),
NTupleVariable("vtxPosY", lambda x : x.userFloat("vtxPosY"), mcOnly=False, help="Y coord of vertex from btag"),
NTupleVariable("vtxPosY", lambda x : x.userFloat("vtxPosY"), mcOnly=False, help="Y coord of vertex from btag"),
NTupleVariable("vtxPosZ", lambda x : x.userFloat("vtxPosZ"), mcOnly=False, help="Z coord of vertex from btag"),
# QG variables:
NTupleVariable("qgl", lambda x : getattr(x,'qgl', 0) , float, mcOnly=False,help="QG Likelihood"),
NTupleVariable("ptd", lambda x : getattr(x,'ptd', 0), float, mcOnly=False,help="QG input variable: ptD"),
NTupleVariable("axis2", lambda x : getattr(x,'axis2', 0) , float, mcOnly=False,help="QG input variable: axis2"),
NTupleVariable("mult", lambda x : getattr(x,'mult', 0) , int, mcOnly=False,help="QG input variable: total multiplicity"),
])


Expand Down
10 changes: 5 additions & 5 deletions VHbbAnalysis/Heppy/test/crab/heppy_crab_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
config = Configuration()

config.section_("General")
config.General.requestName = 'VHBB_HEPPY_V9_002'
config.General.workArea = 'crab_projects_V9_002'
config.General.requestName = 'VHBB_HEPPY_V10_001'
config.General.workArea = 'crab_projects_V10_001'
config.General.transferLogs=True

config.section_("JobType")
Expand All @@ -12,17 +12,17 @@
config.JobType.scriptExe = 'heppy_crab_script.sh'
import os
os.system("tar czf python.tar.gz --dereference --directory $CMSSW_BASE python")
config.JobType.inputFiles = ['heppy_config.py','heppy_crab_script.py','python.tar.gz','MVAJetTags_620SLHCX_Phase1And2Upgrade.db','newbtag.py','../vhbb.py','../TMVAClassification_BDT.weights.xml']
config.JobType.inputFiles = ['heppy_config.py','heppy_crab_script.py','python.tar.gz','MVAJetTags_620SLHCX_Phase1And2Upgrade.db','newbtag.py','../vhbb.py','TMVAClassification_BDT.weights.xml','pdfQG_AK4chs_antib_13TeV_v1.root']
#config.JobType.outputFiles = ['tree.root']

config.section_("Data")
config.Data.inputDataset = '/WH_HToBB_WToLNu_M-125_13TeV_powheg-herwigpp/Phys14DR-PU40bx25_PHYS14_25_V1-v1/MINIAODSIM'
config.Data.inputDBS = 'global'
config.Data.splitting = 'FileBased'
config.Data.unitsPerJob = 10
config.Data.outLFN = '/store/user/arizzi/VHBBHeppyV9/'
config.Data.outLFN = '/store/user/arizzi/VHBBHeppyV10/'
config.Data.publication = True
config.Data.publishDataName = 'VHBB_HEPPY_V9'
config.Data.publishDataName = 'VHBB_HEPPY_V10'

config.section_("Site")
config.Site.storageSite = "T2_IT_Pisa"
Expand Down
1 change: 1 addition & 0 deletions VHbbAnalysis/Heppy/test/crab/newbtag.py
Binary file not shown.
4 changes: 4 additions & 0 deletions VHbbAnalysis/Heppy/test/vhbb.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"ajidx3cj" : NTupleCollection("aJ3Cidx", objectInt, 2,help="additional jet indices 3 cen jets"),
"cleanJetsAll" : NTupleCollection("Jet", jetTypeVHbb, 15, help="Cental+fwd jets after full selection and cleaning, sorted by b-tag"),
"selectedTaus" : NTupleCollection("TauGood", tauTypeVHbb, 3, help="Taus after the preselection"),
# "softActivityJets" : NTupleCollection("softActivityJets", fourVectorType, 5, help="jets made for soft activity"),

#dump of gen objects
"genJets" : NTupleCollection("GenJet", genParticleType, 15, help="Generated top quarks from hard scattering",filter=lambda x: x.pt() > 20,mcOnly=True),
Expand Down Expand Up @@ -124,6 +125,8 @@

from VHbbAnalysis.Heppy.VHbbAnalyzer import VHbbAnalyzer
JetAna.jetPt = 15
JetAna.doQG=True
JetAna.QGpath="pdfQG_AK4chs_antib_13TeV_v1.root"

VHbb = cfg.Analyzer(
verbose=False,
Expand All @@ -136,6 +139,7 @@
zLeadingMuPt = 20,
higgsJetsPreSelection = lambda x: x.puJetId() > 0 and x.jetID('POG_PFID_Loose') and x.pt() > 15 ,
passall=False,
doSoftActivity=False
)

from VHbbAnalysis.Heppy.TTHtoTauTauAnalyzer import TTHtoTauTauAnalyzer
Expand Down

0 comments on commit d79bfb6

Please sign in to comment.