def process(self): def preselection(row): if not row.doubleEPass: return False if not (row.e1MatchesDoubleEPath > 0 and \ row.e2MatchesDoubleEPath > 0): return False if not row.e1Pt > 20: return False if not selections.eSelection(row, 'e1'): return False if not row.e1MVAIDH2TauWP: return False if not selections.eSelection(row, 'e2'): return False if not (row.jetVeto40_DR05 >= 1): return False if not selections.vetos(row): return False return True def fill(the_histos, row, fillNtuple=False): weight = 1 if row.run == 1: weight = self.pucorrector(row.nTruePU) the_histos['electronPt'].Fill(row.e2Pt) the_histos['electronJetPt'].Fill(max(row.e2JetPt, row.e2Pt)) the_histos['electronAbsEta'].Fill(row.e2AbsEta) #the_histos['metSignificance'].Fill(row.metSignificance) the_histos['e1MtToMET'].Fill(row.e1MtToMET) the_histos['e2MtToMET'].Fill(row.e2MtToMET) the_histos['MET'].Fill(row.type1_pfMetEt) the_histos['OSS'].Fill(int(row.e1_e2_SS)) the_histos['e2JetptD'].Fill(row.e2JetptD) the_histos['e2Jetmult'].Fill(row.e2Jetmult) the_histos['e2Jetmultvse2JetPt'].Fill(max(row.e2JetPt, row.e2Pt),row.e2Jetmult) the_histos['e2JetptDvse2JetPt'].Fill(max(row.e2JetPt, row.e2Pt),row.e2JetptD) the_histos['e1e2Mass'].Fill(row.e1_e2_Mass) the_histos['doubleEPrescale'].Fill(row.doubleEPrescale) if fillNtuple: id_iso_vals = [ selections.lepton_id_iso(row, 'e2', label) for label in self.lepIds] #print id_iso_vals #print self.lepIds id_iso_vals = [float( i ) for i in id_iso_vals ] the_histos['electronInfo'].Fill( array("f", [row.e2Pt, row.e2JetPt, weight]+id_iso_vals) ) histos = self.histograms #pprint( histos) for row in self.tree: if not preselection(row): continue region = selections.control_region_ee(row) if region is None: continue if region == 'zee': continue # This is a QCD or Wjets def make_region_plots(full_region): fill(histos[full_region], row, True) for idlabel, idfcn in selections.electronIds.iteritems(): if not idfcn(row, 'e2'): #if it does not pass id skip! continue if row.e2RelPFIsoDB < 0.2: fill(histos[full_region + ( idlabel+'_idiso02',)], row) if (row.e2RelPFIsoDB < 0.15 and row.e2AbsEta < 1.479) or row.e2RelPFIsoDB < 0.1: fill(histos[full_region + ( idlabel+'_h2taucuts',)], row) if (row.e2RelPFIsoDB < 0.20 and row.e2AbsEta < 1.479) or row.e2RelPFIsoDB < 0.15: fill(histos[full_region + ( idlabel+'_h2taucuts020',)], row) make_region_plots((region, 'pt10')) if not (row.e1_e2_Mass > 60 and row.e1_e2_Mass < 120): make_region_plots((region+'NoZmass', 'pt10')) if row.e2Pt > 20: make_region_plots((region, 'pt20')) if not (row.e1_e2_Mass > 60 and row.e1_e2_Mass < 120): make_region_plots((region+'NoZmass', 'pt20'))
def process(self): def preselection(row): if not row.doubleEPass: return False if not (row.e1MatchesDoubleEPath > 0 and \ row.e2MatchesDoubleEPath > 0): return False if not row.e1Pt > 20: return False if not selections.eSelection(row, 'e1'): return False if not row.e1MVAIDH2TauWP: return False if not selections.eSelection(row, 'e2'): return False if not selections.vetos(row): return False return True def fill(the_histos, row): the_histos['electronPt'].Fill(row.e2Pt) the_histos['electronJetPt'].Fill(max(row.e2JetPt, row.e2Pt)) the_histos['electronAbsEta'].Fill(row.e2AbsEta) #the_histos['metSignificance'].Fill(row.metSignificance) the_histos['e1MtToMET'].Fill(row.e1MtToMET) the_histos['e2MtToMET'].Fill(row.e2MtToMET) the_histos['MET'].Fill(row.type1_pfMetEt) the_histos['OSS'].Fill(int(row.e1_e2_SS)) the_histos['e2JetArea'].Fill(row.e2JetArea) the_histos['e2JetEtaEtaMoment'].Fill( row.e2JetEtaEtaMoment ) the_histos['e2JetEtaPhiMoment'].Fill( row.e2JetEtaPhiMoment ) the_histos['e2JetEtaPhiSpread'].Fill( row.e2JetEtaPhiSpread ) the_histos['e2JetPhiPhiMoment'].Fill( row.e2JetPhiPhiMoment ) the_histos['e2JetptD'].Fill(row.e2JetptD) the_histos['e2Jetaxis1'].Fill(row.e2Jetaxis1) the_histos['e2Jetaxis2'].Fill(row.e2Jetaxis2) the_histos['e2Jetmult'].Fill(row.e2Jetmult) the_histos['e2JetmultMLPQC'].Fill(row.e2JetmultMLPQC) the_histos['e2JetmultMLP'].Fill(row.e2JetmultMLP) the_histos['e2JetQGLikelihoodID'].Fill(row.e2JetQGLikelihoodID) the_histos['e2JetQGMVAID'].Fill(row.e2JetQGMVAID) the_histos['e2JetQGLikelihoodIDvse2JetPt'].Fill(max(row.e2JetPt, row.e2Pt),row.e2JetQGLikelihoodID) the_histos['e2JetQGMVAIDvse2JetPt'].Fill(max(row.e2JetPt, row.e2Pt),row.e2JetQGMVAID) the_histos['e2Jetmultvse2JetptD'].Fill(row.e2JetptD,row.e2Jetmult) the_histos['e2JetmultMLPvse2JetptD'].Fill(row.e2JetptD,row.e2JetmultMLP) the_histos['e2JetmultMLPQCvse2JetptD'].Fill(row.e2JetptD,row.e2JetmultMLPQC) the_histos['e2Jetmultvse2JetPt'].Fill(max(row.e2JetPt, row.e2Pt),row.e2Jetmult) the_histos['e2JetmultMLPvse2JetPt'].Fill(max(row.e2JetPt, row.e2Pt),row.e2JetmultMLP) the_histos['e2JetmultMLPQCvse2JetPt'].Fill(max(row.e2JetPt, row.e2Pt),row.e2JetmultMLPQC) the_histos['e2JetptDvse2JetPt'].Fill(max(row.e2JetPt, row.e2Pt),row.e2JetptD) if row.e1_e2_Mass > 60 and row.e1_e2_Mass < 120 : the_histos['MET_Z'].Fill(row.type1_pfMetEt) the_histos['OSS_Z'].Fill(int(row.e1_e2_SS)) the_histos['e1MtToMET_Z'].Fill(row.e1MtToMET) the_histos['e2MtToMET_Z'].Fill(row.e2MtToMET) else: the_histos['MET_NoZ'].Fill(row.type1_pfMetEt) the_histos['e1MtToMET_NoZ'].Fill(row.e1MtToMET) the_histos['e2MtToMET_NoZ'].Fill(row.e2MtToMET) the_histos['e1e2Mass'].Fill(row.e1_e2_Mass) the_histos['doubleEPrescale'].Fill(row.doubleEPrescale) histos = self.histograms #pprint( histos) for row in self.tree: if not preselection(row): continue region = selections.control_region_ee(row) if region is None: continue if region == 'zee': continue # This is a QCD or Wjets def make_region_plots(full_region): fill(histos[full_region], row) if row.e2MVAIDH2TauWP: fill(histos[full_region + ( 'mvaid',)], row) if row.e2RelPFIsoDB < 0.3: fill(histos[full_region + ( 'iso03',)], row) if row.e2MVAIDH2TauWP and row.e2RelPFIsoDB < 0.3: fill(histos[full_region + ( 'mvaidiso03',)], row) if row.e2MVAIDH2TauWP and row.e2RelPFIsoDB < 0.1: fill(histos[full_region + ( 'mvaidiso01',)], row) if row.e2MVAIDH2TauWP and row.e2RelPFIsoDB < 0.2: fill(histos[full_region + ( 'mvaidiso02',)], row) if row.e2MVAIDH2TauWP and ((row.e2RelPFIsoDB < 0.15 and row.e2AbsEta < 1.479) or row.e2RelPFIsoDB < 0.1): fill(histos[full_region + ( 'h2taucuts',)], row) if row.e2MVAIDH2TauWP and ((row.e2RelPFIsoDB < 0.2 and row.e2AbsEta < 1.479) or row.e2RelPFIsoDB < 0.15): fill(histos[full_region + ( 'h2taucuts020',)], row) if row.e2MVAIDH2TauWP and ((row.e2RelPFIsoDB < 0.25 and row.e2AbsEta < 1.479) or row.e2RelPFIsoDB < 0.20): fill(histos[full_region + ( 'h2taucuts025',)], row) make_region_plots((region, 'pt10')) if region == 'wjets' and not (row.e1_e2_Mass > 70 and row.e1_e2_Mass < 110): make_region_plots(('wjetsNoZmass', 'pt10')) if row.e2Pt > 20: make_region_plots((region, 'pt20')) if region == 'wjets' and not (row.e1_e2_Mass > 70 and row.e1_e2_Mass < 110): make_region_plots(('wjetsNoZmass', 'pt20'))
def process(self): cut_flow_histo = self.cut_flow_histo cut_flow_trk = cut_flow_tracker(cut_flow_histo) def preselection(row, cut_flow_trk): if not row.doubleEPass: return False if not (row.e1MatchesDoubleEPath > 0 and \ row.e2MatchesDoubleEPath > 0): return False cut_flow_trk.Fill('trigger') if row.e1_e2_DR < 0.5: return False cut_flow_trk.Fill('e1_e2_DR') if not row.e1Pt > 20: return False if not selections.eSelection(row, 'e1'): return False if not row.e1MVAIDH2TauWP: return False cut_flow_trk.Fill('e1 presel') if not selections.eSelection(row, 'e2'): return False cut_flow_trk.Fill('e2 presel') #if not (row.jetVeto40_DR05 >= 1): return False if row.jetVeto20 == 0: return False cut_flow_trk.Fill('jet requirement') if not selections.vetos(row, cut_flow_trk): return False return True def fill(the_histos, row, fillNtuple=False): weight = 1 if row.run == 1: weight = self.pucorrector(row.nTruePU) the_histos['electronPt'].Fill(row.e2Pt) the_histos['electronJetPt'].Fill(max(row.e2JetPt, row.e2Pt)) the_histos['electronAbsEta'].Fill(row.e2AbsEta) #the_histos['metSignificance'].Fill(row.metSignificance) the_histos['e1MtToMET'].Fill(row.e1MtToMET) the_histos['e2MtToMET'].Fill(row.e2MtToMET) the_histos['MET'].Fill(row.type1_pfMetEt) the_histos['OSS'].Fill(int(row.e1_e2_SS)) the_histos['e2JetptD'].Fill(row.e2JetptD) the_histos['e2Jetmult'].Fill(row.e2Jetmult) the_histos['e2Jetmultvse2JetPt'].Fill(max(row.e2JetPt, row.e2Pt), row.e2Jetmult) the_histos['e2JetptDvse2JetPt'].Fill(max(row.e2JetPt, row.e2Pt), row.e2JetptD) the_histos['e1e2Mass'].Fill(row.e1_e2_Mass) the_histos['doubleEPrescale'].Fill(row.doubleEPrescale) if fillNtuple: id_iso_vals = [ selections.lepton_id_iso(row, 'e2', label) for label in self.lepIds ] #print id_iso_vals #print self.lepIds id_iso_vals = [float(i) for i in id_iso_vals] electron_jet_mass = -1 #inv_mass(row.e2Pt, row.e2Eta, row.e2Phi, row.leadingJetPt, row.leadingJetEta, row.leadingJetPhi) the_histos['electronInfo'].Fill( array("f", [ row.e2Pt, max(row.e2Pt, row.e2JetPt), max(0, row.e2JetCSVBtag), electron_jet_mass, row.jetVeto20, row.jetVeto40_DR05, weight ] + id_iso_vals)) the_histos['evtInfo'].Fill(row) histos = self.histograms #pprint( histos) for row in self.tree: cut_flow_trk.new_row(row.run, row.lumi, row.evt) cut_flow_trk.Fill('bare') if not preselection(row, cut_flow_trk): continue region = selections.control_region_ee(row) if region is None: continue if region == 'zee': continue if region_for_event_list and region == region_for_event_list: cut_flow_trk.Fill('region assignment') if zMassCut and not (60 < row.e1_e2_Mass < 120): cut_flow_trk.Fill('zMassCut') # This is a QCD or Wjets if region_for_event_list and region == region_for_event_list\ and (not zMassCut or not (60 < row.e1_e2_Mass < 120)) \ and not SYNC: print '%i:%i:%i' % (row.run, row.lumi, row.evt) continue def make_region_plots(full_region): fill(histos[full_region], row, True) for idlabel, idfcn in selections.electronIds.iteritems(): if not idfcn(row, 'e2'): #if it does not pass id skip! continue if row.e2RelPFIsoDB < 0.2: fill(histos[full_region + (idlabel + '_idiso02', )], row) if (row.e2RelPFIsoDB < 0.15 and row.e2AbsEta < 1.479) or row.e2RelPFIsoDB < 0.1: fill(histos[full_region + (idlabel + '_h2taucuts', )], row) if (row.e2RelPFIsoDB < 0.20 and row.e2AbsEta < 1.479) or row.e2RelPFIsoDB < 0.15: fill( histos[full_region + (idlabel + '_h2taucuts020', )], row) make_region_plots((region, 'pt10')) if not (row.e1_e2_Mass > 60 and row.e1_e2_Mass < 120): make_region_plots((region + 'NoZmass', 'pt10')) if region == 'wjetsLtLow' and row.e1MtToMET > 55: make_region_plots(('wjetsNoZmass', 'pt10')) if row.e2Pt > 20: make_region_plots((region, 'pt20')) if not (row.e1_e2_Mass > 60 and row.e1_e2_Mass < 120): make_region_plots((region + 'NoZmass', 'pt20')) if region == 'wjetsLtLow' and row.e1MtToMET > 55: make_region_plots(('wjetsNoZmass', 'pt20'))
def process(self): def preselection(row): if not row.doubleEPass: return False if not (row.e1MatchesDoubleEPath > 0 and \ row.e2MatchesDoubleEPath > 0): return False if not row.e1Pt > 20: return False if not selections.eSelection(row, 'e1'): return False if not row.e1MVAIDH2TauWP: return False if not selections.eSelection(row, 'e2'): return False if not (row.jetVeto40_DR05 >= 1): return False if not selections.vetos(row): return False return True def fill(the_histos, row, fillNtuple=False): weight = 1 if row.run == 1: weight = self.pucorrector(row.nTruePU) the_histos['electronPt'].Fill(row.e2Pt) the_histos['electronJetPt'].Fill(max(row.e2JetPt, row.e2Pt)) the_histos['electronAbsEta'].Fill(row.e2AbsEta) #the_histos['metSignificance'].Fill(row.metSignificance) the_histos['e1MtToMET'].Fill(row.e1MtToMET) the_histos['e2MtToMET'].Fill(row.e2MtToMET) the_histos['MET'].Fill(row.type1_pfMetEt) the_histos['OSS'].Fill(int(row.e1_e2_SS)) the_histos['e2JetptD'].Fill(row.e2JetptD) the_histos['e2Jetmult'].Fill(row.e2Jetmult) the_histos['e2Jetmultvse2JetPt'].Fill(max(row.e2JetPt, row.e2Pt), row.e2Jetmult) the_histos['e2JetptDvse2JetPt'].Fill(max(row.e2JetPt, row.e2Pt), row.e2JetptD) the_histos['e1e2Mass'].Fill(row.e1_e2_Mass) the_histos['doubleEPrescale'].Fill(row.doubleEPrescale) if fillNtuple: id_iso_vals = [ selections.lepton_id_iso(row, 'e2', label) for label in self.lepIds ] #print id_iso_vals #print self.lepIds id_iso_vals = [float(i) for i in id_iso_vals] the_histos['electronInfo'].Fill( array("f", [row.e2Pt, row.e2JetPt, weight] + id_iso_vals)) histos = self.histograms #pprint( histos) for row in self.tree: if not preselection(row): continue region = selections.control_region_ee(row) if region is None: continue if region == 'zee': continue # This is a QCD or Wjets def make_region_plots(full_region): fill(histos[full_region], row, True) for idlabel, idfcn in selections.electronIds.iteritems(): if not idfcn(row, 'e2'): #if it does not pass id skip! continue if row.e2RelPFIsoDB < 0.2: fill(histos[full_region + (idlabel + '_idiso02', )], row) if (row.e2RelPFIsoDB < 0.15 and row.e2AbsEta < 1.479) or row.e2RelPFIsoDB < 0.1: fill(histos[full_region + (idlabel + '_h2taucuts', )], row) if (row.e2RelPFIsoDB < 0.20 and row.e2AbsEta < 1.479) or row.e2RelPFIsoDB < 0.15: fill( histos[full_region + (idlabel + '_h2taucuts020', )], row) make_region_plots((region, 'pt10')) if not (row.e1_e2_Mass > 60 and row.e1_e2_Mass < 120): make_region_plots((region + 'NoZmass', 'pt10')) if row.e2Pt > 20: make_region_plots((region, 'pt20')) if not (row.e1_e2_Mass > 60 and row.e1_e2_Mass < 120): make_region_plots((region + 'NoZmass', 'pt20'))
def process(self): cut_flow_histo = self.cut_flow_histo cut_flow_trk = cut_flow_tracker(cut_flow_histo) def preselection(row, cut_flow_trk): if not row.doubleEPass: return False if not (row.e1MatchesDoubleEPath > 0 and \ row.e2MatchesDoubleEPath > 0): return False cut_flow_trk.Fill('trigger') if row.e1_e2_DR < 0.5: return False cut_flow_trk.Fill('e1_e2_DR') if not row.e1Pt > 20: return False if not selections.eSelection(row, 'e1'): return False if not row.e1MVAIDH2TauWP: return False cut_flow_trk.Fill('e1 presel') if not selections.eSelection(row, 'e2'): return False cut_flow_trk.Fill('e2 presel') #if not (row.jetVeto40_DR05 >= 1): return False if row.jetVeto20 == 0: return False cut_flow_trk.Fill('jet requirement') if not selections.vetos(row, cut_flow_trk): return False return True def fill(the_histos, row, fillNtuple=False): weight = 1 if row.run == 1: weight = self.pucorrector(row.nTruePU) the_histos['electronPt'].Fill(row.e2Pt) the_histos['electronJetPt'].Fill(max(row.e2JetPt, row.e2Pt)) the_histos['electronAbsEta'].Fill(row.e2AbsEta) #the_histos['metSignificance'].Fill(row.metSignificance) the_histos['e1MtToMET'].Fill(row.e1MtToMET) the_histos['e2MtToMET'].Fill(row.e2MtToMET) the_histos['MET'].Fill(row.type1_pfMetEt) the_histos['OSS'].Fill(int(row.e1_e2_SS)) the_histos['e2JetptD'].Fill(row.e2JetptD) the_histos['e2Jetmult'].Fill(row.e2Jetmult) the_histos['e2Jetmultvse2JetPt'].Fill(max(row.e2JetPt, row.e2Pt),row.e2Jetmult) the_histos['e2JetptDvse2JetPt'].Fill(max(row.e2JetPt, row.e2Pt),row.e2JetptD) the_histos['e1e2Mass'].Fill(row.e1_e2_Mass) the_histos['doubleEPrescale'].Fill(row.doubleEPrescale) if fillNtuple: id_iso_vals = [ selections.lepton_id_iso(row, 'e2', label) for label in self.lepIds] #print id_iso_vals #print self.lepIds id_iso_vals = [float( i ) for i in id_iso_vals ] electron_jet_mass = -1 #inv_mass(row.e2Pt, row.e2Eta, row.e2Phi, row.leadingJetPt, row.leadingJetEta, row.leadingJetPhi) the_histos['electronInfo'].Fill( array("f", [row.e2Pt, max(row.e2Pt, row.e2JetPt), max(0, row.e2JetCSVBtag), electron_jet_mass, row.jetVeto20, row.jetVeto40_DR05, weight]+id_iso_vals) ) the_histos['evtInfo'].Fill( row ) histos = self.histograms #pprint( histos) for row in self.tree: cut_flow_trk.new_row(row.run,row.lumi,row.evt) cut_flow_trk.Fill('bare') if not preselection(row, cut_flow_trk): continue region = selections.control_region_ee(row) if region is None: continue if region == 'zee': continue if region_for_event_list and region == region_for_event_list: cut_flow_trk.Fill('region assignment') if zMassCut and not (60 < row.e1_e2_Mass < 120): cut_flow_trk.Fill('zMassCut') # This is a QCD or Wjets if region_for_event_list and region == region_for_event_list\ and (not zMassCut or not (60 < row.e1_e2_Mass < 120)) \ and not SYNC: print '%i:%i:%i' % (row.run, row.lumi, row.evt) continue def make_region_plots(full_region): fill(histos[full_region], row, True) for idlabel, idfcn in selections.electronIds.iteritems(): if not idfcn(row, 'e2'): #if it does not pass id skip! continue if row.e2RelPFIsoDB < 0.2: fill(histos[full_region + ( idlabel+'_idiso02',)], row) if (row.e2RelPFIsoDB < 0.15 and row.e2AbsEta < 1.479) or row.e2RelPFIsoDB < 0.1: fill(histos[full_region + ( idlabel+'_h2taucuts',)], row) if (row.e2RelPFIsoDB < 0.20 and row.e2AbsEta < 1.479) or row.e2RelPFIsoDB < 0.15: fill(histos[full_region + ( idlabel+'_h2taucuts020',)], row) make_region_plots((region, 'pt10')) if not (row.e1_e2_Mass > 60 and row.e1_e2_Mass < 120): make_region_plots((region+'NoZmass', 'pt10')) if region == 'wjetsLtLow' and row.e1MtToMET > 55: make_region_plots(('wjetsNoZmass', 'pt10')) if row.e2Pt > 20: make_region_plots((region, 'pt20')) if not (row.e1_e2_Mass > 60 and row.e1_e2_Mass < 120): make_region_plots((region+'NoZmass', 'pt20')) if region == 'wjetsLtLow' and row.e1MtToMET > 55: make_region_plots(('wjetsNoZmass', 'pt20'))