Skip to content

Commit

Permalink
Merge pull request cms-sw#168 from mariadalfonso/MT2smallFixes
Browse files Browse the repository at this point in the history
IsoTrack and Mt2small fixes
  • Loading branch information
gpetruc committed Dec 10, 2014
2 parents 0cbafa1 + f96cc87 commit 243637f
Show file tree
Hide file tree
Showing 15 changed files with 222 additions and 126 deletions.
5 changes: 4 additions & 1 deletion CMGTools/RootTools/python/physicsobjects/Photon.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ class Photon(PhysicsObject ):
''' return object from the photon
'''
def hOVERe(self):
return self.physObj.full5x5_hadTowOverEm()
# return self.physObj.full5x5_hadTowOverEm()
hadTowDepth1O = self.physObj.hadTowDepth1OverEm() * (self.physObj.superCluster().energy()/self.physObj.full5x5_e5x5() if self.physObj.full5x5_e5x5() else 1)
hadTowDepth2O = self.physObj.hadTowDepth2OverEm() * (self.physObj.superCluster().energy()/self.physObj.full5x5_e5x5() if self.physObj.full5x5_e5x5() else 1)
return hadTowDepth1O + hadTowDepth2O

def r9(self):
return self.physObj.full5x5_r9()
Expand Down
23 changes: 1 addition & 22 deletions CMGTools/TTHAnalysis/cfg/run_susyAlphaT_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,27 +71,7 @@
## ISOLATED TRACK
##------------------------------------------

# those are the cuts for the nonEMu
ttHIsoTrackAna = cfg.Analyzer(
'ttHIsoTrackAnalyzer',
# candidates='cmgCandidates',
# candidatesTypes='std::vector<cmg::Candidate>',
candidates ='packedPFCandidates',
candidatesTypes ='std::vector<pat::PackedCandidate>',
ptMin = 5, ### for pion
ptMinEMU = 5, ### for EMU
dzMax = 0.1,
#####
isoDR = 0.3,
ptPartMin = 0,
dzPartMax = 0.1,
maxAbsIso = 8,
#####
MaxIsoSum = 0.1, ### unused
MaxIsoSumEMU = 0.2, ### unused
doSecondVeto = False
)

ttHIsoTrackAna.setOff=False

##------------------------------------------
## ALPHAT VARIABLES
Expand Down Expand Up @@ -166,7 +146,6 @@
#-------- SEQUENCE

