Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
def control_region_muon(row):
    # Figure out what control region we are in.
    if selections.lepton_id_iso(row, 'e', 'eid12Medium_h2taucuts') and row.eMtToMET > 35 and row.mMtToMET < 35 and row.bjetCSVVetoZHLike == 0:
        return 'MwjetsLtLow'
    elif selections.lepton_id_iso(row, 'e', 'eid12Medium_h2taucuts') and row.eMtToMET > 35 and row.mMtToMET < 35 and row.bjetCSVVetoZHLike > 0:
        return 'Mttbar'
    elif row.eRelPFIsoDB > 0.3 and row.type1_pfMetEt < 25: # selections.electronIds['eid12Medium'](row, 'e') and
        return 'Mqcd'
    else:
        return None
Exemplo n.º 3
0
    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 )
Exemplo n.º 4
0
def control_region_muon(row):
    # Figure out what control region we are in.
    if selections.lepton_id_iso(
            row, 'e', 'eid12Medium_h2taucuts'
    ) and row.eMtToMET > 35 and row.mMtToMET < 35 and row.bjetCSVVetoZHLike == 0:
        return 'MwjetsLtLow'
    elif selections.lepton_id_iso(
            row, 'e', 'eid12Medium_h2taucuts'
    ) and row.eMtToMET > 35 and row.mMtToMET < 35 and row.bjetCSVVetoZHLike > 0:
        return 'Mttbar'
    elif row.eRelPFIsoDB > 0.3 and row.type1_pfMetEt < 25:  # selections.electronIds['eid12Medium'](row, 'e') and
        return 'Mqcd'
    else:
        return None
Exemplo n.º 5
0
        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) )
Exemplo n.º 6
0
        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))
Exemplo n.º 7
0
        def fill(the_histos, row, fillNtuple=False):
            weight = 1
            if row.run == 1:
                weight = self.pucorrector(row.nTruePU) *\
                         mcCorrectors.correct_mueg_mu(row.mPt, row.mAbsEta) * \
                         mcCorrectors.correct_mueg_e(row.ePt, row.eAbsEta)

            the_histos['ePt'].Fill(row.ePt)
            the_histos['eJetPt'].Fill(max(row.eJetPt, row.ePt))
            the_histos['eAbsEta'].Fill(row.eAbsEta)
            #the_histos['metSignificance'].Fill(row.metSignificance)
            the_histos['mMtToMET'].Fill(row.mMtToMET)
            the_histos['eJetptD'].Fill(row.mJetptD)
            the_histos['eJetmult'].Fill(row.mJetmult)
            the_histos['eJetmultvseJetPt'].Fill(max(row.eJetPt, row.ePt),
                                                row.eJetmult)
            the_histos['eJetptDvseJetPt'].Fill(max(row.eJetPt, row.ePt),
                                               row.eJetptD)
            if fillNtuple:
                id_iso_vals = [
                    float(selections.lepton_id_iso(row, 'e', label))
                    for label in self.lepIds
                ]
                the_histos['electronInfo'].Fill(
                    array("f", [row.ePt, row.eJetPt, weight] + id_iso_vals))
Exemplo n.º 8
0
        def fill(the_histos, row, fillNtuple=False):
            weight = 1
            if row.run == 1:
                weight = self.pucorrector(row.nTruePU) *\
                         mcCorrectors.correct_mueg_mu(row.mPt, row.mAbsEta) * \
                         mcCorrectors.correct_mueg_e(row.ePt, row.eAbsEta)

            the_histos['ePt'].Fill(row.ePt)
            the_histos['eJetPt'].Fill(max(row.eJetPt, row.ePt))
            the_histos['eAbsEta'].Fill(row.eAbsEta)
            #the_histos['metSignificance'].Fill(row.metSignificance)
            the_histos['mMtToMET'].Fill(row.mMtToMET)
            the_histos['eJetptD'].Fill(row.mJetptD)
            the_histos['eJetmult'].Fill(row.mJetmult)
            the_histos['eJetmultvseJetPt'].Fill(max(row.eJetPt, row.ePt),
                                                row.eJetmult)
            the_histos['eJetptDvseJetPt'].Fill(max(row.eJetPt, row.ePt),
                                               row.eJetptD)
            if fillNtuple:
                id_iso_vals = [
                    float(selections.lepton_id_iso(row, 'e', label))
                    for label in self.lepIds
                ]
                electron_jet_mass = -1.  #inv_mass(row.ePt, row.eEta, row.ePhi, row.leadingJetPt, row.leadingJetEta, row.leadingJetPhi)

                the_histos['electronInfo'].Fill(
                    array("f", [
                        row.ePt,
                        max(row.eJetPt, row.ePt),
                        max(0, row.eJetCSVBtag), electron_jet_mass,
                        row.jetVeto20, row.jetVeto40_DR05, weight
                    ] + id_iso_vals))

                the_histos['evtInfo'].Fill(row)
Exemplo n.º 9
0
 def fill(the_histos, row, fillNtuple=False):
     weight = 1
     if row.run == 1:
         weight = self.pucorrector(row.nTruePU) *\
                  mcCorrectors.correct_mueg_mu(row.mPt, row.mAbsEta) * \
                  mcCorrectors.correct_mueg_e(row.ePt, row.eAbsEta)
     
     the_histos['ePt'].Fill(row.ePt)
     the_histos['eJetPt'].Fill(max(row.eJetPt, row.ePt))
     the_histos['eAbsEta'].Fill(row.eAbsEta)
     #the_histos['metSignificance'].Fill(row.metSignificance)
     the_histos['mMtToMET'].Fill(row.mMtToMET)
     the_histos['eJetptD'].Fill(row.mJetptD)
     the_histos['eJetmult'].Fill(row.mJetmult)
     the_histos['eJetmultvseJetPt'].Fill(max(row.eJetPt, row.ePt),row.eJetmult)
     the_histos['eJetptDvseJetPt'].Fill(max(row.eJetPt, row.ePt),row.eJetptD) 
     if fillNtuple:
         id_iso_vals = [ float( selections.lepton_id_iso(row, 'e', label) ) for label in self.lepIds]
         the_histos['electronInfo'].Fill( array("f", [row.ePt, row.eJetPt, weight]+id_iso_vals) )
Exemplo n.º 10
0
    def process(self):

        #print self.tree.inputfilename
        for row in self.tree:
            jn = row.jetVeto30
            if jn > 3: jn = 3

            if not bool(row.singleE27WP80Pass): continue

            if not bool(row.eMatchesSingleE27WP80): continue

            if row.bjetCSVVeto30 != 0: continue
            if not selections.eLowPtSelection(row, 'e'): continue
            if not selections.lepton_id_iso(row, 'e', 'eid13Loose_idantiso'):
                continue
            if abs(row.eEta) > 1.4442 and abs(row.eEta < 1.566): continue

            if not selections.tauSelection(row, 't'): continue
            if row.tPt < 30: continue

            if not row.tAntiMuon2Loose: continue
            if not row.tAntiElectronMVA5Tight: continue  #was 3
            if row.tauVetoPt20EleTight3MuLoose: continue
            #if row.tauHpsVetoPt20 : continue
            if row.muVetoPt5IsoIdVtx: continue
            if row.eVetoCicLooseIso: continue  # change it with Loose

            sign = 'ss' if row.e_t_SS else 'os'
            if row.tLooseIso3Hits:
                tauiso = 'tLoose'
                folder = sign + '/' + tauiso
                self.fill_histos(row, folder)
                folder = folder + '/' + str(int(jn))
                self.fill_histos(row, folder)

            if row.tTightIso3Hits:
                tauiso = 'tTigh'
                folder = sign + '/' + tauiso
                self.fill_histos(row, folder)
                folder = folder + '/' + str(int(jn))
                self.fill_histos(row, folder)
Exemplo n.º 11
0
        def fill(the_histos, row, fillNtuple=False):
            weight = 1
            if row.run == 1:
                weight = self.pucorrector(row.nTruePU) *\
                         mcCorrectors.correct_mueg_mu(row.mPt, row.mAbsEta) * \
                         mcCorrectors.correct_mueg_e(row.ePt, row.eAbsEta)
            
            the_histos['ePt'].Fill(row.ePt)
            the_histos['eJetPt'].Fill(max(row.eJetPt, row.ePt))
            the_histos['eAbsEta'].Fill(row.eAbsEta)
            #the_histos['metSignificance'].Fill(row.metSignificance)
            the_histos['mMtToMET'].Fill(row.mMtToMET)
            the_histos['eJetptD'].Fill(row.mJetptD)
            the_histos['eJetmult'].Fill(row.mJetmult)
            the_histos['eJetmultvseJetPt'].Fill(max(row.eJetPt, row.ePt),row.eJetmult)
            the_histos['eJetptDvseJetPt'].Fill(max(row.eJetPt, row.ePt),row.eJetptD) 
            if fillNtuple:
                id_iso_vals = [ float( selections.lepton_id_iso(row, 'e', label) ) for label in self.lepIds]
                electron_jet_mass = -1. #inv_mass(row.ePt, row.eEta, row.ePhi, row.leadingJetPt, row.leadingJetEta, row.leadingJetPhi)
                
                the_histos['electronInfo'].Fill( array("f", [row.ePt, max(row.eJetPt, row.ePt), max(0, row.eJetCSVBtag), 
                                                             electron_jet_mass, row.jetVeto20, row.jetVeto40_DR05, weight]+id_iso_vals) )

                the_histos['evtInfo'].Fill(row)
