コード例 #1
0
 def getIntegrals(self,fin,sels,hname="genmass",mean=False,isGen=False):
     folders = getObjects( getObjects( [fin], sels ), ["histograms"] )
     histograms = map(lambda x: (os.path.basename(os.path.dirname(x.GetPath())), 
                                 filter(lambda y: hname in y.GetName() and ("Grav" in y.GetName() or "Spin0" in y.GetName()),  getObjects([x]))),
                      folders )
     
     if isGen and self.options.split_by_r9:
         return self.computeIntegrals(histograms,mean,"HighR9")+self.computeIntegrals(histograms,mean,"LowR9")
     else:
         return self.computeIntegrals(histograms,mean)
コード例 #2
0
 def getIntegrals(self,fin,sels,hname="genmass",mean=False):
     folders = getObjects( getObjects( [fin], sels ), ["histograms"] )
     histograms = map(lambda x: (os.path.basename(os.path.dirname(x.GetPath())), 
                                 filter(lambda y: hname in y.GetName() and "Grav" in y.GetName(),  getObjects([x]))),
                      folders )
     
     if mean: 
         fnc = lambda x: ( x.GetMean(), x.Integral())
     else:
         fnc = lambda x: x.Integral()
     return map(lambda x: (x[0].replace("GenIso",""),map(lambda y: (self.getMassAndCoup(y.GetName()),self.getCategory(y.GetName()),fnc(y)), x[1])), histograms )
コード例 #3
0
    def getIntegrals(self, fin, sels, hname="genmass", mean=False):
        folders = getObjects(getObjects([fin], sels), ["histograms"])
        histograms = map(
            lambda x:
            (os.path.basename(os.path.dirname(x.GetPath())),
             filter(lambda y: hname in y.GetName() and "Grav" in y.GetName(),
                    getObjects([x]))), folders)

        if mean:
            fnc = lambda x: (x.GetMean(), x.Integral())
        else:
            fnc = lambda x: x.Integral()
        return map(
            lambda x: (x[0].replace("GenIso", ""),
                       map(
                           lambda y:
                           (self.getMassAndCoup(y.GetName()),
                            self.getCategory(y.GetName()), fnc(y)), x[1])),
            histograms)
コード例 #4
0
ファイル: limit_plots.py プロジェクト: gfunk723/MonoHiggsToGG
    def __call__(self, options, args):
        self.loadRootStyle()

        # ROOT.gSystem.AddIncludePath( "$ROOTSYS/include" )
        ROOT.gROOT.LoadMacro(
            "$CMSSW_BASE/src/HiggsAnalysis/CombinedLimit/test/plotting/bandUtils.cxx+"
        )

        self.loadXsections(options.x_sections)

        if options.do_comparison:
            if len(options.compare_labels) > 0:
                assert (len(options.compare_labels) == len(
                    options.compare_files))
            else:
                options.compare_labels = map(guessLabel, options.compare_files)
            self.compare = map(
                lambda x: (getObjects([self.open(x[0])]), x[1]),
                zip(options.compare_files, options.compare_labels))
            self.plotComparisons(options)
            return
        if options.compare_expected:
            self.compareExpectedLivia(options, True, False)  #orig
            #self.compareExpectedLivia(options, False, False) #boost
            self.compareExpectedLivia(options, False, True)  #chiara
            return

        print options.couplings
        #if len(options.couplings) == 0:
        #    flist = glob.glob("%s/higgsCombine%s*.%s.root" % (options.input_dir, options.label, options.method) )
        #else:
        #flist = ["%s/higgsCombineTest.%s.mA0300.root" %(options.input_dir, options.method)]
        flist = [
            "%s/higgsCombine%sCombined.%s.mH125_2HDM.root" %
            (options.input_dir, options.label, options.method)
        ]
        #flist = [ "%s/higgsCombine%sCombined.%s.mH125_2HDM.root" % (options.input_dir, options.label, options.method)]
        print options.input_dir, flist

        tflist = {}
        for fname in flist:
            bname = os.path.basename(fname)
            coup = bname.split("_", 1)
            print coup
            coup = coup[1].split(".")
            print coup
            coup = coup[0].replace("k", "")
            print coup
            ## coup = bname.split("_",1)[1].split(".")[0].replace("k","")
            tfin = self.open(fname)
            if not tfin:
                print("unable to open %s" % fname)
                sys.exit(-1)
            tree = tfin.Get("limit")
            if not tree:
                print("unable to find limit tree in %s" % fname)
                sys.exit(-1)

            tflist[coup] = tfin

        self.graphs = []
        for coup, tfile in tflist.iteritems():

            if options.do_limits:
                print coup, tfile
                self.plotLimit(options, coup, tfile)
            if options.do_pvalues:
                self.plotPval(options, coup, tfile)

        self.autosave()

        if len(options.couplings) == 0:
            graphs = self.open(
                "%s/graphs_%s.root" % (options.input_dir, options.method),
                "recreate")
        else:
            graphs = self.open(
                "%s/graphs_%s_%s.root" % (options.input_dir, "_".join(
                    options.couplings), options.method), "recreate")
        graphs.cd()
        for gr in self.graphs:
            gr.Write()
        graphs.Close()
