13 from __future__
import print_function
16 from ROOT
import TObject, TFile, TTree, gROOT, AddressOf
34 def open(self, update=True):
35 print(
'NtupleHandler.open() called')
37 if os.path.exists(self.
fileName)
and update:
51 print(
'ScanNtupleHandler.close() called')
53 self.
tree.Write(
'', TObject.kOverwrite)
57 print(
'ScanNtupleHandler.init() called')
67 self.
tree.GetEntry(entries-1)
76 self.
lbData.coolStartTime = lumi.startTime.timerunlb()
77 self.
lbData.coolEndTime = lumi.endTime.timerunlb()
79 self.
lbData.startTime = lumi.startTime.timerunlb()/1.E9
80 self.
lbData.endTime = lumi.endTime.timerunlb()/1.E9
82 self.
lbData.lbTime = (lumi.endTime.timerunlb() - lumi.startTime.timerunlb())/1.E9
84 self.
lbData.run = lumi.runLB.run
85 self.
lbData.lb = lumi.runLB.lb
97 self.
lbData.onlInstLum = lumi.onlInstLumi
98 self.
lbData.onlInstLumAll = lumi.onlInstLumiAll
99 self.
lbData.onlEvtsPerBX = lumi.onlEvtsPerBX
101 self.
lbData.onlPrefChan = lumi.onlPrefChan
102 self.
lbData.onlValid = lumi.onlValid
103 self.
lbData.olcValid = lumi.olcValid
105 self.
lbData.nColl = lumi.bcid.nbcol()
106 self.
lbData.nBeam1 = lumi.bcid.nb1()
107 self.
lbData.nBeam2 = lumi.bcid.nb2()
108 self.
lbData.qBeam1Col = lumi.IBeam1
109 self.
lbData.qBeam2Col = lumi.IBeam2
110 self.
lbData.qBeam1All = lumi.IBeam1All
111 self.
lbData.qBeam2All = lumi.IBeam2All
113 self.
lbData.specLumi = lumi.specLumi
114 self.
lbData.geomLumi = lumi.geomLumi
115 self.
lbData.maxEvtsPerBX = lumi.maxEvtsPerBX
117 self.
lbData.l1LiveFrac = lumi.l1Livefrac
123 self.
lbData.matched = lumi.matched
128 for (bcid, caliLumi)
in lumi.bcid.caliLumi.iteritems():
131 for (bcid, q)
in lumi.bcid.b1Curr.iteritems():
134 for (bcid, q)
in lumi.bcid.b2Curr.iteritems():
157 for (trig, chan)
in trigChan.iteritems():
158 self.
l1TBP[chan] = trigData.TBP[trig]
159 self.
l1TAP[chan] = trigData.TAP[trig]
160 self.
l1TAV[chan] = trigData.TAV[trig]
163 self.
tree.Branch(name, AddressOf(self.
lbData, name), name+
'/'+type)
166 branch = self.
tree.GetBranch(name)
167 branch.SetAddress(AddressOf(self.
lbData, name))
177 LBDataStructStr =
"struct LBDataStruct {\
178 ULong64_t coolStartTime;\
179 ULong64_t coolEndTime;\
197 Float_t onlInstLumAll;\
198 Float_t onlEvtsPerBX;\
210 Float_t maxEvtsPerBX;\
213 Float_t avgLiveFrac;\
214 Float_t lumiWtLiveFrac;\
220 gROOT.ProcessLine(LBDataStructStr)
221 from ROOT
import LBDataStruct
273 for (var, type)
in self.
varList:
286 self.
qBeam1 = array.array(
'f', (0.,)*3564)
287 self.
qBeam2 = array.array(
'f', (0.,)*3564)
291 self.
tree.GetBranch(
'lumiDel').SetAddress(self.
lumiDel)
292 self.
tree.GetBranch(
'qBeam1').SetAddress(self.
qBeam1)
293 self.
tree.GetBranch(
'qBeam2').SetAddress(self.
qBeam2)
294 self.
tree.GetBranch(
'liveFrac').SetAddress(self.
liveFrac)
298 self.
tree.Branch(
'lumiDel', self.
lumiDel,
'lumiDel[3564]/F')
299 self.
tree.Branch(
'qBeam1', self.
qBeam1,
'qBeam1[3564]/F')
300 self.
tree.Branch(
'qBeam2', self.
qBeam2,
'qBeam2[3564]/F')
301 self.
tree.Branch(
'liveFrac', self.
liveFrac,
'liveFrac[3564]/F')
304 self.
b1BCID = array.array(
'H', (0,)*3564)
305 self.
b2BCID = array.array(
'H', (0,)*3564)
309 self.
tree.GetBranch(
'b1BCID').SetAddress(self.
b1BCID)
310 self.
tree.GetBranch(
'b2BCID').SetAddress(self.
b2BCID)
311 self.
tree.GetBranch(
'colBCID').SetAddress(self.
colBCID)
313 self.
tree.Branch(
'b1BCID', self.
b1BCID,
'b1BCID[nBeam1]/s')
314 self.
tree.Branch(
'b2BCID', self.
b2BCID,
'b2BCID[nBeam2]/s')
315 self.
tree.Branch(
'colBCID', self.
colBCID,
'colBCID[nColl]/s')
322 self.
l1TBP = array.array(
'I', (0,)*256)
323 self.
l1TAP = array.array(
'I', (0,)*256)
324 self.
l1TAV = array.array(
'I', (0,)*256)
327 self.
tree.GetBranch(
'l1TBP').SetAddress(self.
l1TBP)
328 self.
tree.GetBranch(
'l1TAP').SetAddress(self.
l1TAP)
329 self.
tree.GetBranch(
'l1TAV').SetAddress(self.
l1TAV)
332 self.
tree.Branch(
'l1TBP', self.
l1TBP,
'l1TBP[256]/i')
333 self.
tree.Branch(
'l1TAP', self.
l1TAP,
'l1TAP[256]/i')
334 self.
tree.Branch(
'l1TAV', self.
l1TAV,
'l1TAV[256]/i')
348 self.
lbData.stable =
False
350 self.
lbData.physics =
False
351 self.
lbData.larVeto =
False
353 self.
lbData.onlPrefChan = 0
355 self.
lbData.onlInstLum = -1.
356 self.
lbData.onlInstLumAll = -1.
357 self.
lbData.onlEvtsPerBX = -1.
358 self.
lbData.onlValid = 0xFFFFFF
359 self.
lbData.olcValid = 0xFFFFFF
364 self.
lbData.qBeam1Col = -1.
365 self.
lbData.qBeam2Col = -1.
366 self.
lbData.qBeam1All = -1.
367 self.
lbData.qBeam2All = -1.
369 self.
lbData.specLumi = -1.
370 self.
lbData.geomLumi = -1.
371 self.
lbData.maxEvtsPerBX = -1.
373 self.
lbData.l1LiveFrac = -1.
374 self.
lbData.avgLiveFrac = -1.
375 self.
lbData.lumiWtLiveFrac = -1.
382 for i
in range(3564):