Exemplo n.º 12
0
    def process(self):
        cut_flow_histo = self.cut_flow_histo
        cut_flow_trk   = cut_flow_tracker(cut_flow_histo)

        def preselection(row):
            if not row.e_m_SS: return False
            cut_flow_trk.Fill('e_m_SS')

            if row.e_m_DR < 0.5:                      return False
            cut_flow_trk.Fill('e_m_DR')

            if not selections.muSelection(row, 'm'):  return False #applies basic selection (eta, pt > 10, DZ, pixHits, jetBTag)
            cut_flow_trk.Fill('mu presel')

            if not selections.eSelection(row, 'e'):   return False #applies basic selection (eta, pt > 10, DZ, missingHits, jetBTag, HasConversion and chargedIdTight)
            if not row.eChargeIdTight:                return False
            cut_flow_trk.Fill('e presel')

            #if not (row.jetVeto40_DR05 >= 1):         return False
            if row.jetVeto20 == 0: return False
            cut_flow_trk.Fill('jet presence')

            if not selections.vetos(row, cut_flow_trk, False):  return False #applies mu bjet e additional tau vetoes
            #DO NOT APPLY BJet veto. It is used for ttbar CR
            return True
        #if self.is7TeV:
            #base_selection = 'mu17ele8Pass && ' + base_selection

        def fill(the_histos, row, fillNtuple=False):
            weight = 1
            if row.run == 1:
                weight = self.pucorrector(row.nTruePU) *\
                         mcCorrectors.correct_mueg_mu(row.mPt, row.mAbsEta) * \
                         mcCorrectors.correct_mueg_e(row.ePt, row.eAbsEta)
            
            the_histos['ePt'].Fill(row.ePt)
            the_histos['eJetPt'].Fill(max(row.eJetPt, row.ePt))
            the_histos['eAbsEta'].Fill(row.eAbsEta)
            #the_histos['metSignificance'].Fill(row.metSignificance)
            the_histos['mMtToMET'].Fill(row.mMtToMET)
            the_histos['eJetptD'].Fill(row.mJetptD)
            the_histos['eJetmult'].Fill(row.mJetmult)
            the_histos['eJetmultvseJetPt'].Fill(max(row.eJetPt, row.ePt),row.eJetmult)
            the_histos['eJetptDvseJetPt'].Fill(max(row.eJetPt, row.ePt),row.eJetptD) 
            if fillNtuple:
                id_iso_vals = [ float( selections.lepton_id_iso(row, 'e', label) ) for label in self.lepIds]
                electron_jet_mass = -1. #inv_mass(row.ePt, row.eEta, row.ePhi, row.leadingJetPt, row.leadingJetEta, row.leadingJetPhi)
                
                the_histos['electronInfo'].Fill( array("f", [row.ePt, max(row.eJetPt, row.ePt), max(0, row.eJetCSVBtag), 
                                                             electron_jet_mass, row.jetVeto20, row.jetVeto40_DR05, weight]+id_iso_vals) )

                the_histos['evtInfo'].Fill(row)

        def fill_muon(the_histos, row, fillNtuple=False):
            weight = 1.
            if row.run == 1:
                weight = self.pucorrector(row.nTruePU) *\
                         mcCorrectors.correct_mueg_mu(row.mPt, row.mAbsEta) * \
                         mcCorrectors.correct_mueg_e(row.ePt, row.eAbsEta)
                        
            the_histos['muonPt'].Fill(row.mPt, weight)
            the_histos['eMtToMET'].Fill(row.eMtToMET)
            the_histos['muonJetPt'].Fill(max(row.mJetPt, row.mPt), weight)
            the_histos['muonAbsEta'].Fill(row.mAbsEta, weight)
            the_histos['muonPtRatio'].Fill(row.mPt/max(row.mJetPt, row.mPt), weight)
            the_histos['muonPtDiff'].Fill(max(row.mJetPt, row.mPt) - row.mPt, weight)
            if fillNtuple:
                pfidiso02    = float( row.mPFIDTight and row.mRelPFIsoDB < 0.2)
                h2taucuts    = float( row.mPFIDTight and ((row.mRelPFIsoDB < 0.15 and row.mAbsEta < 1.479) or row.mRelPFIsoDB < 0.1 ))
                h2taucuts020 = float( row.mPFIDTight and ((row.mRelPFIsoDB < 0.20 and row.mAbsEta < 1.479) or row.mRelPFIsoDB < 0.15))
                muon_jet_mass = -1. #inv_mass(row.mPt, row.mEta, row.mPhi, row.leadingJetPt, row.leadingJetEta, row.leadingJetPhi)
                
                the_histos['muonInfo'].Fill( array("f", [row.mPt, max(row.mJetPt, row.mPt), max(0, row.mJetCSVBtag), 
                                                         muon_jet_mass, row.jetVeto20, row.jetVeto40_DR05, weight, 
                                                         pfidiso02, h2taucuts, h2taucuts020] ) )

                the_histos['evtInfo'].Fill(row)
                
        def fill_region(region,pt_cut):
            if region is None:
                return None
            fill(histos[(region, pt_cut)], row, True)

            for idlabel, idfcn in selections.electronIds.iteritems():                
                if not idfcn(row, 'e'): #if it does not pass id skip!
                    continue

                if row.eRelPFIsoDB < 0.2:
                    fill(histos[(region, pt_cut, idlabel+'_idiso02')], row)

                if (row.eRelPFIsoDB < 0.15 and row.eAbsEta < 1.479) or row.eRelPFIsoDB < 0.1:
                    fill(histos[(region, pt_cut, idlabel+'_h2taucuts')], row)

                if (row.eRelPFIsoDB < 0.20 and row.eAbsEta < 1.479) or row.eRelPFIsoDB < 0.15:
                    fill(histos[(region, pt_cut, idlabel+'_h2taucuts020')], row)

        def fill_muon_region(region, tag):
            if region is None:
                return None
            # This is a QCD or Wjets
            fill_muon(histos[(region, tag)], row, True)
            
            if row.mPFIDTight:
                if row.mRelPFIsoDB < 0.2:
                    fill_muon(histos[(region, tag, 'pfidiso02')], row)
                    
                if (row.mRelPFIsoDB < 0.15 and row.mAbsEta < 1.479) or row.mRelPFIsoDB < 0.1:
                    fill_muon(histos[(region, tag, 'h2taucuts')], row)

                if (row.mRelPFIsoDB < 0.20 and row.mAbsEta < 1.479) or row.mRelPFIsoDB < 0.15:
                    fill_muon(histos[(region, tag, 'h2taucuts020')], row)

                
        histos = self.histograms
        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):
                continue
            region = control_region(row)
            muon_region = control_region_muon(row)

            is7TeV = bool('7TeV' in os.environ['jobid'])
            use_iso_trigger = not is7TeV
            mu17e8 = (row.mu17ele8isoPass and row.mPt >= 20) if use_iso_trigger else (row.mu17ele8Pass and row.mPt >= 20)
            mu8e17 = (row.mu8ele17isoPass and row.ePt >= 20) if use_iso_trigger else (row.mu8ele17Pass and row.ePt >= 20)

            if env_lepton and env_lepton == 'e':
                if mu17e8:
                    cut_flow_trk.Fill('trigger')
                    if row.mPFIDTight and row.mRelPFIsoDB < 0.15:
                        cut_flow_trk.Fill('tag ID ISO')
                        if row.mMtToMET > 35:
                            cut_flow_trk.Fill('tag MT')
                            if row.eMtToMET < 35:
                                cut_flow_trk.Fill('probe MT')

            elif env_lepton and env_lepton == 'm':
                if mu8e17:
                    cut_flow_trk.Fill('trigger')
                    if selections.lepton_id_iso(row, 'e', 'eid12Medium_h2taucuts'):
                        cut_flow_trk.Fill('tag ID ISO')
                        if row.eMtToMET > 35:
                            cut_flow_trk.Fill('tag MT')
                            if row.mMtToMET < 35:
                                cut_flow_trk.Fill('probe MT')

            cut_flow_trk.flush()

            if mu17e8:
                fill_region(region,'pt10')
                if region == 'wjetsLtLow' and row.mMtToMET > 55:
                    fill_region('wjets', 'pt10')
            if mu8e17:
                fill_region(region,'pt20')
                if region == 'wjetsLtLow' and row.mMtToMET > 55:
                    fill_region('wjets', 'pt20')
                if muon_region:
                    fill_muon_region(muon_region, 'pt10')
                    if muon_region == 'MwjetsLtLow' and row.eMtToMET > 55:
                        fill_muon_region('Mwjets', 'pt10')
                    if row.mPt > 20:
                        fill_muon_region(muon_region, 'pt20')
                        if muon_region == 'MwjetsLtLow' and row.eMtToMET > 55:
                            fill_muon_region('Mwjets', 'pt20')