sequence = cfg.Sequence(susyCoreSequence + [
ttHIsoTrackAna,
ttHAlphaTAna,
ttHAlphaTControlAna,
treeProducer,
Expand Down
31 changes: 6 additions & 25 deletions CMGTools/TTHAnalysis/cfg/run_susyMT2_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
ttHJetAna.jetGammaDR = 0.4
ttHJetAna.minGammaPt = 20
ttHJetAna.gammaEtaCentral = 2.4
ttHJetAna.cleanJetsFromIsoTracks = True ## added for Dominick

# TAU
ttHTauAna.etaMax = 2.3
Expand All @@ -47,7 +48,7 @@
ttHTauAna.vetoLeptonsPOG = True

# Photon
ttHPhoAna.etaCentral = 2.4
ttHPhoAna.etaCentral = 2.5
ttHPhoAna.gammaID = "PhotonCutBasedIDLoose_CSA14"


Expand All @@ -56,26 +57,7 @@
## ISOLATED TRACK
##------------------------------------------

# those are the cuts for the nonEMu
ttHIsoTrackAna = cfg.Analyzer(
'ttHIsoTrackAnalyzer',
# candidates='cmgCandidates',
# candidatesTypes='std::vector<cmg::Candidate>',
candidates='packedPFCandidates',
candidatesTypes='std::vector<pat::PackedCandidate>',
ptMin = 5, # for pion
ptMinEMU = 5, # for EMU
dzMax = 0.1,
#####
isoDR = 0.3,
ptPartMin = 0,
dzPartMax = 0.1,
maxAbsIso = 8,
#####
MaxIsoSum = 0.1, ### unused
MaxIsoSumEMU = 0.2, ### unused
doSecondVeto = False
)
ttHIsoTrackAna.setOff=False

##------------------------------------------
## CONTROL VARIABLES
Expand All @@ -85,7 +67,6 @@
'ttHMT2Control'
)


##------------------------------------------
## TOLOLOGIAL VARIABLES: MT, MT2
##------------------------------------------
Expand Down Expand Up @@ -154,7 +135,6 @@
#-------- SEQUENCE

sequence = cfg.Sequence(susyCoreSequence+[
ttHIsoTrackAna,
ttHMT2Control,
ttHTopoJetAna,
ttHFatJetAna,
Expand All @@ -168,10 +148,11 @@
comp=TTJets_PU20bx25 #TTJets_forSynch
#comp=SMS_T1qqqq_2J_mGl1400_mLSP100_PU_S14_POSTLS170 # small files for testing
#comp=SMS_T1bbbb_2J_mGl1000_mLSP900_PU_S14_POSTLS170
#comp=GJets_HT100to200_PU_S14_POSTLS170
#comp.files = ['/afs/cern.ch/work/p/pandolf/CMSSW_7_0_6_patch1_2/src/CMGTools/TTHAnalysis/cfg/pickevents.root']
comp.files = ['/afs/cern.ch/user/p/pandolf/public/file_gammaJet.root']
#comp.files = ['/afs/cern.ch/user/p/pandolf/public/file_gammaJet.root']
#comp.files = ['/afs/cern.ch/work/p/pandolf/CMSSW_7_0_6_patch1_2/src/CMGTools/TTHAnalysis/cfg/file_gammaJet.root']
#comp.files = ['/afs/cern.ch/user//m/mmasciov/public/TTJets_forSynch_1.root']
comp.files = ['/afs/cern.ch/user//m/mmasciov/public/TTJets_forSynch_1.root']
comp.files = comp.files[:1]
selectedComponents = [comp]
comp.splitFactor = 10
Expand Down
20 changes: 2 additions & 18 deletions CMGTools/TTHAnalysis/cfg/run_susySingleSoftlepton_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,7 @@
)



ttHIsoTrackAna = cfg.Analyzer(
'ttHIsoTrackAnalyzer',
candidates='packedPFCandidates',
candidatesTypes='std::vector<pat::PackedCandidate>',
ptMin = 5, # for pion
ptMinEMU = 5, # for EMU
dzMax = 0.1,
isoDR = 0.3,
ptPartMin = 0,
dzPartMax = 0.1,
maxAbsIso = 8,
MaxIsoSum = 0.1, ### unused
MaxIsoSumEMU = 0.2, ### unused
doSecondVeto = False
)
ttHIsoTrackAna.setOff=False

susyCoreSequence.insert(susyCoreSequence.index(ttHCoreEventAna),
ttHSVAnalyzer)
Expand All @@ -77,13 +62,12 @@

#-------- SAMPLES AND TRIGGERS -----------
from CMGTools.TTHAnalysis.samples.samples_13TeV_CSA14 import *
selectedComponents = [ SingleMu, DoubleElectron, TTHToWW_PUS14, DYJetsM50_PU20bx25, TTJets_PUS14 ]
selectedComponents = [ SingleMu, DoubleElectron, TTHToWW_PUS14, DYJetsToLL_M50_PU20bx25, TTJets_PUS14 ]


#-------- SEQUENCE

sequence = cfg.Sequence(susyCoreSequence+[
ttHIsoTrackAna,
ttHEventAna,
treeProducer,
])
Expand Down
19 changes: 1 addition & 18 deletions CMGTools/TTHAnalysis/cfg/run_susySinglelepton_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,29 +41,13 @@
)


ttHIsoTrackAna = cfg.Analyzer(
'ttHIsoTrackAnalyzer',
candidates='packedPFCandidates',
candidatesTypes='std::vector<pat::PackedCandidate>',
ptMin = 5, # for pion
ptMinEMU = 5, # for EMU
dzMax = 0.1,
isoDR = 0.3,
ptPartMin = 0,
dzPartMax = 0.1,
maxAbsIso = 8,
MaxIsoSum = 0.1, ### unused
MaxIsoSumEMU = 0.2, ### unused
doSecondVeto = False
)
ttHIsoTrackAna.setOff=False

susyCoreSequence.insert(susyCoreSequence.index(ttHCoreEventAna),
ttHSVAnalyzer)
susyCoreSequence.insert(susyCoreSequence.index(ttHCoreEventAna),
ttHHeavyFlavourHadronAnalyzer)



from CMGTools.TTHAnalysis.samples.samples_8TeV_v517 import triggers_1mu, triggers_1muHT, triggers_1eleHT

# Tree Producer
Expand All @@ -87,7 +71,6 @@
#-------- SEQUENCE

sequence = cfg.Sequence(susyCoreSequence+[
ttHIsoTrackAna,
ttHEventAna,
ttHReclusterJets,
treeProducer,
Expand Down
30 changes: 30 additions & 0 deletions CMGTools/TTHAnalysis/python/analyzers/susyCore_modules_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,34 @@
)


#------------------------------------------
## ISOLATED TRACK
##------------------------------------------

# those are the cuts for the nonEMu
ttHIsoTrackAna = cfg.Analyzer(
'ttHIsoTrackAnalyzer',
setOff=True,
#####
candidates='packedPFCandidates',
candidatesTypes='std::vector<pat::PackedCandidate>',
ptMin = 5, # for pion
ptMinEMU = 5, # for EMU
dzMax = 0.1,
#####
isoDR = 0.3,
ptPartMin = 0,
dzPartMax = 0.1,
maxAbsIso = 8,
#####
MaxIsoSum = 0.1, ### unused
MaxIsoSumEMU = 0.2, ### unused
doSecondVeto = False,
#####
doPrune = True
)


# Jets Analyzer (generic)
ttHJetAna = cfg.Analyzer(
'ttHJetAnalyzer',
Expand All @@ -176,6 +204,7 @@
recalibrateJets = False,
shiftJEC = 0, # set to +1 or -1 to get +/-1 sigma shifts
cleanJetsFromTaus = False,
cleanJetsFromIsoTracks = False,
doQG = False,
)

Expand Down Expand Up @@ -260,6 +289,7 @@
ttHPhoAna,
ttHTauAna,
ttHTauMCAna,
ttHIsoTrackAna,
ttHJetAna,
ttHJetMCAna,
#ttHFatJetAna, # out of core sequence for now
Expand Down
22 changes: 11 additions & 11 deletions CMGTools/TTHAnalysis/python/analyzers/treeProducerSusyFullHad.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ def __init__(self, cfg_ana, cfg_comp, looperName):
##--------------------------------------------------
## energy sums
##--------------------------------------------------
NTupleVariable("ht", lambda ev : ev.htJet40j10l, help="H_{T} computed from jets (with |eta|<2.5, pt > 40 GeV) and leptons (electrons and muons with |eta|<2.5, pt > 10 GeV)"),
NTupleVariable("mht_pt", lambda ev : ev.mhtJet40j10l, help="H_{T}^{miss} computed from jets (with |eta|<2.5, pt > 40 GeV) and leptons (electrons ans muons with |eta|<2.5, pt > 10 GeV)"),
NTupleVariable("mht_phi", lambda ev : ev.mhtPhiJet40j10l, help="H_{T}^{miss} #phi computed from jets (with |eta|<2.5, pt > 40 GeV) and leptons (electrons ans muons with |eta|<2.5, pt > 10 GeV)"),
NTupleVariable("ht", lambda ev : ev.htJet40j10l5t, help="H_{T} computed from jets (with |eta|<2.5, pt > 40 GeV) and leptons (electrons and muons with |eta|<2.5, pt > 10 GeV)"),
NTupleVariable("mht_pt", lambda ev : ev.mhtJet40j10l5t, help="H_{T}^{miss} computed from jets (with |eta|<2.5, pt > 40 GeV) and leptons (electrons ans muons with |eta|<2.5, pt > 10 GeV)"),
NTupleVariable("mht_phi", lambda ev : ev.mhtPhiJet40j10l5t, help="H_{T}^{miss} #phi computed from jets (with |eta|<2.5, pt > 40 GeV) and leptons (electrons ans muons with |eta|<2.5, pt > 10 GeV)"),
NTupleVariable("diffMetMht", lambda ev : ev.diffMetMht, help="abs( vec(mht) - vec(met) ) - with jets and leptons"),
NTupleVariable("deltaPhiMin", lambda ev : ev.deltaPhiMin, help="minimal deltaPhi between the MET and the four leading jets with pt>40 and eta<2.4 and leptons (electrons ans muons with |eta|<2.5, pt > 10 GeV)"),

Expand Down Expand Up @@ -76,13 +76,12 @@ def __init__(self, cfg_ana, cfg_comp, looperName):
NTupleVariable("gamma_nJet40", lambda ev: sum([j.pt() > 40 for j in ev.gamma_cleanJets]), int, help="Number of jets after photon-cleaning with pt > 40, |eta|<2.4"),
NTupleVariable("gamma_nBJet40", lambda ev: sum([j.btagWP("CSVM") for j in ev.gamma_cleanJets if j.pt() > 40]), int, help="Number jets after photon-cleaning with pt > 40 passing CSV medium"),
NTupleVariable("gamma_ht", lambda ev : ev.gamma_htJet40j, help="H_{T} computed from only jets (with |eta|<2.5, pt > 40 GeV)"),
NTupleVariable("gamma_deltaPhiMin", lambda ev : ev.gamma_deltaPhiMin, help="minimal deltaPhi between the MET and the four leading jets with pt>40 and eta<2.4"),
NTupleVariable("gamma_diffMetMht", lambda ev : ev.gamma_diffMetMht, help="abs( vec(mht) - vec(met) )"),
NTupleVariable("gamma_mht_pt", lambda ev : ev.gamma_mhtJet40, help="H_{T}^{miss} computed from jets (with |eta|<2.5, pt > 40 GeV) and leptons (electrons ans muons with |eta|<2.5, pt > 10 GeV)"),
NTupleVariable("gamma_mht_phi", lambda ev : ev.gamma_mhtPhiJet40, help="H_{T}^{miss} #phi computed from jets (with |eta|<2.5, pt > 40 GeV) and leptons (electrons ans muons with |eta|<2.5, pt > 10 GeV)"),
NTupleVariable("gamma_diffMetMht_had", lambda ev : ev.gamma_diffMetMht_had, help="abs( vec(mht) - vec(met) ) - only jets"),
NTupleVariable("gamma_mht_had_pt", lambda ev : ev.gamma_mhtJet40j, help="H_{T}^{miss} computed from only jets (with |eta|<2.5, pt > 40 GeV)"),
NTupleVariable("gamma_mht_had_phi", lambda ev : ev.gamma_mhtPhiJet40j, help="H_{T}^{miss} #phi computed from only jets (with |eta|<2.5, pt > 40 GeV)"),
NTupleVariable("gamma_deltaPhiMin", lambda ev : ev.gamma_deltaPhiMin_had, help="minimal deltaPhi between the MET and the four leading jets with pt>40 and eta<2.4"),
NTupleVariable("gamma_diffMetMht", lambda ev : ev.gamma_diffMetMht_had, help="abs( vec(mht) - vec(met) )"),
NTupleVariable("gamma_mht_pt", lambda ev : ev.gamma_mhtJet40j, help="H_{T}^{miss} computed from jets (with |eta|<2.5, pt > 40 GeV) and leptons (electrons ans muons with |eta|<2.5, pt > 10 GeV)"),
NTupleVariable("gamma_mht_phi", lambda ev : ev.gamma_mhtPhiJet40j, help="H_{T}^{miss} #phi computed from jets (with |eta|<2.5, pt > 40 GeV) and leptons (electrons ans muons with |eta|<2.5, pt > 10 GeV)"),
NTupleVariable("gamma_minMTBMet", lambda ev : ev.gamma_minMTBMet, help="min Mt(b,met)"),

##--------------------------------------------------
# Zll variables
##--------------------------------------------------
Expand All @@ -92,6 +91,7 @@ def __init__(self, cfg_ana, cfg_comp, looperName):
NTupleVariable("zll_mht_phi", lambda ev : ev.zll_mhtPhiJet40j, help="H_{T}^{miss} #phi computed from only jets (with |eta|<2.5, pt > 40 GeV)"),
NTupleVariable("zll_met_pt", lambda ev : ev.zll_met_pt, help="E_{T}^{miss} computed from jets (with |eta|<2.5, pt > 40 GeV) + 2 leptons"),
NTupleVariable("zll_met_phi", lambda ev : ev.zll_met_phi, help="E_{T}^{miss} #phi computed from jets (with |eta|<2.5, pt > 40 GeV) + 2 leptons"),
NTupleVariable("zll_ht", lambda ev: ev.zll_ht, float, help="H_{T} computed from only jets (with |eta|<2.5, pt > 40 GeV)"),
NTupleVariable("zll_pt", lambda ev : ev.zll_p4.Pt(), help="Pt of di-lepton system"),
NTupleVariable("zll_eta", lambda ev : ev.zll_p4.Eta(), help="Eta of di-lepton system"),
NTupleVariable("zll_phi", lambda ev : ev.zll_p4.Phi(), help="Phi of di-lepton system"),
Expand Down Expand Up @@ -124,7 +124,7 @@ def __init__(self, cfg_ana, cfg_comp, looperName):
"selectedLeptons" : NTupleCollection("lep", leptonTypeSusy, 50, help="Leptons after the preselection", filter=lambda l : l.pt()>10 ),
"selectedTaus" : NTupleCollection("tau", tauTypeSusy, 50, help="Taus after the preselection"),
"cleanJetsAll" : NTupleCollection("jet", jetTypeSusy, 100, help="all jets (w/ x-cleaning, w/ ID applied w/o PUID applied pt>10 |eta|<5.2) , sorted by pt", filter=lambda l : l.pt()>10 ),
"fatJets" : NTupleCollection("FatJet", fatJetType, 15, help="Cental jets after full selection and cleaning, sorted by pt"),
"fatJets" : NTupleCollection("fatJet", fatJetType, 15, help="Cental jets after full selection and cleaning, sorted by pt"),
"selectedPhotons" : NTupleCollection("gamma", photonTypeSusy, 50, help="photons with pt>20 and loose cut based ID"),
"selectedIsoTrack" : NTupleCollection("isoTrack", isoTrackType, 50, help="isoTrack, sorted by pt"),
"genParticles" : NTupleCollection("genPart", genParticleWithMotherId, 200, help="all pruned genparticles"),
Expand Down
22 changes: 19 additions & 3 deletions CMGTools/TTHAnalysis/python/analyzers/ttHCoreEventAnalyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,14 @@ def process(self, iEvent, event):
objects40 = [ j for j in event.cleanJets if j.pt() > 40 ] + event.selectedLeptons
objects40j = [ j for j in event.cleanJets if j.pt() > 40 ]
objects50j = [ j for j in event.cleanJets if j.pt() > 50 ]
objects40j10l = [ j for j in event.cleanJets if j.pt() > 40 ] + [ l for l in event.selectedLeptons if l.pt() > 10 ]
objects40j10l = [ j for j in event.cleanJets if j.pt() > 40 ] + [ l for l in event.selectedLeptons if l.pt() > 10 ]
objects40j10l.sort(key = lambda obj : obj.pt(), reverse = True)

objects40j10l5t = []
if hasattr(event, 'selectedIsoCleanTrack'):
objects40j10l5t = [ j for j in event.cleanJets if j.pt() > 40 ] + [ l for l in event.selectedLeptons if l.pt() > 10 ] + [ t for t in event.selectedIsoCleanTrack ]
objects40j10l5t.sort(key = lambda obj : obj.pt(), reverse = True)

event.htJet25 = sum([x.pt() for x in objects25])
event.mhtJet25vec = ROOT.reco.Particle.LorentzVector(-1.*(sum([x.px() for x in objects25])) , -1.*(sum([x.py() for x in objects25])), 0, 0 )
event.mhtPhiJet25 = event.mhtJet25vec.phi()
Expand Down Expand Up @@ -224,11 +229,22 @@ def process(self, iEvent, event):
event.mhtJet40j10l = event.mhtJet40j10lvec.pt()
event.mhtPhiJet40j10l = event.mhtJet40j10lvec.phi()

event.htJet40j10l5t = sum([x.pt() for x in objects40j10l5t])
event.mhtJet40j10l5tvec = ROOT.reco.Particle.LorentzVector(-1.*(sum([x.px() for x in objects40j10l5t])) , -1.*(sum([x.py() for x in objects40j10l5t])), 0, 0 )
event.mhtJet40j10l5t = event.mhtJet40j10l5tvec.pt()
event.mhtPhiJet40j10l5t = event.mhtJet40j10l5tvec.phi()

## same but with all eta range
objects25a = [ j for j in event.cleanJetsAll if j.pt() > 25 ] + event.selectedLeptons
objects30a = [ j for j in event.cleanJetsAll if j.pt() > 30 ] + event.selectedLeptons
objects40a = [ j for j in event.cleanJetsAll if j.pt() > 40 ] + event.selectedLeptons
objects40ja = [ j for j in event.cleanJetsAll if j.pt() > 40 ]

objects40ja10l5t = []
if hasattr(event, 'selectedIsoCleanTrack'):
objects40ja10l5t = [ j for j in event.cleanJetsAll if j.pt() > 40 ] + [ l for l in event.selectedLeptons if l.pt() > 10 ] + [ t for t in event.selectedIsoCleanTrack ]
objects40ja10l5t.sort(key = lambda obj : obj.pt(), reverse = True)

objects40ja10l = [ j for j in event.cleanJetsAll if j.pt() > 40 ] + [ l for l in event.selectedLeptons if l.pt() > 10 ]
objects40ja10l.sort(key = lambda obj : obj.pt(), reverse = True)

Expand Down Expand Up @@ -300,7 +316,7 @@ def process(self, iEvent, event):
if thisDeltaPhi < event.deltaPhiMin_had : event.deltaPhiMin_had = thisDeltaPhi

event.deltaPhiMin = 999.
for n,j in enumerate(objects40ja10l):
for n,j in enumerate(objects40ja10l5t):
if n>3: break
thisDeltaPhi = abs( deltaPhi( j.phi(), event.met.phi() ) )
if thisDeltaPhi < event.deltaPhiMin : event.deltaPhiMin = thisDeltaPhi
Expand All @@ -318,7 +334,7 @@ def process(self, iEvent, event):
diffMetMht_had_vec = ROOT.reco.Particle.LorentzVector(event.mhtJet40jvec.px()-event.met.px(), event.mhtJet40jvec.py()-event.met.py(), 0, 0 )
event.diffMetMht_had = sqrt( diffMetMht_had_vec.px()*diffMetMht_had_vec.px() + diffMetMht_had_vec.py()*diffMetMht_had_vec.py() )

diffMetMht_vec = ROOT.reco.Particle.LorentzVector(event.mhtJet40j10lvec.px()-event.met.px(), event.mhtJet40j10lvec.py()-event.met.py(), 0, 0 )
diffMetMht_vec = ROOT.reco.Particle.LorentzVector(event.mhtJet40j10l5tvec.px()-event.met.px(), event.mhtJet40j10l5tvec.py()-event.met.py(), 0, 0 )
event.diffMetMht = sqrt( diffMetMht_vec.px()*diffMetMht_vec.px() + diffMetMht_vec.py()*diffMetMht_vec.py() )
###

Expand Down
Loading

0 comments on commit 243637f

Please sign in to comment.