Пример #1
0
    def makePlots(n, r, s, t):
        hrList = []
        for sys in sysList:
            #All the rest will be within the json file
            print t
            if sys != 'nominal':
                file_ = '%s/Efficiency%s_%s_%s/%s_%sid%s_%s/%s' % (
                    path_in[1], n, r, sys, t.upper(), t, r, sys, s)
            else:
                file_ = '%s/Efficiency%s_%s/%s_%sid%s/%s' % (
                    path_in[0], n, r, t.upper(), t, r, s)
            print 'file_ is', file_
            hr = HistoReader('RUN%s_%s%s%s' % (r, n, t, sys))
            hr.readfile(file_)
            hr.SetNewRange(20, 120)
            hr.setInfo(sys)
            hr.CleanBigError(0.01)
            hr.setType(t)
            hrList.append(hr)

        hp = HistoPloter('.')
        ##Uncomment next line to have only min, max variations
        hp.MinMax = True
        hp.setRatioRange(0.98,
                         1.02)  #Set the ratio range. Default one is 0.85, 1.15
        hp.PlotEff1D(hrList)  #making the 1D plot
Пример #2
0
 def Gethr(lumi, run, file, name, info):
     ''' retrieve historeader for a single efficiency'''
     hr = HistoReader(name)
     hr.setInfo(info)
     hr.readfile(file)
     hr.setLumi(lumi)
     hr.setType(info)
     return hr
Пример #3
0
    def makePlots(n, r, s, t):
        hrList = []
        for sys in sysList:
            #All the rest will be within the json file
            print t
            path = ''
            if sys == 'nominal':
                path = path_in[0]
            else:
                path = path_in[1]

            if not sys == 'nominal':
                #file_ = '%s/Efficiency%s_%s_%s/%s_%sid%s_%s/%s'%(path_in[1],n,r,sys,t.upper(),t,r,sys,s)
                file_ = '%s/%s/%s_%s_all/%s' % (path, sysDic[sys], t.upper(),
                                                t, s)
            else:
                #file_ = '%s/Efficiency%s_%s/%s_%sid%s/%s'%(path_in[0],n,r,t.upper(),t,r,s)
                file_ = '%s/EfficiencyRun2017B_F/%s_%s_all/%s' % (
                    path, t.upper(), t, s)
            print 'file_ is', file_
            #sys_.exit()
            hr = HistoReader('RUN%s_%s%s%s' % (r, n, t, sys))
            hr.readfile(file_)
            #hr.SetNewRange(20, 120)
            hr.setInfo(sys)
            hr.CleanBigError(0.01)
            hr.setType(t)
            hrList.append(hr)

        hp = HistoPloter('.')
        ##Uncomment next line to have only min, max variations
        hp.MinMax = True
        hp.setRatioRange(0.98,
                         1.02)  #Set the ratio range. Default one is 0.85, 1.15
        print 'hrList is', hrList
Пример #4
0
    def GetSumLumihr(lumiDic, runList, file, name, info):
        ''' retrieve historeader in case separated for multiple runs'''
        hr = HistoReader(name)
        for run in runList:
            file = file.replace('RUN', run)
            if run == runList[0]:
                hr = Gethr(lumiDic[run], run, file, name, info)
            else:
                hr_run = Gethr(lumiDic[run], run, file, name, info)
                hr.Sum(hr_run)

        return hr
    def makePlots(n, r, s, t):
        hrList = []
        for sys in sysList:
            #All the rest will be within the json file
            print t
            file_ = '%s/Efficiency%s_%s_%s/%s_%sid%s_%s/%s' % (
                path_in, n, r, sys, t.upper(), t, r, sys, s)
            print 'file_ is', file_
            hr = HistoReader('%s%s%s' % (n, t, sys))
            hr.readfile(file_)
            hr.SetNewRange(20, 120)
            hr.setInfo(sys)
            hr.CleanBigError(0.01)
            hr.setType(t)
            hrList.append(hr)

        hp = HistoPloter('.')
        hp.setRatioRange(0.98,
                         1.02)  #Set the ratio range. Default one is 0.85, 1.15
        hp.PlotEff1D(hrList)  #making the 1D plot
