예제 #1
0
    def update(self):
        content_min = self.content[0]
        content_max = self.content[0]

        if (self.range_min == -1):
            for calo in range(1, self.ncalo):
                if (self.content[calo] < content_min):
                    content_min = self.content[calo]
                if (self.content[calo] > content_max):
                    content_max = self.content[calo]
        else:
            self.range_min = 0
            content_max = self.range_max

        for calo in range(self.ncalo):
            if (self.content[calo] != 0):
                self.ombox[calo].SetFillColor(self.palette_index + (
                    int)(99 * (self.content[calo] - content_min) /
                         (content_max - content_min)))
            else:
                self.ombox[calo].SetFillColor(0)

        self.canvas.Modified()
        self.canvas.Update()
        gSystem.ProcessEvents()
        return 0
예제 #2
0
    def reset(self):
        for calo in range(self.ncalo):
            self.content[calo] = 0
            # for calo=0; calo<self.ncalo; ++calo)
            self.ombox[calo].SetFillColor(0)

        self.canvas.Modified()
        self.canvas.Update()
        gSystem.ProcessEvents()

        return 0
예제 #3
0
    def draw(self, fiber_map=False):
        if (self.canvas == None):
            self.canvas = TCanvas(self.name, "SuperNEMO calorimeter", 1750,
                                  500)
            self.canvas.SetEditable(True)
            self.canvas.cd()

        for mw0 in range(2):
            for mw1 in range(20):
                for mw2 in range(13):
                    id = mw0 * 20 * 13 + mw1 * 13 + mw2

                    self.ombox[id].Draw("l")
                    self.omtext[id].Draw()

        for xw0 in range(2):
            for xw1 in range(2):
                for xw2 in range(2):
                    for xw3 in range(16):
                        id = 520 + xw0 * 2 * 2 * 16 + xw1 * 2 * 16 + xw2 * 16 + xw3
                        self.ombox[id].Draw("l")
                        self.omtext[id].Draw()

        for gv0 in range(2):
            for gv1 in range(2):
                for gv2 in range(16):
                    id = 520 + 128 + gv0 * 2 * 16 + gv1 * 16 + gv2
                    self.ombox[id].Draw("l")
                    self.omtext[id].Draw()

        self.source_foil.Draw()
        self.it_label.Draw()
        self.fr_label.Draw()

        if fiber_map == True:
            for line in self.fiber_map_lines:
                line.SetLineColor(kBlack)
                line.SetLineStyle(9)
                line.SetLineWidth(3)
                line.Draw()

        self.canvas.SetEditable(False)
        gSystem.ProcessEvents()
        return 0
예제 #4
0
파일: hsimple.py 프로젝트: govoni/learn
    # Fill histograms.
    hpxFill(px)
    hpxpyFill(px, py)
    hprofFill(px, pz)
    ntupleFill(px, py, pz, random, i)

    # Update display every kUPDATE events.
    if i and i % kUPDATE == 0:
        if i == kUPDATE:
            hpx.Draw()

        c1.Modified()
        c1.Update()

        if gSystem.ProcessEvents():  # allow user interrupt
            break

# Destroy member functions cache.
for name in histos:
    exec 'del %sFill' % name
del histos

gBenchmark.Show('hsimple')