Exemplo n.º 13
0
    def process(self):

        cut_flow_histo = self.cut_flow_histo
        cut_flow_trk = cut_flow_tracker(cut_flow_histo)
        myevent = ()
        #print self.tree.inputfilename
        for row in self.tree:
            jn = row.jetVeto30
            if jn > 3: jn = 3

            #if row.run > 2:
            if not bool(row.singleE27WP80Pass): continue
            #            if hasattr(self.tree, 'row.e1MatchesEle27WP80') and hasattr(self.tree, 'row.e2MatchesEle27WP80') :
            #if not bool(row.e1MatchesEle27WP80) and not bool(row.e2MatchesEle27WP80) : continue

            #else :
            if not bool(row.e3MatchesSingleE27WP80): continue
            #if not bool(row.singleEPass) : continue
            #if not bool(row.e1MatchesSingleE) and  not bool(row.e2MatchesSingleE) : continue

            if row.bjetCSVVeto30 != 0: continue
            if row.e1Pt < 30: continue
            if row.e2Pt < 30: continue
            if row.e3Pt < 30: continue

            #        for i, row in enumerate(self.tree):
            #            if  i >= 100:
            #                return
            # print bool(cut_flow_trk.disabled)
            cut_flow_trk.new_row(row.run, row.lumi, row.evt)
            #print row.run,row.lumi,row.evt
            cut_flow_trk.Fill('allEvents')
            if not selections.eSelection(row, 'e1'): continue
            cut_flow_trk.Fill('e1sel')
            if not selections.lepton_id_iso(row, 'e1', 'eid13Loose_idiso05'):
                continue
            if abs(row.e1Eta) > 1.4442 and abs(row.e1Eta < 1.566): continue

            cut_flow_trk.Fill('e1IDiso')
            if not selections.eSelection(row, 'e2'): continue
            cut_flow_trk.Fill('e2sel')
            if not selections.lepton_id_iso(row, 'e2', 'eid13Loose_idiso05'):
                continue
            if abs(row.e2Eta) > 1.4442 and abs(row.e2Eta) < 1.566: continue

            ##            cut_flow_trk.Fill('e2IDiso')
            ##            if not abs(row.e1_e2_Mass-91.2) < 20: continue
            ##            cut_flow_trk.Fill('ZMass')
            if not selections.eSelection(row, 'e3'): continue
            if not selections.lepton_id_iso(row, 'e3', 'eid13Loose_idiso05'):
                continue  #very loose loose eid13Tight_mvaLoose
            if abs(row.e3Eta) > 1.4442 and abs(row.e3Eta) < 1.566: continue

            Zs = [(abs(row.e1_e2_Mass - 91.2), ['e1', 'e2', 'e3']),
                  (abs(row.e2_e3_Mass - 91.2), ['e2', 'e3', 'e1']),
                  (abs(row.e1_e3_Mass - 91.2), ['e1', 'e3', 'e2'])]

            for ele in range(0, 2):

                if Zs[ele][0] == min(Zs[z][0] for z in range(0, 2)):
                    self.mye1 = Zs[ele][1][0]
                    self.mye2 = Zs[ele][1][1]
                    self.mye3 = Zs[ele][1][2]

            cut_flow_trk.Fill('tsel')

            if row.tauVetoPt20EleTight3MuLoose: continue
            if row.muVetoPt5IsoIdVtx: continue
            if row.eVetoCicLooseIso: continue  # change it with Loose

            #if not row.e3MtToMET < 50:  continue
            cut_flow_trk.Fill('MtToMet')

            #if (row.run, row.lumi, row.evt, row.e1Pt, row.e2Pt)==myevent: continue
            #myevent=(row.run, row.lumi, row.evt, row.e1Pt, row.e2Pt)

            eleiso = 'eLoose'
            sign = 'ss' if row.e1_e2_SS else 'os'
            folder = sign + '/' + eleiso

            self.fill_histos(row, folder)
            folder = folder + '/' + str(int(jn))
            self.fill_histos(row, folder)

            if selections.lepton_id_iso(row, 'e3', 'eid13Loose_etauiso01'):
                eleiso = 'eTigh'
                folder = sign + '/' + eleiso
                self.fill_histos(row, folder)
                cut_flow_trk.Fill('tTightIso')
                folder = folder + '/' + str(int(jn))
                self.fill_histos(row, folder)

        cut_flow_trk.flush()
Exemplo n.º 14
0
 def obj1_id(row, leadleptonId='h2taucuts', subleadleptonId=None):
     return selections.lepton_id_iso(row, 'm1', leadleptonId)
