Beispiel #1
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
Beispiel #2
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
Beispiel #3
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
    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
Beispiel #5
0
            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)
                r_.makeROOT(MapList)
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])

#    hKS = ROOT.TH1F('KS','',20, min(hp.KSs)*0.9, max(hp.KSs)*1.1)
Beispiel #7
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')
    eff2D.Print('down')