# Save all objects in this file.
hpx.SetFillColor(0)
hfile.Write()
hpx.SetFillColor(48)
c1.Modified()
c1.Update()
예제 #5
0
def plotter(plotdir,
            plot,
            xTitle,
            logY,
            channels=['VV'],
            includeData=False,
            scaleSignal=0,
            UserRange=[None, None, None, None],
            initPath=''):

    # channelTex={'WPWP':'W^{+}W^{+}', 'WPWM':'W^{+}W^{-}','WMWM':'W^{-}W^{-}','WPZ':'W^{+}Z','WMZ':'W^{-}Z','ZZ':'ZZ'}
    channelTex = {'ZZ': 'ZZ'}
    # plotstyle=[(1,1),(1,2),(2,1),(2,2),(4,1),(4,2)]
    plotstyle = [(1, 1)]
    #             0              1                       2                        3             4              5             6
    # Backgrounds=['QCD',     'WJetsToQQ_HT600ToInf', 'ZJetsToQQ_HT600ToInf',     'TT',         'WW',          'WZ',         'ZZ']
    # BGColors=   [rt.kAzure+7,   rt.kRed-4,              rt.kOrange-2,            rt.kGreen+2,  rt.kOrange+7,  rt.kBlue+1,   rt.kMagenta+2]
    # BGTeX=      ['QCD',        'W+JetsToQQ',           'Z+JetsToQQ',             'TTbar'],      'WW',          'WZ',         'ZZ']
    #stackOrder= [4,5,6,2,1,3,0]
    Backgrounds = [
        'QCD'
    ]  # 'WJetsToQQ_HT600ToInf', 'ZJetsToQQ_HT600ToInf', 'ZZ']  'TT',         'WW',          'WZ',         'ZZ']
    BGColors = [
        rt.kAzure + 7
    ]  #,              rt.kOrange-2,            rt.kGreen+2],  rt.kOrange+7,  rt.kBlue+1,   rt.kMagenta+2]
    BGTeX = ['QCD']  #

    stackOrder = [0]

    PreSelection = [
        'nocuts', 'common', 'corrections', 'cleaner', 'softdropmassCorr',
        'AK4pfidfilter', 'AK8pfidfilter', 'invMAk8sel', 'detaAk8sel',
        'AK8N2sel'
    ]
    Selection = [
        'preselection', 'softdropAK8sel', 'tau21sel', 'deltaR48', 'VVRegion',
        'AK4N2sel', 'OpSignsel', 'detaAk4sel', 'invMAk4sel_1p0', 'Kin_AK8'
    ]

    cutnames = [
        'cleaner', 'AK8N2sel', 'invMAk8sel', 'detaAk8sel', 'softdropAK8sel',
        'tau21sel', 'AK4cleaner', 'AK4N2sel', 'OpSignsel', 'detaAk4sel',
        'invMAk4sel_1p0'
    ]

    cuts = {
        'cleaner':
        '#splitline{p_{T-AK8} > 200 GeV, |#eta_{AK8}| < 2.5}{p_{T-AK4} > 30 GeV, |#eta_{AK4}| < 5.0}',
        'AK8N2sel': 'N_{AK8} #geq 2',
        'invMAk8sel': 'M_{jj-AK8} > 1050 GeV',
        'detaAk8sel': '|#Delta#eta_{jj-AK8}|<1.3',
        'softdropAK8sel': '65 GeV <M_{SD}< 105 GeV',
        'tau21sel': '0 #leq #tau_{2}/#tau_{1}<0.45',
        # 'AK4cleaner':'p_{T-AK4} > 30 GeV, |#eta_{AK4}| < 5.0',
        'AK4cleaner': '',
        'AK4N2sel': 'N_{AK4} #geq 2',
        'OpSignsel': '#eta_{1-AK4} #eta_{2-AK4} < 0',
        'detaAk4sel': '|#Delta#eta_{jj-AK4}| > 3.0',
        'invMAk4sel_1p0': 'M_{jj-AK4} > 1.0 TeV'
    }

    VV = ('VV' in channels)
    seperate = (not VV)
    if VV:
        #channels=["WPWP","WPWM","WMWM","WPZ","WMZ","ZZ"]
        channels = ["ZZ"]

    plottitle = plotdir + '_' + plot

    lumi = 36.814
    xLabelSize = 18.
    yLabelSize = 18.
    xTitleSize = 20.
    yTitleSize = 22.
    xTitleOffset = 4.
    yTitleOffset = 1.3

    printout = False
    Portrait = True
    cutname = False
    ratio = includeData

    if ('highbin' in plot):
        binning = 'dijetbinning'
    else:
        binning = 'default'

    if (Portrait):
        canvX = 600
        canvY = 600
    else:
        canvX = 900
        canvY = 675

    if (plotdir in PreSelection):
        region = 'PreSelection'
        initPath = ''
        referenceHistPath = 'detaAk8sel/N_pv'
        if (PreSelection.index(plotdir) < 4 and ('softdrop' in plot)):
            return 'SofdropMass not filled yet!'
    else:
        region = 'SignalRegion'
        referenceHistPath = 'tau21sel/N_pv'
    referenceHistPath = plotdir + '/' + plot

    if (initPath == ''):
        path = '/nfs/dust/cms/user/loemkerj/bachelor/CMSSW_10_2_16/src/UHH2/aQGCVVjjhadronic/%s' % region
    else:
        path = initPath
    outputPath = path.replace(
        '/nfs/dust/cms/user/loemkerj/bachelor/CMSSW_10_2_16/src/UHH2/aQGCVVjjhadronic/SignalRegion',
        'plots/')
    if (plotdir in PreSelection):
        CutNumber = PreSelection.index(plotdir)
    else:
        CutNumber = Selection.index(plotdir)
    outputPath = outputPath + '/%02i_%s' % (CutNumber, plotdir) + '/'
    if (printout):
        print('InputPath:', path)
        print('OutputPath:', outputPath)
    #check if OutputPath exists - and if not create it!
    if not os.path.exists(outputPath):
        os.makedirs(outputPath)
    # path='/home/albrec/Master/signal/'
    scaleVV = (scaleSignal != 0)
    VVScale = scaleSignal

    if (UserRange[2] == None or UserRange[3] == None):
        YRangeUser = False
        Ymin = UserRange[2]
        Ymax = UserRange[3]
    else:
        YRangeUser = True
        Ymin = UserRange[2]
        Ymax = UserRange[3]

    if (UserRange[0] == None or UserRange[1] == None):
        XRangeUser = False
        Xmin = UserRange[0]
        Xmax = UserRange[1]
    else:
        XRangeUser = True
        Xmin = UserRange[0]
        Xmax = UserRange[1]

    # YRangeUser=False
    # Ymin=0.11
    # Ymax=9*10**3

    # XRangeUser=False
    # Xmin=0
    # Xmax=6000.

    gROOT.ProcessLine("gErrorIgnoreLevel = 2001;")
    SFiles = []
    for i in range(len(channels)):
        SFiles.append(
            TFile(
                path +
                "/uhh2.AnalysisModuleRunner.MC.MC_aQGC_%sjj_hadronic_2016v3.root"
                % channels[i]))