Exemplo n.º 15
0
    def process(self):
        cut_flow_histo = self.cut_flow_histo
        cut_flow_trk = cut_flow_tracker(cut_flow_histo)

        def preselection(row):
            if not row.e_m_SS: return False
            cut_flow_trk.Fill('e_m_SS')

            if row.e_m_DR < 0.5: return False
            cut_flow_trk.Fill('e_m_DR')

            if not selections.muSelection(row, 'm'):
                return False  #applies basic selection (eta, pt > 10, DZ, pixHits, jetBTag)
            cut_flow_trk.Fill('mu presel')

            if not selections.eSelection(row, 'e'):
                return False  #applies basic selection (eta, pt > 10, DZ, missingHits, jetBTag, HasConversion and chargedIdTight)
            if not row.eChargeIdTight: return False
            cut_flow_trk.Fill('e presel')

            #if not (row.jetVeto40_DR05 >= 1):         return False
            if row.jetVeto20 == 0: return False
            cut_flow_trk.Fill('jet presence')

            if not selections.vetos(row, cut_flow_trk, False):
                return False  #applies mu bjet e additional tau vetoes
            #DO NOT APPLY BJet veto. It is used for ttbar CR
            return True

        #if self.is7TeV:
        #base_selection = 'mu17ele8Pass && ' + base_selection

        def fill(the_histos, row, fillNtuple=False):
            weight = 1
            if row.run == 1:
                weight = self.pucorrector(row.nTruePU) *\
                         mcCorrectors.correct_mueg_mu(row.mPt, row.mAbsEta) * \
                         mcCorrectors.correct_mueg_e(row.ePt, row.eAbsEta)

            the_histos['ePt'].Fill(row.ePt)
            the_histos['eJetPt'].Fill(max(row.eJetPt, row.ePt))
            the_histos['eAbsEta'].Fill(row.eAbsEta)
            #the_histos['metSignificance'].Fill(row.metSignificance)
            the_histos['mMtToMET'].Fill(row.mMtToMET)
            the_histos['eJetptD'].Fill(row.mJetptD)
            the_histos['eJetmult'].Fill(row.mJetmult)
            the_histos['eJetmultvseJetPt'].Fill(max(row.eJetPt, row.ePt),
                                                row.eJetmult)
            the_histos['eJetptDvseJetPt'].Fill(max(row.eJetPt, row.ePt),
                                               row.eJetptD)
            if fillNtuple:
                id_iso_vals = [
                    float(selections.lepton_id_iso(row, 'e', label))
                    for label in self.lepIds
                ]
                electron_jet_mass = -1.  #inv_mass(row.ePt, row.eEta, row.ePhi, row.leadingJetPt, row.leadingJetEta, row.leadingJetPhi)

                the_histos['electronInfo'].Fill(
                    array("f", [
                        row.ePt,
                        max(row.eJetPt, row.ePt),
                        max(0, row.eJetCSVBtag), electron_jet_mass,
                        row.jetVeto20, row.jetVeto40_DR05, weight
                    ] + id_iso_vals))

                the_histos['evtInfo'].Fill(row)

        def fill_muon(the_histos, row, fillNtuple=False):
            weight = 1.
            if row.run == 1:
                weight = self.pucorrector(row.nTruePU) *\
                         mcCorrectors.correct_mueg_mu(row.mPt, row.mAbsEta) * \
                         mcCorrectors.correct_mueg_e(row.ePt, row.eAbsEta)

            the_histos['muonPt'].Fill(row.mPt, weight)
            the_histos['eMtToMET'].Fill(row.eMtToMET)
            the_histos['muonJetPt'].Fill(max(row.mJetPt, row.mPt), weight)
            the_histos['muonAbsEta'].Fill(row.mAbsEta, weight)
            the_histos['muonPtRatio'].Fill(row.mPt / max(row.mJetPt, row.mPt),
                                           weight)
            the_histos['muonPtDiff'].Fill(
                max(row.mJetPt, row.mPt) - row.mPt, weight)
            if fillNtuple:
                pfidiso02 = float(row.mPFIDTight and row.mRelPFIsoDB < 0.2)
                h2taucuts = float(
                    row.mPFIDTight
                    and ((row.mRelPFIsoDB < 0.15 and row.mAbsEta < 1.479)
                         or row.mRelPFIsoDB < 0.1))
                h2taucuts020 = float(
                    row.mPFIDTight
                    and ((row.mRelPFIsoDB < 0.20 and row.mAbsEta < 1.479)
                         or row.mRelPFIsoDB < 0.15))
                muon_jet_mass = -1.  #inv_mass(row.mPt, row.mEta, row.mPhi, row.leadingJetPt, row.leadingJetEta, row.leadingJetPhi)

                the_histos['muonInfo'].Fill(
                    array("f", [
                        row.mPt,
                        max(row.mJetPt, row.mPt),
                        max(0, row.mJetCSVBtag), muon_jet_mass, row.jetVeto20,
                        row.jetVeto40_DR05, weight, pfidiso02, h2taucuts,
                        h2taucuts020
                    ]))

                the_histos['evtInfo'].Fill(row)

        def fill_region(region, pt_cut):
            if region is None:
                return None
            fill(histos[(region, pt_cut)], row, True)

            for idlabel, idfcn in selections.electronIds.iteritems():
                if not idfcn(row, 'e'):  #if it does not pass id skip!
                    continue

                if row.eRelPFIsoDB < 0.2:
                    fill(histos[(region, pt_cut, idlabel + '_idiso02')], row)

                if (row.eRelPFIsoDB < 0.15
                        and row.eAbsEta < 1.479) or row.eRelPFIsoDB < 0.1:
                    fill(histos[(region, pt_cut, idlabel + '_h2taucuts')], row)

                if (row.eRelPFIsoDB < 0.20
                        and row.eAbsEta < 1.479) or row.eRelPFIsoDB < 0.15:
                    fill(histos[(region, pt_cut, idlabel + '_h2taucuts020')],
                         row)

        def fill_muon_region(region, tag):
            if region is None:
                return None
            # This is a QCD or Wjets
            fill_muon(histos[(region, tag)], row, True)

            if row.mPFIDTight:
                if row.mRelPFIsoDB < 0.2:
                    fill_muon(histos[(region, tag, 'pfidiso02')], row)

                if (row.mRelPFIsoDB < 0.15
                        and row.mAbsEta < 1.479) or row.mRelPFIsoDB < 0.1:
                    fill_muon(histos[(region, tag, 'h2taucuts')], row)

                if (row.mRelPFIsoDB < 0.20
                        and row.mAbsEta < 1.479) or row.mRelPFIsoDB < 0.15:
                    fill_muon(histos[(region, tag, 'h2taucuts020')], row)

        histos = self.histograms
        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):
                continue
            region = control_region(row)
            muon_region = control_region_muon(row)

            is7TeV = bool('7TeV' in os.environ['jobid'])
            use_iso_trigger = not is7TeV
            mu17e8 = (row.mu17ele8isoPass
                      and row.mPt >= 20) if use_iso_trigger else (
                          row.mu17ele8Pass and row.mPt >= 20)
            mu8e17 = (row.mu8ele17isoPass
                      and row.ePt >= 20) if use_iso_trigger else (
                          row.mu8ele17Pass and row.ePt >= 20)

            if env_lepton and env_lepton == 'e':
                if mu17e8:
                    cut_flow_trk.Fill('trigger')
                    if row.mPFIDTight and row.mRelPFIsoDB < 0.15:
                        cut_flow_trk.Fill('tag ID ISO')
                        if row.mMtToMET > 35:
                            cut_flow_trk.Fill('tag MT')
                            if row.eMtToMET < 35:
                                cut_flow_trk.Fill('probe MT')

            elif env_lepton and env_lepton == 'm':
                if mu8e17:
                    cut_flow_trk.Fill('trigger')
                    if selections.lepton_id_iso(row, 'e',
                                                'eid12Medium_h2taucuts'):
                        cut_flow_trk.Fill('tag ID ISO')
                        if row.eMtToMET > 35:
                            cut_flow_trk.Fill('tag MT')
                            if row.mMtToMET < 35:
                                cut_flow_trk.Fill('probe MT')

            cut_flow_trk.flush()

            if mu17e8:
                fill_region(region, 'pt10')
                if region == 'wjetsLtLow' and row.mMtToMET > 55:
                    fill_region('wjets', 'pt10')
            if mu8e17:
                fill_region(region, 'pt20')
                if region == 'wjetsLtLow' and row.mMtToMET > 55:
                    fill_region('wjets', 'pt20')
                if muon_region:
                    fill_muon_region(muon_region, 'pt10')
                    if muon_region == 'MwjetsLtLow' and row.eMtToMET > 55:
                        fill_muon_region('Mwjets', 'pt10')
                    if row.mPt > 20:
                        fill_muon_region(muon_region, 'pt20')
                        if muon_region == 'MwjetsLtLow' and row.eMtToMET > 55:
                            fill_muon_region('Mwjets', 'pt20')
Exemplo n.º 16
0
 def obj2_id(self, row):
     return selections.lepton_id_iso(row, 'e2', subleading_iso)
Exemplo n.º 17
0
 def obj2_id(self, row):
     return selections.lepton_id_iso(row, 'm2', subleptonId)