コード例 #5
0
ファイル: limit_plots.py プロジェクト: ArnabPurohit/diphotons
    def __call__(self,options,args):
        self.loadRootStyle()
        
        ROOT.gStyle.SetTitleYOffset(1.)
        ROOT.gStyle.SetTitleXOffset(1.15)

        if options.do_comparison or options.do_nll:
            if len(options.compare_labels) > 0: assert( len(options.compare_labels) == len(options.compare_files) )
            else: options.compare_labels = map(guessLabel, options.compare_files)
            if len(options.compare_obs) == 0:
              options.compare_obs = ["r"]*len(options.compare_files)
            assert( len(options.compare_obs) == len(options.compare_files)  )
            
            self.compare = map(lambda x: (getObjects([self.open(x[0])]),x[1],x[2]), zip(options.compare_files,options.compare_labels,options.compare_obs) )

        if options.do_nll:
            self.plotNLLScan(options)
            return

        # ROOT.gSystem.AddIncludePath( "$ROOTSYS/include" )
        ROOT.gROOT.LoadMacro( "$CMSSW_BASE/src/HiggsAnalysis/CombinedLimit/test/plotting/bandUtils.cxx+" )
        
        self.loadXsections(options.x_sections)

        if options.do_comparison:
            self.plotComparisons(options)
            return

        print options.couplings
        if len(options.couplings) == 0:
            flist = glob.glob("%s/higgsCombine%s_k*.%s.root" % (options.input_dir, options.label, options.method) )
        else:
            flist = [ "%s/higgsCombine%s_k%s.%s.root" % (options.input_dir, options.label, coup, options.method) for coup in options.couplings ]
        print options.input_dir, flist
            
        tflist = {}
        for fname in flist:
            bname = os.path.basename(fname)
            coup = bname.split("_",1)
            print coup
            coup = coup[1].split(".")
            print coup
            coup = coup[0].replace("k","")
            print coup
            ## coup = bname.split("_",1)[1].split(".")[0].replace("k","")
            tfin = self.open(fname)
            if not tfin: 
                print ("unable to open %s" % fname)
                sys.exit(-1)
            tree = tfin.Get("limit")
            if not tree: 
                print ("unable to find limit tree in %s" % fname)
                sys.exit(-1)
        
            tflist[coup] = tfin
        
        self.graphs = []
        for coup,tfile in tflist.iteritems():

            if options.do_limits:
                print coup, tfile
                self.plotLimit(options,coup,tfile)
            if options.do_pvalues:
                self.plotPval(options,coup,tfile)
                
        self.autosave()

        if len(options.couplings) == 0:
            graphs = self.open("%s/graphs_%s.root" % (options.input_dir,options.method),"recreate")
        else:
            graphs = self.open("%s/graphs_%s_%s.root" % (options.input_dir,"_".join(options.couplings),options.method),"recreate")
        graphs.cd()
        for gr in self.graphs: gr.Write()
        graphs.Close()
