Belle II Software development
SaveCanvases Class Reference
Inheritance diagram for SaveCanvases:

Public Member Functions

def makePlot (self, h, slot, pmt)
 
def initialize (self)
 

Detailed Description

 Extract pulse height distributions from TOPCalPhotonYields and save canvases into a root file 

Definition at line 34 of file pmtPulseHeights.py.

Member Function Documentation

◆ initialize()

def initialize (   self)
 initialize: implementation 

Definition at line 69 of file pmtPulseHeights.py.

69 def initialize(self):
70 ''' initialize: implementation '''
71
72 gROOT.SetBatch(True)
73
74 db = Belle2.PyDBObj("TOPCalPhotonYields")
75 if not db:
76 return
77
78 fileName = "pmtPulseHeights-" + time.strftime("%Y-%m-%d", time.localtime(db.getTimeStamp())) + ".root"
79 f = TFile.Open(fileName, "recreate")
80
81 print("- global tag:", globalTag)
82 print("- time of measurement:",
83 time.strftime("%d %b %Y %H:%M:%S", time.localtime(db.getTimeStamp())), "(mean), ",
84 round(db.getTimeStampStd() / 3600 / 24, 2), "days (rms)")
85 oldDir = gDirectory
86 histos = []
87 for slot in range(1, 17):
88 oldDir.mkdir("slot" + f'{slot:02d}').cd()
89 h = db.getPulseHeights(slot)
90 if not h:
91 continue
92 hmean = TH1F('meanPH', 'slot ' + str(slot) + '; PMT number; mean pulse-height', 32, 0.5, 32.5)
93 for pmt in range(1, 33):
94 meanPH = self.makePlot(h, slot, pmt)
95 hmean.SetBinContent(pmt, meanPH)
96 histos.append(hmean)
97 oldDir.cd("..")
98
99 canvas = TCanvas("meanPH", "Mean pulse-heights", 1000, 1000)
100 canvas.Divide(4, 4)
101 for i, h in enumerate(histos):
102 canvas.cd(i + 1)
103 h.Draw()
104 canvas.Write()
105 f.Close()
106 print("--> canvases saved to:", fileName)
107
108
Class to access a DBObjPtr from Python.
Definition: PyDBObj.h:50

◆ makePlot()

def makePlot (   self,
  h,
  slot,
  pmt 
)
Makes a plot of pulse-height distributions of pixels of a single PMT and saves the canvas
:param h: a 2D histogram of pulse-height vs. pixel
:param slot: slot number
:param pmt: PMT number

Definition at line 37 of file pmtPulseHeights.py.

37 def makePlot(self, h, slot, pmt):
38 '''
39 Makes a plot of pulse-height distributions of pixels of a single PMT and saves the canvas
40 :param h: a 2D histogram of pulse-height vs. pixel
41 :param slot: slot number
42 :param pmt: PMT number
43 '''
44
45 name = 's' + f'{slot:02d}' + '_pmt' + f'{pmt:02d}'
46 canvas = TCanvas(name, "slot " + str(slot) + " pmt " + str(pmt), 1000, 1000)
47 canvas.Divide(4, 4)
48 meanPH = 0
49 N = 0
50 for pmtPix in range(16):
51 col = ((pmt - 1) % 16) * 4 + pmtPix % 4
52 row = int((pmt - 1) / 16) * 4 + int(pmtPix / 4)
53 pix = row * 64 + col + 1
54 py = h.ProjectionY("px_" + str(slot) + "_" + str(pix), pix, pix)
55 py.SetTitle("PMT pixel " + str(pmtPix + 1))
56 irow = int(pmtPix / 4)
57 icol = pmtPix % 4
58 canvas.cd(icol + (3 - irow) * 4 + 1)
59 py.Draw()
60 if py.GetEntries() > 0:
61 n = py.Integral()
62 meanPH += py.GetMean() * n
63 N += n
64 canvas.Write()
65 if N > 0:
66 meanPH /= N
67 return meanPH
68

The documentation for this class was generated from the following file: