Skip to content

Commit

Permalink
Merge pull request cms-sw#16 from CMSEdge/dev-marc
Browse files Browse the repository at this point in the history
merged dev-marc into the head. updated edgeFriends
  • Loading branch information
mdunser committed Oct 30, 2015
2 parents ea1b7db + ebce76d commit b0c050f
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 34 deletions.
77 changes: 49 additions & 28 deletions CMGTools/TTHAnalysis/cfg/run_susyEdge_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@
#lepAna.loose_muon_dxy = 0.05
#lepAna.loose_muon_dz = 0.1
#But I go more inclusive for further selection in the edgeFriends
lepAna.loose_electron_dxy = 1.0
lepAna.loose_electron_dz = 1.0
lepAna.loose_muon_dxy = 0.3
lepAna.loose_muon_dz = 20.0
lepAna.loose_electron_dxy = 0.15
lepAna.loose_electron_dz = 0.5
lepAna.loose_muon_dxy = 0.15
lepAna.loose_muon_dz = 0.5


jetAna.recalibrateJets = False
Expand Down Expand Up @@ -198,6 +198,12 @@
treeProducer.globalVariables.append(NTupleVariable("hbheFilterIso", lambda ev: ev.hbheFilterIso, int, help="HBHE iso-based noise filter"))


## not needed for Oct05 and prompt-v4doT1METCorr = True
## not needed for Oct05 and prompt-v4if doT1METCorr:
## not needed for Oct05 and prompt-v4 jetAna.calculateType1METCorrection = True
## not needed for Oct05 and prompt-v4 metAna.recalibrate = "type1"
## not needed for Oct05 and prompt-v4 #metAna.old74XMiniAODs = old74XMiniAODs


##########################################################
############Trigger Definition and bits #################
Expand Down Expand Up @@ -275,48 +281,63 @@

runData = True
if runData:
## # Run2015C, 25 ns, 3.8T
## json = "/afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions15/13TeV/Cert_246908-256869_13TeV_PromptReco_Collisions15_25ns_JSON.txt"
## json = "/afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions15/13TeV/Cert_246908-258159_13TeV_PromptReco_Collisions15_25ns_JSON_v3.txt"
## processing = "Run2015C-PromptReco-v1"; short = "Run2015C_v1"; run_ranges = [ (246908,258160) ]; useAAA=False; is50ns=False; triggerFlagsAna.checkL1Prescale = False;
## json = "/afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions15/13TeV/Cert_246908-258714_13TeV_PromptReco_Collisions15_25ns_JSON.txt"
json = "/afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions15/13TeV/Cert_246908-258750_13TeV_PromptReco_Collisions15_25ns_JSON.txt"

## # Run2015C, 25 ns, 3.8T
## processing = "Run2015C-05Oct2015-v1"; short = "Run2015C_miniAODv2"; run_ranges = [ (246908,258714) ]; useAAA=False; is50ns=False; triggerFlagsAna.checkL1Prescale = False;

# Run2015D, 25 ns, 3.8 T re-miniAOD
##processing = "Run2015D-05Oct2015-v1"; short = "Run2015D_05Oct_v1"; run_ranges = [ (246908,258714) ]; useAAA=False; is50ns=False
##processing2 = "Run2015D-05Oct2015-v2"; short2 = "Run2015D_05Oct_v2"

# Run2015D, 25 ns, 3.8T
## json = "/afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions15/13TeV/Cert_246908-257599_13TeV_PromptReco_Collisions15_25ns_JSON.txt"
json = "/afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions15/13TeV/Cert_246908-258159_13TeV_PromptReco_Collisions15_25ns_JSON_v3.txt"
processing = "Run2015D-PromptReco-v3"; short = "Run2015D_v3"; run_ranges = [ (246908,258160) ]; useAAA=False; is50ns=False
# Run2015D, prompt-v4
processing = "Run2015D-PromptReco-v4"; short = "Run2015D_v4"; run_ranges = [ (246908,258751) ]; useAAA=False; is50ns=False
processing2 = "Run2015D-PromptReco-v4"; short2 = "Run2015D_v4";

compSelection = ""; compVeto = ""
DatasetsAndTriggers = []
selectedComponents = []; vetos = []