コード例 #6
0
ファイル: scan_expected.py プロジェクト: crovelli/diphotons-1
    def compareSensitivity(self,options,args):
        

        ## self.open(options.limit_bias_file).GetListOfKeys().Print()
        bias_limits = filter(lambda x: "expected_" in x.GetName(),  getObjects( [self.open(options.limit_bias_file)], types=["TGraph"] ) ) if options.limit_bias_file else []
        
        no_bias_limits = filter(lambda x: "expected_" in x.GetName(), getObjects( [self.open(options.limit_no_bias_file)], types=["TGraph"] ) ) if options.limit_no_bias_file else []

        bias_zscans = filter(lambda x: "_bias" in x.GetName(), getObjects( [self.open(options.zscan_bias_file)], types=["TGraph"] ) ) if options.zscan_bias_file else []
        no_bias_zscans = filter(lambda x: "_nobias" in x.GetName(), getObjects( [self.open(options.zscan_no_bias_file)], types=["TGraph"] ) ) if options.zscan_bias_file else []

        biases = getObjects( [self.open(options.bias_file)], types=["TGraph"] ) if options.bias_file else []
        

        ## print bias_limits, no_bias_limits, bias_zscan, no_bias_zscan, biases
        print bias_zscans, no_bias_zscans,
        
        coups = map( lambda x: x.GetName().replace("expected_",""), bias_limits )
        print coups
        
        common = [["SetLineStyle",0],["SetMarkerSize",1],["SetLineWidth",2]]
        styles = [ [["colors",ROOT.kRed],["SetMarkerStyle",ROOT.kFullCircle]], 
                   [["colors",ROOT.kBlue],["SetMarkerStyle",ROOT.kFullTriangleUp]],
                   [["colors",ROOT.kGreen],["SetMarkerStyle",ROOT.kFullDiamond]],
                   [["colors",ROOT.kGreen+1],["SetMarkerStyle",ROOT.kOpenDiamond]],
                   ]
        

        for coup in coups:
            bias_limit = filter(lambda x: x.GetName().endswith("_%s" % coup), bias_limits )
            no_bias_limit = filter(lambda x: x.GetName().endswith("_%s" % coup), no_bias_limits )
     
            bias_zscan = filter(lambda x: x.GetName().startswith("%s_" % coup), bias_zscans )
            no_bias_zscan = filter(lambda x: x.GetName().startswith("%s_" % coup), no_bias_zscans )
            
            bias_terms = filter(lambda x: x.GetName().startswith("%s_" % coup), biases )
            
            for g in bias_limit: g.SetTitle("expected limit bias")
            for g in no_bias_limit: g.SetTitle("expected limit no bias")
            for g in bias_zscan: g.SetTitle("expected #sigma #times BR (Z_{0}=3) bias")
            for g in no_bias_zscan: g.SetTitle("expected #sigma #times BR (Z_{0}=3) no bias")

            for g in bias_terms: g.SetTitle("bias term %s" % g.GetName().split("_")[-1])
            
            print bias_zscan, no_bias_zscan

            if len(bias_limit) > 0:
                graphs = bias_limit+no_bias_limit+bias_terms
                map( lambda x: style_utils.apply(x[0],common+x[1]), zip(graphs,styles) )
                
                canv  = ROOT.TCanvas("limits_comparison_%s" % coup,"limits_comparison_%s" % coup)
                legend = ROOT.TLegend(0.5,0.6,0.8,0.9)
                legend.AddEntry(None,"#tilde{#kappa} = 0.%s" % coup[1:],"")
                
                ypoints = reduce( lambda x,y: x+y, map(lambda g: [g.GetY()[ip] for ip in xrange(g.GetN())], graphs ) )
                ymin = min( ypoints ) 
                ymax = max( ypoints ) 
                
                
                graphs[0].Draw("al")
                graphs[0].GetYaxis().SetRangeUser(0.5*ymin,1.5*ymax)
                for g in graphs[1:]: g.Draw("l")
                
                for g in graphs: legend.AddEntry(g,g.GetTitle(),"l")
                legend.Draw()
                
                self.keep([canv,graphs,legend])
                self.autosave(True)
    
            if len(bias_zscan) > 0:
                graphs = bias_zscan+no_bias_zscan+bias_terms
                map( lambda x: style_utils.apply(x[0],common+x[1]), zip(graphs,styles) )
                
                canv  = ROOT.TCanvas("zscans_comparison_%s" % coup,"zscans_comparison_%s" % coup)
                legend = ROOT.TLegend(0.5,0.6,0.8,0.9)
                legend.AddEntry(None,"#tilde{#kappa} = 0.%s" % coup[1:],"")
                
                ypoints = reduce( lambda x,y: x+y, map(lambda g: [g.GetY()[ip] for ip in xrange(g.GetN())], graphs ) )
                ymin = min( ypoints ) 
                ymax = max( ypoints ) 
                
                
                graphs[0].Draw("al")
                graphs[0].GetYaxis().SetRangeUser(0.5*ymin,1.5*ymax)
                for g in graphs[1:]: g.Draw("l")
                
                for g in graphs: legend.AddEntry(g,g.GetTitle(),"l")
                legend.Draw()
                
                print canv
                self.keep([canv,graphs,legend])
                self.autosave(True)
