Belle II Software development
ana.py
1
8import datetime
9import re
10import sys
11import basf2 as b2
12from tracking import add_cr_tracking_reconstruction
13
14# reset_database()
15# use_local_database("centraldb/dbcache.txt")
16
17d = datetime.datetime.today()
18print(d.strftime('This Calculution is done at : %d-%m-%y %H:%M:%S\n'))
19# reunpack the data
20reUnpack = True
21# trigger size, for create trigger Image cut(width(rphi plane), length(z direction)
22triggerSize = [50, 200]
23
24# trigger position.
25triggerPos = [0., 0., 0.]
26
27# Normal trigger direction
28normTriggerPlanDirection = [0, 1, 0]
29
30
31argvs = sys.argv
32name = argvs[1]
33argc = len(argvs)
34probcut = 0
35if argc == 3:
36 probcut = argvs[2]
37elif argc == 2:
38 probcut = 0.001
39
40probcut = float(probcut)
41# print(probcut)
42
43rootdir = None
44prefix = None
45datadir = None
46param_dir = None
47t0_file = None
48tw_file = None
49xt_file = None
50sigma_file = None
51
52with open('location') as file:
53 lines = file.readlines()
54 for line in lines:
55 if re.match(r'dir_root', line):
56 rootdir = line.split('"')[1]
57 if re.match(r'prefix', line):
58 prefix = line.split('"')[1]
59 if re.match(r'dir_data', line):
60 datadir = line.split('"')[1]
61 if re.match(r'dir_params', line):
62 param_dir = line.split('"')[1]
63 if re.match(r't0_file', line):
64 t0_file = line.split('"')[1]
65 if re.match(r'tw_file', line):
66 tw_file = line.split('"')[1]
67 if re.match(r'xt_file', line):
68 xt_file = line.split('"')[1]
69 if re.match(r'sigma_file', line):
70 sigma_file = line.split('"')[1]
71# getname
72names = name.split(".")
73
74inputfilename = datadir + f"r{int(names[2]):05}/sub00/" + name
75outputfilename = rootdir + '/output_' + name
76outputfilename2 = rootdir + '/twotracks_' + name
77logfilename = rootdir + '/run_' + name
78
79# param_dir = '201607/'
80
81print("input : ", inputfilename)
82print("output: ", outputfilename)
83print("log : ", logfilename)
84
85# Compose basf2 module path #
86
87main_path = b2.create_path()
88b2.logging.log_level = b2.LogLevel.ERROR
89
90# Master module: RootInput
91main_path.add_module('RootInput',
92 inputFileNames=inputfilename)
93if reUnpack:
94 main_path.add_module('CDCUnpacker',
95 # Enable/Disable to store the CDCRawHit Object.
96 enableStoreCDCRawHit=True,
97 enableDatabase=False,
98 xmlMapFileName="data/cdc/ch_map_201702.dat",
99 # Enable/Disable print out the ADC/TDC data to the terminal.
100 enablePrintOut=False,
101 enable2ndHit=False,
102 boardIDTrig=7,
103 channelTrig=1,
104 subtractTrigTiming=False
105 )
106
107# gearbox & geometry needs to be registered any way
108main_path.add_module('Gearbox')
109main_path.add_module('CDCJobCntlParModifier',
110 MapperGeometry=True,
111 MapperPhiAngle=43.3,
112 T0InputType=False,
113 T0File=param_dir + t0_file,
114 XtInputType=False,
115 XtFile=param_dir + xt_file,
116 SigmaInputType=False,
117 SigmaFile=param_dir + sigma_file,
118 TimeWalkInputType=False,
119 TimeWalkFile=param_dir + tw_file,
120 ChannelMapInputType=False,
121 ChannelMapFile="ch_map_201702.dat",
122 AlignmentInputType=False,
123 AlignmentFile=param_dir + "align_201702.dat"
124 )
125main_path.add_module('Geometry', excludedComponents=['SVD', 'PXD', 'ARICH', 'BeamPipe', 'HeavyMetalShield'])
126# Progress module
127main_path.add_module('Progress')
128main_path.add_module('SetupGenfitExtrapolation')
129add_cr_tracking_reconstruction(path=main_path, prune_tracks=False,
130 skip_geometry_adding=False,
131 event_time_extraction=True,
132 data_taking_period="gcr2017",
133 top_in_counter=False,
134 merge_tracks=False,
135 use_second_cdc_hits=False)
136'''
137#for analysis, if you want to check performance please enable this part
138main_path.add_module('CDCCosmicAnalysis',
139 Output = outputfilename2,
140 EventT0Extraction = True,
141 noBFit = False
142 )
143'''
144main_path.add_module('CDCCRTest', logLevel=b2.LogLevel.ERROR,
145 RecoTracksColName='RecoTracks',
146 histogramDirectoryName='trackfit',
147 MinimumPt=0.1,
148 noBFit=False,
149 EventT0Extraction=True,
150 plotResidual=False,
151 calExpectedDriftTime=True,
152 TriggerPos=triggerPos,
153 NormTriggerPlaneDirection=normTriggerPlanDirection,
154 TriggerSize=triggerSize,
155 EstimateResultForUnFittedLayer=False,
156 StoreHitDistribution=False,
157 StoreTrackParams=False,
158 SmallerOutput=True
159 )
160
161main_path.add_module('HistoManager', histoFileName=outputfilename)
162# main_path.add_module('RootOutput',
163# outputFileName = datadir + "evtT0." +prefix + name+'.root',
164# branchNames = ['CDCHits','EventT0'])
165b2.print_path(main_path)
166b2.process(main_path)
167
168d = datetime.datetime.today()
169print(b2.statistics)
170print(d.strftime('Finish at : %y-%m-%d %H:%M:%S\n'))