19from ROOT
import Belle2
21from ROOT
import gStyle, gROOT, addressof, TH2F
26gROOT.ProcessLine(
'struct TreeStruct {\
41from ROOT
import TreeStruct
47 ''' t0const ntpule infomation '''
54 f = ROOT.TFile.Open(
't0const_slot' + str(args[1]) +
'.root')
56 t0const[event.channel] = event.t0Const
59 histTimeCh = TH2F(
'before T0Cal slot#' + str(args[1]),
'before T0Cal slot#' + str(args[1]), 512, 0, 511, 500, 50, 100)
61 histCalTimeCh = TH2F(
'after T0Cal slot#' + str(args[1]),
'after T0Cal slot#' + str(args[1]), 512, 0, 511, 500, 50, 100)
63 histTimeCh.GetXaxis().SetTitle(
'channel')
64 histTimeCh.GetYaxis().SetTitle(
'time [ns]')
65 histCalTimeCh.GetXaxis().SetTitle(
'channel')
66 histCalTimeCh.GetYaxis().SetTitle(
'time [ns]')
69 ''' Initialize the Module: output root file '''
72 self.
file = ROOT.TFile(
't0CalTime_slot' + str(args[1]) +
'.root',
'recreate')
74 self.
tree = ROOT.TTree(
'laser',
'')
78 for key
in TreeStruct.__dict__.keys():
81 if isinstance(self.
data.__getattribute__(key), int):
83 self.
tree.Branch(key, addressof(self.
data, key), key + formstring)
86 ''' Event processor: fill the tree and scatter plots '''
90 if digit.getModuleID() == int(args[1]):
91 self.
data.slot = digit.getModuleID()
92 self.
data.channel = digit.getChannel()
93 self.
data.pixel = digit.getPixelID()
94 self.
data.time = digit.getTime()
95 self.
data.caltime = digit.getTime() + t0const.get(digit.getChannel())
96 self.
data.height = digit.getPulseHeight()
97 self.
data.width = digit.getPulseWidth()
98 self.
data.quality = digit.getHitQuality()
99 self.
data.rawtime = digit.getRawTime()
100 self.
data.firstwindow = digit.getFirstWindow()
101 self.
data.pmtpixel = digit.getPMTPixel()
102 self.
data.pmt = digit.getPMTNumber()
107 self.
histTimeCh.Fill(digit.getChannel(), digit.getTime())
108 self.
histCalTimeCh.Fill(digit.getChannel(), digit.getTime() - t0const.get(digit.getChannel()))
111 ''' Write the file '''
121main = b2.create_path()
124main.add_module(
'RootInput')
130main.add_module(
'Progress')
A (simplified) python wrapper for StoreArray.
TH2F histCalTimeCh
scatter plot after t0 calibartion
TH2F histTimeCh
scatter plot before t0 calibartion