コード例 #7
0
ファイル: limit_plots.py プロジェクト: lsoffi/MonoHggFits
    def __call__(self,options,args):
        self.loadRootStyle()
        
        # ROOT.gSystem.AddIncludePath( "$ROOTSYS/include" )
        ROOT.gROOT.LoadMacro( "$CMSSW_BASE/src/HiggsAnalysis/CombinedLimit/test/plotting/bandUtils.cxx+" )
        
        self.loadXsections(options.x_sections)

        if options.do_comparison:
            if len(options.compare_labels) > 0: assert( len(options.compare_labels) == len(options.compare_files) )
            else: options.compare_labels = map(guessLabel, options.compare_files)
            self.compare = map(lambda x: (getObjects([self.open(x[0])]),x[1]), zip(options.compare_files,options.compare_labels) )
            self.plotComparisons(options)
            return
        if options.compare_expected:
            #self.compareExpectedLivia(options, True, False) #orig
            #self.compareExpectedLivia(options, False, False) #boost
            self.compareExpectedLivia(options, False, True) #chiara
            return

        print options.couplings
        #if len(options.couplings) == 0:
        #    flist = glob.glob("%s/higgsCombine%s*.%s.root" % (options.input_dir, options.label, options.method) )
        #else:
        flist = [ "%s/higgsCombine%sCombined.%s.mH125_2HDM.root" % (options.input_dir, options.label, options.method)]
        print options.input_dir, flist
            
        tflist = {}
        for fname in flist:
            bname = os.path.basename(fname)
            coup = bname.split("_",1)
            print coup
            coup = coup[1].split(".")
            print coup
            coup = coup[0].replace("k","")
            print coup
            ## coup = bname.split("_",1)[1].split(".")[0].replace("k","")
            tfin = self.open(fname)
            if not tfin: 
                print ("unable to open %s" % fname)
                sys.exit(-1)
            tree = tfin.Get("limit")
            if not tree: 
                print ("unable to find limit tree in %s" % fname)
                sys.exit(-1)
        
            tflist[coup] = tfin
        
        self.graphs = []
        for coup,tfile in tflist.iteritems():

            if options.do_limits:
                print coup, tfile
                self.plotLimit(options,coup,tfile)
            if options.do_pvalues:
                self.plotPval(options,coup,tfile)
                
        self.autosave()

        if len(options.couplings) == 0:
            graphs = self.open("%s/graphs_%s.root" % (options.input_dir,options.method),"recreate")
        else:
            graphs = self.open("%s/graphs_%s_%s.root" % (options.input_dir,"_".join(options.couplings),options.method),"recreate")
        graphs.cd()
        for gr in self.graphs: gr.Write()
        graphs.Close()
コード例 #8
0
ファイル: limit_plots.py プロジェクト: rdangovs/diphotons
    def __call__(self, options, args):
        self.loadRootStyle()

        ROOT.gStyle.SetTitleYOffset(1.)
        ROOT.gStyle.SetTitleXOffset(1.15)

        if options.do_comparison or options.do_nll:
            if len(options.compare_labels) > 0:
                assert (len(options.compare_labels) == len(
                    options.compare_files))
            else:
                options.compare_labels = map(guessLabel, options.compare_files)
            if len(options.compare_obs) == 0:
                options.compare_obs = ["r"] * len(options.compare_files)
            assert (len(options.compare_obs) == len(options.compare_files))

            self.compare = map(
                lambda x: (getObjects([self.open(x[0])]), x[1], x[2]),
                zip(options.compare_files, options.compare_labels,
                    options.compare_obs))

        if options.do_nll:
            self.plotNLLScan(options)
            return

        # ROOT.gSystem.AddIncludePath( "$ROOTSYS/include" )
        ROOT.gROOT.LoadMacro(
            "$CMSSW_BASE/src/HiggsAnalysis/CombinedLimit/test/plotting/bandUtils.cxx+"
        )

        self.loadXsections(options.x_sections)

        if options.do_comparison:
            self.plotComparisons(options)
            return

        print options.couplings
        if len(options.couplings) == 0:
            flist = glob.glob(
                "%s/higgsCombine%s_k*.%s.root" %
                (options.input_dir, options.label, options.method))
        else:
            flist = [
                "%s/higgsCombine%s_k%s.%s.root" %
                (options.input_dir, options.label, coup, options.method)
                for coup in options.couplings
            ]
        print options.input_dir, flist

        tflist = {}
        for fname in flist:
            bname = os.path.basename(fname)
            coup = bname.split("_", 1)
            print coup
            coup = coup[1].split(".")
            print coup
            coup = coup[0].replace("k", "")
            print coup
            ## coup = bname.split("_",1)[1].split(".")[0].replace("k","")
            tfin = self.open(fname)
            if not tfin:
                print("unable to open %s" % fname)
                sys.exit(-1)
            tree = tfin.Get("limit")
            if not tree:
                print("unable to find limit tree in %s" % fname)
                sys.exit(-1)

            tflist[coup] = tfin

        self.graphs = []
        for coup, tfile in tflist.iteritems():

            if options.do_limits:
                print coup, tfile
                self.plotLimit(options, coup, tfile)
            if options.do_pvalues:
                self.plotPval(options, coup, tfile)

        self.autosave()

        if len(options.couplings) == 0:
            graphs = self.open(
                "%s/graphs_%s.root" % (options.input_dir, options.method),
                "recreate")
        else:
            graphs = self.open(
                "%s/graphs_%s_%s.root" % (options.input_dir, "_".join(
                    options.couplings), options.method), "recreate")
        graphs.cd()
        for gr in self.graphs:
            gr.Write()
        graphs.Close()