12 Example script storing ADC, TDC and Hit distribution histograms.
14 basf2 CDCHistMaker exp run
17 from ROOT
import Belle2
18 from ROOT
import TFile, TH1D, TH2D
25 b2.use_database_chain()
26 b2.use_central_database(
"Calibration_Offline_Development", b2.LogLevel.INFO)
29 nWires = [160, 160, 160, 160, 160, 160, 160, 160,
30 160, 160, 160, 160, 160, 160,
31 192, 192, 192, 192, 192, 192,
32 224, 224, 224, 224, 224, 224,
33 256, 256, 256, 256, 256, 256,
34 288, 288, 288, 288, 288, 288,
35 320, 320, 320, 320, 320, 320,
36 352, 352, 352, 352, 352, 352,
37 384, 384, 384, 384, 384, 384
47 def getHistID(lay, wire):
49 Get histogram ID from (layer ID, wire ID).
51 return nWiresSum[lay - 1] + wire
if lay > 0
else wire
58 for l_adc
in range(56):
59 histADCinLayer.append(TH1D(
'h' + str(500000 + l_adc),
60 'ADC Layer' + str(l_adc),
62 for w
in range(nWires[l_adc]):
63 hid = getHistID(l_adc, w)
64 hADC = TH1D(
'h' + str(100000 + hid),
65 'ADC Layer' + str(l_adc) +
'Wire' + str(w),
67 hTDC = TH1D(
'h' + str(200000 + hid),
68 'TDC Layer' + str(l_adc) +
'Wire' + str(w),
74 histADCTDC = [TH2D(
'h' + str(300000 + l_adc),
75 'ADC2TDC Layer' + str(l_adc),
76 200, 0.0, 400., 200, 4000, 6000)
77 for l_adc
in range(56)]
79 histHit = [TH1D(
'h' + str(400000 + l_adc),
80 'HitDist Layer' + str(l_adc),
81 400, 0.0, 400.)
for l_adc
in range(56)]
92 call constructor of base class, required.
95 super(CDCHistMakerModule, self).
__init__()
102 if os.path.exists(self.
m_destm_dest)
is False:
103 os.mkdir(self.
m_destm_dest)
109 reimplement b2.Module::event()
116 sl = hit.getISuperLayer()
117 l_hit = hit.getILayer()
118 cl = l_hit
if sl == 0
else 8 + (sl - 1) * 6 + l_hit
120 adc = hit.getADCCount()
121 tdc = hit.getTDCCount()
128 hid = getHistID(cl, w)
129 histADCinLayer[cl].Fill(adc)
130 histADC[hid].Fill(adc)
131 histTDC[hid].Fill(tdc)
132 histADCTDC[cl].Fill(adc, tdc)
137 Draw histograms on canvas and save image.
145 for h
in histADCinLayer:
153 def main(exp=1, run=3118, prefix='', dest=''):
156 files = glob.glob(prefix +
'/dst.cosmic.{0:0>4}.{1:0>5}'.format(exp, run) +
'*.root')
158 main = b2.create_path()
160 main.add_module(
'RootInput',
161 inputFileNames=files)
164 main.add_module(
'Progress')
170 if __name__ ==
"__main__":
171 parser = argparse.ArgumentParser()
173 parser.add_argument(
'exp', help=
'Experimental number')
174 parser.add_argument(
'run', help=
'Run number')
175 args = parser.parse_args()
177 main(exp=args.exp, run=args.run,
178 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.
int main(int argc, char **argv)
Run all tests.