Exemplo n.º 18
0
    def process(self):
        logging.debug('Starting processing')
        systematics = self.systematics

        frw = []
        lock = ()
        ievt = 0
        logging.debug('Starting evt loop')

        #pre-compute static things
        sys_shifts = systematics['trig'] + \
            systematics['pu'] + \
            systematics['eid'] + \
            systematics['eiso'] #+ \

        jes_dirs = [i.strip('_') for i in systematics['jes']]
        #anyway the first is always ""
        tes_dirs = [i.strip('_') for i in systematics['tes']][1:]
        ees_dirs = [i.strip('_') for i in systematics['ees']][1:]

        for row in self.tree:
            if (ievt % 100) == 0:
                logging.debug('New event')
            ievt += 1
            #avoid double counting events!
            evt_id = (row.run, row.lumi, row.evt)
            if evt_id == lock: continue
            if lock != () and evt_id == lock:
                logging.info('Removing duplicate of event: %d %d %d' % evt_id)

            #
            #preselection, common to everything and everyone
            #
            #trigger
            if self.is_embedded:
                if not bool(row.doubleMuPass): continue
            else:
                if not bool(row.singleE27WP80Pass): continue
                if not bool(row.eMatchesSingleE27WP80): continue

            #objects
            if not selections.eSelection(row, 'e'): continue
            #if row.ePt < 30 : continue
            if not selections.tauSelection(row, 't'): continue
            if not row.tAntiElectronMVA5Tight: continue
            if not row.tAntiMuon2Loose: continue
            if not row.tLooseIso3Hits: continue
            logging.debug('object selection passed')
            #e ID/ISO
            if not selections.lepton_id_iso(row, 'e', 'eid13Tight_idiso02'):
                continue
            logging.debug('Passed preselection')

            #
            # Compute event weight
            #
            #event weight
            #sys_shifts is precomputed

            #set_trace()
            weight_map = self.event_weight(row, sys_shifts)

            #Fill embedded sample normalization BEFORE the vetoes
            if not row.e_t_SS:
                self.fill_histos('os/gg/ept30', row, weight_map[''])

            # it is better vetoing on b-jets  after the histo for the DY embedded
            #bjet veto
            if row.bjetCSVVeto30 == 0: continue

            #tau ID, id Tau is tight then go in full selection, otherwise use for fakes
            isTauTight = bool(row.tTightIso3Hits)
            isETight = bool(
                selections.lepton_id_iso(row, 'e', 'eid13Tight_etauiso01'))
            etau_category = ['']
            if (not isETight) and (not isTauTight):
                etau_category = ['etLoose', 'etLoose/Up', 'etLoose/Down']
            elif (not isTauTight):
                etau_category = [
                    'tLoose', 'tLoose/Up', 'tLoose/Down', 'tLooseUnweight'
                ]
            elif (not isETight):
                etau_category = ['eLoose', 'eLoose/Up', 'eLoose/Down']

            #jet category
            central = struct(
                njets=2,
                #njets = min(row.jetVeto30, 3),
                tPt=row.tPt,
                ePt=row.ePt)
            #jets = [min(row.jetVeto30, 3), min(row.jetVeto30jes_plus, 3),  min(row.jetVeto30jes_minus, 3)]
            jets = [2, 2, 2]
            tpts = [row.tPt_tes_plus, row.tPt_tes_minus]
            epts = [row.ePt_ees_plus, row.ePt_ees_minus]
            sys_effects = [(name, central.clone(njets=jnum))
                           for name, jnum in zip(jes_dirs, jets)]
            sys_effects.extend([(name, central.clone(tPt=pt))
                                for name, pt in zip(tes_dirs, tpts)])
            sys_effects.extend([(name, central.clone(ePt=pt))
                                for name, pt in zip(ees_dirs, epts)])

            #
            # Full tight selection
            #
            passes_full_selection = False
            selection_categories = []
            for name, shifted in sys_effects:
                #preselection. flat pt values
                if shifted.ePt > 30 and shifted.tPt > 30:
                    selection_categories.append(
                        (name, '%i' % shifted.njets, ''))
                else:
                    continue

                ##if shifted.njets == 0 :
                ##    if shifted.tPt < 35: continue
                ##    if shifted.ePt < 40: continue
                ##    if deltaPhi(row.ePhi, row.tPhi) < 2.7 : continue
                ##    if row.tMtToPfMet > 50 : continue
                ##    selection_categories.append((name, '0', 'selected'))
                ##    passes_full_selection = True
                ##elif shifted.njets == 1 :
                ##    if shifted.tPt < 40: continue
                ##    if shifted.ePt < 35: continue
                ##    if row.tMtToPfMet > 35 : continue
                ##    selection_categories.append((name, '1', 'selected'))
                ##    passes_full_selection = True
                ##el
                if shifted.njets == 2:
                    if shifted.tPt < 40: continue
                    if shifted.ePt < 30: continue
                    if row.tMtToPfMet > 35: continue
                    if row.vbfMass < 550: continue
                    if row.vbfDeta < 3.5: continue
                    selection_categories.append((name, '2', 'selected'))
                    passes_full_selection = True

            if passes_full_selection:
                logging.debug('Passed full selection')

            #
            #different selections
            #
            sign = 'ss' if row.e_t_SS else 'os'
            processtype = 'gg'
            ptthreshold = ['ept30']

            #
            # Lepton vetoes
            #
            tvetoes = [
                row.tauVetoPt20EleTight3MuLoose,
                row.tauVetoPt20EleTight3MuLoose_tes_plus,
                row.tauVetoPt20EleTight3MuLoose_tes_minus
            ]
            mvetoes = [
                row.muVetoPt5IsoIdVtx, row.muVetoPt5IsoIdVtx_mes_plus,
                row.muVetoPt5IsoIdVtx_mes_minus
            ]
            evetoes = [
                row.eVetoCicLooseIso, row.eVetoCicLooseIso_ees_plus,
                row.eVetoCicLooseIso_ees_minus
            ]

            tdirs = [
                i for i, j in zip(systematics['tvetos'], tvetoes) if not j
            ]
            mdirs = [
                i for i, j in zip(systematics['mvetos'], mvetoes) if not j
            ]
            edirs = [
                i for i, j in zip(systematics['evetos'], evetoes) if not j
            ]

            #if any of the lists is empty
            #set_trace()
            if not tdirs or not mdirs or not edirs:
                continue
            logging.debug('Passed Vetoes')

            #make all possible veto combos...
            all_dirs = [
                ''.join(i) for i in itertools.product(tdirs, mdirs, edirs)
            ]
            #...and choose only the meaningful ones
            veto_sys = set(systematics['tvetos'] + systematics['mvetos'] +
                           systematics['evetos'])
            all_dirs = [i for i in all_dirs if i in veto_sys]

            sys_directories = all_dirs + sys_shifts
            #remove duplicates
            sys_directories = list(set(sys_directories))

            #at least one loose object
            if (not isETight) or (not isTauTight):
                #if is a loose tau just compute the fakes!
                sys_directories = etau_category

                #gather the one and only weight we do care about
                mc_weight = weight_map['']

                #weights are the fr ones...
                weight_map = self.fakerate_weights(row.tEta)
                for i in weight_map:
                    #...times the mc weight (if any)
                    weight_map[i] *= mc_weight

            #Fill histograms in appropriate direcotries
            #if passes_full_selection:
            #dirs = [os.path.join(sys, sign, processtype, e_thr, jet_dir) for sys, e_thr, jet_dir in itertools.product(sys_directories, ptthreshold, jet_directories)]
            #if len(dirs) <> len(set(dirs)):
            #    set_trace()
            for sys, e_thr, selection in itertools.product(
                    sys_directories, ptthreshold, selection_categories):
                selection_sys, jet_dir, selection_step = selection
                #if we have multiple systematic shifts applied
                #reject the combination
                if selection_sys and sys:
                    continue

                #if we fill a histogram, lock the event
                lock = evt_id
                dir_name = os.path.join(sys, selection_sys, sign, processtype,
                                        e_thr, jet_dir, selection_step)
                if dir_name[-1] == '/':
                    dir_name = dir_name[:-1]
                if passes_full_selection:
                    logging.debug('Filling %s' % dir_name)
                #fill them!
                weight_to_use = weight_map[
                    sys] if sys in weight_map else weight_map['']
                self.fill_histos(dir_name, row, weight_to_use)
Exemplo n.º 19
0
    def process(self):
        
        

        central_weights = fakerate_central_histogram(25,0, 2.5)
        
        p1s_weights = fakerate_p1s_histogram(25,0, 2.5)#fakerate_p1s_histogram(25,0, 2.5)
        
        m1s_weights = fakerate_m1s_histogram(25,0, 2.5)#fakerate_m1s_histogram(25,0, 2.5)
        
                
        
        frw = []
        myevent =()
        for row in self.tree:
        #for n, row in enumerate(self.tree):
            
            sign = 'ss' if row.e_t_SS else 'os'
            processtype = '' ## use a line as for sign when the vbf when selections are defined            
            ptthreshold = [30]
            processtype ='gg'##changed from 20
            jn = row.jetVeto30
            if jn > 3 : jn = 3
            jn_jes_plus = row.jetVeto30jes_plus
            jn_jes_minus = row.jetVeto30jes_minus

            if jn_jes_plus >3 :  jn_jes_plus=3
            if jn_jes_minus >3 : jn_jes_minus=3

            #if row.run > 2 : #apply the trigger to data only (MC triggers enter in the scale factors)
            
            if self.is_embedded :

                if not bool(row.doubleMuPass) : continue
            else: 
                if not bool(row.singleE27WP80Pass) : continue
                if  not  bool(row.eMatchesSingleE27WP80): continue
                        
            if not selections.eSelection(row, 'e'): continue
               
            if not selections.lepton_id_iso(row, 'e', 'eid13Tight_etauiso01'): continue
                        
            if abs(row.eEta) > 1.4442 and abs(row.eEta) < 1.566 : continue
            if not selections.tauSelection(row, 't'): continue
                        
            if row.ePt < 30 : continue
            #if row.eMtToPFMET <40 : continue
            
            if not row.tAntiElectronMVA5Tight : continue
            if not row.tAntiMuon2Loose : continue
            if not row.tLooseIso3Hits : continue
            
            #isTauTight = False
            frw=self.fakerate_weights(row.tEta, central_weights, p1s_weights, m1s_weights )

            #if row.tauVetoPt20EleTight3MuLoose : continue 
            #if row.muVetoPt5IsoIdVtx : continue
            #if row.eVetoCicLooseIso : continue # change it with Loose

            if row.tauVetoPt20EleTight3MuLoose  and row.tauVetoPt20EleTight3MuLoose_tes_minus and row.tauVetoPt20EleTight3MuLoose_tes_plus: continue 
            if row.muVetoPt5IsoIdVtx and row.muVetoPt5IsoIdVtx_mes_minus and row.muVetoPt5IsoIdVtx_mes_plus : continue
            if row.eVetoCicLooseIso and row.eVetoCicLooseIso_ees_minus and row.eVetoCicLooseIso_ees_plus : continue
            
            standardSelection=True
            tesminus =True
            tesplus  =True
            mesminus =True
            mesplus  =True
            eesminus =True
            eesplus  =True        
            
            if  row.tauVetoPt20EleTight3MuLoose or row.muVetoPt5IsoIdVtx or  row.eVetoCicLooseIso : standardSelection =  False             

            if  row.tauVetoPt20EleTight3MuLoose_tes_minus or row.muVetoPt5IsoIdVtx or  row.eVetoCicLooseIso : tesminus =  False 
            if  row.tauVetoPt20EleTight3MuLoose_tes_plus or row.muVetoPt5IsoIdVtx or  row.eVetoCicLooseIso  : tesplus  =  False 
            if  row.tauVetoPt20EleTight3MuLoose or row.muVetoPt5IsoIdVtx_mes_minus or  row.eVetoCicLooseIso : mesminus =  False 
            if  row.tauVetoPt20EleTight3MuLoose or row.muVetoPt5IsoIdVtx_mes_plus or  row.eVetoCicLooseIso  : mesplus  =  False 
            if  row.tauVetoPt20EleTight3MuLoose or row.muVetoPt5IsoIdVtx or  row.eVetoCicLooseIso_ees_minus : eesminus =  False 
            if  row.tauVetoPt20EleTight3MuLoose or row.muVetoPt5IsoIdVtx or  row.eVetoCicLooseIso_ees_plus  : eesplus  =  False 
            
            dirpaths = [(standardSelection, sign+'/'+processtype), (mesplus, 'mVetoUp/'+sign+'/'+processtype),  (mesminus, 'mVetoDown/'+sign+'/'+processtype), \
                        (eesplus, 'eVetoUp/'+sign+'/'+processtype),  (eesminus, 'eVetoDown/'+sign+'/'+processtype), \
                        (tesplus, 'tVetoUp/'+sign+'/'+processtype),  (tesminus, 'tVetoDown/'+sign+'/'+processtype)]

            
            
            if (row.run, row.lumi, row.evt)==myevent: continue
            if myevent!=() and (row.run, row.lumi, row.evt)==(myevent[0], myevent[1], myevent[2]): print row.ePt, row.tPt
            
            myevent=(row.run, row.lumi, row.evt)

            isTauTight = bool(row.tTightIso3Hits)
            folder = dirpaths[0][1]+'/ept30'
            if dirpaths[0][0] == True and sign=='os':
                self.fill_histos(row, folder,isTauTight, frw)
                   
            
            if row.bjetCSVVeto30!=0 : continue # it is better vetoing on b-jets  after the histo for the DY embedded

            for n,dirpath in enumerate(dirpaths):
                jetlist = [(int(jn), str(int(jn)))]
                if  dirpath[0]==False : continue 
                if n==0:
                    jetlist.extend([(int(jn_jes_plus), str(int(jn_jes_plus))+'_jes_plus'), (int(jn_jes_minus), str(int(jn_jes_plus))+'_jes_minus')])
                for jet in jetlist:
                    #for j in ptthreshold:
                    folder = dirpath[1]+'/ept30/'+jet[1]
                                        
                        #print row.tLooseIso3Hits, row.tTightIso3Hits, isTauTight
                                                
                    self.fill_histos(row, folder,isTauTight, frw)
                
                    if jet[0] == 0 :
                        if row.tPt < 35: continue 
                        if row.ePt < 40 : continue
                        if deltaPhi(row.ePhi, row.tPhi) < 2.7 : continue
                        if row.tMtToPFMET > 50 : continue
                    if jet[0] == 1 :
                        if row.tPt < 40: continue 
                        if row.ePt < 35 : continue
                        if row.tMtToPFMET > 35 : continue
                    if jet[0] == 2 :
                        if row.tPt < 40: continue 
                        if row.ePt < 30 : continue # no cut as only electrons with pt>30 are in the ntuples
                        if row.tMtToPFMET > 35 : continue
                        if row.vbfMass < 550 : continue
                        if row.vbfDeta < 3.5 : continue
                    folder = dirpath[1]+'/ept30/'+jet[1]+'/selected'
                    self.fill_histos(row, folder, isTauTight,frw)
