def event_weight(self, row): if row.run > 2: #FIXME! add tight ID correction return 1. return self.pucorrector(row.nTruePU) * \ mcCorrectors.get_electron_corrections(row,'e2') *\ mcCorrectors.electron_tight_corrections(row.e1Pt, row.e1AbsEta) *\ mcCorrectors.double_electron_trigger(row)
def event_weight(self, row): if row.run > 2: return 1. return self.pucorrector(row.nTruePU) * \ mcCorrectors.get_muon_corrections(row,'m1','m2') * \ mcCorrectors.get_electron_corrections(row, 'e') * \ mcCorrectors.double_muon_trigger(row,'m1','m2')
def fill_histos(dirname, row, weight): mass = frfits.default_scaler(row.e1_e2_Mass) if "charge_weight" in dirname else row.e1_e2_Mass mass_up = frfits.default_scaler_up(row.e1_e2_Mass) if "charge_weight" in dirname else row.e1_e2_Mass mass_dw = frfits.default_scaler_down(row.e1_e2_Mass) if "charge_weight" in dirname else row.e1_e2_Mass histos[dirname]['ePt' ].Fill(row.e1Pt,weight) histos[dirname]['eAbsEta' ].Fill(row.e1AbsEta,weight) histos[dirname]['SCEnergy'].Fill(row.e1SCEnergy,weight) histos[dirname]['ePt' ].Fill(row.e2Pt,weight) histos[dirname]['eAbsEta' ].Fill(row.e2AbsEta,weight) histos[dirname]['SCEnergy'].Fill(row.e2SCEnergy,weight) histos[dirname]['TrkMass' ].Fill(mass, weight) histos[dirname]['TrkMass_low' ].Fill(mass_dw, weight) histos[dirname]['TrkMass_high' ].Fill(mass_up, weight) #histos[dirname]['SCMass' ].Fill(sc_inv_mass(row),weight) histos[dirname]["e1Pt" ].Fill(row.e1Pt,weight) histos[dirname]["e2Pt" ].Fill(row.e2Pt,weight) histos[dirname]["e1AbsEta"].Fill(row.e1AbsEta,weight) histos[dirname]["e2AbsEta"].Fill(row.e2AbsEta,weight) histos[dirname]['TrkMass_NOSCALE'].Fill(row.e1_e2_Mass, weight) histos[dirname]['TrkMass_NoWeight'].Fill(row.e1_e2_Mass) histos[dirname]['type1_pfMetEt'].Fill(row.type1_pfMetEt, weight) histos[dirname]['mva_metEt'].Fill(row.mva_metEt, weight) if row.run < 2: histos[dirname]["trig_weight" ].Fill( self.pucorrector(row.nTruePU) ) histos[dirname]["PU_weight" ].Fill( mcCorrectors.get_electron_corrections(row,'e1','e2') ) histos[dirname]["idIso_weight"].Fill( mcCorrectors.double_electron_trigger(row) )
def fill_folder(x, w): histos[x + '/weight'].Fill(w) histos[x + '/rho'].Fill(row.rho, w) histos[x + '/nvtx'].Fill(row.nvtx, w) histos[x + '/prescale'].Fill(row.mu17ele8Prescale, w) histos[x + '/group'].Fill(row.mu17ele8Group, w) histos[x + '/ePt'].Fill(row.ePt, w) histos[x + '/mPt'].Fill(row.mPt, w) histos[x + '/eAbsEta'].Fill(row.eAbsEta, w) histos[x + '/mAbsEta'].Fill(row.mAbsEta, w) histos[x + '/mPixHits'].Fill(row.mPixHits, w) histos[x + '/eJetBtag'].Fill(row.eJetBtag, w) histos[x + '/mJetBtag'].Fill(row.mJetBtag, w) histos[x + '/emMass'].Fill(row.e_m_Mass, w) histos[x + '/emMass_noweight'].Fill(row.e_m_Mass) histos[x + '/bjetVeto'].Fill(row.bjetVeto, w) histos[x + '/bjetCSVVeto'].Fill(row.bjetCSVVeto, w) histos[x + '/muVetoPt5'].Fill(row.muVetoPt5, w) histos[x + '/tauVetoPt20'].Fill(row.tauVetoPt20, w) histos[x + '/eVetoCicTightIso'].Fill(row.eVetoCicTightIso, w) if row.run < 2: histos[x + "/trig_weight"].Fill( mcCorrectors.correct_mueg_mu(row.mPt, row.mAbsEta) * mcCorrectors.correct_mueg_e(row.ePt, row.eAbsEta)) histos[x + "/PU_weight"].Fill(self.pucorrector(row.nTruePU)) histos[x + "/idIso_weight"].Fill( mcCorrectors.get_muon_corrections(row, 'm') * mcCorrectors.get_electron_corrections(row, 'e'))
def fill_folder(x, w): histos[x + '/weight'].Fill(w) histos[x + '/rho'].Fill(row.rho, w) histos[x + '/nvtx'].Fill(row.nvtx, w) histos[x + '/prescale'].Fill(row.mu17ele8Prescale, w) histos[x + '/group'].Fill(row.mu17ele8Group, w) histos[x + '/ePt'].Fill(row.ePt, w) histos[x + '/mPt'].Fill(row.mPt, w) histos[x + '/eAbsEta'].Fill(row.eAbsEta, w) histos[x + '/mAbsEta'].Fill(row.mAbsEta, w) histos[x + '/mPixHits'].Fill(row.mPixHits, w) histos[x + '/eJetBtag'].Fill(row.eJetBtag, w) histos[x + '/mJetBtag'].Fill(row.mJetBtag, w) histos[x + '/emMass'].Fill(row.e_m_Mass, w) histos[x + '/emMass_noweight'].Fill(row.e_m_Mass) histos[x + '/bjetVeto'].Fill(row.bjetVeto, w) histos[x + '/bjetCSVVeto'].Fill(row.bjetCSVVeto, w) histos[x + '/muVetoPt5'].Fill(row.muVetoPt5, w) histos[x + '/tauVetoPt20'].Fill(row.tauVetoPt20, w) histos[x + '/eVetoCicTightIso'].Fill(row.eVetoCicTightIso, w) if row.run < 2: histos[x + "/trig_weight" ].Fill(mcCorrectors.correct_mueg_mu(row.mPt, row.mAbsEta)* mcCorrectors.correct_mueg_e(row.ePt, row.eAbsEta) ) histos[x + "/PU_weight" ].Fill(self.pucorrector(row.nTruePU)) histos[x + "/idIso_weight"].Fill(mcCorrectors.get_muon_corrections(row,'m') * mcCorrectors.get_electron_corrections(row,'e') )
def mc_weight(self, row): if row.run > 2: return 1. else: return self.pucorrector(row.nTruePU) * \ mcCorrectors.get_electron_corrections(row,'e2') *\ mcCorrectors.electron_tight_corrections(row.e1Pt, row.e1AbsEta) *\ mcCorrectors.double_electron_trigger(row)
def event_weight(self, row): if row.run > 2: return 1. return self.pucorrector(row.nTruePU) * \ mcCorrectors.get_muon_corrections(row,'m') * \ mcCorrectors.get_electron_corrections(row,'e') * \ mcCorrectors.correct_mueg_mu(row.mPt, row.mAbsEta) * \ mcCorrectors.correct_mueg_e(row.ePt, row.eAbsEta)
def event_weight(self, row): if row.run > 2: return 1 return ( self.pucorrector(row.nTruePU) * mcCorrectors.get_electron_corrections(row, "e1", "e2") * mcCorrectors.get_muon_corrections(row, "m1", "m2") )
def process(self): def preselection(row): if not row.doubleEPass: return False if not (row.e1MatchesDoubleEPath > 0 and row.e2MatchesDoubleEPath > 0): return False if row.e1Pt < 20: return False if not selections.eSelection(row, "e1"): return False if not selections.eSelection(row, "e2"): return False if any([row.muVetoPt5, row.tauVetoPt20, row.eVetoCicTightIso]): return False if not (row.jetVeto40 >= 1): return False if row.e1_e2_Mass < 40: return False return True histos = self.histograms pucorrector = self.pucorrector for row in self.tree: if not preselection(row): continue evt_weight = pucorrector(row.nTruePU) * mcCorrectors.get_electron_corrections(row, "e1", "e2") for iso_label in lep_id: if not selections.lepton_id_iso(row, "e1", iso_label): continue if not selections.lepton_id_iso(row, "e2", iso_label): continue folder = "%s" % iso_label if row.e1GenPdgId != -999 and row.e2GenPdgId != -999: if row.e1_e2_SS: histos["%s/ss_trkMass" % folder].Fill(row.e1_e2_Mass, evt_weight) else: histos["%s/os_trkMass" % folder].Fill(row.e1_e2_Mass, evt_weight) for el in ["e1", "e2"]: pdgid = getattr(row, name_mapping(el, "GenPdgId")) if pdgid != -999: eta = getattr(row, name_mapping(el, "AbsEta")) pt = getattr(row, name_mapping(el, "Pt")) charge = getattr(row, name_mapping(el, "Charge")) if eta < barrelThr: histos["%s/pt_in_barrel" % folder].Fill(pt, evt_weight) elif eta < accThr: histos["%s/pt_in_endcap" % folder].Fill(pt, evt_weight) histos["%s/matched_electrons" % folder].Fill(eta, pt, evt_weight) single_hist = "%s/matched_%s" % (folder, el) histos[single_hist].Fill(eta, pt, evt_weight) if charge * (11) == pdgid: ##e- --> -11; e+ --> 11 MISMEASURED ELECTRON single_hist = "%s/flipped_%s" % (folder, el) histos[single_hist].Fill(eta, pt, evt_weight) histos["%s/flipped_electrons" % folder].Fill(eta, pt, evt_weight)
def process(self): def preselection(row): if not row.doubleEPass: return False if not (row.e1MatchesDoubleEPath > 0 and \ row.e2MatchesDoubleEPath > 0): return False if row.e1Pt < 20: return False if not selections.eSelection(row, 'e1'): return False if not selections.eSelection(row, 'e2'): return False if any([ row.muVetoPt5, row.tauVetoPt20, row.eVetoCicTightIso]): return False if not (row.jetVeto40 >= 1): return False if row.e1_e2_Mass < 40: return False return True histos = self.histograms pucorrector = self.pucorrector for row in self.tree: if not preselection(row): continue evt_weight = pucorrector(row.nTruePU) * \ mcCorrectors.get_electron_corrections(row,'e1','e2') *\ mcCorrectors.double_electron_trigger(row) for iso_label in lep_id: if not selections.lepton_id_iso(row, 'e1', iso_label): continue if not selections.lepton_id_iso(row, 'e2', iso_label): continue folder = '%s' % iso_label if row.e1GenPdgId != -999 and row.e2GenPdgId != -999: if row.e1_e2_SS: histos['%s/ss_trkMass' % folder].Fill(row.e1_e2_Mass, evt_weight) else: histos['%s/os_trkMass' % folder].Fill(row.e1_e2_Mass, evt_weight) for el in ['e1','e2']: pdgid = getattr(row, name_mapping(el,'GenPdgId')) if pdgid != -999: eta = getattr(row, name_mapping(el,'AbsEta') ) pt = getattr(row, name_mapping(el,'Pt') ) charge = getattr(row, name_mapping(el,'Charge') ) if eta < barrelThr: histos['%s/pt_in_barrel' % folder].Fill(pt, evt_weight) elif eta < accThr: histos['%s/pt_in_endcap' % folder].Fill(pt, evt_weight) histos['%s/matched_electrons' % folder].Fill( eta, pt, evt_weight) single_hist = '%s/matched_%s' % (folder, el) histos[single_hist].Fill( eta, pt, evt_weight) if charge*(11) == pdgid: ##e- --> -11; e+ --> 11 MISMEASURED ELECTRON single_hist = '%s/flipped_%s' % (folder, el) histos[single_hist].Fill( eta, pt, evt_weight) histos['%s/flipped_electrons' % folder].Fill( eta, pt, evt_weight )
def fill_histos(dirname, row, weight): mass = frfits.default_scaler( row.e1_e2_Mass ) if "charge_weight" in dirname else row.e1_e2_Mass mass_up = frfits.default_scaler_up( row.e1_e2_Mass ) if "charge_weight" in dirname else row.e1_e2_Mass mass_dw = frfits.default_scaler_down( row.e1_e2_Mass ) if "charge_weight" in dirname else row.e1_e2_Mass histos[dirname]['ePt'].Fill(row.e1Pt, weight) histos[dirname]['eAbsEta'].Fill(row.e1AbsEta, weight) histos[dirname]['SCEnergy'].Fill(row.e1SCEnergy, weight) histos[dirname]['ePt'].Fill(row.e2Pt, weight) histos[dirname]['eAbsEta'].Fill(row.e2AbsEta, weight) histos[dirname]['SCEnergy'].Fill(row.e2SCEnergy, weight) histos[dirname]['TrkMass'].Fill(mass, weight) histos[dirname]['TrkMass_low'].Fill(mass_dw, weight) histos[dirname]['TrkMass_high'].Fill(mass_up, weight) #histos[dirname]['SCMass' ].Fill(sc_inv_mass(row),weight) histos[dirname]["e1Pt"].Fill(row.e1Pt, weight) histos[dirname]["e2Pt"].Fill(row.e2Pt, weight) histos[dirname]["e1AbsEta"].Fill(row.e1AbsEta, weight) histos[dirname]["e2AbsEta"].Fill(row.e2AbsEta, weight) histos[dirname]['TrkMass_NOSCALE'].Fill(row.e1_e2_Mass, weight) histos[dirname]['TrkMass_NoWeight'].Fill(row.e1_e2_Mass) histos[dirname]['type1_pfMetEt'].Fill(row.type1_pfMetEt, weight) histos[dirname]['mva_metEt'].Fill(row.mva_metEt, weight) if row.run < 2: histos[dirname]["trig_weight"].Fill( self.pucorrector(row.nTruePU)) histos[dirname]["PU_weight"].Fill( mcCorrectors.get_electron_corrections(row, 'e1', 'e2')) histos[dirname]["idIso_weight"].Fill( mcCorrectors.double_electron_trigger(row))
def event_weight(self, row): if row.run > 2: return 1. return self.pucorrector(row.nTruePU) * \ mcCorrectors.get_electron_corrections(row,'e1','e2')
def correction(self, row): return self.pucorrector(row.nTruePU) * \ mcCorrectors.get_muon_corrections(row,'m') * \ mcCorrectors.get_electron_corrections(row,'e') * \ mcCorrectors.correct_mueg_mu(row.mPt, row.mAbsEta) * \ mcCorrectors.correct_mueg_e(row.ePt, row.eAbsEta)
def event_weight(self, row): if row.run > 2: return 1. return self.pucorrector(row.nTruePU) * \ mcCorrectors.get_muon_corrections(row,'m') * \ mcCorrectors.get_electron_corrections(row, 'e1','e2')