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#145 from CMSAlphaT/CMG_MiniAOD_Lite_V6_0_fr…
…om-CMSSW_7_0_6_20141116 Updates to the ttHAnalysis framework from the RA1 SUSY group (alphaT)
- Loading branch information
Showing
12 changed files
with
494 additions
and
42 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
123 changes: 123 additions & 0 deletions
123
CMGTools/TTHAnalysis/python/analyzers/ttHAlphaTControlAnalyzer.py
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,123 @@ | ||
import operator | ||
import itertools | ||
import copy | ||
from math import * | ||
|
||
#from ROOT import TLorentzVector, TVectorD | ||
|
||
from CMGTools.RootTools.fwlite.Analyzer import Analyzer | ||
from CMGTools.RootTools.fwlite.Event import Event | ||
from CMGTools.RootTools.statistics.Counter import Counter, Counters | ||
from CMGTools.RootTools.fwlite.AutoHandle import AutoHandle | ||
# from CMGTools.RootTools.physicsobjects.Lepton import Lepton | ||
# from CMGTools.RootTools.physicsobjects.Photon import Photon | ||
# from CMGTools.RootTools.physicsobjects.Electron import Electron | ||
# from CMGTools.RootTools.physicsobjects.Muon import Muon | ||
# from CMGTools.RootTools.physicsobjects.Tau import Tau | ||
from CMGTools.RootTools.physicsobjects.Jet import Jet | ||
|
||
from CMGTools.RootTools.utils.DeltaR import deltaR | ||
|
||
import os | ||
|
||
# Function to calculate the transverse mass | ||
def mtw(x1,x2): | ||
return sqrt(2*x1.pt()*x2.pt()*(1-cos(x1.phi()-x2.phi()))) | ||
|
||
class ttHAlphaTControlAnalyzer( Analyzer ): | ||
def __init__(self, cfg_ana, cfg_comp, looperName ): | ||
super(ttHAlphaTControlAnalyzer,self).__init__(cfg_ana,cfg_comp,looperName) | ||
|
||
def declareHandles(self): | ||
super(ttHAlphaTControlAnalyzer, self).declareHandles() | ||
#genJets | ||
self.handles['genJets'] = AutoHandle( 'slimmedGenJets','std::vector<reco::GenJet>') | ||
|
||
def beginLoop(self): | ||
super(ttHAlphaTControlAnalyzer,self).beginLoop() | ||
self.counters.addCounter('pairs') | ||
count = self.counters.counter('pairs') | ||
count.register('all events') | ||
|
||
|
||
# Calculate MT_W (stolen from the MT2 code) | ||
# Modularize this later? | ||
def makeMT(self, event): | ||
# print '==> INSIDE THE PRINT MT' | ||
# print 'MET=',event.met.pt() | ||
|
||
if len(event.selectedLeptons)>0: | ||
for lepton in event.selectedLeptons: | ||
event.mtw = mtw(lepton, event.met) | ||
|
||
if len(event.selectedTaus)>0: | ||
for myTau in event.selectedTaus: | ||
event.mtwTau = mtw(myTau, event.met) | ||
foundTau = True | ||
|
||
if len(event.selectedIsoTrack)>0: | ||
for myTrack in event.selectedIsoTrack: | ||
event.mtwIsoTrack = mtw(myTrack, event.met) | ||
|
||
return | ||
|
||
# Calculate the invariant mass from two lead leptons | ||
def makeMll(self, event): | ||
|
||
if len(event.selectedLeptons)>=2: | ||
event.mll = (event.selectedLeptons[0].p4()+event.selectedLeptons[1].p4()).M() | ||
|
||
return | ||
|
||
# Calculate the DeltaR between the lepton and the closest jet | ||
def makeDeltaRLepJet(self, event): | ||
|
||
event.minDeltaRLepJet = [] | ||
|
||
for lepton in event.selectedLeptons: | ||
|
||
minDeltaR = 999 | ||
|
||
for jet in event.cleanJets: | ||
minDeltaR=min(deltaR(lepton.eta(),lepton.phi(),jet.eta(),jet.phi()), minDeltaR) | ||
|
||
# Fill event with the min deltaR for each lepton | ||
event.minDeltaRLepJet.append(minDeltaR) | ||
|
||
return | ||
|
||
# Calculate the DeltaR between the photon and the closest jet | ||
def makeDeltaRPhoJet(self, event): | ||
|
||
event.minDeltaRPhoJet = [] | ||
|
||
for photon in event.selectedPhotons: | ||
|
||
minDeltaR = 999 | ||
|
||
for jet in event.cleanJets: | ||
minDeltaR=min(deltaR(photon.eta(),photon.phi(),jet.eta(),jet.phi()), minDeltaR) | ||
|
||
# Fill event with the min deltaR for each photon | ||
event.minDeltaRPhoJet.append(minDeltaR) | ||
|
||
return | ||
|
||
def process(self, iEvent, event): | ||
self.readCollections( iEvent ) | ||
|
||
#W variables | ||
event.mtw = -999 | ||
event.mtwTau = -999 | ||
event.mtwIsoTrack = -999 | ||
self.makeMT(event) | ||
|
||
#Z variables | ||
event.mll = -999 | ||
self.makeMll(event) | ||
|
||
#Delta R variables | ||
self.makeDeltaRLepJet(event) | ||
self.makeDeltaRPhoJet(event) | ||
|
||
return True |
54 changes: 54 additions & 0 deletions
54
CMGTools/TTHAnalysis/python/analyzers/ttHAlphaTControlSkimmer.py
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 CMGTools.RootTools.fwlite.Analyzer import Analyzer | ||
from CMGTools.RootTools.fwlite.Event import Event | ||
from CMGTools.RootTools.statistics.Counter import Counter, Counters | ||
from CMGTools.RootTools.fwlite.AutoHandle import AutoHandle | ||
|
||
class ttHAlphaTControlSkimmer( Analyzer ): | ||
def __init__(self, cfg_ana, cfg_comp, looperName ): | ||
super(ttHAlphaTControlSkimmer,self).__init__(cfg_ana,cfg_comp,looperName) | ||
|
||
def declareHandles(self): | ||
super(ttHAlphaTControlSkimmer, self).declareHandles() | ||
|
||
def beginLoop(self): | ||
super(ttHAlphaTControlSkimmer,self).beginLoop() | ||
self.counters.addCounter('events') | ||
count = self.counters.counter('events') | ||
count.register('all events') | ||
count.register('pass mtw cuts') | ||
count.register('pass mll cuts') | ||
count.register('pass lepton deltaR cuts') | ||
count.register('pass photon deltaR cuts') | ||
count.register('accepted events') | ||
|
||
|
||
def process(self, iEvent, event): | ||
self.readCollections( iEvent ) | ||
self.counters.counter('events').inc('all events') | ||
|
||
#Perform W mass MTW cut | ||
if event.mtw < self.cfg_ana.mtwCut[0] or event.mtw > self.cfg_ana.mtwCut[1]: | ||
return False | ||
self.counters.counter('events').inc('pass mtw cuts') | ||
|
||
#Perform Z mass MLL cut | ||
if event.mll < self.cfg_ana.mllCut[0] or event.mll > self.cfg_ana.mllCut[1]: | ||
return False | ||
self.counters.counter('events').inc('pass mll cuts') | ||
|
||
#Perform deltaR cuts | ||
for dR in event.minDeltaRLepJet: | ||
if dR < self.cfg_ana.lepDeltaRCut: | ||
return False | ||
self.counters.counter('events').inc('pass lepton deltaR cuts') | ||
|
||
for dR in event.minDeltaRPhoJet: | ||
if dR < self.cfg_ana.photonDeltaRCut: | ||
return False | ||
self.counters.counter('events').inc('pass photon deltaR cuts') | ||
|
||
#If everything passed return true | ||
self.counters.counter('events').inc('accepted events') | ||
return True | ||
|
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,58 @@ | ||
|
||
from CMGTools.RootTools.fwlite.Analyzer import Analyzer | ||
from CMGTools.RootTools.fwlite.Event import Event | ||
from CMGTools.RootTools.statistics.Counter import Counter, Counters | ||
from CMGTools.RootTools.fwlite.AutoHandle import AutoHandle | ||
|
||
class ttHAlphaTSkimmer( Analyzer ): | ||
def __init__(self, cfg_ana, cfg_comp, looperName ): | ||
super(ttHAlphaTSkimmer,self).__init__(cfg_ana,cfg_comp,looperName) | ||
|
||
def declareHandles(self): | ||
super(ttHAlphaTSkimmer, self).declareHandles() | ||
|
||
def beginLoop(self): | ||
super(ttHAlphaTSkimmer,self).beginLoop() | ||
self.counters.addCounter('events') | ||
count = self.counters.counter('events') | ||
count.register('all events') | ||
count.register('pass forwardJetVeto') | ||
count.register('pass MHT/MET cut') | ||
count.register('pass alphaTCuts') | ||
count.register('accepted events') | ||
|
||
|
||
def process(self, iEvent, event): | ||
self.readCollections( iEvent ) | ||
self.counters.counter('events').inc('all events') | ||
|
||
#Veto forward jets that have passed the jet requirement | ||
if self.cfg_ana.forwardJetVeto and len(event.cleanJetsFwd) > 0: | ||
return False | ||
self.counters.counter('events').inc('pass forwardJetVeto') | ||
|
||
#Veto events that don't pass the MHT/MET cut | ||
if getattr(event, self.cfg_ana.mhtDivMetCut[0])/getattr(event, self.cfg_ana.mhtDivMetCut[1]).pt() > self.cfg_ana.mhtDivMetCut[2]: | ||
return False | ||
self.counters.counter('events').inc('pass MHT/MET cut') | ||
|
||
#Check if the event passes the alphaT cut | ||
|
||
if self.cfg_ana.invertAlphaT: #This is for the multijet enriched control region | ||
|
||
for aTCut in self.cfg_ana.alphaTCuts: | ||
if event.alphaT < aTCut[0] and event.htJet50j >= aTCut[1] and event.htJet50j < aTCut[2]: | ||
self.counters.counter('events').inc('pass alphaTCuts') | ||
self.counters.counter('events').inc('accepted events') | ||
return True | ||
|
||
else: | ||
|
||
for aTCut in self.cfg_ana.alphaTCuts: | ||
if event.alphaT > aTCut[0] and event.htJet50j >= aTCut[1] and event.htJet50j < aTCut[2]: | ||
self.counters.counter('events').inc('pass alphaTCuts') | ||
self.counters.counter('events').inc('accepted events') | ||
return True | ||
|
||
#If none of the alphaT cuts are passed, veto the event | ||
return False |
Oops, something went wrong.