Belle II Software  release-05-01-25
cr_example.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
14 
15 from basf2 import *
16 from reconstruction import add_cosmics_reconstruction
17 from cdc.cr import *
18 
19 # use the CDC CR tag
20 use_central_database("cdc_cr_test1", LogLevel.WARNING)
21 
22 # create path
23 main = create_path()
24 
25 # specify number of events to be generated
26 rootinput = register_module('RootInput')
27 input = '/ghi/fs01/belle2/bdata/group/detector/CDC/unpacked/exp00/cr.cdc.0000.001733.root'
28 rootinput.param('inputFileName', input)
29 main.add_module(rootinput)
30 
31 # this sample is for CDC cosmics only
32 components = ['CDC']
33 
34 # get the run number
35 run_number = getRunNumber(input)
36 
37 # Set the peiod of data taking.
38 data_period = getDataPeriod(run_number)
39 
40 # create a working directory for this sample
41 if os.path.exists(data_period) is False:
42  os.mkdir(data_period)
43 
44 # gearbox & geometry needs to be registered
45 globalPhiRotation = getPhiRotation()
46 main.add_module('Gearbox',
47  override=[("/DetectorComponent[@name='CDC']//GlobalPhiRotation", str(globalPhiRotation), "deg")
48  ],
49  fileName='/geometry/Beast2_phase2.xml')
50 main.add_module('Geometry', components=components)
51 
52 # Set CDC CR parameters.
53 set_cdc_cr_parameters(data_period)
54 
55 # reconstruction
56 add_cosmics_reconstruction(main, components=components)
57 
58 # full output
59 main.add_module('RootOutput', outputFileName='cr_output.root')
60 
61 # display a progress bar while running
62 main.add_module('ProgressBar')
63 
64 # process events and print call statistics
65 process(main)
66 print(statistics)
cr