#uhh2.AnalysisModuleRunner.MC.MC_aQGC_ZZjj_hadronic_2016v3.root
##Open Files to get BackgroundHist:
    BFiles = []
    for i in range(len(Backgrounds)):
        BFiles.append(
            TFile(path +
                  "/uhh2.AnalysisModuleRunner.MC.MC_%s.root" % Backgrounds[i]))

    #Open File to get DataHist:

# DataFile = TFile(path+"/uhh2.AnalysisModuleRunner.Data.DATA.root")

#gROOT.ProcessLine( "gErrorIgnoreLevel = 0;")

    if (includeData == True):
        #calculate QCDscale with Integrals from the following Histogram:
        # referenceHistPath = 'tau21sel/N_AK4'
        # referenceHistPath = 'detaAk8sel/N_pv'
        # referenceHistPath = 'tau21sel/met_pt_over_sumptAK8_2'
        QCDscale = float(DataFile.Get(referenceHistPath).Integral())
        QCDNorm = 1
        for i in range(len(BFiles)):
            if ('QCD' in BFiles[i].GetName()):
                QCDNorm = float(BFiles[i].Get(referenceHistPath).Integral())
            else:
                QCDscale -= float(BFiles[i].Get(referenceHistPath).Integral())
        QCDscale /= QCDNorm
    else:
        QCDscale = 1.0
    if (printout):
        print('using QCDscale:', QCDscale)

    SHists = []
    for i in range(len(channels)):
        SHists.append(SFiles[i].Get(plotdir + '/' + plot))

    BHists = []
    for i in range(len(BFiles)):
        BHists.append(BFiles[i].Get(plotdir + '/' + plot))
        if ('QCD' in BFiles[i].GetName()):
            BHists[-1].Scale(QCDscale)

    #if(includeData):
    #    DataHist=DataFile.Get(plotdir+'/'+plot)

    if (binning == 'dijetbinning'):
        fitbinning = array('d')
        binwidth = 200
        NBins = (14000 / binwidth) - ((1040 / binwidth) + 1)
        NBins = int(NBins)
        for i in range(NBins + 1):
            fitbinning.append(1050 + i * binwidth)

        for i in range(len(channels)):
            SHists[i] = SHists[i].Rebin(NBins, "new binning", fitbinning)
        for i in range(len(Backgrounds)):
            BHists[i] = BHists[i].Rebin(NBins, "new binning", fitbinning)

        if (includeData):
            DataHist = DataHist.Rebin(NBins, "new binning", fitbinning)

    canv = TCanvas(plottitle, plottitle, canvX, canvY)

    yplot = 0.7
    yratio = 0.3
    ymax = 1.0
    xmax = 1.0
    xmin = 0.0
    if (ratio):
        plotpad = TPad("plotpad", "Plot", xmin, ymax - yplot, xmax, ymax)
        ratiopad = TPad("ratiopad", "Ratio", xmin, ymax - yplot - yratio, xmax,
                        ymax - yplot)
    else:
        plotpad = TPad("plotpad", "Plot", xmin, ymax - yplot - yratio, xmax,
                       ymax)

    plotpad.SetTopMargin(0.08)
    plotpad.SetLeftMargin(0.1)
    plotpad.SetRightMargin(0.05)
    plotpad.SetTicks()
    plotpad.Draw()

    if (ratio):
        plotpad.SetBottomMargin(0.016)
        ratiopad.SetTopMargin(0.016)
        ratiopad.SetBottomMargin(0.35)
        ratiopad.SetLeftMargin(0.1)
        ratiopad.SetRightMargin(0.05)
        ratiopad.SetTicks()
        ratiopad.Draw()
    else:
        plotpad.SetBottomMargin(0.1)

    if (logY):
        plotpad.SetLogy()
        canv.SetLogy()
    if ('-logX' in xTitle):
        plotpad.SetLogx()
        if (ratio):
            ratiopad.SetLogx()
        canv.SetLogx()

    drawOptions = "HE"

    stack = THStack(plottitle, plottitle)

    BHist = THStack(plottitle, plottitle)

    # for i in range(len(Backgrounds)):
    for i in stackOrder:
        # BHists[i].SetFillColor(BGColors[i])
        BHists[i].SetLineColor(BGColors[i])
        BHist.Add(BHists[i], 'Hist')

    BHist.SetTitle(plottitle)

    BHistErr = BHists[0].Clone()
    for i in range(1, len(Backgrounds)):
        BHistErr.Add(BHists[i])

    BHistErr.SetFillStyle(3204)
    BHistErr.SetFillColor(rt.kGray + 2)
    BHistErr.SetLineColor(1)

    BGMax = BHist.GetMaximum()
    SIGMax = 0
    #if(VV):       #new
    #    SIGMax=VVsum.GetMaximum()
    #else:
    for i in range(len(channels)):
        tmpmax = SHists[i].GetMaximum()
        if (tmpmax > SIGMax):
            SIGMax = tmpmax
    if (scaleVV):
        SIGMax = SIGMax * VVScale
    if (logY):
        MAX = 0.9 * float(10**(magnitude(max(BGMax, SIGMax)) + 1))
        MIN = float(10**(magnitude(max(BGMax, SIGMax)) - 5))
        MIN += float(10**(magnitude(MIN)))
        legendMIN = math.log(max(BGMax, SIGMax)) / math.log(MAX)
    else:
        MAX = (1.0 / 0.8) * max(BGMax, SIGMax)
        legendMIN = 0.7
        MIN = 0.
    legendMIN = (legendMIN * 0.7) + 0.3 - 0.016

    legend = TLegend(0.5, 0.75, 0.85, 0.89)
    legend.SetFillStyle(0)
    legend.SetTextSize(0.02)
    legend.SetMargin(0.4)
    legend.SetNColumns(2)
    legend.SetColumnSeparation(0.3)

    if (includeData):
        DataHist.SetMarkerStyle(8)
        DataHist.SetLineColor(1)
        DataHist.SetTitle(plottitle)

    if VV:
        for i in range(len(channels)):
            if (i == 0):
                VVsum = SHists[i].Clone()
            else:
                VVsum.Add(SHists[i])
        legentry = 'VVjj'
        if (scaleVV):
            VVsum.Scale(VVScale)
            legentry += ' *%0.f' % VVScale
        VVsum.SetLineColor(1)
        VVsum.SetLineStyle(plotstyle[0][1])
        VVsum.SetLineWidth(2)
        legend.AddEntry(VVsum, legentry)
    else:
        for i in range(len(channels)):
            SHists[i].SetLineColor(plotstyle[i][0])
            SHists[i].SetLineStyle(plotstyle[i][1])
            SHists[i].SetLineWidth(2)
            legentry = "%sjj" % channelTex[channels[i]]
            if (scaleVV):
                SHists[i].Scale(VVScale)
                legentry += ' *%.2E' % VVScale
            legend.AddEntry(SHists[i], legentry)

    for i in stackOrder:
        legend.AddEntry(BHists[i], BGTeX[i], "f")
    legend.AddEntry(BHistErr, "stat. Uncertainty", "f")

    if (includeData):
        legend.AddEntry(DataHist, "Data", "lep")

    canv.SetTitle(plottitle)

    BHistErr.GetYaxis().SetTitle('Events')
    BHistErr.GetYaxis().SetRangeUser(MIN, MAX)
    BHistErr.GetYaxis().SetTitleFont(43)
    BHistErr.GetYaxis().SetTitleSize(yTitleSize)
    BHistErr.GetYaxis().SetTitleOffset(yTitleOffset)
    BHistErr.GetYaxis().SetLabelFont(43)
    BHistErr.GetYaxis().SetLabelSize(yLabelSize)
    if (ratio):
        BHistErr.GetXaxis().SetTitleSize(0.0)
        BHistErr.GetXaxis().SetLabelSize(0.0)
    else:
        BHistErr.GetXaxis().SetTitle(xTitle)
        BHistErr.GetXaxis().SetTitleFont(43)
        BHistErr.GetXaxis().SetTitleSize(xTitleSize)
        # BHistErr.GetXaxis().SetTitleOffset(xTitleOffset)
        BHistErr.GetXaxis().SetTitleOffset(1.2)
        BHistErr.GetXaxis().SetLabelFont(43)
        BHistErr.GetXaxis().SetLabelSize(xLabelSize)
        # BHistErr.GetXaxis().SetTickLength(0.08)
        # BHistErr.GetXaxis().SetNdivisions(506)

    if (YRangeUser):
        BHistErr.GetYaxis().SetRangeUser(Ymin, Ymax)
    if (XRangeUser):
        BHistErr.GetXaxis().SetRangeUser(Xmin, Xmax)

    plotpad.cd()

    BHistErr.Draw("E2")
    BHist.Draw("HistSAME")
    BHistErr.Draw("E2SAME")

    if (VV):
        VVsum.Draw("SAME" + drawOptions)
    elif ('-noSig' not in xTitle):
        for i in range(len(channels)):
            SHists[i].Draw("SAME" + drawOptions)

    if (includeData):
        DataHist.Draw("APE1SAME")

    plotpad.RedrawAxis()
    if (ratio):
        ratiopad.cd()

        if (includeData):
            ratioHist = DataHist.Clone()
        else:
            ratioHist = BHistErr.Clone()
        ratioHist.SetLineColor(rt.kBlack)
        # ratioHist.Sumw2()
        ratioHist.SetStats(0)
        ratioHist.Divide(BHistErr)
        ratioHist.SetMarkerStyle(21)
        ratioHist.SetMarkerSize(0.7)

        #Yaxis
        ratioHist.GetYaxis().SetRangeUser(0.3, 1.7)
        ratioHist.GetYaxis().SetTitle("Data/BG")
        ratioHist.GetYaxis().CenterTitle()
        ratioHist.GetYaxis().SetTitleFont(43)
        ratioHist.GetYaxis().SetTitleSize(yTitleSize)
        ratioHist.GetYaxis().SetTitleOffset(yTitleOffset)
        ratioHist.GetYaxis().SetLabelFont(43)
        ratioHist.GetYaxis().SetLabelSize(yLabelSize)
        ratioHist.GetYaxis().SetNdivisions(506)
        #Xaxis
        ratioHist.GetXaxis().SetTitle(xTitle)
        ratioHist.GetXaxis().SetTitleFont(43)
        ratioHist.GetXaxis().SetTitleSize(xTitleSize)
        ratioHist.GetXaxis().SetTitleOffset(xTitleOffset)
        ratioHist.GetXaxis().SetLabelFont(43)
        ratioHist.GetXaxis().SetLabelSize(xLabelSize)
        ratioHist.GetXaxis().SetTickLength(0.08)
        ratioHist.GetXaxis().SetNdivisions(506)

        # if(YRangeUser):
        #     ratioHist.GetYaxis().SetRangeUser(Ymin,Ymax)
        if (XRangeUser):
            ratioHist.GetXaxis().SetRangeUser(Xmin, Xmax)
            ratioXMin = Xmin
            ratioXMax = Xmax
        else:
            ratioXMin = ratioHist.GetXaxis().GetXmin()
            ratioXMax = ratioHist.GetXaxis().GetXmax()
        ratioHist.Draw("ep")

        zeropercent = TLine(ratioXMin, 1, ratioXMax, 1)
        zeropercent.Draw()
        plus10percent = TLine(ratioXMin, 1.1, ratioXMax, 1.1)
        plus10percent.SetLineStyle(rt.kDashed)
        plus10percent.Draw()
        minus10percent = TLine(ratioXMin, 0.9, ratioXMax, 0.9)
        minus10percent.SetLineStyle(rt.kDashed)
        minus10percent.Draw()

    canv.cd()
    gPad.RedrawAxis()
    legend.Draw()

    latex = TLatex()
    latex.SetNDC(kTRUE)
    latex.SetTextSize(20)
    latex.DrawLatex(0.69, 0.953, "%.2f fb^{-1} (13 TeV)" % lumi)
    latex.DrawLatex(0.1, 0.953, "private work")

    lastcut = 'nocuts'
    for cut in cutnames:
        if cut in plotdir:
            lastcut = cut

    if (not (lastcut == 'nocuts') and cutname):
        # latex.SetTextSize(0.03)
        latex.SetTextSize(15)
        for l in range(cutnames.index(lastcut) + 1):
            latex.DrawLatex(0.12, 0.8 - l * 0.04, cuts[cutnames[l]])

    canv.Update()
    canv.Print(outputPath + '/%s_%s.pdf' % (plotdir, plot))
    #prevents memory leak in Canvas Creation/Deletion
    #see: https://root.cern.ch/root/roottalk/roottalk04/2484.html
    gSystem.ProcessEvents()
    if (ratio):
        del ratiopad
    del plotpad, canv
    # gc.collect()
    return 'done!'