hadtriggers = triggers_pfht200 + triggers_pfht250 + triggers_pfht300 + triggers_ht350 + triggers_pfht400 + triggers_ht475 + triggers_ht600 + triggers_HT800 + triggers_HT900 + triggers_at57 + triggers_at55 + triggers_at53 + triggers_at52 + triggers_at51
DatasetsAndTriggers.append( ("DoubleMuon", triggers_mu17mu8 + triggers_mu17mu8_dz + triggers_mu17tkmu8_dz + triggers_mumu_noniso_50ns) )
DatasetsAndTriggers.append( ("DoubleEG", triggers_el17el12_dz + triggers_el23el12_dz + triggers_doubleele33) )
DatasetsAndTriggers.append( ("MuonEG", triggers_mu8el17 + triggers_mu8el23 + triggers_mu17el12 + triggers_mu30ele30) )
##DatasetsAndTriggers.append( ("JetHT", hadtriggers) )
##DatasetsAndTriggers.append( ("HTMHT", hadtriggers) )
## DatasetsAndTriggers.append( ("DoubleMuon", triggers_mu17mu8 + triggers_mu17mu8_dz + triggers_mu17tkmu8_dz + triggers_mumu_noniso_50ns) )
## DatasetsAndTriggers.append( ("DoubleEG", triggers_el17el12_dz + triggers_el23el12_dz + triggers_doubleele33) )
## DatasetsAndTriggers.append( ("MuonEG", triggers_mu8el17 + triggers_mu8el23 + triggers_mu17el12 + triggers_mu30ele30) )
## DatasetsAndTriggers.append( ("JetHT", hadtriggers) )
## DatasetsAndTriggers.append( ("HTMHT", hadtriggers) )
DatasetsAndTriggers.append( ("DoubleMuon",[] ) )
DatasetsAndTriggers.append( ("DoubleEG", [] ) )
DatasetsAndTriggers.append( ("MuonEG", [] ) )
DatasetsAndTriggers.append( ("JetHT", []) )
DatasetsAndTriggers.append( ("HTMHT", []) )

for pd,triggers in DatasetsAndTriggers:
short_use = short2 if pd == "MuonEG" else short
processing_use = processing2 if pd == "MuonEG" else processing
#if pd == "MuonEG": processing = processing.replace("v1", "v2")
for run_range in run_ranges:
label = "runs_%d_%d" % run_range if run_range[0] != run_range[1] else "run_%d" % (run_range[0],)
compname = pd+"_"+short+"_"+label
if ((compSelection and not re.search(compSelection, compname)) or
(compVeto and re.search(compVeto, compname))):
print "Will skip %s" % (compname)
continue
compname = pd+"_"+short_use+"_"+label
## if ((compSelection and not re.search(compSelection, compname)) or
## (compVeto and re.search(compVeto, compname))):
## print "Will skip %s" % (compname)
## continue
comp = kreator.makeDataComponent(compname,
"/"+pd+"/"+processing+"/MINIAOD",
"/"+pd+"/"+(processing2 if pd == "MuonEG" else processing) +"/MINIAOD",
"CMS", ".*root",
json=json,
run_range=run_range,
triggers=triggers[:], vetoTriggers = vetos[:],
#triggers=triggers[:], vetoTriggers = vetos[:],
triggers=[], vetoTriggers = vetos[:],
useAAA=useAAA)
print "Will process %s (%d files)" % (comp.name, len(comp.files))
# print "\ttrigger sel %s, veto %s" % (triggers, vetos)
comp.splitFactor = len(comp.files)
comp.splitFactor = len(comp.files)/2
comp.fineSplitFactor = 1
selectedComponents.append( comp )
vetos += triggers
#vetos += triggers
if json is None:
susyCoreSequence.remove(jsonAna)

Expand All @@ -327,10 +348,10 @@
print 'I\'m in the synch test thing here!!'
comp = TTLep_pow
selectedComponents = [comp]
comp.files = comp.files[:1]
#comp.files = [
#'/afs/cern.ch/work/m/mdunser/public/synchFiles/004613BA-C46D-E511-9EB6-001E67248732.root',
#]
#comp.files = comp.files[:1]
comp.files = [
'/afs/cern.ch/work/m/mdunser/public/synchFiles/004613BA-C46D-E511-9EB6-001E67248732.root',
]
#comp.finesplitFactor = 10
#comp.finesplitFactor = 4
elif test == '74X-MC':
Expand Down
21 changes: 15 additions & 6 deletions CMGTools/TTHAnalysis/python/tools/edgeFriends.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from CMGTools.TTHAnalysis.treeReAnalyzer import *

