Skip to content

Commit

Permalink
Merge pull request cms-sw#93 from mariadalfonso/pr92_remerged
Browse files Browse the repository at this point in the history
Pr92 remerged
  • Loading branch information
gpetruc committed Jul 20, 2014
2 parents 1e443ff + b1e2d85 commit 4d45770
Show file tree
Hide file tree
Showing 11 changed files with 140 additions and 48 deletions.
29 changes: 20 additions & 9 deletions CMGTools/TTHAnalysis/cfg/run_susyFullHad_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,27 @@
## Redefine what I need
##------------------------------------------

#Lepton
ttHLepAna.loose_muon_dxy = 0.5
ttHLepAna.loose_muon_dz = 1.0
ttHLepAna.loose_muon_relIso = 0.15
ttHLepAna.loose_electron_id = "POG_Cuts_ID_2012_Veto"
ttHLepAna.loose_electron_pt = 5
ttHLepAna.loose_electron_eta = 2.4
ttHLepAna.loose_electron_dxy = 0.04
ttHLepAna.loose_electron_dz = 0.2
ttHLepAna.loose_electron_relIso = 0.15
ttHLepAna.loose_electron_lostHits = 999 # no cut


# JET (do not apply the jetID and PUID yet)
ttHJetAna.relaxJetId = True
ttHJetAna.doPuId = False
ttHJetAna.jetEtaCentral = 2.5
ttHJetAna.jetEtaCentral = 5.2
ttHJetAna.jetPt = 10.
ttHJetAna.recalibrateJets = False
ttHJetAna.jetLepDR = 0.4
ttHJetMCAna.smearJets = False

# TAU
ttHTauAna.etaMax = 2.3
Expand Down Expand Up @@ -52,11 +69,7 @@

# Tree Producer
ttHTopoJetAna = cfg.Analyzer(
'ttHTopoVarAnalyzer',
muons='cmgMuonSel',
electrons='cmgElectronSel',
taus='cmgTauSel',
jetCol = 'cmgPFJetSelCHS'
'ttHTopoVarAnalyzer'
)


Expand Down Expand Up @@ -107,9 +120,7 @@
for comp in selectedComponents:
comp.splitFactor = 1
comp.files = comp.files[:1]




config = cfg.Config( components = selectedComponents,
sequence = sequence )

Expand Down
6 changes: 4 additions & 2 deletions CMGTools/TTHAnalysis/python/analyzers/ntupleTypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
NTupleVariable("btagCSV", lambda x : x.btag('combinedSecondaryVertexBJetTags'), help="CSV discriminator"),
NTupleVariable("rawPt", lambda x : x.pt() * x.rawFactor(), help="p_{T} before JEC"),
NTupleVariable("mcPt", lambda x : x.mcJet.pt() if x.mcJet else 0., mcOnly=True, help="p_{T} of associated gen jet"),
NTupleVariable("mcFlavour", lambda x : abs(x.partonFlavour()), int, mcOnly=True, help="parton flavour (physics definition, i.e. including b's from shower)"),
NTupleVariable("mcFlavour", lambda x : x.partonFlavour(), int, mcOnly=True, help="parton flavour (physics definition, i.e. including b's from shower)"),
#NTupleVariable("quarkGluonID", lambda x : x.QG, mcOnly=False),
])
jetTypeTTH = NTupleObjectType("jetTTH", baseObjectTypes = [ jetType ], variables = [
Expand Down Expand Up @@ -201,6 +201,8 @@
NTupleVariable("sourceId", lambda x : x.sourceId, int, help="origin of the particle: 6=t, 25=h, 23/24=W/Z")
])
genParticleWithMotherId = NTupleObjectType("genParticleWithMotherId", baseObjectTypes = [ genParticleType ], mcOnly=True, variables = [
NTupleVariable("motherId", lambda x : x.motherId, int, help="pdgId of the mother of the particle")
#NTupleVariable("motherId", lambda x : x.motherId, int, help="pdgId of the mother of the particle")
NTupleVariable("motherId", lambda x : x.mother(0).pdgId() if x.mother(0) else 0, int, help="pdgId of the mother of the particle"),
NTupleVariable("grandmaId", lambda x : x.mother(0).mother(0).pdgId() if x.mother(0) and x.mother(0).mother(0) else 0, int, help="pdgId of the grandmother of the particle")
])

