28from ROOT
import Belle2, TFile, TH1F, TH2D
29from ROOT
import TF1, gDirectory, gROOT
31from ROOT.Belle2
import SVDCoGCalibrationFunction
34svd_recoDigits =
"SVDRecoDigitsFromTracks"
36svd_Clusters =
"SVDClustersFromTracks"
45 Python class used for checking SVD CoG
Calibration stored in a localDB,
46 creating a localDB
with the correction
and a root file to check the corrections
51 Function that allows to set if apply the CDC latency correction
55 -
if True ->
not apply correction
56 -
if False -> apply correction
62 def fillLists(self, svdRecoDigits_rel_Clusters, svdClusters_rel_RecoTracks_cl):
64 Function that fill the lists needed for the CoG corrections
67 svdRecoDigits_rel_Clusters (SVDRecoDigit): reco digits related to clusters
68 svdClusters_rel_RecoTracks_cl (SVDCluster): cluster related to tracks
71 timeCluster = svdClusters_rel_RecoTracks_cl.getClsTime()
72 snrCluster = svdClusters_rel_RecoTracks_cl.getSNR()
73 layerCluster = svdClusters_rel_RecoTracks_cl.getSensorID().getLayerNumber()
74 layerIndex = layerCluster - 3
75 sensorCluster = svdClusters_rel_RecoTracks_cl.getSensorID().getSensorNumber()
76 sensorIndex = sensorCluster - 1
77 ladderCluster = svdClusters_rel_RecoTracks_cl.getSensorID().getLadderNumber()
78 ladderIndex = ladderCluster - 1
79 sideCluster = svdClusters_rel_RecoTracks_cl.isUCluster()
89 TBClusters = svdEventInfo.getModeByte().getTriggerBin()
90 TBIndex = ord(TBClusters)
94 tZeroSync = tZero - 4000./509 * (3 - TBIndex)
100 resHist = self.
resList[layerIndex][ladderIndex][sensorIndex][sideIndex]
101 resHist.Fill(timeCluster - tZeroSync)
102 spHist = self.
spList[layerIndex][ladderIndex][sensorIndex][sideIndex]
104 spHist.Fill(timeCluster, tZeroSync)
105 cogHist = self.
cogList[layerIndex][ladderIndex][sensorIndex][sideIndex]
106 cogHist.Fill(timeCluster)
107 cdcHist = self.
cdcList[layerIndex][ladderIndex][sensorIndex][sideIndex]
108 cdcHist.Fill(tZeroSync)
109 snrHist = self.
snrList[layerIndex][ladderIndex][sensorIndex][sideIndex]
110 snrHist.Fill(snrCluster)
112 self.
nList[layerIndex][ladderIndex][sensorIndex][sideIndex] += 1
114 self.
sumCOGList[layerIndex][ladderIndex][sensorIndex][sideIndex] += timeCluster
115 self.
sumCOGList2[layerIndex][ladderIndex][sensorIndex][sideIndex] += timeCluster * timeCluster
116 self.
sumCOGList3[layerIndex][ladderIndex][sensorIndex][sideIndex] += timeCluster * timeCluster * timeCluster
117 self.
sumCOGList4[layerIndex][ladderIndex][sensorIndex][sideIndex] += timeCluster * \
118 timeCluster * timeCluster * timeCluster
119 self.
sumCOGList5[layerIndex][ladderIndex][sensorIndex][sideIndex] += timeCluster * \
120 timeCluster * timeCluster * timeCluster * timeCluster
121 self.
sumCOGList6[layerIndex][ladderIndex][sensorIndex][sideIndex] += timeCluster * \
122 timeCluster * timeCluster * timeCluster * timeCluster * timeCluster
124 self.
sumCDCList[layerIndex][ladderIndex][sensorIndex][sideIndex] += tZeroSync
125 self.
sumCDCCOGList[layerIndex][ladderIndex][sensorIndex][sideIndex] += tZeroSync * timeCluster
126 self.
sumCDCCOGList2[layerIndex][ladderIndex][sensorIndex][sideIndex] += tZeroSync * timeCluster * timeCluster
127 self.
sumCDCCOGList3[layerIndex][ladderIndex][sensorIndex][sideIndex] += tZeroSync * \
128 timeCluster * timeCluster * timeCluster
135 Function that allows to set the localDB
138 localDB (str): Name of the localDB used
145 Initialize object (histograms, lists, ...) used by the class
188 for layer
in geoCache.getLayers(Belle2.VXD.SensorInfoBase.SVD):
209 self.
resList.append(layerList0)
210 self.
spList.append(layerList1)
211 self.
cogList.append(layerList2)
212 self.
cdcList.append(layerList3)
213 self.
snrList.append(layerList4)
215 self.
nList.append(layerList8)
229 for ladder
in geoCache.getLadders(layer):
250 layerList0.append(ladderList0)
251 layerList1.append(ladderList1)
252 layerList2.append(ladderList2)
253 layerList3.append(ladderList3)
254 layerList4.append(ladderList4)
255 layerList5.append(ladderList5)
256 layerList6.append(ladderList6)
257 layerList7.append(ladderList7)
258 layerList8.append(ladderList8)
260 layerList9.append(ladderList9)
261 layerList10.append(ladderList10)
262 layerList11.append(ladderList11)
263 layerList12.append(ladderList12)
264 layerList13.append(ladderList13)
265 layerList14.append(ladderList14)
266 layerList15.append(ladderList15)
267 layerList16.append(ladderList16)
268 layerList17.append(ladderList17)
270 for sensor
in geoCache.getSensors(ladder):
291 ladderList0.append(sensorList0)
292 ladderList1.append(sensorList1)
293 ladderList2.append(sensorList2)
294 ladderList3.append(sensorList3)
295 ladderList4.append(sensorList4)
296 ladderList5.append(sensorList5)
297 ladderList6.append(sensorList6)
298 ladderList7.append(sensorList7)
299 ladderList8.append(sensorList8)
301 ladderList9.append(sensorList9)
302 ladderList10.append(sensorList10)
303 ladderList11.append(sensorList11)
304 ladderList12.append(sensorList12)
305 ladderList13.append(sensorList13)
306 ladderList14.append(sensorList14)
307 ladderList15.append(sensorList15)
308 ladderList16.append(sensorList16)
309 ladderList17.append(sensorList17)
312 for side
in range(2):
322 sensorList0.append(sideList0)
323 sensorList1.append(sideList1)
324 sensorList2.append(sideList2)
325 sensorList3.append(sideList3)
326 sensorList4.append(sideList4)
327 sensorList5.append(sideList5)
328 sensorList6.append(sideList6)
329 sensorList7.append(sideList7)
330 sensorList8.append(sideList8)
332 for i
in geoCache.getLayers(Belle2.VXD.SensorInfoBase.SVD):
333 layerN = i.getLayerNumber()
335 for j
in geoCache.getLadders(i):
336 ladderN = j.getLadderNumber()
338 for k
in geoCache.getSensors(j):
339 sensorN = k.getSensorNumber()
342 self.
resList[li][ldi][si].append(
343 TH1F(
"res" +
"_" + str(k) +
"." + str(s),
" ", 200, -100, 100))
344 self.
spList[li][ldi][si].append(
345 TH2D(
"sp" +
"_" + str(k) +
"." + str(s),
" ", 300, -150, 150, 300, -150, 150))
346 self.
cogList[li][ldi][si].append(
347 TH1F(
"cog" +
"_" + str(k) +
"." + str(s),
" ", 200, -100, 100))
348 self.
cdcList[li][ldi][si].append(
349 TH1F(
"cdc" +
"_" + str(k) +
"." + str(s),
" ", 200, -100, 100))
350 self.
snrList[li][ldi][si].append(
351 TH1F(
"snr" +
"_" + str(k) +
"." + str(s),
" ", 100, 0, 100))
352 self.
nList[li][ldi][si].append(0)
367 self.
gaus = TF1(
"gaus",
'gaus(0)', -150, 100)
369 self.
pol = TF1(
"pol",
"[0] + [1]*x + [2]*x*x + [3]*x*x*x", -150, 150)
375 Function that allows to cicle on the events
390 for svdCluster
in svdCluster_list:
391 svdRecoDigit = svdCluster.getRelatedTo(svd_recoDigits)
396 Terminates te class and produces the output rootfile
404 timeCal = SVDCoGCalibrationFunction()
411 for layer
in geoCache.getLayers(Belle2.VXD.SensorInfoBase.SVD):
412 layerNumber = layer.getLayerNumber()
414 for ladder
in geoCache.getLadders(layer):
415 ladderNumber = ladder.getLadderNumber()
416 ldi = ladderNumber - 1
417 for sensor
in geoCache.getSensors(ladder):
418 sensorNumber = sensor.getSensorNumber()
419 si = sensorNumber - 1
420 for side
in range(2):
422 n = self.
nList[li][ldi][si][side][tb]
426 gDirectory.mkdir("plots")
427 gDirectory.cd(
"plots")
428 for layer
in geoCache.getLayers(Belle2.VXD.SensorInfoBase.SVD):
429 layerNumber = layer.getLayerNumber()
431 gDirectory.mkdir(
"layer" + str(layer))
432 gDirectory.cd(
"layer" + str(layer))
433 for ladder
in geoCache.getLadders(layer):
434 ladderNumber = ladder.getLadderNumber()
435 ldi = ladderNumber - 1
436 for sensor
in geoCache.getSensors(ladder):
437 sensorNumber = sensor.getSensorNumber()
438 si = sensorNumber - 1
439 for side
in range(2):
441 res = self.
resList[li][ldi][si][side]
446 cog = self.
cogList[li][ldi][si][side]
449 cdc = self.
cdcList[li][ldi][si][side]
452 snr = self.
snrList[li][ldi][si][side]
456 sp = self.
spList[li][ldi][si][side]
458 pfxsp = sp.ProfileX()
459 self.
pol.SetParameters(-50, 1.5, 0.001, 0.00001)
460 pfxsp.Fit(self.
pol,
"R")
461 par[0] = self.
pol.GetParameter(0)
462 par[1] = self.
pol.GetParameter(1)
463 par[2] = self.
pol.GetParameter(2)
464 par[3] = self.
pol.GetParameter(3)
469 T0MEAN = cdc.GetMean()
472 "Mean of the CoG corrected distribution: " +
474 " Mean of the T0 distribution: " +
477 timeCal.set_current(1)
478 timeCal.set_pol3parameters(par[0] - T0MEAN, par[1], par[2], par[3])
479 print("setting CoG calibration for " + str(layerNumber) +
"." + str(ladderNumber) +
"." + str(sensorNumber))
480 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.