Belle II Software development
runReconstruction.py
1#!/usr/bin/env python3
2
3
10
11'''
12An example script to reconstruct osmics events with standalone CDC.
13Usage :
14basf2 runReconstruction.py <input> <output>
15input: Input root file (Raw data)
16 GCR1 (RAW) /hsm/belle2/bdata/Data/Raw/e0001/
17 GCR2 (RAW) /hsm/belle2/bdata/Data/Raw/e0002/
18
19output : Output root file, which contains helix parameters.
20 N.B. this is not the basf2 root file!
21 To see the helix parameters.
22 Please use compare2Tracks.C for example.
23'''
24
25import basf2 as b2
26import os
27import os.path
28import argparse
29from cdc import cr
30
31# Set your suitable DB
32b2.reset_database()
33b2.use_database_chain()
34b2.use_central_database("332_COPY-OF_GT_gen_prod_004.11_Master-20171213-230000", b2.LogLevel.INFO)
35b2.use_central_database("MagneticFieldPhase2QCSoff")
36# use_local_database("/home/belle/muchida/basf2/work/caf/gcr2/test6/localDB/database.txt")
37
38
39def rec(input, output, topInCounter=False, magneticField=True,
40 unpacking=True, fieldMapper=False):
41 main_path = b2.create_path()
42 b2.logging.log_level = b2.LogLevel.INFO
43
44 # Get experiment and runnumber.
45 exp_number, run_number = cr.getExpRunNumber(input)
46
47 # Set the peiod of data taking.
48 data_period = cr.getDataPeriod(exp=exp_number,
49 run=run_number)
50
51 mapperAngle = cr.getMapperAngle(exp=exp_number,
52 run=run_number)
53
54 # print(data_period)
55 if os.path.exists('output') is False:
56 os.mkdir('output')
57
58 # RootInput
59 main_path.add_module('RootInput',
60 # entrySequences=['0:1000'],
61 inputFileNames=input)
62 if unpacking is True:
63 main_path.add_module('CDCUnpacker')
64
65 if data_period == 'gcr2017':
66 gearbox = b2.register_module('Gearbox',
67 fileName="/geometry/GCR_Summer2017.xml",
68 override=[("/Global/length", "8.", "m"),
69 ("/Global/width", "8.", "m"),
70 ("/Global/height", "8.", "m"),
71 ])
72 main_path.add_module(gearbox)
73 else:
74 main_path.add_module('Gearbox')
75
76 if fieldMapper is True:
77 main_path.add_module('CDCJobCntlParModifier',
78 MapperGeometry=True,
79 MapperPhiAngle=mapperAngle)
80
81 if magneticField is True:
82 main_path.add_module('Geometry', useDB=True)
83 else:
84 main_path.add_module('Geometry',
85 components=['CDC', 'ECL'])
86
87 main_path.add_module('Progress')
88
89 # Add CDC CR reconstruction.
90 cr.set_cdc_cr_parameters(data_period)
92 # add_cosmics_reconstruction(main_path,
93 # data_taking_period=data_period,
94 # merge_tracks=False)
95
96 # Simple analysis module.
97 output = "/".join(['output', output])
98 main_path.add_module('CDCCosmicAnalysis',
99 noBFit=not magneticField,
100 Output=output)
101
102 # main_path.add_module("RootOutput", outputFileName='full.root')
103 b2.print_path(main_path)
104 b2.process(main_path)
105 print(b2.statistics)
106
107
108if __name__ == "__main__":
109 # Make the parameters accessible form the outside.
110 parser = argparse.ArgumentParser()
111 parser.add_argument('input', help='Input file to be processed (unpacked CDC data).')
112 parser.add_argument('output', help='Output file you want to store the results.')
113 args = parser.parse_args()
114 rec(args.input, args.output, topInCounter=False, magneticField=True,
115 unpacking=True, fieldMapper=False)
def set_cdc_cr_parameters(period)
Definition: __init__.py:95
def getDataPeriod(exp=0, run=0)
Definition: __init__.py:321
def add_cdc_cr_reconstruction(path, eventTimingExtraction=True, topInCounter=False, pval2ndTrial=0.001)
Definition: __init__.py:180
def getMapperAngle(exp=1, run=3118)
Definition: __init__.py:361
def getExpRunNumber(fname)
Definition: __init__.py:294