def compare(filerun3, filerun1):
    f = [TFile(filerun1, "READ"), TFile(filerun3, "READ")]
    # gROOT.SetStyle("Plain")
    gStyle.SetOptStat(0)
    gStyle.SetOptTitle(0)
    # gStyle.SetOptStat(0000)
    # gStyle.SetPalette(0)
    # gStyle.SetCanvasColor(0)
    # gStyle.SetFrameFillColor(0)

    hp_NoCut = get(f, "hp_NoCut", "filterEl-task/", "p-task/")
    hp_TrkCut = get(f, "hp_TrkCut", "filterEl-task/", "p-task/")
    hp_TOFCut = get(f, "hp_TOFCut", "filterEl-task/", "p-task/")
    #
    hlength_NoCut = get(f, "hlength_NoCut", "filterEl-task/", "tofpidqa-task/")
    htime_NoCut = get(f, "htime_NoCut", "filterEl-task/", "tofpidqa-task/")
    hevtime_NoCut = get(f, "hevtime_NoCut", "filterEl-task/", "tofpidqa-task/")
    #
    hp_El = get(f, "hp_El", "filterEl-task/")
    hpt_El = get(f, "hpt_El", "filterEl-task/")
    hlength_El = get(f, "hlength_El", "filterEl-task/")
    htime_El = get(f, "htime_El", "filterEl-task/")
    hp_beta = get(f, "hp_beta", "filterEl-task/")
    hp_beta_El = get(f, "hp_beta_El", "filterEl-task/")
    hp_betasigma_El = get(f, "hp_betasigma_El", "filterEl-task/")

    makelegend(hp_El)

    if True:
        makecanvas("cmom", "Momentum").Divide(2, 3)
        drawtwo(hp_NoCut)
        drawtwo(hp_TrkCut)
        drawtwo(hp_TOFCut)
    #
    if True:
        makecanvas("ctof", "TOFInfo").Divide(2, 3)
        drawtwo(hlength_NoCut, logy=True)
        drawtwo(htime_NoCut, logy=True)
        drawtwo(hevtime_NoCut)
    if True:
        makecanvas("ctofEl", "TOFInfoEl").Divide(2, 3)
        drawtwo(hlength_El)
        drawtwo(htime_El)
        # drawtwo(hevtime_El)
    #
    if True:
        makecanvas("cbetaslice", "BetaSlice").Divide(2, 3)
        drawtwo(hp_beta)
        drawtwo(hp_beta_El)
        drawtwo(hp_betasigma_El)
    #
    if True:
        makecanvas("cmom_El", "Momentum_El").Divide(2, 2)
        drawtwo(hp_El)
        drawtwo(hpt_El)

    #
    if True:
        makecanvas("hp_beta", "Beta").Divide(3, 2)
        drawtwo(hp_beta, project=False, ratio=False)
        nextpad()
        drawdiff(hp_beta, "COLZ")
        drawtwo(hp_beta_El, project=False, ratio=False)
        nextpad()
        drawdiff(hp_beta_El, "COLZ")
    #
    if True:
        makecanvas("hp_betasigma_El", "BetaElSigma").Divide(3)
        nextpad()
        draw(hp_betasigma_El[0], "COLZ")
        nextpad()
        draw(hp_betasigma_El[1], "COLZ")
        nextpad()
        drawdiff(hp_betasigma_El, "COLZ")

    gSystem.ProcessEvents()
    canvaslist[0].SaveAs("plots.pdf[")
    for i in canvaslist:
        i.SaveAs("plots.pdf")
    canvaslist[-1].SaveAs("plots.pdf]")
    input()
예제 #7
0
파일: RootUtils.py 프로젝트: pfs/HGCal
 def __exit__(self, exception_type, exception_value, traceback):
     for _ic in range(len(self._c)):
         self._c[_ic].Close()
         gSystem.ProcessEvents()
예제 #8
0
#!/usr/bin/python
import ROOT
# Example: displaying a ROOT histogram with Python
# install root first
from ROOT import gRandom, TCanvas, TH1F, gSystem

c1 = TCanvas('c1', 'Example', 200, 10, 700, 500)
hpx = TH1F('hpx', 'px', 200, -10, 10)
for i in xrange(25000):
    px = gRandom.Gaus(0, 1)
    #print px
    hpx.Fill(px)
    hpx.Draw()
    c1.Update()
    c1.Modified()
    if gSystem.ProcessEvents():
        break