2 changes: 0 additions & 2 deletions CMGTools/TTHAnalysis/python/analyzers/treeProducerSusyCore.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ def __init__(self, cfg_ana, cfg_comp, looperName):
"metNoPU" : NTupleObject("metNoPU", fourVectorType, help="PF noPU E_{T}^{miss}"),
}
self.collections = {
"selectedLeptons" : NTupleCollection("LepGood", leptonTypeSusy, 8, help="Leptons after the preselection"),
"selectedTaus" : NTupleCollection("TauGood", tauTypeSusy, 3, help="Taus after the preselection"),
##--------------------------------------------------
"gentopquarks" : NTupleCollection("GenTop", genParticleType, 2, help="Generated top quarks from hard scattering"),
"genbquarks" : NTupleCollection("GenBQuark", genParticleType, 2, help="Generated bottom quarks from top quark decays"),
Expand Down
27 changes: 13 additions & 14 deletions CMGTools/TTHAnalysis/python/analyzers/treeProducerSusyFullHad.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,14 @@ def __init__(self, cfg_ana, cfg_comp, looperName):
## Declare what we want to fill (in addition to susy core ones)
self.globalVariables += [

#NTupleVariable("crossSection", lambda ev : ev.crossSection, help="process cross section in pb"),

NTupleVariable("nBJetLoose40", lambda ev: sum([j.btagWP("CSVL") for j in ev.cleanJets if j.pt() > 40]), int, help="Number of jets with pt > 40 passing CSV medium"),

NTupleVariable("ht", lambda ev : ev.htJet40j, help="H_{T} computed from only jets (with |eta|<2.4, pt > 40 GeV)"),

#NTupleVariable("crossSection", lambda ev : ev.crossSection, help="process cross section in pb"),
NTupleVariable("nBJet40", lambda ev: sum([j.btagWP("CSVM") for j in ev.cleanJets if j.pt() > 40]), int, help="Number of jets with pt > 40 passing CSV medium"),
NTupleVariable("ht", lambda ev : ev.htJet40jc, help="H_{T} computed from only jets (with |eta|<2.5, pt > 40 GeV)"),
NTupleVariable("deltaPhiMin", lambda ev : ev.deltaPhiMin, help="minimal deltaPhi between the MET and the four leading jets with pt>40 and eta<2.4"),
NTupleVariable("diffMetMht", lambda ev : ev.diffMetMht, help="abs( vec(mht) - vec(met) )"),

NTupleVariable("mht_pt", lambda ev : ev.mhtJet40j, help="H_{T}^{miss} computed from only jets (with |eta|<2.4, pt > 40 GeV)"),
NTupleVariable("mht_phi", lambda ev : ev.mhtPhiJet40j, help="H_{T}^{miss} #phi computed from onlyy jets (with |eta|<2.4, pt > 40 GeV)"),
NTupleVariable("mht_pt", lambda ev : ev.mhtJet40jc, help="H_{T}^{miss} computed from only jets (with |eta|<2.5, pt > 40 GeV)"),
NTupleVariable("mht_phi", lambda ev : ev.mhtPhiJet40jc, help="H_{T}^{miss} #phi computed from onlyy jets (with |eta|<2.5, pt > 40 GeV)"),
##--------------------------------------------------
NTupleVariable("nMuons10", lambda ev: sum([l.pt() > 10 and abs(l.pdgId()) == 13 for l in ev.inclusiveLeptons]), int, help="Number of muons with pt > 10"),
NTupleVariable("nElectrons10", lambda ev: sum([l.pt() > 10 and abs(l.pdgId()) == 11 for l in ev.inclusiveLeptons]), int, help="Number of electrons with pt > 10"),
Expand All @@ -32,7 +29,8 @@ def __init__(self, cfg_ana, cfg_comp, looperName):
# NTupleVariable("mtwTau", lambda ev: ev.mtwTau, int, help="mt(tau,met)"),
# NTupleVariable("IsoTrack_mtw", lambda ev: ev.mtwIsoTrack, int, help="mt(isoTrack,met)"),
##--------------------------------------------------
NTupleVariable("mt2", lambda ev: ev.mt2, float, help="mt2(l,met)"),
NTupleVariable("mt2", lambda ev: ev.mt2, float, help="mt2(j1,j2,,met)"),
NTupleVariable("mt2_gen", lambda ev: ev.mt2_gen, float, help="mt2(j1,j2,,met) with genInfo"),
# NTupleVariable("mt2w", lambda ev: ev.mt2w, float, help="mt2w(l,b,met)"),
##--------------------------------------------------
# NTupleVariable("minMWjj", lambda ev: ev.minMWjj, int, help="minMWjj"),
Expand All @@ -51,11 +49,12 @@ def __init__(self, cfg_ana, cfg_comp, looperName):
})
self.collections.update({
# put more here
"inclusiveLeptons" : NTupleCollection("lep", leptonTypeSusy, 8, help="Leptons after the preselection", filter=lambda l : l.pt()>10 ),
#"inclusiveLeptonsCuts" : NTupleCollection("lep", leptonTypeSusy, 8, help="Leptons after the preselection", filter=lambda l : l.pt()>10 ),
"cleanJetsAll" : NTupleCollection("jet", jetTypeSusy, 8, help="all jets after full selection and cleaning, sorted by pt"),
"selectedPhotons" : NTupleCollection("gamma", photonTypeSusy, 5, help="photons with pt>20 and loose cut based ID"),
"selectedIsoTrack" : NTupleCollection("isoTrack", isoTrackType, 3, help="isoTrack, sorted by pt"),
"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 after full selection and cleaning, sorted by pt", filter=lambda j : j.jetID("POG_PFID")>0),
"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"),
})