Exemplo n.º 20
0
 def obj2_id(row, ledleptonId='h2taucuts', subledleptonId='h2taucuts'):
     return selections.lepton_id_iso(row, 'e', subledleptonId)
Exemplo n.º 21
0
 def obj1_id(self, row):
     return selections.lepton_id_iso(row, 'm1', leadleptonId) 
Exemplo n.º 22
0
 def obj2_id(row, leadleptonId=None, subleadleptonId='eid13Looseh2taucuts'):
     return selections.lepton_id_iso(row, 'e2', subleadleptonId)
Exemplo n.º 23
0
 def obj2_id( row, ledleptonId='h2taucuts', subledleptonId='h2taucuts'):
     return selections.lepton_id_iso(row, 'e', subledleptonId)
Exemplo n.º 24
0
 def obj1_id(self, row):
     return selections.lepton_id_iso(row, 'e1', leading_iso)
Exemplo n.º 25
0
 def obj2_id(row, leadleptonId=None, subleadleptonId='h2taucuts'):
     return selections.lepton_id_iso(row, 'm2', subleadleptonId)
Exemplo n.º 26
0
    def process(self):
        
        cut_flow_histo = self.cut_flow_histo
        cut_flow_trk   = cut_flow_tracker(cut_flow_histo)
        myevent =()
        #print self.tree.inputfilename
        for row in self.tree:
            jn = row.jetVeto30
            if jn > 3 : jn = 3
            
            #if row.run > 2: 
            if not bool(row.singleE27WP80Pass) : continue
            #            if hasattr(self.tree, 'row.e1MatchesEle27WP80') and hasattr(self.tree, 'row.e2MatchesEle27WP80') :
            #if not bool(row.e1MatchesEle27WP80) and not bool(row.e2MatchesEle27WP80) : continue
            
            #else :
            if not bool(row.e1MatchesSingleE27WP80) and  not bool(row.e2MatchesSingleE27WP80) : continue
                #if not bool(row.singleEPass) : continue
                #if not bool(row.e1MatchesSingleE) and  not bool(row.e2MatchesSingleE) : continue
                
            if row.bjetCSVVeto30!=0 : continue 
            if row.e1Pt < 30 : continue
            if row.e2Pt < 30 : continue
                       
#        for i, row in enumerate(self.tree):
#            if  i >= 100:
#                return
           # print bool(cut_flow_trk.disabled)
            cut_flow_trk.new_row(row.run,row.lumi,row.evt)
            #print row.run,row.lumi,row.evt
            cut_flow_trk.Fill('allEvents')
            if not selections.eSelection(row, 'e1'): continue
            cut_flow_trk.Fill('e1sel')
            if not selections.lepton_id_iso(row, 'e1', 'eid13Tight_etauiso01'): continue
            if abs(row.e1Eta) > 1.4442 and abs(row.e1Eta < 1.566) : continue
            
            
            cut_flow_trk.Fill('e1IDiso')
            if not selections.eSelection(row, 'e2'): continue
            cut_flow_trk.Fill('e2sel')
            if not selections.lepton_id_iso(row, 'e2', 'eid13Tight_etauiso01'): continue
            if abs(row.e2Eta) > 1.4442 and abs(row.e2Eta) < 1.566 : continue
            
            cut_flow_trk.Fill('e2IDiso')
            if not abs(row.e1_e2_Mass-91.2) < 20: continue
            cut_flow_trk.Fill('ZMass')
            if not selections.tauSelection(row, 't'): continue
            if row.tPt < 30 : continue
            cut_flow_trk.Fill('tsel')

            if not row.tAntiMuon2Loose: continue
            cut_flow_trk.Fill('tAntiMuon')
            if not row.tAntiElectronMVA5Tight: continue #was 3
            cut_flow_trk.Fill('tAntiEle')

            if row.tauVetoPt20EleTight3MuLoose : continue 
            #if row.tauHpsVetoPt20 : continue
            if row.muVetoPt5IsoIdVtx : continue
            if row.eVetoCicLooseIso : continue # change it with Loose

            
            # if not row.tMtToMET < 50:  continue
            cut_flow_trk.Fill('MtToMet')
            
            #            if  etDR(row) < 1. : continue 
            if (row.run, row.lumi, row.evt, row.e1Pt, row.e2Pt)==myevent: continue
            myevent=(row.run, row.lumi, row.evt, row.e1Pt, row.e2Pt)

            tauiso = 'tNoCuts'
            sign = 'ss' if row.e1_e2_SS else 'os'
            folder = sign+'/'+tauiso
          
            self.fill_histos(row, folder)
            folder=folder+'/'+str(int(jn))
            self.fill_histos(row, folder)
            
            
            if  row.tPt < 90 and row.tPt>65 : 
                folder = folder+'/tptregion'
                self.fill_histos(row, folder)
                folder = sign+'/'+tauiso+'/tptregion'
                self.fill_histos(row, folder)
                
            if not row.tRawIso3Hits < 10 : continue
            cut_flow_trk.Fill('tRawIso10')
            tauiso = 'tSuperSuperLoose'
            folder = sign+'/'+tauiso
            self.fill_histos(row, folder)
            folder=folder+'/'+str(int(jn))
            self.fill_histos(row, folder)
            if  row.tPt < 90 and row.tPt>65 : 
                folder = folder+'/tptregion'
                self.fill_histos(row, folder)
                folder = sign+'/'+tauiso+'/tptregion'
                self.fill_histos(row, folder)
                
            if not row.tRawIso3Hits < 5 : continue
            cut_flow_trk.Fill('tRawIso5')
            tauiso = 'tSuperLoose'
            folder = sign+'/'+tauiso
            self.fill_histos(row, folder)
            folder=folder+'/'+str(int(jn))
            self.fill_histos(row, folder)
            if  row.tPt < 90 and row.tPt>65 : 
                folder = folder+'/tptregion'
                self.fill_histos(row, folder)
                folder = sign+'/'+tauiso+'/tptregion'
                self.fill_histos(row, folder)

                        
            if  row.tLooseIso3Hits : 
                tauiso = 'tLoose'
                folder = sign+'/'+tauiso
                self.fill_histos(row,  folder)
                cut_flow_trk.Fill('tLooseIso')
                folder=folder+'/'+str(int(jn))
                self.fill_histos(row, folder)
                if  row.tPt < 90 and row.tPt>65 : 
                    folder = folder+'/tptregion'
                    self.fill_histos(row, folder)
                    folder = sign+'/'+tauiso+'/tptregion'
                    self.fill_histos(row, folder)

            if row.tTightIso3Hits :
                tauiso = 'tTigh' 
                folder = sign+'/'+tauiso
                self.fill_histos(row,  folder)
                cut_flow_trk.Fill('tTightIso')
                folder=folder+'/'+str(int(jn))
                self.fill_histos(row, folder)
                if  row.tPt < 90 and row.tPt>65 : 
                    folder = folder+'/tptregion'
                    self.fill_histos(row, folder)
                    folder = sign+'/'+tauiso+'/tptregion'
                    self.fill_histos(row, folder)
                    
 
             
        cut_flow_trk.flush()
