4 Example script storing ADC, TDC and Hit distribution histograms.
6 basf2 CDCHistMaker exp run
9 from ROOT
import Belle2
10 from ROOT
import TH1D, TH2D, TCanvas, TFile
17 use_central_database(
"Calibration_Offline_Development", LogLevel.INFO)
20 nWires = [160, 160, 160, 160, 160, 160, 160, 160,
21 160, 160, 160, 160, 160, 160,
22 192, 192, 192, 192, 192, 192,
23 224, 224, 224, 224, 224, 224,
24 256, 256, 256, 256, 256, 256,
25 288, 288, 288, 288, 288, 288,
26 320, 320, 320, 320, 320, 320,
27 352, 352, 352, 352, 352, 352,
28 384, 384, 384, 384, 384, 384
38 def getHistID(lay, wire):
40 Get histogram ID from (layer ID, wire ID).
42 return nWiresSum[lay - 1] + wire
if lay > 0
else wire
50 histADCinLayer.append(TH1D(
'h' + str(500000 + l),
53 for w
in range(nWires[l]):
55 hADC = TH1D(
'h' + str(100000 + hid),
56 'ADC Layer' + str(l) +
'Wire' + str(w),
58 hTDC = TH1D(
'h' + str(200000 + hid),
59 'TDC Layer' + str(l) +
'Wire' + str(w),
65 histADCTDC = [TH2D(
'h' + str(300000 + l),
66 'ADC2TDC Layer' + str(l),
67 200, 0.0, 400., 200, 4000, 6000)
70 histHit = [TH1D(
'h' + str(400000 + l),
71 'HitDist Layer' + str(l),
72 400, 0.0, 400.)
for l
in range(56)]
83 call constructor of base class, required.
86 super(CDCHistMakerModule, self).
__init__()
93 if os.path.exists(self.
m_dest)
is False:
100 reimplement Module::event()
107 sl = hit.getISuperLayer()
109 cl = l
if sl == 0
else 8 + (sl - 1) * 6 + l
111 adc = hit.getADCCount()
112 tdc = hit.getTDCCount()
119 hid = getHistID(cl, w)
120 histADCinLayer[cl].Fill(adc)
121 histADC[hid].Fill(adc)
122 histTDC[hid].Fill(tdc)
123 histADCTDC[cl].Fill(adc, tdc)
128 Draw histograms on canvas and save image.
136 for h
in histADCinLayer:
144 def main(exp=1, run=3118, prefix='', dest=''):
147 files = glob.glob(prefix +
'/dst.cosmic.{0:0>4}.{1:0>5}'.format(exp, run) +
'*.root')
151 main.add_module(
'RootInput',
152 inputFileNames=files)
155 main.add_module(
'Progress')
161 if __name__ ==
"__main__":
162 parser = argparse.ArgumentParser()
164 parser.add_argument(
'exp', help=
'Experimental number')
165 parser.add_argument(
'run', help=
'Run number')
166 args = parser.parse_args()
168 main(exp=args.exp, run=args.run,
169 prefix=
'/ghi/fs01/belle2/bdata/users/karim/data/GCR1/build-2017-08-21',