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

Public Member Functions

def fillLists (self, svdClusterFromTracks)
 
def set_localdb (self, localDB)
 
def set_run_number (self, run)
 
def set_exp_number (self, exp)
 
def initialize (self)
 
def event (self)
 
def terminate (self)
 

Public Attributes

 NTOT
 counts the number of clusters
 
 localdb
 set the name of the localDB used
 
 runnumber
 set the run number
 
 expnumber
 set the experiment number
 
 outputFileName
 name of the output file
 
 resList
 lists used to create the histograms for each TB : residuals
 
 spList
 scatterplot t0 vs cog
 
 cogList
 cog
 
 cdcList
 t0
 
 snrList
 Cluster SNR.
 
 sizeList
 Cluster Size.
 
 chargeList
 Cluster charge.
 
 cdcErrorList
 t0 no synchronized
 
 Evt
 counts the number of events
 
 EventT0Hist
 distribution of EventT0
 
 gaus
 gaus function used for fitting distributions
 
 pol1
 order 1 polynomium used for the calibration
 
 pol3
 order 3 polynomium used for the calibration
 
 cdcEventT0
 registers PyStoreObj EventT0
 
 TB
 trigger bin
 

Detailed Description

Python class used for checking SVD CoG Calibration stored in a localDB

Definition at line 37 of file CoGCalibration_utils_checkCalibration.py.

Member Function Documentation

◆ event()

def event (   self)
Function that allows to cicle on the events

Definition at line 252 of file CoGCalibration_utils_checkCalibration.py.

252 def event(self):
253 """
254 Function that allows to cicle on the events
255 """
256 self.Evt = self.Evt + 1
257
258 # fill EventT0 histogram
259
260 self.cdcEventT0 = Belle2.PyStoreObj(cdc_Time0)
261 if self.cdcEventT0.hasEventT0():
262 et0 = self.EventT0Hist
263 et0.Fill(self.cdcEventT0.getEventT0())
264
265 # fill plots
266 svdCluster_list = Belle2.PyStoreArray(svd_Clusters)
267 svd_evtInfo = Belle2.PyStoreObj(svd_EventInfo)
268 clsTB = svd_evtInfo.getModeByte().getTriggerBin()
269
270 self.TB = ord(clsTB)
271
272 for svdCluster in svdCluster_list:
273 self.fillLists(svdCluster)
274
A (simplified) python wrapper for StoreArray.
Definition: PyStoreArray.h:72
a (simplified) python wrapper for StoreObjPtr.
Definition: PyStoreObj.h:67

◆ fillLists()

def fillLists (   self,
  svdClusterFromTracks 
)
Function that fill the lists needed for the check of the calibration

parameters:
     svdClusterFromTracks (SVDCluster): Cluster related to tracks

Definition at line 42 of file CoGCalibration_utils_checkCalibration.py.

42 def fillLists(self, svdClusterFromTracks):
43 """
44 Function that fill the lists needed for the check of the calibration
45
46 parameters:
47 svdClusterFromTracks (SVDCluster): Cluster related to tracks
48 """
49 timeCluster = svdClusterFromTracks.getClsTime()
50 snrCluster = svdClusterFromTracks.getSNR()
51 sizeCluster = svdClusterFromTracks.getSize()
52 chargeCluster = svdClusterFromTracks.getCharge()
53 layerCluster = svdClusterFromTracks.getSensorID().getLayerNumber()
54 layerIndex = layerCluster - 3
55 sensorCluster = svdClusterFromTracks.getSensorID().getSensorNumber()
56 sensorIndex = sensorCluster - 1
57 ladderCluster = svdClusterFromTracks.getSensorID().getLadderNumber()
58 ladderIndex = ladderCluster - 1
59 sideCluster = svdClusterFromTracks.isUCluster()
60 sideIndex = 0
61 if sideCluster:
62 sideIndex = 1
63
64 hasTimezero = self.cdcEventT0.hasEventT0()
65 if hasTimezero:
66 tZero = self.cdcEventT0.getEventT0()
67 tZeroError = self.cdcEventT0.getEventT0Uncertainty()
68
69 # filling histograms
70 resHist = self.resList[layerIndex][ladderIndex][sensorIndex][sideIndex]
71 resHist.Fill(timeCluster - tZero)
72 spHist = self.spList[layerIndex][ladderIndex][sensorIndex][sideIndex]
73 spHist.Fill(timeCluster, tZero)
74 cogHist = self.cogList[layerIndex][ladderIndex][sensorIndex][sideIndex]
75 cogHist.Fill(timeCluster)
76 cdcHist = self.cdcList[layerIndex][ladderIndex][sensorIndex][sideIndex]
77 cdcHist.Fill(tZero)
78 snrHist = self.snrList[layerIndex][ladderIndex][sensorIndex][sideIndex]
79 snrHist.Fill(snrCluster)
80 sizeHist = self.sizeList[layerIndex][ladderIndex][sensorIndex][sideIndex]
81 sizeHist.Fill(sizeCluster)
82 chargeHist = self.chargeList[layerIndex][ladderIndex][sensorIndex][sideIndex]
83 chargeHist.Fill(chargeCluster/1000.)
84 cdcErrorHist = self.cdcErrorList[layerIndex][ladderIndex][sensorIndex][sideIndex]
85 cdcErrorHist.Fill(tZeroError)
86
87
88 self.NTOT = self.NTOT + 1
89

