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