Example #1
0
  def init(self):
    # Load SF files
    if not self.isData:
      #self.LoadHisto('MuonIsoSF', basepath+'./inputs/MuonISO.root', 'NUM_TightRelIso_DEN_TightIDandIPCut_pt_abseta') # pt, abseta
      #self.LoadHisto('MuonIdSF',  basepath+'./inputs/MuonID.root',  'NUM_TightID_DEN_genTracks_pt_abseta') # pt, abseta
      #self.LoadHisto('ElecSF',    basepath+'./inputs/ElecTightCBid94X.root',  'EGamma_SF2D') # eta, pt
      self.LoadHisto('MuonIsoSF', basepath+'./inputs/MuonISO.root', 'NUM_TightRelIso_DEN_TightIDandIPCut_pt_abseta') # pt, abseta
      self.LoadHisto('MuonIdSF',  basepath+'./inputs/MuonID.root',  'NUM_TightID_DEN_genTracks_pt_abseta') # pt, abseta
      self.LoadHisto('RecoEB',    basepath+'./inputs/ElecReco_EB_30_100.root',  'g_scalefactors') # Barrel
      self.LoadHisto('RecoEE',    basepath+'./inputs/ElecReco_EE_30_100.root',  'g_scalefactors') # Endcap
      self.LoadHisto('ElecEB',    basepath+'./inputs/sf_tight_id.root',  'g_eff_ratio_pt_barrel') # Endcap
      self.LoadHisto('ElecEE',    basepath+'./inputs/sf_tight_id.root',  'g_eff_ratio_pt_endcap') # Endcap
      self.LoadHisto('ElecTrigEB',    basepath+'./inputs/ScaleFactors_PbPb_LooseWP_EB_Centr_0_100_HLTonly_preliminaryID.root',  'g_scalefactors') # Barrel
      self.LoadHisto('ElecTrigEE',    basepath+'./inputs/ScaleFactors_PbPb_LooseWP_EE_Centr_0_100_HLTonly_preliminaryID.root',  'g_scalefactors') # Endcap

      # Modules to have some weights in MC
      self.PUweight = puWeight_5TeV(self.tchain)
      self.PrefCorr = PrefCorr5TeV()

    # To apply b tagging SF
    self.BtagSF   = BtagReader('DeepCSV', 'mujets', 'Medium', 2017)

    # Uncertainties
    self.doSyst = False if ('noSyst' in self.options or self.isData) else True
    self.doJECunc = True if 'JECunc'   in self.options else False
    self.jetptvar = 'Jet_pt_nom' if 'JetPtNom' in self.options else 'Jet_pt'
    self.metptvar = 'Met_pt_nom' if 'JetPtNom' in self.options else 'Met_pt'

    if self.doJECunc:
      systlabel[systematic.JESUp]   = 'JESUp'
      systlabel[systematic.JESDo]   = 'JESDown'
      systlabel[systematic.JERUp]   = 'JERUp'
      systlabel[systematic.JERDo]   = 'JERDown'

    self.resetObjects()

    # Sample name
    name = self.sampleName
    self.isDY = True if 'DY' in self.sampleName else False

    # It it's data, store dataset index
    self.sampleDataset = -1
    for i, dataName in dataset.items(): 
      if dataName == name: self.sampleDataset = i

    # Jet and lep pT
    self.JetPtCut  = 20
    self.LepPtCut  = 8
    self.Lep0PtCut = 20