◆ initialize()

def initialize (   self)
Initialize object (histograms, lists, ...) used by the class

Definition at line 120 of file CoGCalibration_utils_checkCalibration.py.

120 def initialize(self):
121 """
122 Initialize object (histograms, lists, ...) used by the class
123 """
124
125
126 self.outputFileName = "../caf/tree/SVDCoGCalibrationCheck_Exp" + \
127 str(self.expnumber) + "_Run" + str(self.runnumber) + ".root"
128
130 self.resList = []
131
132 self.spList = []
133
134 self.cogList = []
135
136 self.cdcList = []
137
138 self.snrList = []
139
140 self.sizeList = []
141
142 self.chargeList = []
143
144 self.cdcErrorList = []
145
147
148
149 self.Evt = 0
150 for layer in geoCache.getLayers(Belle2.VXD.SensorInfoBase.SVD):
151 layerList0 = []
152 layerList1 = []
153 layerList2 = []
154 layerList3 = []
155 layerList4 = []
156 layerList5 = []
157 layerList6 = []
158 layerList7 = []
159
160 self.resList.append(layerList0)
161 self.spList.append(layerList1)
162 self.cogList.append(layerList2)
163 self.cdcList.append(layerList3)
164 self.snrList.append(layerList4)
165 self.sizeList.append(layerList5)
166 self.chargeList.append(layerList6)
167 self.cdcErrorList.append(layerList7)
168
169 for ladder in geoCache.getLadders(layer):
170 ladderList0 = []
171 ladderList1 = []
172 ladderList2 = []
173 ladderList3 = []
174 ladderList4 = []
175 ladderList5 = []
176 ladderList6 = []
177 ladderList7 = []
178
179 layerList0.append(ladderList0)
180 layerList1.append(ladderList1)
181 layerList2.append(ladderList2)
182 layerList3.append(ladderList3)
183 layerList4.append(ladderList4)
184 layerList5.append(ladderList5)
185 layerList6.append(ladderList6)
186 layerList7.append(ladderList7)
187
188 for sensor in geoCache.getSensors(ladder):
189 sensorList0 = []
190 sensorList1 = []
191 sensorList2 = []
192 sensorList3 = []
193 sensorList4 = []
194 sensorList5 = []
195 sensorList6 = []
196 sensorList7 = []
197
198 ladderList0.append(sensorList0)
199 ladderList1.append(sensorList1)
200 ladderList2.append(sensorList2)
201 ladderList3.append(sensorList3)
202 ladderList4.append(sensorList4)
203 ladderList5.append(sensorList5)
204 ladderList6.append(sensorList6)
205 ladderList7.append(sensorList7)
206
207 for i in geoCache.getLayers(Belle2.VXD.SensorInfoBase.SVD):
208 layerN = i.getLayerNumber()
209 li = layerN - 3
210 for j in geoCache.getLadders(i):
211 ladderN = j.getLadderNumber()
212 ldi = ladderN - 1
213 for k in geoCache.getSensors(j):
214 sensorN = k.getSensorNumber()
215 si = sensorN - 1
216 for s in range(2):
217 self.resList[li][ldi][si].append(TH1F("res" + "_" + str(layerN) + "." +
218 str(ladderN) + "." + str(sensorN) + "." +
219 str(s), " ", 200, -100, 100))
220 self.spList[li][ldi][si].append(TH2D("sp" + "_" + str(layerN) + "." +
221 str(ladderN) + "." + str(sensorN) + "." +
222 str(s), " ", 300, -150, 150, 300, -150, 150))
223 self.cogList[li][ldi][si].append(TH1F("cog" + "_" + str(layerN) + "." +
224 str(ladderN) + "." + str(sensorN) + "." + str(s),
225 " ", 200, -100, 100))
226 self.cdcList[li][ldi][si].append(TH1F("cdc" + "_" + str(layerN) + "." +
227 str(ladderN) + "." + str(sensorN) + "." + str(s),
228 " ", 200, -100, 100))
229 self.snrList[li][ldi][si].append(TH1F("snr" + "_" + str(layerN) + "." +
230 str(ladderN) + "." + str(sensorN) + "." + str(s), " ", 100, 0, 100))
231 self.sizeList[li][ldi][si].append(TH1F("size" + "_" + str(layerN) + "." +
232 str(ladderN) + "." + str(sensorN) + "." + str(s), " ", 20, 0, 20))
233 self.chargeList[li][ldi][si].append(TH1F("charge" + "_" + str(layerN) + "." +
234 str(ladderN) + "." + str(sensorN) + "." + str(s),
235 " ", 100, 0, 200))
236 self.cdcErrorList[li][ldi][si].append(TH1F("cdcError" + "_" + str(layerN) + "." +
237 str(ladderN) + "." + str(sensorN) + "." + str(s),
238 " ", 200, 0, 50))
239
240
241 self.EventT0Hist = TH1F("EventT0", " ", 160, -40, 40)
242
243
244 self.gaus = TF1("gaus", 'gaus(0)', -150, 150)
245
246 self.pol1 = TF1("pol1", "[0] + [1]*x", -30, 30)
247
248 self.pol3 = TF1("pol3", "[0] + [1]*x + [2]*x*x + [3]*x*x*x", -50, 50)
249
250 self.NTOT = 0
251
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:214

