20 from ROOT
import Belle2
22 from ROOT
import gStyle, gROOT, addressof, TH2F
27 gROOT.ProcessLine(
'struct TreeStruct {\
42 from ROOT
import TreeStruct
48 ''' t0const ntpule infomation '''
55 f = ROOT.TFile.Open(
't0const_slot' + str(args[1]) +
'.root')
57 t0const[event.channel] = event.t0Const
60 histTimeCh = TH2F(
'before T0Cal slot#' + str(args[1]),
'before T0Cal slot#' + str(args[1]), 512, 0, 511, 500, 50, 100)
62 histCalTimeCh = TH2F(
'after T0Cal slot#' + str(args[1]),
'after T0Cal slot#' + str(args[1]), 512, 0, 511, 500, 50, 100)
64 histTimeCh.GetXaxis().SetTitle(
'channel')
65 histTimeCh.GetYaxis().SetTitle(
'time [ns]')
66 histCalTimeCh.GetXaxis().SetTitle(
'channel')
67 histCalTimeCh.GetYaxis().SetTitle(
'time [ns]')
70 ''' Initialize the Module: output root file '''
73 self.
filefile = ROOT.TFile(
't0CalTime_slot' + str(args[1]) +
'.root',
'recreate')
75 self.
treetree = ROOT.TTree(
'laser',
'')
77 self.
datadata = TreeStruct()
79 for key
in TreeStruct.__dict__.keys():
82 if isinstance(self.
datadata.__getattribute__(key), int):
84 self.
treetree.Branch(key, addressof(self.
datadata, key), key + formstring)
87 ''' Event processor: fill the tree and scatter plots '''
91 if digit.getModuleID() == int(args[1]):
92 self.
datadata.slot = digit.getModuleID()
93 self.
datadata.channel = digit.getChannel()
94 self.
datadata.pixel = digit.getPixelID()
95 self.
datadata.time = digit.getTime()
96 self.
datadata.caltime = digit.getTime() + t0const.get(digit.getChannel())
97 self.
datadata.height = digit.getPulseHeight()
98 self.
datadata.width = digit.getPulseWidth()
99 self.
datadata.quality = digit.getHitQuality()
100 self.
datadata.rawtime = digit.getRawTime()
101 self.
datadata.firstwindow = digit.getFirstWindow()
102 self.
datadata.pmtpixel = digit.getPMTPixel()
103 self.
datadata.pmt = digit.getPMTNumber()
108 self.
histTimeChhistTimeCh.Fill(digit.getChannel(), digit.getTime())
109 self.
histCalTimeChhistCalTimeCh.Fill(digit.getChannel(), digit.getTime() - t0const.get(digit.getChannel()))
112 ''' Write the file '''
115 self.
filefile.Write()
118 self.
filefile.Close()
122 main = b2.create_path()
125 main.add_module(
'RootInput')
131 main.add_module(
'Progress')
A (simplified) python wrapper for StoreArray.
histCalTimeCh
scatter plot after t0 calibartion
histTimeCh
scatter plot before t0 calibartion