Example #2
0
    def init(self):
        self.selFRLep = 0
        self.selTRLep = 0
        # Load Scale Factor files
        if not self.isData:
            self.LoadHisto(
                'MuonIsoSF', basepath + './inputs/MuonISO.root',
                'NUM_TightRelIso_DEN_TightIDandIPCut_pt_abseta')  # pt, abseta
            self.LoadHisto('MuonIdSF', basepath + './inputs/MuonID.root',
                           'NUM_TightID_DEN_genTracks_pt_abseta')  # pt, abseta
            self.LoadHisto('RecoEB',
                           basepath + './inputs/ElecReco_EB_30_100.root',
                           'g_scalefactors')  # Barrel
            self.LoadHisto('RecoEE',
                           basepath + './inputs/ElecReco_EE_30_100.root',
                           'g_scalefactors')  # Endcap
            self.LoadHisto('ElecEB', basepath + './inputs/sf_tight_id.root',
                           'g_eff_ratio_pt_barrel')  # Endcap
            self.LoadHisto('ElecEE', basepath + './inputs/sf_tight_id.root',
                           'g_eff_ratio_pt_endcap')  # Endcap
            self.LoadHisto(
                'ElecTrigEB', basepath +
                './inputs/ScaleFactors_PbPb_LooseWP_EB_Centr_0_100_HLTonly_preliminaryID.root',
                'g_scalefactors')  # Barrel
            self.LoadHisto(
                'ElecTrigEE', basepath +
                './inputs/ScaleFactors_PbPb_LooseWP_EE_Centr_0_100_HLTonly_preliminaryID.root',
                'g_scalefactors')  # Endcap

            # Modules to have some weights in MC
            # Pile Up
            self.PUweight = puWeight_5TeV(self.tchain, False)
            # Trigger prefiring
            self.PrefCorr = PrefCorr5TeV(False)

        # To apply b tagging SF
        #self.BtagSF   = BtagReader('DeepCSV', 'mujets', 'Medium', 2017)

        # Uncertainties
        self.doSyst = False if ('noSyst' in self.options
                                or self.isData) else True
        self.doJECunc = False if 'JECunc' in self.options else False  #XXX Lo hemos puesto a False para obligar a que no haga los otros que no interesan
        self.jetptvar = 'Jet_pt_nom' if 'JetPtNom' in self.options else 'Jet_pt'
        self.metptvar = 'Met_pt_nom' if 'JetPtNom' in self.options else 'Met_pt'
        self.doFiducialAndTotalRegion = True  #Flag to use or not the part of the code to do the fiducial and total yields. Do only to WZ sample

        if self.doJECunc:
            systlabel[systematic.JESUp] = 'JESUp'
            systlabel[systematic.JESDo] = 'JESDown'
            systlabel[systematic.JERUp] = 'JERUp'
            systlabel[systematic.JERDo] = 'JERDown'

        self.resetObjects()

        # Sample names
        name = self.sampleName
        self.isDY = True if 'DY' in self.sampleName else False

        # It it's data, store dataset index
        self.sampleDataset = -1
        for i, dataName in dataset.items():
            if dataName == name: self.sampleDataset = i

        # Jet global pT cuts
        self.JetPtCut = 20