## Book the variables, but only if we're called explicitly and not through a base class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ def __init__(self, cfg_ana, cfg_comp, looperName):
})
self.collections.update({
# put more here
"selectedTaus" : NTupleCollection("TauGood", tauTypeSusy, 3, help="Taus after the preselection"),
"otherLeptons" : NTupleCollection("LepOther", leptonTypeSusy, 8, help="Leptons after the preselection"),
"selectedLeptons" : NTupleCollection("LepGood", leptonTypeSusy, 8, help="Leptons after the preselection"),
##------------------------------------------------
"cleanJets" : NTupleCollection("Jet", jetTypeSusy, 8, help="Cental jets after full selection and cleaning, sorted by pt"),
"cleanJetsFwd" : NTupleCollection("JetFwd", jetTypeSusy, 4, help="Forward jets after full selection and cleaning, sorted by pt"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ def __init__(self, cfg_ana, cfg_comp, looperName):
})
self.collections.update({
# put more here
"selectedLeptons" : NTupleCollection("LepGood", leptonTypeSusy, 8, help="Leptons after the preselection"),
"otherLeptons" : NTupleCollection("LepOther", leptonTypeSusy, 8, help="Leptons after the preselection"),
"selectedTaus" : NTupleCollection("TauGood", tauTypeSusy, 3, help="Taus after the preselection"),
##------------------------------------------------
"cleanJetsAll" : NTupleCollection("Jet", jetTypeSusy, 8, help="Cental jets after full selection and cleaning, sorted by pt"),
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ def __init__(self, cfg_ana, cfg_comp, looperName):
})
self.collections.update({
# put more here
"selectedLeptons" : NTupleCollection("LepGood", leptonTypeSusy, 8, help="Leptons after the preselection"),
"otherLeptons" : NTupleCollection("LepOther", leptonTypeSusy, 8, help="Leptons after the preselection"),
"selectedTaus" : NTupleCollection("TauGood", tauTypeSusy, 3, help="Taus after the preselection"),
##------------------------------------------------
"cleanJetsAll" : NTupleCollection("Jet", jetTypeSusy, 8, help="Cental jets after full selection and cleaning, sorted by pt"),
})
Expand Down
26 changes: 16 additions & 10 deletions CMGTools/TTHAnalysis/python/analyzers/ttHCoreEventAnalyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,50 +164,56 @@ def process(self, iEvent, event):
objects30 = [ j for j in event.cleanJets if j.pt() > 30 ] + event.selectedLeptons
objects40 = [ j for j in event.cleanJets if j.pt() > 40 ] + event.selectedLeptons
objects40j = [ j for j in event.cleanJets if j.pt() > 40 ]
objects40jc = [ j for j in event.cleanJets if j.pt() > 40 and abs(j.eta())<2.5 ]

event.htJet25 = sum([x.pt() for x in objects25])
event.mhtJet25vec = ROOT.reco.Particle.LorentzVector(sum([x.px() for x in objects25]) , sum([x.py() for x in objects25]), 0, 0 )
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()
event.mhtJet25 = event.mhtJet25vec.pt()

event.htJet30 = sum([x.pt() for x in objects30])
event.mhtJet30vec = ROOT.reco.Particle.LorentzVector(sum([x.px() for x in objects30]) , sum([x.py() for x in objects30]), 0, 0 )
event.mhtJet30vec = ROOT.reco.Particle.LorentzVector(-1.*(sum([x.px() for x in objects30])) , -1.*(sum([x.py() for x in objects30])), 0, 0 )
event.mhtJet30 = event.mhtJet30vec.pt()
event.mhtPhiJet30 = event.mhtJet30vec.phi()

event.htJet40 = sum([x.pt() for x in objects40])
event.mhtJet40vec = ROOT.reco.Particle.LorentzVector(sum([x.px() for x in objects40]) , sum([x.py() for x in objects40]), 0, 0 )
event.mhtJet40vec = ROOT.reco.Particle.LorentzVector(-1.*(sum([x.px() for x in objects40])) , -1.*(sum([x.py() for x in objects40])), 0, 0 )
event.mhtJet40 = event.mhtJet40vec.pt()
event.mhtPhiJet40 = event.mhtJet40vec.phi()

event.htJet40j = sum([x.pt() for x in objects40j])
event.mhtJet40jvec = ROOT.reco.Particle.LorentzVector(sum([x.px() for x in objects40j]) , sum([x.py() for x in objects40j]), 0, 0 )
event.mhtJet40jvec = ROOT.reco.Particle.LorentzVector(-1.*(sum([x.px() for x in objects40j])) , -1.*(sum([x.py() for x in objects40j])), 0, 0 )
event.mhtJet40j = event.mhtJet40jvec.pt()
event.mhtPhiJet40j = event.mhtJet40jvec.phi()

event.htJet40jc = sum([x.pt() for x in objects40jc])
event.mhtJet40jcvec = ROOT.reco.Particle.LorentzVector(-1.*(sum([x.px() for x in objects40jc])) , -1.*(sum([x.py() for x in objects40jc])), 0, 0 )
event.mhtJet40jc = event.mhtJet40jcvec.pt()
event.mhtPhiJet40jc = event.mhtJet40jcvec.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 ]

