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
    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 #3
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 #4
0
                    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:]:
                DATA_hr.Sum(d)

            for d in MC_hrList[1:]:
                MC_hr.Sum(d)

            hp = HistoPloter('.')
            hp.PlotEff1D([DATA_hr, MC_hr])

#    #########
#    #Will contain hr for run BC, DE and F to compute SF on BCDEF
#    #########
#    for n in Num:
#        #Used for SF
#        SF_MapList = []
#        MC_MapList = []
#        DATA_MapList = []
#        SFoutputJSONname ='RunBCDEF_%s_%s'%('SF',n)
#        jSF = JsonMaker(SFoutputJSONname)
#        for t in Type:
#            #All the rest will be within the json file
#            outputJSONname ='RunBCDEF_%s_%s'%(t,n)
    #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)
#    for i in hp.KSs:
#        hKS.Fill(i)

#    c=ROOT.TCanvas()
Beispiel #6
0
    #file_mc = '/afs/cern.ch/user/s/sfonseca/public/for_Gael/nominal/EfficiencyRun2017B_F/MC_mc_all/TnP_MC_NUM_LooseID_DEN_genTracks_PAR_pt_eta.root'
    #Tight
    file_mc = '/afs/cern.ch/user/s/sfonseca/public/for_Gael/nominal/EfficiencyRun2017B_F/MC_mc_all/TnP_MC_NUM_TightID_DEN_genTracks_PAR_pt_eta.root'
    #Medium
    #file_mc = '/afs/cern.ch/user/s/sfonseca/public/for_Gael/nominal/EfficiencyRun2017B_F/MC_mc_all/TnP_MC_NUM_MediumID_DEN_genTracks_PAR_pt_eta.root'
    #Soft
    #file_mc = '/afs/cern.ch/user/s/sfonseca/public/for_Gael/nominal/EfficiencyRun2017B_F/MC_mc_all/TnP_MC_NUM_SoftID_DEN_genTracks_PAR_pt_eta.root'
    hr_mc = Gethr('1', 'BCDEF', file_mc, 'JPsi', 'JPsi')
    #sys.exit()
    print '===================='
    print 'set new range in mc'
    print '===================='
    #hr_mc.SetNewRange(20, 40)
    #sys.exit()
    hr_data.Divide(hr_mc)

    print 'I am going to divide'
    print 'debug this'

    #hr_data.Divide(hr_mc)
    hr_JPsi_SF = hr_data
    #hr_JPsi_SF.SetNewRange(20, 40)
    #hr_DY_SF.setInfo('JPsi SF')
    hr_data = None

    #plot and compare the SF
    hp = HistoPloter('.')
    hp.setEffRange(0.9, 1.2)
    hp.PlotEff1D([hr_DY_SF, hr_JPsi_SF])
    #hp.PlotEff1D([hr_SF_DY])
                    #hr.SetNewRange(20, 120) 
                    hr.SetNewRange(20, 200) 
                    hr.setInfo(r)         
                    hr.CleanBigError(0.01)  
                    hr.setType(t)      
                    print hr.EffList
                    #For SF
                    if t == 'mc':
                        MC_hr = hr
                    elif t == 'data':
                        DATA_hr = hr
                        print 'yeah baby'
                print DATA_hr.EffList


                hp = HistoPloter('.')
                hp.setEffRange(0.5,1.2)
                #print 'going to plot'
                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: