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