Пример #6
0
            #Used for SF
            SF_MapList = []
            MC_MapList = []
            DATA_MapList = []
            SFoutputJSONname ='RunBCDEF_%s_%s_%s'%('SF',n, r)
            jSF = JsonMaker(SFoutputJSONname)
            rSF = RootFileMaker(SFoutputJSONname)
            for t in Type:
                #All the rest will be within the json file
                outputJSONname ='RunBCDEF_%s_%s_%s_%s'%('Eff',t,n,r)
                MapList = []
                j = JsonMaker(outputJSONname)
                r_ = RootFileMaker(outputJSONname)
                for s in NumDic[n]:
                    file_ = '/eos/cms/store/group/phys_muon/fernanpe/Efficiencies_LegacyReReco2016_final/Efficiency%s_BCDEF_%s/%s_%sid_BCDEF/%s'%(n,r,t.upper(),t,s)
                    hr = HistoReader('hr')
                    hr.readfile(file_)     
#                    hr.SetNewRange(20, 120) 
                    hr.setInfo('dummy')         
                    hr.CleanBigError(0.01)  
                    hr.setType(t)      
                    MapList.append(hr.eff2D)

                    #For SF
                    if t == 'mc':
                        MC_MapList.append(hr.eff2D)
                    elif t == 'data':
                        DATA_MapList.append(hr.eff2D)

                #For DATA, MC
                j.makeJSON(MapList)
            # for each sys variation, store data and mc maps
            sysSFMapList[sys] = {}
            for t in Type:
                MapList = []
                ##All the rest will be within the json file
                #outputJSONname ='RunBCDEF_%s_%s'%(t,n)
                #j = JsonMaker(outputJSONname)
                #r_ = RootFileMaker(outputJSONname)
                MapList = []
                for s in NumDic[n]:
                    #Contains hr from Run BC, DE and F that will be summed up at the end
                    hrList = []
                    for r in Run:
                        file_ = '%s/Efficiency%s_%s_%s/%s_%sid%s_%s/%s' % (
                            path_in, n, r, sys, t.upper(), t, r, sys, s)
                        hr = HistoReader('hr')
                        hr.setInfo(sys + ' ' + t)
                        hr.readfile(file_)
                        hr.SetNewRange(20, 120)
                        hr.setLumi(LumiDic[r])
                        #hr.CleanBigError(0.05)
                        hr.setType(t)
                        hrList.append(hr)

                    #lumi sum of all the hr
                    hr0 = hrList[0]
                    for hr in hrList[1:]:
                        hr0.Sum(hr)

                    MapList.append(hr0.eff2D)
Пример #8
0
        for r in Run:
            #Used for SF
            SF_MapList = []
            MC_MapList = []
            DATA_MapList = []
            SFoutputJSONname = 'Run%s_%s_%s' % (r, 'SF', n)
            jSF = JsonMaker(SFoutputJSONname)
            for t in Type:
                #All the rest will be within the json file
                outputJSONname = 'Run%s_%s_%s' % (r, t, n)
                MapList = []
                j = JsonMaker(outputJSONname)
                for s in NumDic[n]:
                    file_ = '/afs/cern.ch/user/f/fernanpe/public/for_Gael/Efficiencies_2017/Efficiency%s_%s/%s_%sid%s/%s' % (
                        n, r, t.upper(), t, r, s)
                    hr = HistoReader('hr')
                    hr.readfile(file_)
                    hr.SetNewRange(20, 120)
                    hr.setInfo('dummy')
                    hr.CleanBigError(0.05)
                    hr.setType(t)
                    MapList.append(hr.eff2D)

                    #For SF
                    if t == 'mc':
                        MC_MapList.append(hr.eff2D)
                    elif t == 'data':
                        DATA_MapList.append(hr.eff2D)

                #For DATA, MC
                j.makeJSON(MapList)