Exemplo n.º 27
0
    def process(self):
        logging.debug('Starting processing')
        systematics = self.systematics

        frw = []
        lock = ()
        ievt = 0
        logging.debug('Starting evt loop')

        #pre-compute static things
        sys_shifts = systematics['trig']  # + \
        #         systematics['pu'] + \
        #         systematics['eid'] + \
        #         systematics['eiso'] #+ \

        jes_dirs = [i.strip('_') for i in systematics['jes']]
        #anyway the first is always ""
        tes_dirs = [i.strip('_') for i in systematics['tes']][1:]
        ees_dirs = [i.strip('_') for i in systematics['ees']][1:]

        for row in self.tree:
            if (ievt % 100) == 0:
                logging.debug('New event')
            ievt += 1
            #avoid double counting events!
            evt_id = (row.run, row.lumi, row.evt)
            if evt_id == lock: continue
            if lock != () and evt_id == lock:
                logging.info('Removing duplicate of event: %d %d %d' % evt_id)

            #
            #preselection, common to everything and everyone
            #
            #trigger
            if self.is_embedded:
                if not bool(row.doubleMuPass): continue
            else:
                if not bool(row.singleE27WP80Pass): continue
                if not bool(row.eMatchesSingleE27WP80): continue

            #objects
            if not selections.eSelection(row, 'e'): continue
            #if row.ePt < 30 : continue
            if not selections.tauSelection(row, 't'): continue
            if not row.tAntiElectronMVA5Tight: continue
            if not row.tAntiMuon2Loose: continue
            if not row.tLooseIso3Hits: continue
            logging.debug('object selection passed')
            #e ID/ISO
            if not selections.lepton_id_iso(row, 'e', 'eid13Tight_idiso02'):
                continue
            logging.debug('Passed preselection')

            #
            # Compute event weight
            #
            #event weight
            #sys_shifts is precomputed

            #set_trace()
            weight_map = self.event_weight(row, sys_shifts)

            #Fill embedded sample normalization BEFORE the vetoes
            #        if not row.e_t_SS:
            #            self.fill_histos('os/gg/ept30', row, weight_map[''])

            # it is better vetoing on b-jets  after the histo for the DY embedded
            #bjet veto
            if row.bjetCSVVeto30 != 0: continue

            #tau ID, id Tau is tight then go in full selection, otherwise use for fakes
            isTauTight = bool(row.tTightIso3Hits)
            isETight = bool(
                selections.lepton_id_iso(row, 'e', 'eid13Tight_etauiso01'))
            #         etau_category = ['']
            #         if (not isETight) and (not isTauTight):
            #             etau_category = ['etLoose', 'etLoose/Up', 'etLoose/Down']
            #         elif (not isTauTight):
            #             etau_category = ['tLoose', 'tLoose/Up', 'tLoose/Down', 'tLooseUnweight']
            #         elif (not isETight):
            #             etau_category = ['eLoose', 'eLoose/Up', 'eLoose/Down']

            #jet category
            central = struct(njets=min(row.jetVeto30, 3),
                             tPt=row.tPt,
                             ePt=row.ePt)
            jets = [
                min(row.jetVeto30, 3),
                min(row.jetVeto30jes_plus, 3),
                min(row.jetVeto30jes_minus, 3)
            ]
            tpts = [row.tPt_tes_plus, row.tPt_tes_minus]
            epts = [row.ePt_ees_plus, row.ePt_ees_minus]
            sys_effects = [(name, central.clone(njets=jnum))
                           for name, jnum in zip(jes_dirs, jets)]
            #            sys_effects.extend(
            #                [(name, central.clone(tPt = pt)) for name, pt in zip(tes_dirs, tpts)]
            #                )
            #            sys_effects.extend(
            #                [(name, central.clone(ePt = pt)) for name, pt in zip(ees_dirs, epts)]
            #                )

            #
            # Full tight selection
            #
            passes_full_selection = False
            selection_categories = []
            #  for name, shifted in sys_effects:
            #preselection. flat pt values
            if row.ePt < 30 and row.tPt < 30:
                #        selection_categories.append((name, '%i' % shifted.njets, ''))
                #   else:
                continue

            #   if shifted.njets == 0 :
            #       if shifted.tPt < 35: continue
            #       if shifted.ePt < 40: continue
            #       if deltaPhi(row.ePhi, row.tPhi) < 2.7 : continue
            #       if row.tMtToPfMet > 50 : continue
            #       selection_categories.append((name, '0', 'selected'))
            #       passes_full_selection = True
            #   elif shifted.njets == 1 :
            #       if shifted.tPt < 40: continue
            #       if shifted.ePt < 35: continue
            #       if row.tMtToPfMet > 35 : continue
            #       selection_categories.append((name, '1', 'selected'))
            #       passes_full_selection = True
            #   elif shifted.njets == 2 :
            #       if shifted.tPt < 40: continue
            #       if shifted.ePt < 30: continue
            #       if row.tMtToPfMet > 35 : continue
            #       if row.vbfMass < 550 : continue
            #       if row.vbfDeta < 3.5 : continue
            #       selection_categories.append((name, '2', 'selected'))
            #       passes_full_selection = True
            #dir_name1 = os.path.join(sys, selection_sys, sign, processtype,
            #                        e_thr, jet_dir, selection_step)
    #       tvetoes = [row.tauVetoPt20EleTight3MuLoose, row.tauVetoPt20EleTight3MuLoose_tes_plus, row.tauVetoPt20EleTight3MuLoose_tes_minus]
    #       mvetoes = [row.muVetoPt5IsoIdVtx          , row.muVetoPt5IsoIdVtx_mes_plus          , row.muVetoPt5IsoIdVtx_mes_minus          ]
    #       evetoes = [row.eVetoCicLooseIso           , row.eVetoCicLooseIso_ees_plus           , row.eVetoCicLooseIso_ees_minus           ]

    #       tdirs = [ i for i, j in zip( systematics['tvetos'], tvetoes) if not j]
    #       mdirs = [ i for i, j in zip( systematics['mvetos'], mvetoes) if not j]
    #       edirs = [ i for i, j in zip( systematics['evetos'], evetoes) if not j]

    #if any of the lists is empty
    #set_trace()
    #       if not tdirs or not mdirs or not edirs:
    #           continue
    #       logging.debug('Passed Vetoes')
            jet0panel = [('tPtcut', 1, 1, 30, 70), ('ePtcut', 1, 1, 30, 70),
                         ('deltaPhicut', 1, 1, 20, 35),
                         ('tMtToPFMETcut', 1, 1, 20, 80)]
            jet1panel = [('tPtcut', 1, 1, 30, 70), ('ePtcut', 1, 1, 30, 70),
                         ('tMtToPFMETcut', 1, 1, 20, 80)]
            jet2panel = [('tPtcut', 1, 1, 30, 70), ('ePtcut', 1, 1, 30, 70),
                         ('tMtToPFMETcut', 1, 1, 20, 80),
                         ('vbfMasscut', 1, 4, 300, 700),
                         ('vbfDetacut', 1, 1, 20, 60)]
            jet0refer = (30, 30, 2, 80)
            jet1refer = (30, 30, 80)
            jet2refer = (30, 30, 80, 300, 2)
            if (not isETight) or (not isTauTight):
                continue
            jn = row.jetVeto30
            if jn > 3: jn = 3
            jetlist = [(int(jn), str(int(jn)))]
            for jet in jetlist:
                foldertofill = 'os/gg/ept30/' + jet[1] + '/selected'
                if jets[0] == 0:
                    for nbjet0, jetwhole0 in enumerate(jet0panel):
                        if nbjet0 == 0 and jetwhole0[1] == 1:
                            for j in range(jetwhole0[3], jetwhole0[4],
                                           jetwhole0[2]):
                                if row.tPt < j: continue
                                if row.ePt < jet0refer[1]: continue
                                if deltaPhi(row.ePhi, row.tPhi) < jet0refer[2]:
                                    continue
                                if row.tMtToPfMet > jet0refer[3]: continue
                                passes_full_selection = True
                                self.fill_histos3(jetwhole0[0], j,
                                                  foldertofill, row,
                                                  weight_map[''])
                        if nbjet0 == 1 and jetwhole0[1] == 1:
                            for j in range(jetwhole0[3], jetwhole0[4],
                                           jetwhole0[2]):
                                if row.tPt < jet0refer[0]: continue
                                if row.ePt < j: continue
                                if deltaPhi(row.ePhi, row.tPhi) < jet0refer[2]:
                                    continue
                                if row.tMtToPfMet > jet0refer[3]: continue
                                passes_full_selection = True
                                self.fill_histos3(jetwhole0[0], j,
                                                  foldertofill, row,
                                                  weight_map[''])
                        if nbjet0 == 2 and jetwhole0[1] == 1:
                            for j in range(jetwhole0[3], jetwhole0[4],
                                           jetwhole0[2]):
                                if row.tPt < jet0refer[0]: continue
                                if row.ePt < jet0refer[1]: continue
                                if deltaPhi(row.ePhi, row.tPhi) < j / 10.0:
                                    continue
                                if row.tMtToPfMet > jet0refer[3]: continue
                                passes_full_selection = True
                                self.fill_histos3(jetwhole0[0], j / 10.0,
                                                  foldertofill, row,
                                                  weight_map[''])
                        if nbjet0 == 3 and jetwhole0[1] == 1:
                            for j in range(jetwhole0[3], jetwhole0[4],
                                           jetwhole0[2]):
                                if row.tPt < jet0refer[0]: continue
                                if row.ePt < jet0refer[1]: continue
                                if deltaPhi(row.ePhi, row.tPhi) < jet0refer[2]:
                                    continue
                                if row.tMtToPfMet > j: continue
                                passes_full_selection = True
                                self.fill_histos3(jetwhole0[0], j,
                                                  foldertofill, row,
                                                  weight_map[''])
                elif jets[0] == 1:
                    for nbjet1, jetwhole1 in enumerate(jet1panel):
                        if nbjet1 == 0 and jetwhole1[1] == 1:
                            for j in range(jetwhole1[3], jetwhole1[4],
                                           jetwhole1[2]):
                                if row.tPt < j: continue
                                if row.ePt < jet1refer[1]: continue
                                if row.tMtToPfMet > jet1refer[2]: continue
                                #   selection_categories.append((name, '1', 'selected'))
                                passes_full_selection = True
                                self.fill_histos3(jetwhole1[0], j,
                                                  foldertofill, row,
                                                  weight_map[''])
                        if nbjet1 == 1 and jetwhole1[1] == 1:
                            for j in range(jetwhole1[3], jetwhole1[4],
                                           jetwhole1[2]):
                                if row.tPt < jet1refer[0]: continue
                                if row.ePt < j: continue
                                if row.tMtToPfMet > jet1refer[2]: continue
                                #   selection_categories.append((name, '1', 'selected'))
                                passes_full_selection = True
                                self.fill_histos3(jetwhole1[0], j,
                                                  foldertofill, row,
                                                  weight_map[''])
                        if nbjet1 == 2 and jetwhole1[1] == 1:
                            for j in range(jetwhole1[3], jetwhole1[4],
                                           jetwhole1[2]):
                                if row.tPt < jet1refer[0]: continue
                                if row.ePt < jet1refer[1]: continue
                                if row.tMtToPfMet > j: continue
                                #   selection_categories.append((name, '1', 'selected'))
                                passes_full_selection = True
                                self.fill_histos3(jetwhole1[0], j,
                                                  foldertofill, row,
                                                  weight_map[''])
                elif jets[0] == 2:
                    for nbjet2, jetwhole2 in enumerate(jet2panel):
                        if nbjet2 == 0 and jetwhole2[1] == 1:
                            for j in range(jetwhole2[3], jetwhole2[4],
                                           jetwhole2[2]):
                                if row.tPt < j: continue
                                if row.ePt < jet2refer[1]: continue
                                if row.tMtToPfMet > jet2refer[2]: continue
                                if row.vbfMass < jet2refer[3]: continue
                                if row.vbfDeta < jet2refer[4]: continue
                                passes_full_selection = True
                                self.fill_histos3(jetwhole2[0], j,
                                                  foldertofill, row,
                                                  weight_map[''])
                        if nbjet2 == 1 and jetwhole2[1] == 1:
                            for j in range(jetwhole2[3], jetwhole2[4],
                                           jetwhole2[2]):
                                if row.tPt < jet2refer[0]: continue
                                if row.ePt < j: continue
                                if row.tMtToPfMet > jet2refer[2]: continue
                                if row.vbfMass < jet2refer[3]: continue
                                if row.vbfDeta < jet2refer[4]: continue
                                passes_full_selection = True
                                self.fill_histos3(jetwhole2[0], j,
                                                  foldertofill, row,
                                                  weight_map[''])
                        if nbjet2 == 2 and jetwhole2[1] == 1:
                            for j in range(jetwhole2[3], jetwhole2[4],
                                           jetwhole2[2]):
                                if row.tPt < jet2refer[0]: continue
                                if row.ePt < jet2refer[1]: continue
                                if row.tMtToPfMet > j: continue
                                if row.vbfMass < jet2refer[3]: continue
                                if row.vbfDeta < jet2refer[4]: continue
                                passes_full_selection = True
                                self.fill_histos3(jetwhole2[0], j,
                                                  foldertofill, row,
                                                  weight_map[''])
                        if nbjet2 == 3 and jetwhole2[1] == 1:
                            for j in range(jetwhole2[3], jetwhole2[4],
                                           jetwhole2[2]):
                                if row.tPt < jet2refer[0]: continue
                                if row.ePt < jet2refer[1]: continue
                                if row.tMtToPfMet > jet2refer[2]: continue
                                if row.vbfMass < j: continue
                                if row.vbfDeta < jet2refer[4]: continue
                                passes_full_selection = True
                                self.fill_histos3(jetwhole2[0], j,
                                                  foldertofill, row,
                                                  weight_map[''])
                        if nbjet2 == 4 and jetwhole2[1] == 1:
                            for j in range(jetwhole2[3], jetwhole2[4],
                                           jetwhole2[2]):
                                if row.tPt < jet2refer[0]: continue
                                if row.ePt < jet2refer[1]: continue
                                if row.tMtToPfMet > jet2refer[2]: continue
                                if row.vbfMass < jet2refer[3]: continue
                                if row.vbfDeta < j / 10.0: continue
                                passes_full_selection = True
                                self.fill_histos3(jetwhole2[0], j / 10.0,
                                                  foldertofill, row,
                                                  weight_map[''])
                #   selection_categories.append((name, '2', 'selected'))

            if passes_full_selection:
                logging.debug('Passed full selection')
Exemplo n.º 28
0
 def obj1_id(self, row):
     return selections.lepton_id_iso(row, 'm1', leadleptonId)
Exemplo n.º 29
0
 def obj2_id(self, row):
     return selections.lepton_id_iso(row, 'm2', subleptonId )
Exemplo n.º 30
0
 def obj2_id(row, leadleptonId=None, subleadleptonId='eid13Looseh2taucuts'):
     return selections.lepton_id_iso(row, 'e2', subleadleptonId)
Exemplo n.º 31
0
 def obj1_id(self, row):
     return selections.lepton_id_iso(row, 'e1', leading_iso)
Exemplo n.º 32
0
 def obj2_id(self, row):
     return selections.lepton_id_iso(row, 'e2', subleading_iso)
Exemplo n.º 33
0
    def process(self):
        event = ()
        filename = 'unnamed'
        evts_processed = 0
        #set_trace()
        for row in self.tree:
            #for i, row in enumerate(self.tree):
            #   if  i >= 100:
            #      return

            #current_file = self.tree.inputfilename
            #if filename != 'unnamed' and current_file <> filename:
            #     self.histograms['jobInfo/jobInfo'].Fill([[i for i in filename], evts_processed])
            #if not filename == 'unnamed' or current_file <> filename:
            #    filename = current_file
            evts_processed += 1
            #self.histograms[folder+'/jobInfo'].Fill(row)

            jn = row.jetVeto30
            if jn > 3: jn = 3
            sign = 'ss' if row.e1_e2_SS else 'os'
            #if row.run > 2 : #apply the trigger to data only (MC triggers enter in the scale factors)
            if not bool(row.singleE27WP80Pass): continue
            if not bool(row.e1MatchesSingleE27WP80) and not bool(
                    row.e1MatchesSingleE27WP80):
                continue

            if jn != 0 and row.bjetCSVVeto30 != 0: continue

            if row.e1Pt < 30: continue
            if row.e2Pt < 30: continue
            if not abs(row.e1_e2_Mass - 91.2) < 20: continue

            if not selections.eSelection(row, 'e1'): continue
            if not selections.lepton_id_iso(row, 'e1', 'eid13Tight_etauiso01'):
                continue
            if abs(row.e1Eta) > 1.4442 and abs(row.e1Eta) < 1.566: continue

            if not selections.eSelection(row, 'e2'): continue
            if not selections.lepton_id_iso(row, 'e2', 'eid13Tight_etauiso01'):
                continue
            if abs(row.e2Eta) > 1.4442 and abs(row.e2Eta) < 1.566: continue

            #if not selections.vetos(row) : continue
            if row.muVetoPt5IsoIdVtx: continue
            if row.eVetoCicLooseIso: continue  # change it with Loose
            if row.tauVetoPt20EleTight3MuLoose: continue
            #            if row.tauHpsVetoPt20 : continue

            folder = sign
            self.histograms[folder + '/evtInfo'].Fill(row)
            new_event = (row.run, row.lumi, row.evt)
            if event != new_event:
                event = new_event
                self.fill_histos(row, folder)
                folder = sign + '/' + str(int(jn))
                self.fill_histos(row, folder)

        if filename != 'unnamed':
            self.histograms['jobInfo/jobInfo'].Fill([[i for i in filename],
                                                     evts_processed])