11Example script storing ADC, TDC and Hit distribution histograms.
13basf2 CDCHistMaker exp run
16from ROOT
import Belle2
17from ROOT
import TFile, TH1D, TH2D
24b2.use_database_chain()
25b2.use_central_database(
"Calibration_Offline_Development", b2.LogLevel.INFO)
28nWires = [160, 160, 160, 160, 160, 160, 160, 160,
29 160, 160, 160, 160, 160, 160,
30 192, 192, 192, 192, 192, 192,
31 224, 224, 224, 224, 224, 224,
32 256, 256, 256, 256, 256, 256,
33 288, 288, 288, 288, 288, 288,
34 320, 320, 320, 320, 320, 320,
35 352, 352, 352, 352, 352, 352,
36 384, 384, 384, 384, 384, 384
46def getHistID(lay, wire):
48 Get histogram ID from (layer ID, wire ID).
50 return nWiresSum[lay - 1] + wire
if lay > 0
else wire
57for l_adc
in range(56):
58 histADCinLayer.append(TH1D(
'h' + str(500000 + l_adc),
59 'ADC Layer' + str(l_adc),
61 for w
in range(nWires[l_adc]):
62 hid = getHistID(l_adc, w)
63 hADC = TH1D(
'h' + str(100000 + hid),
64 'ADC Layer' + str(l_adc) +
'Wire' + str(w),
66 hTDC = TH1D(
'h' + str(200000 + hid),
67 'TDC Layer' + str(l_adc) +
'Wire' + str(w),
73histADCTDC = [TH2D(
'h' + str(300000 + l_adc),
74 'ADC2TDC Layer' + str(l_adc),
75 200, 0.0, 400., 200, 4000, 6000)
76 for l_adc
in range(56)]
78histHit = [TH1D(
'h' + str(400000 + l_adc),
79 'HitDist Layer' + str(l_adc),
80 400, 0.0, 400.)
for l_adc
in range(56)]
91 call constructor of base class, required.
101 if os.path.exists(self.
m_dest)
is False:
108 reimplement b2.Module::event()
115 sl = hit.getISuperLayer()
116 l_hit = hit.getILayer()
117 cl = l_hit
if sl == 0
else 8 + (sl - 1) * 6 + l_hit
119 adc = hit.getADCCount()
120 tdc = hit.getTDCCount()
127 hid = getHistID(cl, w)
128 histADCinLayer[cl].Fill(adc)
129 histADC[hid].Fill(adc)
130 histTDC[hid].Fill(tdc)
131 histADCTDC[cl].Fill(adc, tdc)
136 Draw histograms on canvas and save image.
144 for h
in histADCinLayer:
152def main(exp=1, run=3118, prefix='', dest=''):
155 files = glob.glob(prefix + f
'/dst.cosmic.{exp:0>4}.{run:0>5}' +
'*.root')
157 main = b2.create_path()
159 main.add_module(
'RootInput',
160 inputFileNames=files)
163 main.add_module(
'Progress')
169if __name__ ==
"__main__":
170 parser = argparse.ArgumentParser()
172 parser.add_argument(
'exp', help=
'Experimental number')
173 parser.add_argument(
'run', help=
'Run number')
174 args = parser.parse_args()
176 main(exp=args.exp, run=args.run,
177 prefix=
'/ghi/fs01/belle2/bdata/users/karim/data/GCR1/build-2017-08-21',
A (simplified) python wrapper for StoreArray.
def __init__(self, exp=0, run=0, dest='.')
m_outputFile
Output file name.
m_exp
Experimental number.