Belle II Software  release-08-01-10
ana.py
1 
8 import datetime
9 import re
10 import sys
11 import basf2 as b2
12 from tracking import add_cr_tracking_reconstruction
13 
14 # reset_database()
15 # use_local_database("centraldb/dbcache.txt")
16 
17 d = datetime.datetime.today()
18 print(d.strftime('This Calculution is done at : %d-%m-%y %H:%M:%S\n'))
19 # reunpack the data
20 reUnpack = True
21 # trigger size, for create trigger Image cut(width(rphi plane), length(z direction)
22 triggerSize = [50, 200]
23 
24 # trigger position.
25 triggerPos = [0., 0., 0.]
26 
27 # Normal trigger direction
28 normTriggerPlanDirection = [0, 1, 0]
29 
30 
31 argvs = sys.argv
32 name = argvs[1]
33 argc = len(argvs)
34 probcut = 0
35 if argc == 3:
36  probcut = argvs[2]
37 elif argc == 2:
38  probcut = 0.001
39 
40 probcut = float(probcut)
41 # print(probcut)
42 
43 rootdir = None
44 prefix = None
45 datadir = None
46 param_dir = None
47 t0_file = None
48 tw_file = None
49 xt_file = None
50 sigma_file = None
51 
52 with 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
72 names = name.split(".")
73 
74 inputfilename = datadir + "r{0:05}/sub00/".format(int(names[2])) + name
75 outputfilename = rootdir + '/output_' + name
76 outputfilename2 = rootdir + '/twotracks_' + name
77 logfilename = rootdir + '/run_' + name
78 
79 # param_dir = '201607/'
80 
81 print("input : ", inputfilename)
82 print("output: ", outputfilename)
83 print("log : ", logfilename)
84 
85 # Compose basf2 module path #
86 
87 main_path = b2.create_path()
88 b2.logging.log_level = b2.LogLevel.ERROR
89 
90 # Master module: RootInput
91 main_path.add_module('RootInput',
92  inputFileNames=inputfilename)
93 if 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
108 main_path.add_module('Gearbox')
109 main_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  )
125 main_path.add_module('Geometry', excludedComponents=['SVD', 'PXD', 'ARICH', 'BeamPipe', 'HeavyMetalShield'])
126 # Progress module
127 main_path.add_module('Progress')
128 main_path.add_module('SetupGenfitExtrapolation')
129 add_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
138 main_path.add_module('CDCCosmicAnalysis',
139  Output = outputfilename2,
140  EventT0Extraction = True,
141  noBFit = False
142  )
143 '''
144 main_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 
161 main_path.add_module('HistoManager', histoFileName=outputfilename)
162 # main_path.add_module('RootOutput',
163 # outputFileName = datadir + "evtT0." +prefix + name+'.root',
164 # branchNames = ['CDCHits','EventT0'])
165 b2.print_path(main_path)
166 b2.process(main_path)
167 
168 d = datetime.datetime.today()
169 print(b2.statistics)
170 print(d.strftime('Finish at : %y-%m-%d %H:%M:%S\n'))