class edgeFriends:
def __init__(self,label,tightLeptonSel,cleanJet,isMC=True):
def __init__(self,label,tightLeptonSel,cleanJet,isMC=False):
self.label = "" if (label in ["",None]) else ("_"+label)
self.tightLeptonSel = tightLeptonSel
self.cleanJet = cleanJet
self.isMC = isMC
self.puFile = open("/afs/cern.ch/work/m/mdunser/public/puWeighting/puWeightsVince.txt","r")
self.puFile = open("/afs/cern.ch/work/m/mdunser/public/puWeighting/puWeightsVinceLumi1p28.txt","r")
self.pu_dict = eval(self.puFile.read())
self.puFile.close()
def listBranches(self):
Expand All @@ -17,12 +17,12 @@ def listBranches(self):
("nLepGood20"+label, "I"), ("nLepGood20T"+label, "I"),
("nJet35"+label, "I"), ("htJet35j"+label), ("nBJetLoose35"+label, "I"), ("nBJetMedium35"+label, "I"),
("iL1T"+label, "I"), ("iL2T"+label, "I"),
("lepsMll"+label, "F"), ("lepsJZB"+label, "F"), ("lepsDR"+label, "F"), ("lepsMETRec"+label, "F"), ("lepsZPt"+label, "F"),
("lepsMll"+label, "F"), ("lepsJZB"+label, "F"), ("lepsDR"+label, "F"), ("lepsMETRec"+label, "F"), ("lepsZPt"+label, "F"),
("Lep1_pt"+label, "F"), ("Lep1_eta"+label, "F"), ("Lep1_phi"+label, "F"), ("Lep1_miniRelIso"+label, "F"), ("Lep1_pdgId"+label, "I"), ("Lep1_mvaIdSpring15"+label, "F"), ("Lep1_minTauDR"+label, "F"),
("Lep2_pt"+label, "F"), ("Lep2_eta"+label, "F"), ("Lep2_phi"+label, "F"), ("Lep2_miniRelIso"+label, "F"), ("Lep2_pdgId"+label, "I"), ("Lep2_mvaIdSpring15"+label, "F"), ("Lep2_minTauDR"+label, "F"),
("PileupW"+label, "F"),
("min_mlb1"+label, "F"),
("min_mlb2"+label, "F"),
("Lep1_pt"+label, "F"), ("Lep1_eta"+label, "F"), ("Lep1_phi"+label, "F"), ("Lep1_miniRelIso"+label, "F"), ("Lep1_pdgId"+label, "I"), ("Lep1_mvaIdSpring15"+label, "F"),
("Lep2_pt"+label, "F"), ("Lep2_eta"+label, "F"), ("Lep2_phi"+label, "F"), ("Lep2_miniRelIso"+label, "F"), ("Lep2_pdgId"+label, "I"), ("Lep2_mvaIdSpring15"+label, "F")
]
## for lfloat in 'pt eta phi miniRelIso pdgId'.split():
## if lfloat == 'pdgId':
Expand All @@ -42,6 +42,8 @@ def __call__(self,event):
jetsc = [j for j in Collection(event,"Jet","nJet")]
jetsd = [j for j in Collection(event,"DiscJet","nDiscJet")]
(met, metphi) = event.met_pt, event.met_phi
if self.isMC:
gentaus = [t for t in Collection(event,"genTau","ngenTau")]
##ntrue = event.nTrueInt
nvtx = event.nVert
metp4 = ROOT.TLorentzVector()
Expand Down Expand Up @@ -123,8 +125,15 @@ def __call__(self,event):
lep = leps[idx] if idx >= 0 else lepso[-1-idx]
#for lfloat in 'pt eta phi miniRelIso pdgId'.split():
# lepret[lfloat].append( getattr(lep,lfloat) )
minDRTau = 99.
if self.isMC:
for tau in gentaus:
tmp_dr = deltaR(lep, tau)
if tmp_dr < minDRTau:
minDRTau = tmp_dr
for lfloat in 'pt eta phi miniRelIso pdgId mvaIdSpring15'.split():
lepret["Lep"+str(lcount)+"_"+lfloat+self.label] = getattr(lep,lfloat)
lepret["Lep"+str(lcount)+"_"+"minTauDR"+self.label] = minDRTau
ltlvs[lcount-1].SetPtEtaPhiM(lep.pt, lep.eta, lep.phi, 0.0005 if lep.pdgId == 11 else 0.106)
lcount += 1
#print 'good lepton', getattr(lep,'pt'), getattr(lep,'eta'), getattr(lep,'phi'), getattr(lep,'pdgId')
Expand Down Expand Up @@ -181,7 +190,7 @@ def __call__(self,event):
if not j._clean: continue
ret["nJet35"] += 1; ret["htJet35j"] += j.pt;
if j.btagCSV>0.423: ret["nBJetLoose35"] += 1
if j.btagCSV>0.814: ret["nBJetMedium35"] += 1
if j.btagCSV>0.890: ret["nBJetMedium35"] += 1
## compute mlb for the two lepton

jet = ROOT.TLorentzVector()
Expand Down

0 comments on commit b0c050f

Please sign in to comment.