event.htJet25a = sum([x.pt() for x in objects25a])
event.mhtJet25veca = ROOT.reco.Particle.LorentzVector(sum([x.px() for x in objects25a]) , sum([x.py() for x in objects25a]), 0, 0 )
event.mhtJet25veca = ROOT.reco.Particle.LorentzVector(-1.*(sum([x.px() for x in objects25a])) , -1.*(sum([x.py() for x in objects25a])), 0, 0 )
event.mhtPhiJet25a = event.mhtJet25veca.phi()
event.mhtJet25a = event.mhtJet25veca.pt()

event.htJet30a = sum([x.pt() for x in objects30a])
event.mhtJet30veca = ROOT.reco.Particle.LorentzVector(sum([x.px() for x in objects30a]) , sum([x.py() for x in objects30a]), 0, 0 )
event.mhtJet30veca = ROOT.reco.Particle.LorentzVector(-1.*(sum([x.px() for x in objects30a])) , -1.*(sum([x.py() for x in objects30a])), 0, 0 )
event.mhtJet30a = event.mhtJet30veca.pt()
event.mhtPhiJet30a = event.mhtJet30veca.phi()

event.htJet40a = sum([x.pt() for x in objects40a])
event.mhtJet40veca = ROOT.reco.Particle.LorentzVector(sum([x.px() for x in objects40a]) , sum([x.py() for x in objects40a]), 0, 0 )
event.mhtJet40veca = ROOT.reco.Particle.LorentzVector(-1.*(sum([x.px() for x in objects40a])) , -1.*(sum([x.py() for x in objects40a])), 0, 0 )
event.mhtJet40a = event.mhtJet40veca.pt()
event.mhtPhiJet40a = event.mhtJet40veca.phi()

