Skip to content

Instantly share code, notes, and snippets.

@kpedro88
Created August 30, 2019 18:35
Show Gist options
  • Save kpedro88/1d58fc10abc9f66f73b8c996097148ad to your computer and use it in GitHub Desktop.
Save kpedro88/1d58fc10abc9f66f73b8c996097148ad to your computer and use it in GitHub Desktop.
from EventListFilter import *
filter_dir = '/uscms_data/d3/pedrok/SUSY2015/upgrade/for2018/CMSSW_10_2_11_patch1/src/TreeMaker/ecalBadCalibFilterLists/test/'
filter_files = [
filter_dir+'Summer16v5-Nano1June2019_QCD_Pt_300to470_TuneCUETP8M1_13TeV_pythia8_EcalDeadCellBoundaryEnergyFilterList.txt',
filter_dir+'Summer16v5-Nano1June2019_QCD_Pt_300to470_TuneCUETP8M1_13TeV_pythia8_ext1_EcalDeadCellBoundaryEnergyFilterList.txt',
]
EcalDeadCellBoundaryEnergyFilter = EventListFilterMC(filter_files)
skim_dir = 'root://cmseos.fnal.gov//store/user/lpcsusyhad/SVJ2017/Run2ProductionV17/Skims/tree_dijetmtdetahadloose/'
skim_file = 'tree_QCD_Pt_300to470_MC2016.root'
from ROOT import TFile, TTree
rfile = TFile.Open(skim_dir+skim_file)
tree = rfile.Get("tree")
tree.SetBranchStatus('*',0)
branches = ['RunNum','LumiBlockNum','EvtNum','GenJets','EcalDeadCellTriggerPrimitiveFilter']
for branch in branches:
tree.SetBranchStatus(branch,1)
total_EcalDeadCellBoundaryEnergyFilter = 0
total_EcalDeadCellTriggerPrimitiveFilter = 0
total_both = 0
for event in tree:
pass_EcalDeadCellBoundaryEnergyFilter = EcalDeadCellBoundaryEnergyFilter.CheckEvent(event.RunNum,event.LumiBlockNum,event.EvtNum,int(event.GenJets[0].Pt()))
pass_EcalDeadCellTriggerPrimitiveFilter = event.EcalDeadCellTriggerPrimitiveFilter
if not pass_EcalDeadCellBoundaryEnergyFilter: total_EcalDeadCellBoundaryEnergyFilter += 1
if not pass_EcalDeadCellTriggerPrimitiveFilter: total_EcalDeadCellTriggerPrimitiveFilter += 1
if not pass_EcalDeadCellBoundaryEnergyFilter and not pass_EcalDeadCellTriggerPrimitiveFilter: total_both += 1
print "Failed EcalDeadCellBoundaryEnergyFilter = "+str(total_EcalDeadCellBoundaryEnergyFilter)
print "Failed EcalDeadCellTriggerPrimitiveFilter = "+str(total_EcalDeadCellTriggerPrimitiveFilter)
print "Failed both = "+str(total_both)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment