Skip to content

Commit

Permalink
Merge pull request #255 from mariadalfonso/Zskimmer
Browse files Browse the repository at this point in the history
Zskimmer
  • Loading branch information
gpetruc committed Feb 13, 2015
2 parents cffd269 + f09dd7c commit 0391b9b
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 12 deletions.
24 changes: 22 additions & 2 deletions CMGTools/TTHAnalysis/cfg/run_susyMT2_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,22 @@
doOnlyDefault = True
)

##------------------------------------------
## Z skim
##------------------------------------------

from CMGTools.TTHAnalysis.analyzers.ttHmllSkimmer import ttHmllSkimmer
# Tree Producer
ttHZskim = cfg.Analyzer(
ttHmllSkimmer, name='ttHmllSkimmer',
lepId=[13],
maxLeps=3,
massMin=60,
massMax=120,
doZGen = False,
doZReco = True
)


##------------------------------------------
## PRODUCER
Expand Down Expand Up @@ -119,9 +135,12 @@
defaultFloatType = 'F',
)


susyCoreSequence.insert(susyCoreSequence.index(skimAnalyzer),
susyCounter)

#susyCoreSequence.insert(susyCoreSequence.index(ttHLepSkim),
# ttHZskim)

sequence = cfg.Sequence(
susyCoreSequence+[
ttHMT2Control,
Expand Down Expand Up @@ -179,12 +198,13 @@
## 25 ns ttbar PHYS14
# comp = TTJets
# comp.files = comp.files[:1]

# comp=TTJets
# comp.files = ['/afs/cern.ch/work/d/dalfonso/public/ttjets_miniaodsim_00C90EFC-3074-E411-A845-002590DB9262.root']
comp=GJets_HT200to400
# comp.files = ['/afs/cern.ch/work/d/dalfonso/public/gjets_ht200to400_miniaodsim_060B8ED3-8571-E411-A2CD-002590D0AFEA.root']
comp.files = ['/afs/cern.ch/user/d/dalfonso/public/TESTfilesPHY14/gjets_ht200to400_miniaodsim_fix.root']
# comp=DYJetsToLL_M50_PU4bx50
# comp.files = comp.files[:1]

selectedComponents = [comp]
comp.splitFactor = 10
Expand Down
2 changes: 1 addition & 1 deletion CMGTools/TTHAnalysis/cfg/validate_MT2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ X=$PWD/$1;
if test \! -d $X/ETHCERN; then echo "Did not find ETHCERN in $X"; exit 1; fi
test -L $PWD/SNT || ln -sd $PWD/SNT $X/ -v;
( cd ../python/plotter;
python mcPlots.py -f --s2v --tree mt2 -P $X bins/validation_mca_mt2.txt bins/validation_MT2.txt bins/validation_plots_MT2.txt --pdir plots/70X/validation -p ref_ttHWWdata,ttHWWdata -u -e --plotmode=norm --showRatio --maxRatioRange 0.65 1.35 --flagDifferences
python mcPlots.py -f --tree mt2 -P $X bins/validation_mca_mt2.txt bins/validation_MT2.txt bins/validation_plots_MT2.txt --pdir plots/70X/validation -p ref_ttHWWdata,ttHWWdata -u -e --plotmode=norm --showRatio --maxRatioRange 0.65 1.35 --flagDifferences
)

## bins/validation_mca.txt --> this contains stile
Expand Down
50 changes: 50 additions & 0 deletions CMGTools/TTHAnalysis/python/analyzers/ttHmllSkimmer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from PhysicsTools.Heppy.analyzers.core.Analyzer import Analyzer
from PhysicsTools.HeppyCore.framework.event import Event
from PhysicsTools.HeppyCore.statistics.counter import Counter, Counters
from PhysicsTools.Heppy.analyzers.core.AutoHandle import AutoHandle

class ttHmllSkimmer( Analyzer ):
def __init__(self, cfg_ana, cfg_comp, looperName ):
super(ttHmllSkimmer,self).__init__(cfg_ana,cfg_comp,looperName)

def declareHandles(self):
super(ttHmllSkimmer, self).declareHandles()

def beginLoop(self,setup):
super(ttHmllSkimmer,self).beginLoop(setup)
self.counters.addCounter('events')
count = self.counters.counter('events')
count.register('all events')
count.register('pass gen Zll skim')
count.register('pass reco Zll skim')

def makeZs(self, event, maxLeps, lepId):
event.bestZ = [ 0., -1,-1 ]
nlep = len(event.selectedLeptons)
for i,l1 in enumerate(event.selectedLeptons):
for j in range(i+1,nlep):
if j >= maxLeps: break
l2 = event.selectedLeptons[j]
if l1.pdgId() == -l2.pdgId() and abs(l1.pdgId()) in lepId:
zmass = (l1.p4() + l2.p4()).M()
if event.bestZ[0] == 0 or abs(zmass - 91.188) < abs(event.bestZ[0] - 91.188):
event.bestZ = [ zmass, i, j ]

def process(self, event):
self.readCollections( event.input )
self.counters.counter('events').inc('all events')

if self.cfg_ana.doZGen and len(event.genleps)==2:
if event.genleps[0].pdgId() == - event.genleps[1].pdgId() and abs(event.genleps[0].pdgId()) in self.cfg_ana.lepId :
if (event.genleps[0].sourceId==23 and event.genleps[1].sourceId==23) :
self.counters.counter('events').inc('pass gen Zll skim')
return True

if self.cfg_ana.doZReco:
self.makeZs( event, self.cfg_ana.maxLeps, self.cfg_ana.lepId)
if event.bestZ[0] > self.cfg_ana.massMin and event.bestZ[0] < self.cfg_ana.massMax:
self.counters.counter('events').inc('pass reco Zll skim')
return True

#If none of the Z selection return veto
return False
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ mt2: mt2: 16,0,800 ; XTitle="MT2 [GeV]"

mt2_gen: mt2_gen: 16,0,800 ; XTitle="MT2 gen [GeV]"

#pseudoJet1_pt: pseudoJet1_pt: 16,0,800 ; XTitle="PseJet1 p_{T} [GeV]", Legend='TR'
#pseudoJet1_phi: pseudoJet1_phi: 8,-3.15,3.15 ; XTitle="PseJet1 phi"
#pseudoJet1_eta: pseudoJet1_eta: 10,-5.,5. ; XTitle="PseJet1 eta"
#pseudoJet1_mass: pseudoJet1_mass: 20,0,400. ; XTitle="PseJet1 mass [GeV]"

#pseudoJet2_pt: pseudoJet2_pt: 16,0,800 ; XTitle="PseJet12 p_{T} [GeV]"
#pseudoJet2_phi: pseudoJet2_phi: 8,-3.15,3.15 ; XTitle="PseJet2 phi"
#pseudoJet2_eta: pseudoJet2_eta: 10,-5.,5. ; XTitle="PseJet2 eta"
#pseudoJet2_mass: pseudoJet2_mass: 20,0,400. ; XTitle="PseJet2 mass [GeV]"
pseudoJet1_pt: pseudoJet1_pt: 16,0,800 ; XTitle="PseJet1 p_{T} [GeV]", Legend='TR'
pseudoJet1_phi: pseudoJet1_phi: 8,-3.15,3.15 ; XTitle="PseJet1 phi"
pseudoJet1_eta: pseudoJet1_eta: 10,-5.,5. ; XTitle="PseJet1 eta"
pseudoJet1_mass: pseudoJet1_mass: 20,0,400. ; XTitle="PseJet1 mass [GeV]"

pseudoJet2_pt: pseudoJet2_pt: 16,0,800 ; XTitle="PseJet12 p_{T} [GeV]"
pseudoJet2_phi: pseudoJet2_phi: 8,-3.15,3.15 ; XTitle="PseJet2 phi"
pseudoJet2_eta: pseudoJet2_eta: 10,-5.,5. ; XTitle="PseJet2 eta"
pseudoJet2_mass: pseudoJet2_mass: 20,0,400. ; XTitle="PseJet2 mass [GeV]"

nPFLep5LowMT: nPFLep5LowMT: [-0.5,0.5,1.5,2.5,3.5,4.5,5.5,6.5,7.5,8.5,9.5,10.5] ; XTitle='N(PFLep\, p_{T} > 5\, M_{T} < 100)'

Expand Down

0 comments on commit 0391b9b

Please sign in to comment.