Пример #9
0
    #            hp.PlotEff1D([DATA_hr, MC_hr])
    #            #print 's is', s

    #########
    #Provide Plots separetly for run BCDEF
    #########
    for n in Num:
        for s in NumDic[n]:
            DATA_hrList = []
            MC_hrList = []
            for r in Run:
                #All the rest will be within the json file
                for t in Type:
                    file_ = '/afs/cern.ch/user/f/fernanpe/public/for_Gael/Efficiencies_2017/Efficiency%s_%s/%s_%sid%s/%s' % (
                        n, r, t.upper(), t, r, s)
                    hr = HistoReader('%s%s' % (t, r))
                    hr.readfile(file_)
                    hr.SetNewRange(20, 120)
                    hr.setInfo(r)
                    hr.CleanBigError(0.01)
                    hr.setLumi(LumiDic[r])
                    hr.setType(t)
                    #For SF
                    if t == 'mc':
                        MC_hrList.append(hr)
                    elif t == 'data':
                        DATA_hrList.append(hr)

            DATA_hr = DATA_hrList[0]
            MC_hr = MC_hrList[0]
            for d in DATA_hrList[1:]:
if __name__ == "__main__":
    
    #input root file containing all the efficiencies
    #test_file = '/eos/cms/store/group/phys_muon/perrin/FitForTest/TnP_MC_NUM_hlt_Mu17_Mu8_OR_TkMu8_leg8_DEN_LooseIDnISO_PAR_pt_eta.root'
    #test_file = '/afs/cern.ch/work/s/sesanche/private/Muonico/CMSSW_9_2_4/src/MuonAnalysis/TagAndProbe/test/TnP_Muon_ID_Simple.root'

    #test_file  = '/afs/cern.ch/work/g/gaperrin/public/ForSergio/FitExample/Good/TnP_MC_NUM_TightID_DEN_genTracks_PAR_pt_eta.root'
#    test_file  = '/afs/cern.ch/work/g/gaperrin/public/ForSergio/FitExample/Bad/TnP_MC_NUM_TightID_DEN_genTracks_PAR_pt_eta_BIGSTAT.root'
    #test_file  = '/afs/cern.ch/work/g/gaperrin/public/ForSergio/FitExample/Bad/TnP_MC_NUM_TightID_DEN_genTracks_PAR_pt_eta.root'
    test_file  = 'output_20.root'

    #path where all the plots are going to be saved
    plot_path = 'TnP_SFfromFitTool'

    hr = HistoReader('Data test2')
    hr.readfile(test_file)

    effList = hr.EffList  

    hp = HistoPloter(plot_path)

    ##Plot add the fits
    hp.PlotFitList(effList)
    
    ## Make chi2 tests
    #hp.CheckFitList(effList)

    #Make all 1D efficiency plots
    hp.PlotEff1D([effList])
Пример #11
0
if __name__ == "__main__":

    Id = 'TnP_MC_NUM_HighPtID_DEN_genTracks_PAR_newpt_eta.root'
    hr_data_List = []

    print 'Readind'
    print '================'
    print Id
    print '================'

    ########
    #Test 2D map
    ########
    fileBC = '/afs/cern.ch/user/f/fernanpe/public/for_Gael/Efficiencies_2017/EfficiencyID_BC/DATA_dataidBC/' + Id
    hr_dataBC = HistoReader('DataBC')
    hr_dataBC.readfile(fileBC)

    print 'Initial map'
    print '----------------'
    eff2D = hr_dataBC.eff2D
    eff2D.Print()
    eff2D.Print('up')
    eff2D.Print('down')

    print 'After Changing Range'
    print '----------------'
    hr_dataBC.SetNewRange(20, 90)
    eff2D = hr_dataBC.eff2D
    eff2D.Print()
    eff2D.Print('up')