29 from ROOT
import Belle2, TFile, TH1F, TH2D
30 from ROOT
import TF1, gDirectory, gROOT
32 from ROOT.Belle2
import SVDCoGCalibrationFunction
35 svd_recoDigits =
"SVDRecoDigitsFromTracks"
37 svd_Clusters =
"SVDClustersFromTracks"
46 Python class used for checking SVD CoG Calibration stored in a localDB,
47 creating a localDB with the correction and a root file to check the corrections
52 Function that allows to set if apply the CDC latency correction
56 - if True -> not apply correction
57 - if False -> apply correction
63 def fillLists(self, svdRecoDigits_rel_Clusters, svdClusters_rel_RecoTracks_cl):
65 Function that fill the lists needed for the CoG corrections
68 svdRecoDigits_rel_Clusters (SVDRecoDigit): reco digits related to clusters
69 svdClusters_rel_RecoTracks_cl (SVDCluster): cluster related to tracks
72 timeCluster = svdClusters_rel_RecoTracks_cl.getClsTime()
73 snrCluster = svdClusters_rel_RecoTracks_cl.getSNR()
74 layerCluster = svdClusters_rel_RecoTracks_cl.getSensorID().getLayerNumber()
75 layerIndex = layerCluster - 3
76 sensorCluster = svdClusters_rel_RecoTracks_cl.getSensorID().getSensorNumber()
77 sensorIndex = sensorCluster - 1
78 ladderCluster = svdClusters_rel_RecoTracks_cl.getSensorID().getLadderNumber()
79 ladderIndex = ladderCluster - 1
80 sideCluster = svdClusters_rel_RecoTracks_cl.isUCluster()
86 hasTimezero = self.
cdcEventT0cdcEventT0.hasEventT0()
90 TBClusters = svdEventInfo.getModeByte().getTriggerBin()
91 TBIndex = ord(TBClusters)
95 tZeroSync = tZero - 4000./509 * (3 - TBIndex)
101 resHist = self.
resListresList[layerIndex][ladderIndex][sensorIndex][sideIndex]
102 resHist.Fill(timeCluster - tZeroSync)
103 spHist = self.
spListspList[layerIndex][ladderIndex][sensorIndex][sideIndex]
105 spHist.Fill(timeCluster, tZeroSync)
106 cogHist = self.
cogListcogList[layerIndex][ladderIndex][sensorIndex][sideIndex]
107 cogHist.Fill(timeCluster)
108 cdcHist = self.
cdcListcdcList[layerIndex][ladderIndex][sensorIndex][sideIndex]
109 cdcHist.Fill(tZeroSync)
110 snrHist = self.
snrListsnrList[layerIndex][ladderIndex][sensorIndex][sideIndex]
111 snrHist.Fill(snrCluster)
113 self.
nListnList[layerIndex][ladderIndex][sensorIndex][sideIndex] += 1
115 self.
sumCOGListsumCOGList[layerIndex][ladderIndex][sensorIndex][sideIndex] += timeCluster
116 self.
sumCOGList2sumCOGList2[layerIndex][ladderIndex][sensorIndex][sideIndex] += timeCluster * timeCluster
117 self.
sumCOGList3sumCOGList3[layerIndex][ladderIndex][sensorIndex][sideIndex] += timeCluster * timeCluster * timeCluster
118 self.
sumCOGList4sumCOGList4[layerIndex][ladderIndex][sensorIndex][sideIndex] += timeCluster * \
119 timeCluster * timeCluster * timeCluster
120 self.
sumCOGList5sumCOGList5[layerIndex][ladderIndex][sensorIndex][sideIndex] += timeCluster * \
121 timeCluster * timeCluster * timeCluster * timeCluster
122 self.
sumCOGList6sumCOGList6[layerIndex][ladderIndex][sensorIndex][sideIndex] += timeCluster * \
123 timeCluster * timeCluster * timeCluster * timeCluster * timeCluster
125 self.
sumCDCListsumCDCList[layerIndex][ladderIndex][sensorIndex][sideIndex] += tZeroSync
126 self.
sumCDCCOGListsumCDCCOGList[layerIndex][ladderIndex][sensorIndex][sideIndex] += tZeroSync * timeCluster
127 self.
sumCDCCOGList2sumCDCCOGList2[layerIndex][ladderIndex][sensorIndex][sideIndex] += tZeroSync * timeCluster * timeCluster
128 self.
sumCDCCOGList3sumCDCCOGList3[layerIndex][ladderIndex][sensorIndex][sideIndex] += tZeroSync * \
129 timeCluster * timeCluster * timeCluster
136 Function that allows to set the localDB
139 localDB (str): Name of the localDB used
146 Initialize object (histograms, lists, ...) used by the class
189 for layer
in geoCache.getLayers(Belle2.VXD.SensorInfoBase.SVD):
210 self.
resListresList.append(layerList0)
211 self.
spListspList.append(layerList1)
212 self.
cogListcogList.append(layerList2)
213 self.
cdcListcdcList.append(layerList3)
214 self.
snrListsnrList.append(layerList4)
216 self.
nListnList.append(layerList8)
230 for ladder
in geoCache.getLadders(layer):
251 layerList0.append(ladderList0)
252 layerList1.append(ladderList1)
253 layerList2.append(ladderList2)
254 layerList3.append(ladderList3)
255 layerList4.append(ladderList4)
256 layerList5.append(ladderList5)
257 layerList6.append(ladderList6)
258 layerList7.append(ladderList7)
259 layerList8.append(ladderList8)
261 layerList9.append(ladderList9)
262 layerList10.append(ladderList10)
263 layerList11.append(ladderList11)
264 layerList12.append(ladderList12)
265 layerList13.append(ladderList13)
266 layerList14.append(ladderList14)
267 layerList15.append(ladderList15)
268 layerList16.append(ladderList16)
269 layerList17.append(ladderList17)
271 for sensor
in geoCache.getSensors(ladder):
292 ladderList0.append(sensorList0)
293 ladderList1.append(sensorList1)
294 ladderList2.append(sensorList2)
295 ladderList3.append(sensorList3)
296 ladderList4.append(sensorList4)
297 ladderList5.append(sensorList5)
298 ladderList6.append(sensorList6)
299 ladderList7.append(sensorList7)
300 ladderList8.append(sensorList8)
302 ladderList9.append(sensorList9)
303 ladderList10.append(sensorList10)
304 ladderList11.append(sensorList11)
305 ladderList12.append(sensorList12)
306 ladderList13.append(sensorList13)
307 ladderList14.append(sensorList14)
308 ladderList15.append(sensorList15)
309 ladderList16.append(sensorList16)
310 ladderList17.append(sensorList17)
313 for side in range(2):
323 sensorList0.append(sideList0)
324 sensorList1.append(sideList1)
325 sensorList2.append(sideList2)
326 sensorList3.append(sideList3)
327 sensorList4.append(sideList4)
328 sensorList5.append(sideList5)
329 sensorList6.append(sideList6)
330 sensorList7.append(sideList7)
331 sensorList8.append(sideList8)
333 for i
in geoCache.getLayers(Belle2.VXD.SensorInfoBase.SVD):
334 layerN = i.getLayerNumber()
336 for j
in geoCache.getLadders(i):
337 ladderN = j.getLadderNumber()
339 for k
in geoCache.getSensors(j):
340 sensorN = k.getSensorNumber()
343 self.
resListresList[li][ldi][si].append(
344 TH1F(
"res" +
"_" + str(k) +
"." + str(s),
" ", 200, -100, 100))
345 self.
spListspList[li][ldi][si].append(
346 TH2D(
"sp" +
"_" + str(k) +
"." + str(s),
" ", 300, -150, 150, 300, -150, 150))
347 self.
cogListcogList[li][ldi][si].append(
348 TH1F(
"cog" +
"_" + str(k) +
"." + str(s),
" ", 200, -100, 100))
349 self.
cdcListcdcList[li][ldi][si].append(
350 TH1F(
"cdc" +
"_" + str(k) +
"." + str(s),
" ", 200, -100, 100))
351 self.
snrListsnrList[li][ldi][si].append(
352 TH1F(
"snr" +
"_" + str(k) +
"." + str(s),
" ", 100, 0, 100))
353 self.
nListnList[li][ldi][si].append(0)
354 self.
sumCOGListsumCOGList[li][ldi][si].append(0)
360 self.
sumCDCListsumCDCList[li][ldi][si].append(0)
366 self.
EventT0HistEventT0Hist = TH1F(
"EventT0",
" ", 200, -100, 100)
368 self.
gausgaus = TF1(
"gaus",
'gaus(0)', -150, 100)
370 self.
polpol = TF1(
"pol",
"[0] + [1]*x + [2]*x*x + [3]*x*x*x", -150, 150)
376 Function that allows to cicle on the events
384 self.
EvtEvt = self.
EvtEvt + 1
391 for svdCluster
in svdCluster_list:
392 svdRecoDigit = svdCluster.getRelatedTo(svd_recoDigits)
393 self.
fillListsfillLists(svdRecoDigit, svdCluster)
397 Terminates te class and produces the output rootfile
405 timeCal = SVDCoGCalibrationFunction()
411 geoCache = Belle2.VXD.GeoCache.getInstance()
412 for layer in geoCache.getLayers(Belle2.VXD.SensorInfoBase.SVD):
413 layerNumber = layer.getLayerNumber()
415 for ladder in geoCache.getLadders(layer):
416 ladderNumber = ladder.getLadderNumber()
417 ldi = ladderNumber - 1
418 for sensor in geoCache.getSensors(ladder):
419 sensorNumber = sensor.getSensorNumber()
420 si = sensorNumber - 1
421 for side in range(2):
423 n = self.nList[li][ldi][si][side][tb]
427 gDirectory.mkdir(
"plots")
428 gDirectory.cd(
"plots")
429 for layer
in geoCache.getLayers(Belle2.VXD.SensorInfoBase.SVD):
430 layerNumber = layer.getLayerNumber()
432 gDirectory.mkdir(
"layer" + str(layer))
433 gDirectory.cd(
"layer" + str(layer))
434 for ladder
in geoCache.getLadders(layer):
435 ladderNumber = ladder.getLadderNumber()
436 ldi = ladderNumber - 1
437 for sensor
in geoCache.getSensors(ladder):
438 sensorNumber = sensor.getSensorNumber()
439 si = sensorNumber - 1
440 for side
in range(2):
442 res = self.
resListresList[li][ldi][si][side]
447 cog = self.
cogListcogList[li][ldi][si][side]
450 cdc = self.
cdcListcdcList[li][ldi][si][side]
453 snr = self.
snrListsnrList[li][ldi][si][side]
457 sp = self.
spListspList[li][ldi][si][side]
459 pfxsp = sp.ProfileX()
460 self.
polpol.SetParameters(-50, 1.5, 0.001, 0.00001)
461 pfxsp.Fit(self.
polpol,
"R")
462 par[0] = self.
polpol.GetParameter(0)
463 par[1] = self.
polpol.GetParameter(1)
464 par[2] = self.
polpol.GetParameter(2)
465 par[3] = self.
polpol.GetParameter(3)
470 T0MEAN = cdc.GetMean()
473 "Mean of the CoG corrected distribution: " +
475 " Mean of the T0 distribution: " +
478 timeCal.set_current(1)
479 timeCal.set_pol3parameters(par[0] - T0MEAN, par[1], par[2], par[3])
480 print(
"setting CoG calibration for " + str(layerNumber) +
"." + str(ladderNumber) +
"." + str(sensorNumber))
481 payload.set(layerNumber, ladderNumber, sensorNumber, bool(side), 1, timeCal)
static IntervalOfValidity always()
Function that returns an interval of validity that is always valid, c.f.
A (simplified) python wrapper for StoreArray.
a (simplified) python wrapper for StoreObjPtr.
base class for calibrations classes
static GeoCache & getInstance()
Return a reference to the singleton instance.
gaus
gaus function used for fitting distributions
Evt
counts the number of events
notApplyCDCLatencyCorrection
parameter that allows to apply or not the CDC latency correction
EventT0Hist
distribution of EventT0
def fillLists(self, svdRecoDigits_rel_Clusters, svdClusters_rel_RecoTracks_cl)
resList
lists used to create the histograms for each TB : residuals
pol
third order polynomial function used for fitting distributions
def set_localdb(self, localDB)
NTOT
counts the number of clusters
localdb
set the name of the localDB used
cdcEventT0
registers PyStoreObj EventT0
sumCDCCOGList
sum of t0*cog
sumCOGList5
sum of CoG times to the fifth
outputFileName
name of the output file
sumCDCCOGList2
sum of t0*cog squared
sumCDCCOGList3
sum of t0 times to the third
spList
scatterplot t0 vs cog
sumCOGList6
sum of CoG times to the sixth
sumCDCList
sum of t0 times
sumCOGList2
sum of CoG times squared
sumCOGList4
sum of CoG times to the fourth
def notApplyCorrectForCDCLatency(self, mode)
sumCOGList
sum of CoG times
sumCOGList3
sum of CoG times to the third
static Database & Instance()
Instance of a singleton Database.