20from ROOT
import (Belle2, TFile, TFitResultPtr, TH1F, TH2D, TTree, TF1,
28svd_Clusters =
"SVDClustersFromTracks"
29svd_EventInfo =
"SVDEventInfo"
39 Python class used for checking SVD CoG
Calibration stored in a localDB
44 Function that fill the lists needed for the check of the calibration
47 svdClusterFromTracks (SVDCluster): Cluster related to tracks
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()
67 tZeroError = self.
cdcEventT0.getEventT0Uncertainty()
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]
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)
92 Function that allows to set the localDB
95 localDB (str): Name of the localDB used
102 Function that allows to save the run number
105 run (int): run number
112 Function that allows to save the experiment number
115 exp (int): experiment number
122 Initialize object (histograms, lists, ...) used by the class
150 for layer
in geoCache.getLayers(Belle2.VXD.SensorInfoBase.SVD):
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)
169 for ladder
in geoCache.getLadders(layer):
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)
188 for sensor
in geoCache.getSensors(ladder):
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)
207 for i
in geoCache.getLayers(Belle2.VXD.SensorInfoBase.SVD):
208 layerN = i.getLayerNumber()
210 for j
in geoCache.getLadders(i):
211 ladderN = j.getLadderNumber()
213 for k
in geoCache.getSensors(j):
214 sensorN = k.getSensorNumber()
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),
236 self.
cdcErrorList[li][ldi][si].append(TH1F(
"cdcError" +
"_" + str(layerN) +
"." +
237 str(ladderN) +
"." + str(sensorN) +
"." + str(s),
244 self.
gaus = TF1(
"gaus",
'gaus(0)', -150, 150)
246 self.
pol1 = TF1(
"pol1",
"[0] + [1]*x", -30, 30)
248 self.
pol3 = TF1(
"pol3",
"[0] + [1]*x + [2]*x*x + [3]*x*x*x", -50, 50)
254 Function that allows to cicle on the events
268 clsTB = svd_evtInfo.getModeByte().getTriggerBin()
272 for svdCluster
in svdCluster_list:
277 Terminates te class and produces the output rootfile
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)
292 expnumber = np.zeros(1, dtype=int)
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)
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")
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
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):
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")))
351 cog = self.
cogList[li][ldi][si][side]
352 cog.GetXaxis().SetTitle(
"cluster time (ns)")
355 cdc = self.
cdcList[li][ldi][si][side]
356 cdc.GetXaxis().SetTitle(
"EventT0 (ns)")
359 cdcError.GetXaxis().SetTitle(
"EventT0 Error (ns)")
362 snr = self.
snrList[li][ldi][si][side]
363 clsSNR[0] = snr.GetMean()
364 snr.GetXaxis().SetTitle(
"cluster SNR")
367 size = self.
sizeList[li][ldi][si][side]
368 clsSize[0] = size.GetMean()
369 size.GetXaxis().SetTitle(
"cluster Size")
373 clsCharge[0] = charge.GetMean()
374 charge.GetXaxis().SetTitle(
"cluster Charge")
377 sp = self.
spList[li][ldi][si][side]
379 pfxsp = sp.ProfileX()
380 sp.GetXaxis().SetTitle(
"cluster time (ns)")
381 sp.GetYaxis().SetTitle(
"EventT0 (ns)")
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:
393 cogmeanerr[0] = cog.GetRMS()/math.sqrt(cog.GetEntries())
394 evttime[0] = cdc.GetMean()
395 if cdc.GetEntries() == 0:
398 jitter[0] = cdc.GetRMS()
399 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)