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