event.htJet40ja = sum([x.pt() for x in objects40ja])
event.mhtJet40jveca = ROOT.reco.Particle.LorentzVector(sum([x.px() for x in objects40ja]) , sum([x.py() for x in objects40ja]), 0, 0 )
event.mhtJet40jveca = ROOT.reco.Particle.LorentzVector(-1.*(sum([x.px() for x in objects40ja])) , -1.*(sum([x.py() for x in objects40ja])), 0, 0 )
event.mhtJet40ja = event.mhtJet40jveca.pt()
event.mhtPhiJet40ja = event.mhtJet40jveca.phi()

Expand All @@ -219,7 +225,7 @@ def process(self, iEvent, event):

# look for minimal deltaPhi between MET and four leading jets with pt>40 and eta<2.4
event.deltaPhiMin = 999.
for n,j in enumerate(event.cleanJets):
for n,j in enumerate(objects40jc):
if n>3: break
thisDeltaPhi = abs( deltaPhi( j.phi(), event.met.phi() ) )
if thisDeltaPhi < event.deltaPhiMin : event.deltaPhiMin = thisDeltaPhi
Expand All @@ -232,7 +238,7 @@ def process(self, iEvent, event):


# absolute value of the vectorial difference between met and mht
diffMetMht_vec = ROOT.reco.Particle.LorentzVector(event.mhtJet40jvec.px()-event.met.px(), event.mhtJet40jvec.py()-event.met.py(), 0, 0 )
diffMetMht_vec = ROOT.reco.Particle.LorentzVector(event.mhtJet40jcvec.px()-event.met.px(), event.mhtJet40jcvec.py()-event.met.py(), 0, 0 )
event.diffMetMht = sqrt( diffMetMht_vec.px()*diffMetMht_vec.px() + diffMetMht_vec.py()*diffMetMht_vec.py() )

return True
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def isFlavour(x,f):
def matchJets(self, event):
match = matchObjectCollection2(event.cleanJetsAll,
event.genbquarks + event.genwzquarks,
deltaRMax = 0.5)
deltaRMax = 0.3)
for jet in event.cleanJetsAll:
gen = match[jet]
jet.mcParton = gen
Expand All @@ -66,7 +66,7 @@ def matchJets(self, event):

match = matchObjectCollection2(event.cleanJetsAll,
event.genJets,
deltaRMax = 0.5)
deltaRMax = 0.3)
for jet in event.cleanJetsAll:
jet.mcJet = match[jet]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def declareCoreVariables(self, tr, isMC):
## PU weights
tr.var("puWeight")
## number of true interactions
tr.var("nTrueInt")
tr.var("nTrueInt",int)
## PDF weights
self.pdfWeights = []
if hasattr(self.cfg_ana, "PDFWeights") and len(self.cfg_ana.PDFWeights) > 0:
Expand Down
Loading

0 comments on commit 4d45770

Please sign in to comment.