21 from ROOT
import (Belle2, TFile, TFitResultPtr, TH1F, TH2D, TTree, TF1,
29 svd_Clusters =
"SVDClustersFromTracks"
30 svd_EventInfo =
"SVDEventInfo"
40 Python class used for checking SVD CoG Calibration stored in a localDB
45 Function that fill the lists needed for the check of the calibration
48 svdClusterFromTracks (SVDCluster): Cluster related to tracks
50 timeCluster = svdClusterFromTracks.getClsTime()
51 snrCluster = svdClusterFromTracks.getSNR()
52 sizeCluster = svdClusterFromTracks.getSize()
53 chargeCluster = svdClusterFromTracks.getCharge()
54 layerCluster = svdClusterFromTracks.getSensorID().getLayerNumber()
55 layerIndex = layerCluster - 3
56 sensorCluster = svdClusterFromTracks.getSensorID().getSensorNumber()
57 sensorIndex = sensorCluster - 1
58 ladderCluster = svdClusterFromTracks.getSensorID().getLadderNumber()
59 ladderIndex = ladderCluster - 1
60 sideCluster = svdClusterFromTracks.isUCluster()
65 hasTimezero = self.
cdcEventT0cdcEventT0.hasEventT0()
68 tZeroError = self.
cdcEventT0cdcEventT0.getEventT0Uncertainty()
71 resHist = self.
resListresList[layerIndex][ladderIndex][sensorIndex][sideIndex]
72 resHist.Fill(timeCluster - tZero)
73 spHist = self.
spListspList[layerIndex][ladderIndex][sensorIndex][sideIndex]
74 spHist.Fill(timeCluster, tZero)
75 cogHist = self.
cogListcogList[layerIndex][ladderIndex][sensorIndex][sideIndex]
76 cogHist.Fill(timeCluster)
77 cdcHist = self.
cdcListcdcList[layerIndex][ladderIndex][sensorIndex][sideIndex]
79 snrHist = self.
snrListsnrList[layerIndex][ladderIndex][sensorIndex][sideIndex]
80 snrHist.Fill(snrCluster)
81 sizeHist = self.
sizeListsizeList[layerIndex][ladderIndex][sensorIndex][sideIndex]
82 sizeHist.Fill(sizeCluster)
83 chargeHist = self.
chargeListchargeList[layerIndex][ladderIndex][sensorIndex][sideIndex]
84 chargeHist.Fill(chargeCluster/1000.)
85 cdcErrorHist = self.
cdcErrorListcdcErrorList[layerIndex][ladderIndex][sensorIndex][sideIndex]
86 cdcErrorHist.Fill(tZeroError)
93 Function that allows to set the localDB
96 localDB (str): Name of the localDB used
103 Function that allows to save the run number
106 run (int): run number
113 Function that allows to save the experiment number
116 exp (int): experiment number
123 Initialize object (histograms, lists, ...) used by the class
151 for layer
in geoCache.getLayers(Belle2.VXD.SensorInfoBase.SVD):
161 self.
resListresList.append(layerList0)
162 self.
spListspList.append(layerList1)
163 self.
cogListcogList.append(layerList2)
164 self.
cdcListcdcList.append(layerList3)
165 self.
snrListsnrList.append(layerList4)
166 self.
sizeListsizeList.append(layerList5)
170 for ladder
in geoCache.getLadders(layer):
180 layerList0.append(ladderList0)
181 layerList1.append(ladderList1)
182 layerList2.append(ladderList2)
183 layerList3.append(ladderList3)
184 layerList4.append(ladderList4)
185 layerList5.append(ladderList5)
186 layerList6.append(ladderList6)
187 layerList7.append(ladderList7)
189 for sensor
in geoCache.getSensors(ladder):
199 ladderList0.append(sensorList0)
200 ladderList1.append(sensorList1)
201 ladderList2.append(sensorList2)
202 ladderList3.append(sensorList3)
203 ladderList4.append(sensorList4)
204 ladderList5.append(sensorList5)
205 ladderList6.append(sensorList6)
206 ladderList7.append(sensorList7)
208 for i
in geoCache.getLayers(Belle2.VXD.SensorInfoBase.SVD):
209 layerN = i.getLayerNumber()
211 for j
in geoCache.getLadders(i):
212 ladderN = j.getLadderNumber()
214 for k
in geoCache.getSensors(j):
215 sensorN = k.getSensorNumber()
218 self.
resListresList[li][ldi][si].append(TH1F(
"res" +
"_" + str(layerN) +
"." +
219 str(ladderN) +
"." + str(sensorN) +
"." +
220 str(s),
" ", 200, -100, 100))
221 self.
spListspList[li][ldi][si].append(TH2D(
"sp" +
"_" + str(layerN) +
"." +
222 str(ladderN) +
"." + str(sensorN) +
"." +
223 str(s),
" ", 300, -150, 150, 300, -150, 150))
224 self.
cogListcogList[li][ldi][si].append(TH1F(
"cog" +
"_" + str(layerN) +
"." +
225 str(ladderN) +
"." + str(sensorN) +
"." + str(s),
226 " ", 200, -100, 100))
227 self.
cdcListcdcList[li][ldi][si].append(TH1F(
"cdc" +
"_" + str(layerN) +
"." +
228 str(ladderN) +
"." + str(sensorN) +
"." + str(s),
229 " ", 200, -100, 100))
230 self.
snrListsnrList[li][ldi][si].append(TH1F(
"snr" +
"_" + str(layerN) +
"." +
231 str(ladderN) +
"." + str(sensorN) +
"." + str(s),
" ", 100, 0, 100))
232 self.
sizeListsizeList[li][ldi][si].append(TH1F(
"size" +
"_" + str(layerN) +
"." +
233 str(ladderN) +
"." + str(sensorN) +
"." + str(s),
" ", 20, 0, 20))
234 self.
chargeListchargeList[li][ldi][si].append(TH1F(
"charge" +
"_" + str(layerN) +
"." +
235 str(ladderN) +
"." + str(sensorN) +
"." + str(s),
237 self.
cdcErrorListcdcErrorList[li][ldi][si].append(TH1F(
"cdcError" +
"_" + str(layerN) +
"." +
238 str(ladderN) +
"." + str(sensorN) +
"." + str(s),
245 self.
gausgaus = TF1(
"gaus",
'gaus(0)', -150, 150)
247 self.
pol1pol1 = TF1(
"pol1",
"[0] + [1]*x", -30, 30)
249 self.
pol3pol3 = TF1(
"pol3",
"[0] + [1]*x + [2]*x*x + [3]*x*x*x", -50, 50)
255 Function that allows to cicle on the events
257 self.
EvtEvt = self.
EvtEvt + 1
264 et0.Fill(self.
cdcEventT0cdcEventT0.getEventT0())
269 clsTB = svd_evtInfo.getModeByte().getTriggerBin()
271 self.
TBTB = ord(clsTB)
273 for svdCluster
in svdCluster_list:
278 Terminates te class and produces the output rootfile
281 layerNumberTree = np.zeros(1, dtype=int)
282 ladderNumberTree = np.zeros(1, dtype=int)
283 sensorNumberTree = np.zeros(1, dtype=int)
284 sideTree = np.zeros(1, dtype=int)
285 mean = np.zeros(1, dtype=float)
286 meanerr = np.zeros(1, dtype=float)
287 width = np.zeros(1, dtype=float)
288 widtherr = np.zeros(1, dtype=float)
289 cogmean = np.zeros(1, dtype=float)
290 cogmeanerr = np.zeros(1, dtype=float)
291 runnumber = np.zeros(1, dtype=int)
292 runnumber[0] = int(self.
runnumberrunnumber)
293 expnumber = np.zeros(1, dtype=int)
294 expnumber[0] = int(self.
expnumberexpnumber)
295 evttime = np.zeros(1, dtype=float)
296 jitter = np.zeros(1, dtype=float)
297 cdcErrorMean = np.zeros(1, dtype=float)
298 clsSize = np.zeros(1, dtype=float)
299 clsCharge = np.zeros(1, dtype=float)
300 clsSNR = np.zeros(1, dtype=float)
304 tree = TTree(
"cog",
"tree")
305 tree.Branch(
"Layer", layerNumberTree,
"Layer/I")
306 tree.Branch(
"Ladder", ladderNumberTree,
"Ladder/I")
307 tree.Branch(
"Sensor", sensorNumberTree,
"Sensor/I")
308 tree.Branch(
"Side", sideTree,
"Side/I")
309 tree.Branch(
"ResMean", mean,
"ResMean/D")
310 tree.Branch(
"ResMeanErr", meanerr,
"ResMeanErr/D")
311 tree.Branch(
"ResWidth", width,
"ResWidth/D")
312 tree.Branch(
"ResWidthErr", widtherr,
"ResWidthErr/D")
313 tree.Branch(
"CoGMean", cogmean,
"CoGMean/D")
314 tree.Branch(
"CoGMeanErr", cogmeanerr,
"CoGMeanErr/D")
315 tree.Branch(
"RunNumber", runnumber,
"RunNumber/I")
316 tree.Branch(
"ExpNumber", expnumber,
"ExpNumber/I")
317 tree.Branch(
"EvtT0Mean", evttime,
"EvtT0Mean/D")
318 tree.Branch(
"Jitter", jitter,
"Jitter/D")
319 tree.Branch(
"EvtT0ErrorMean", cdcErrorMean,
"EvtT0ErrorMean/D")
320 tree.Branch(
"ClsSizeMean", clsSize,
"ClsSizeMean/D")
321 tree.Branch(
"ClsChargeMean", clsCharge,
"ClsChargeMean/D")
322 tree.Branch(
"ClsSNRMean", clsSNR,
"ClsSNRMean/D")
328 gDirectory.mkdir(
"plots")
329 gDirectory.cd(
"plots")
330 for layer
in geoCache.getLayers(Belle2.VXD.SensorInfoBase.SVD):
331 layerNumber = layer.getLayerNumber()
332 layerNumberTree[0] = layerNumber
334 gDirectory.mkdir(
"layer" + str(layerNumber))
335 gDirectory.cd(
"layer" + str(layerNumber))
336 for ladder
in geoCache.getLadders(layer):
337 ladderNumber = ladder.getLadderNumber()
338 ladderNumberTree[0] = ladderNumber
339 ldi = ladderNumber - 1
340 for sensor
in geoCache.getSensors(ladder):
341 sensorNumber = sensor.getSensorNumber()
342 sensorNumberTree[0] = sensorNumber
343 si = sensorNumber - 1
344 for side
in range(2):
347 res = self.
resListresList[li][ldi][si][side]
348 res.GetXaxis().SetTitle(
"cluster time - EventT0 (ns)")
349 fitResult = int(TFitResultPtr(res.Fit(self.
gausgaus,
"R")))
352 cog = self.
cogListcogList[li][ldi][si][side]
353 cog.GetXaxis().SetTitle(
"cluster time (ns)")
356 cdc = self.
cdcListcdcList[li][ldi][si][side]
357 cdc.GetXaxis().SetTitle(
"EventT0 (ns)")
359 cdcError = self.
cdcErrorListcdcErrorList[li][ldi][si][side]
360 cdcError.GetXaxis().SetTitle(
"EventT0 Error (ns)")
363 snr = self.
snrListsnrList[li][ldi][si][side]
364 clsSNR[0] = snr.GetMean()
365 snr.GetXaxis().SetTitle(
"cluster SNR")
368 size = self.
sizeListsizeList[li][ldi][si][side]
369 clsSize[0] = size.GetMean()
370 size.GetXaxis().SetTitle(
"cluster Size")
373 charge = self.
chargeListchargeList[li][ldi][si][side]
374 clsCharge[0] = charge.GetMean()
375 charge.GetXaxis().SetTitle(
"cluster Charge")
378 sp = self.
spListspList[li][ldi][si][side]
380 pfxsp = sp.ProfileX()
381 sp.GetXaxis().SetTitle(
"cluster time (ns)")
382 sp.GetYaxis().SetTitle(
"EventT0 (ns)")
386 mean[0] = self.
gausgaus.GetParameter(1)
387 meanerr[0] = self.
gausgaus.GetParError(1)
388 width[0] = self.
gausgaus.GetParameter(2)
389 widtherr[0] = self.
gausgaus.GetParError(2)
390 cogmean[0] = cog.GetMean()
391 if cog.GetEntries() == 0:
394 cogmeanerr[0] = cog.GetRMS()/math.sqrt(cog.GetEntries())
395 evttime[0] = cdc.GetMean()
396 if cdc.GetEntries() == 0:
399 jitter[0] = cdc.GetRMS()
400 cdcErrorMean[0] = cdcError.GetMean()
A (simplified) python wrapper for StoreArray.
a (simplified) python wrapper for StoreObjPtr.
static GeoCache & getInstance()
Return a reference to the singleton instance.
gaus
gaus function used for fitting distributions
def fillLists(self, svdClusterFromTracks)
Evt
counts the number of events
EventT0Hist
distribution of EventT0
def set_run_number(self, run)
cdcErrorList
t0 no synchronized
resList
lists used to create the histograms for each TB : residuals
def set_localdb(self, localDB)
NTOT
counts the number of clusters
localdb
set the name of the localDB used
cdcEventT0
registers PyStoreObj EventT0
expnumber
set the experiment number
outputFileName
name of the output file
pol3
order 3 polynomium used for the calibration
chargeList
Cluster charge.
spList
scatterplot t0 vs cog
pol1
order 1 polynomium used for the calibration
runnumber
set the run number
def set_exp_number(self, exp)