◆ set_exp_number()

def set_exp_number (   self,
  exp 
)
Function that allows to save the experiment number

parameters:
     exp (int): experiment number

Definition at line 110 of file CoGCalibration_utils_checkCalibration.py.

110 def set_exp_number(self, exp):
111 """
112 Function that allows to save the experiment number
113
114 parameters:
115 exp (int): experiment number
116 """
117
118 self.expnumber = exp
119

◆ set_localdb()

def set_localdb (   self,
  localDB 
)
Function that allows to set the localDB

parameters:
     localDB (str): Name of the localDB used

Definition at line 90 of file CoGCalibration_utils_checkCalibration.py.

90 def set_localdb(self, localDB):
91 """
92 Function that allows to set the localDB
93
94 parameters:
95 localDB (str): Name of the localDB used
96 """
97
98 self.localdb = localDB
99

◆ set_run_number()

def set_run_number (   self,
  run 
)
Function that allows to save the run number

parameters:
     run (int): run number

Definition at line 100 of file CoGCalibration_utils_checkCalibration.py.

100 def set_run_number(self, run):
101 """
102 Function that allows to save the run number
103
104 parameters:
105 run (int): run number
106 """
107
108 self.runnumber = run
109

◆ terminate()

def terminate (   self)
Terminates te class and produces the output rootfile

Definition at line 275 of file CoGCalibration_utils_checkCalibration.py.

275 def terminate(self):
276 """
277 Terminates te class and produces the output rootfile
278 """
279
280 layerNumberTree = np.zeros(1, dtype=int)
281 ladderNumberTree = np.zeros(1, dtype=int)
282 sensorNumberTree = np.zeros(1, dtype=int)
283 sideTree = np.zeros(1, dtype=int)
284 mean = np.zeros(1, dtype=float)
285 meanerr = np.zeros(1, dtype=float)
286 width = np.zeros(1, dtype=float)
287 widtherr = np.zeros(1, dtype=float)
288 cogmean = np.zeros(1, dtype=float)
289 cogmeanerr = np.zeros(1, dtype=float)
290 runnumber = np.zeros(1, dtype=int)
291 runnumber[0] = int(self.runnumber)
292 expnumber = np.zeros(1, dtype=int)
293 expnumber[0] = int(self.expnumber)
294 evttime = np.zeros(1, dtype=float)
295 jitter = np.zeros(1, dtype=float)
296 cdcErrorMean = np.zeros(1, dtype=float)
297 clsSize = np.zeros(1, dtype=float)
298 clsCharge = np.zeros(1, dtype=float)
299 clsSNR = np.zeros(1, dtype=float)
300
301 tfile = TFile(self.outputFileName, 'recreate')
302 tfile.cd()
303 tree = TTree("cog", "tree")
304 tree.Branch("Layer", layerNumberTree, "Layer/I")
305 tree.Branch("Ladder", ladderNumberTree, "Ladder/I")
306 tree.Branch("Sensor", sensorNumberTree, "Sensor/I")
307 tree.Branch("Side", sideTree, "Side/I")
308 tree.Branch("ResMean", mean, "ResMean/D")
309 tree.Branch("ResMeanErr", meanerr, "ResMeanErr/D")
310 tree.Branch("ResWidth", width, "ResWidth/D")
311 tree.Branch("ResWidthErr", widtherr, "ResWidthErr/D")
312 tree.Branch("CoGMean", cogmean, "CoGMean/D")
313 tree.Branch("CoGMeanErr", cogmeanerr, "CoGMeanErr/D")
314 tree.Branch("RunNumber", runnumber, "RunNumber/I")
315 tree.Branch("ExpNumber", expnumber, "ExpNumber/I")
316 tree.Branch("EvtT0Mean", evttime, "EvtT0Mean/D")
317 tree.Branch("Jitter", jitter, "Jitter/D")
318 tree.Branch("EvtT0ErrorMean", cdcErrorMean, "EvtT0ErrorMean/D")
319 tree.Branch("ClsSizeMean", clsSize, "ClsSizeMean/D")
320 tree.Branch("ClsChargeMean", clsCharge, "ClsChargeMean/D")
321 tree.Branch("ClsSNRMean", clsSNR, "ClsSNRMean/D")
322
323 # par = [0, 1]
324
325 # tfileHist.cd()
327 gDirectory.mkdir("plots")
328 gDirectory.cd("plots")
329 for layer in geoCache.getLayers(Belle2.VXD.SensorInfoBase.SVD):
330 layerNumber = layer.getLayerNumber()
331 layerNumberTree[0] = layerNumber
332 li = layerNumber - 3
333 gDirectory.mkdir("layer" + str(layerNumber))
334 gDirectory.cd("layer" + str(layerNumber))
335 for ladder in geoCache.getLadders(layer):
336 ladderNumber = ladder.getLadderNumber()
337 ladderNumberTree[0] = ladderNumber
338 ldi = ladderNumber - 1
339 for sensor in geoCache.getSensors(ladder):
340 sensorNumber = sensor.getSensorNumber()
341 sensorNumberTree[0] = sensorNumber
342 si = sensorNumber - 1
343 for side in range(2):
344 sideTree[0] = side
345 # Resolution distribution Histograms with Gaussian Fit
346 res = self.resList[li][ldi][si][side]
347 res.GetXaxis().SetTitle("cluster time - EventT0 (ns)")
348 fitResult = int(TFitResultPtr(res.Fit(self.gaus, "R")))
349 res.Write()
350 # COG Distribution Histograms
351 cog = self.cogList[li][ldi][si][side]
352 cog.GetXaxis().SetTitle("cluster time (ns)")
353 cog.Write()
354 # CDC EventT0 Distribution Histograms
355 cdc = self.cdcList[li][ldi][si][side]
356 cdc.GetXaxis().SetTitle("EventT0 (ns)")
357 cdc.Write()
358 cdcError = self.cdcErrorList[li][ldi][si][side]
359 cdcError.GetXaxis().SetTitle("EventT0 Error (ns)")
360 cdcError.Write()
361 # SNR Distribution Histograms
362 snr = self.snrList[li][ldi][si][side]
363 clsSNR[0] = snr.GetMean()
364 snr.GetXaxis().SetTitle("cluster SNR")
365 snr.Write()
366 # Size Distribution Histograms
367 size = self.sizeList[li][ldi][si][side]
368 clsSize[0] = size.GetMean()
369 size.GetXaxis().SetTitle("cluster Size")
370 size.Write()
371 # Charge Distribution Histograms
372 charge = self.chargeList[li][ldi][si][side]
373 clsCharge[0] = charge.GetMean()
374 charge.GetXaxis().SetTitle("cluster Charge")
375 charge.Write()
376 # ScatterPlot Histograms with Linear Fit
377 sp = self.spList[li][ldi][si][side]
378 # covscalebias = sp.GetCovariance()
379 pfxsp = sp.ProfileX()
380 sp.GetXaxis().SetTitle("cluster time (ns)")
381 sp.GetYaxis().SetTitle("EventT0 (ns)")
382 sp.Write()
383 pfxsp.Write()
384
385 mean[0] = self.gaus.GetParameter(1)
386 meanerr[0] = self.gaus.GetParError(1)
387 width[0] = self.gaus.GetParameter(2)
388 widtherr[0] = self.gaus.GetParError(2)
389 cogmean[0] = cog.GetMean()
390 if cog.GetEntries() == 0:
391 cogmeanerr[0] = -1
392 else:
393 cogmeanerr[0] = cog.GetRMS()/math.sqrt(cog.GetEntries())
394 evttime[0] = cdc.GetMean()
395 if cdc.GetEntries() == 0:
396 jitter[0] = -1
397 else:
398 jitter[0] = cdc.GetRMS()
399 cdcErrorMean[0] = cdcError.GetMean()
400
401 if fitResult == -1:
402 mean[0] = -100.0
403 meanerr[0] = -100.0
404 width[0] = -100.0
405 widtherr[0] = -100.0
406
407 tree.Fill()
408
409 gDirectory.cd("../")
410
411 gDirectory.cd("../")
412 self.EventT0Hist.Write()
413 tree.Write()
414 tfile.Purge()
415 tfile.Close()
416 del tfile

Member Data Documentation

◆ cdcErrorList

cdcErrorList

t0 no synchronized

Definition at line 144 of file CoGCalibration_utils_checkCalibration.py.

◆ cdcEventT0

cdcEventT0

registers PyStoreObj EventT0

Definition at line 260 of file CoGCalibration_utils_checkCalibration.py.

◆ cdcList

cdcList

t0

Definition at line 136 of file CoGCalibration_utils_checkCalibration.py.

◆ chargeList

chargeList

Cluster charge.

Definition at line 142 of file CoGCalibration_utils_checkCalibration.py.

◆ cogList

cogList

cog

Definition at line 134 of file CoGCalibration_utils_checkCalibration.py.

◆ EventT0Hist

EventT0Hist

distribution of EventT0

Definition at line 241 of file CoGCalibration_utils_checkCalibration.py.

◆ Evt

Evt

counts the number of events

Definition at line 149 of file CoGCalibration_utils_checkCalibration.py.

◆ expnumber

expnumber

set the experiment number

Definition at line 118 of file CoGCalibration_utils_checkCalibration.py.

◆ gaus

gaus

gaus function used for fitting distributions

Definition at line 244 of file CoGCalibration_utils_checkCalibration.py.

◆ localdb

localdb

set the name of the localDB used

Definition at line 98 of file CoGCalibration_utils_checkCalibration.py.

◆ NTOT

NTOT

counts the number of clusters

Definition at line 88 of file CoGCalibration_utils_checkCalibration.py.

◆ outputFileName

outputFileName

name of the output file

Definition at line 126 of file CoGCalibration_utils_checkCalibration.py.

◆ pol1

pol1

order 1 polynomium used for the calibration

Definition at line 246 of file CoGCalibration_utils_checkCalibration.py.

◆ pol3

pol3

order 3 polynomium used for the calibration

Definition at line 248 of file CoGCalibration_utils_checkCalibration.py.

◆ resList

resList

lists used to create the histograms for each TB : residuals

Definition at line 130 of file CoGCalibration_utils_checkCalibration.py.

◆ runnumber

runnumber

set the run number

Definition at line 108 of file CoGCalibration_utils_checkCalibration.py.

◆ sizeList

sizeList

Cluster Size.

Definition at line 140 of file CoGCalibration_utils_checkCalibration.py.

◆ snrList

snrList

Cluster SNR.

Definition at line 138 of file CoGCalibration_utils_checkCalibration.py.

◆ spList

spList

scatterplot t0 vs cog

Definition at line 132 of file CoGCalibration_utils_checkCalibration.py.

◆ TB

TB

trigger bin

Definition at line 270 of file CoGCalibration_utils_checkCalibration.py.


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