Example #3
0
    def init(self):
        # Load SF files
        if not self.isData:
            # Lepton and trigger SF
            self.LoadHisto(
                'MuonIsoSF', basepath + './inputs/MuonISO.root',
                'NUM_TightRelIso_DEN_TightIDandIPCut_pt_abseta')  # pt, abseta
            self.LoadHisto('MuonIdSF', basepath + './inputs/MuonID.root',
                           'NUM_TightID_DEN_genTracks_pt_abseta')  # pt, abseta
            self.LoadHisto('RecoEB',
                           basepath + './inputs/ElecReco_EB_30_100.root',
                           'g_scalefactors')  # Barrel
            self.LoadHisto('RecoEE',
                           basepath + './inputs/ElecReco_EE_30_100.root',
                           'g_scalefactors')  # Endcap
            self.LoadHisto('ElecEB', basepath + './inputs/sf_tight_id.root',
                           'g_eff_ratio_pt_barrel')  # Endcap
            self.LoadHisto('ElecEE', basepath + './inputs/sf_tight_id.root',
                           'g_eff_ratio_pt_endcap')  # Endcap
            #self.LoadHisto('ElecTrigEB',    basepath+'./inputs/ScaleFactors_PbPb_LooseWP_EB_Centr_0_100_HLTonly_preliminaryID.root',  'g_scalefactors') # Barrel
            #self.LoadHisto('ElecTrigEE',    basepath+'./inputs/ScaleFactors_PbPb_LooseWP_EE_Centr_0_100_HLTonly_preliminaryID.root',  'g_scalefactors') # Endcap
            self.LoadHisto(
                'ElecTrigEBnum', basepath +
                './inputs/eleTreeEff0_PbPb_LooseWP_EB_Centr_0_100_HLTOnly_Data.root',
                'Graph')  # Barrel data
            self.LoadHisto(
                'ElecTrigEBden', basepath +
                './inputs/eleTreeEff0_PbPb_LooseWP_EB_Centr_0_100_HLTOnly_MC.root',
                'Graph')  # Barrel MC
            self.LoadHisto(
                'ElecTrigEEnum', basepath +
                './inputs/eleTreeEff0_PbPb_LooseWP_EE_Centr_0_100_HLTOnly_Data.root',
                'Graph')  # Endcap data
            self.LoadHisto(
                'ElecTrigEEden', basepath +
                './inputs/eleTreeEff0_PbPb_LooseWP_EE_Centr_0_100_HLTOnly_MC.root',
                'Graph')  # Endcap MC

            # Modules to have some weights in MC
            self.PUweight = puWeight_5TeV(self.tchain, self.index <= 0)
            self.PrefCorr = PrefCorr5TeV(self.index <= 0)

        # To apply b tagging SF
        self.BtagSF = BtagReader('DeepCSV', 'mujets', 'Medium', 2017)

        # Uncertainties
        self.doSyst = False if ('noSyst' in self.options
                                or self.isData) else True
        self.doJECunc = True if 'JECunc' in self.options else False
        self.doPU = True if 'PUweight' in self.options else False
        self.doIFSR = True if 'doIFSR' in self.options and self.outname == 'TT' else False
        self.jetptvar = 'Jet_pt_nom' if 'JetPtNom' in self.options else 'Jet_pt'
        self.jetmassvar = 'Jet_mass_nom' if 'JetPtNom' in self.options else 'Jet_mass'
        self.metptvar = 'Met_pt_nom' if 'JetPtNom' in self.options else 'Met_pt'

        if self.doPU:
            systlabel[systematic.PUUp] = 'PUUp'
            systlabel[systematic.PUDo] = 'PUDown'

        if self.doJECunc:
            systlabel[systematic.JESUp] = 'JESUp'
            systlabel[systematic.JESDo] = 'JESDown'
            systlabel[systematic.JERUp] = 'JERUp'
            systlabel[systematic.JERDo] = 'JERDown'

        if self.doIFSR:
            systlabel[systematic.ISRDo] = 'ISRDown'
            systlabel[systematic.ISRUp] = 'ISRUp'
            systlabel[systematic.FSRDo] = 'FSRDown'
            systlabel[systematic.FSRUp] = 'FSRUp'

        # Objects for the analysis
        self.selLeptons = []
        self.selJets = []
        self.pmet = TLorentzVector()

        if not self.isData and self.doSyst:
            self.selJetsJESUp = []
            self.selJetsJESDo = []
            self.selJetsJERUp = []
            self.selJetsJERDo = []
            self.pmetJESUp = TLorentzVector()
            self.pmetJESDo = TLorentzVector()
            self.pmetJERUp = TLorentzVector()
            self.pmetJERDo = TLorentzVector()

        # Sample name
        name = self.outname  #sampleName
        self.isTT = True if name[0:2] == 'TT' else False
        self.isTTnom = True if self.sampleName == ttnomname else False
        self.doTTbarSemilep = False
        if self.isTT and 'semi' in name or 'Semi' in name:
            self.doTTbarSemilep = True
            self.SetOutName("TTsemilep")
            if self.index <= 0: print 'Setting out name to TTsemilep...'
        self.isDY = True if 'DY' in self.sampleName else False

        # PDF and scale histos for TT sample
        if self.isTTnom and self.index <= 0:
            hSumPDF = GetHistoFromSetOfFiles(self.GetFiles(),
                                             'SumOfPDFweights')
            hSumScale = GetHistoFromSetOfFiles(self.GetFiles(),
                                               'SumOfScaleWeights')
            self.AddToOutputs('SumOfPDFweights', hSumPDF)
            self.AddToOutputs('SumOfScaleWeights', hSumScale)

        # It it's data, store dataset index
        self.sampleDataset = -1
        for i, dataName in dataset.items():
            if dataName == name: self.sampleDataset = i

        # Jet and lep pT
        self.JetPtCut = 25
        self.LepPtCut = 12
        self.Lep0PtCut = 20