Exemplo n.º 1
0
    def save_plots(self,
                   savename,
                   sub_dir=None,
                   canvas=None,
                   x=1,
                   y=1,
                   prnt=True,
                   save=True,
                   show=True):
        """ Saves the canvas at the desired location. If no canvas is passed as argument, the active canvas will be saved. """

        if canvas is None:
            try:
                canvas = gROOT.GetListOfCanvases()[-1]
            except Exception as inst:
                print log_warning(
                    'Error in save canvas: {err}'.format(err=inst))
                return
        try:
            self.Analysis.draw_run_info(canvas=canvas, x=x, y=y)
        except AttributeError as err:
            log_warning(err)
        canvas.Modified()
        canvas.Update()
        if save:
            try:
                self.save_canvas(canvas,
                                 sub_dir=sub_dir,
                                 name=savename,
                                 print_names=prnt,
                                 show=show)
            except Exception as inst:
                print log_warning('Error in save_canvas:\n{0}'.format(inst))
Exemplo n.º 2
0
def show_single_waveforms(n=1, cut='', start_event=0):
    global count
    start = start_event + count
    activated_wfs = [wf for wf in range(4) if wf_exists(wf)]
    print('activated wafeforms:', activated_wfs)
    print('Start at event number:', start)
    wfs = [draw_waveforms(n=n, start_event=start, cut_string=cut, show=False, ch=wf) for wf in activated_wfs]
    n_wfs = len(activated_wfs)
    cs = {c.GetName(): c for c in gROOT.GetListOfCanvases()}
    if 'c_wfs' not in cs:
        c = TCanvas('c_wfs', 'Waveforms', 2000, n_wfs * 500)
        c.Divide(1, n_wfs)
    else:
        c = cs['c_wfs']
    for i, wf in enumerate(wfs, 1):
        wf[0].SetTitle('{nam} WaveForm'.format(nam=channels[activated_wfs[i - 1]]))
        wf[0].GetXaxis().SetTitleSize(.06)
        wf[0].GetYaxis().SetTitleSize(.06)
        wf[0].GetXaxis().SetLabelSize(.06)
        wf[0].GetYaxis().SetLabelSize(.06)
        pad = c.cd(i)
        pad.SetMargin(.05, .05, .1, .1)
        wf[0].Draw('alp')
    stuff.append([c, wfs])
    cnt = wfs[0][1]
    # if cnt is None:
    #     return
    count += cnt
Exemplo n.º 3
0
    ntuple.Fill(px, py, pz, random, i)
c1 = gROOT.FindObject('c1')
if c1:
    c1 = 0
c1 = TCanvas('c1', 'Histogram Example', 200, 10, 700, 500)
c1.SetFillColor(42)
c1.GetFrame().SetFillColor(21)
c1.GetFrame().SetBorderSize(6)
c1.GetFrame().SetBorderMode(-1)
hpx.SetFillColor(48)
hpx.Draw()
c1.Modified()
c1.Update()
# In[ ]:
# In[7]:
gROOT.GetListOfCanvases().Draw()
# In[7]:
hpx.SetFillColor(0)
c1.Modified()
c1.Update()
gROOT.GetListOfCanvases().Draw()
# In[8]:
hpx.SetLineColor(2)
hpx.SetFillColor(6)
hpx.SetFillStyle(3244)
c1.Modified()
c1.Update()
gROOT.GetListOfCanvases().Draw()
# In[9]:
c2 = gROOT.FindObject('c2')
if c2: