50from tracking
import add_tracking_reconstruction
52from optparse
import OptionParser
55parser = OptionParser()
56parser.add_option(
'-i',
'--inputfile',
57 dest=
'infilename', default=
'',
58 help=
'Input ROOT filename [no default]')
59parser.add_option(
'-e',
'--experiment',
60 dest=
'eNumber', default=
'',
61 help=
'Experiment number [no default]')
62parser.add_option(
'-r',
'--run',
63 dest=
'rNumber', default=
'',
64 help=
'Run number [no default]')
65parser.add_option(
'-n',
'--nEvents',
66 dest=
'nEvents', default=
'',
67 help=
'Max # of analyzed events [no default]')
68parser.add_option(
'-d',
'--displays',
69 dest=
'displays', default=
'100',
70 help=
'Max # of displayed events [default=100]')
71parser.add_option(
'-m',
'--minRPCHits',
72 dest=
'minRPCHits', default=
'4',
73 help=
'Minimum # of RPC hits in one sector [default=4]')
74parser.add_option(
'-u',
'--muids',
75 dest=
'minMuidHits', default=
'1',
76 help=
'Minimum # of Muid hits in the event [default=1]')
77parser.add_option(
'-t',
'--tag',
78 dest=
'tagName', default=
'data_reprocessing_prompt',
79 help=
'Conditions-database global-tag name [data_reprocessing_prompt]')
80(options, args) = parser.parse_args()
83if options.nEvents !=
'':
84 maxCount = int(options.nEvents)
86 print(
"Maximum number of events to analyze is", maxCount,
" - nothing to do.")
89maxDisplays = int(options.displays)
91minRPCHits = int(options.minRPCHits)
93minMuidHits = int(options.minMuidHits)
95tagName = options.tagName
100if options.infilename !=
'':
101 inputName = options.infilename
102 fileList = glob.glob(inputName)
103 if len(fileList) == 0:
104 print(f
'No file(s) match {inputName}')
106if options.eNumber !=
'':
107 if not options.eNumber.isdecimal():
108 print(f
'Experiment number ({options.eNumber}) is not valid')
110 exp = f
'{int(options.eNumber):04d}'
112 eStart = inputName.find(
'/e') + 2
114 print(
'Input filename does not contain the required experiment number')
116 eEnd = inputName.find(
'/', eStart)
117 exp = inputName[eStart:eEnd]
118 if not exp.isdecimal():
119 print(f
'Input filename experiment number({exp}) is not valid')
121if options.rNumber !=
'':
122 if not options.rNumber.isdecimal():
123 print(f
'Run number ({options.rNumber}) is not valid')
125 run = f
'{int(options.rNumber):05d}'
127 rStart = inputName.find(
'/r') + 2
129 print(
'Input filename does not contain the required run number')
131 rEnd = inputName.find(
'/', rStart)
132 run = inputName[rStart:rEnd]
133 if not run.isdecimal():
134 print(f
'Input filename run number({run}) is not valid')
136if len(inputName) == 0:
137 fileList = glob.glob(f
'/ghi/fs01/belle2/bdata/Data/Raw/e{exp}/r{run}/sub00/*.{exp}.{run}.HLT2.f00000.root')
138 if len(fileList) == 0:
139 print(f
'No file(s) found for experiment <{options.eNumber}> run <{options.rNumber}>')
141 inputName = fileList[0].replace(
'f00000',
'f*')
143eventPdfName = f
'bklmEvents-e{exp}r{run}.pdf'
146 print(
'bklm-display: exp=' + exp +
' run=' + run +
' input=' + inputName +
'. Analyze', maxCount,
'events using ' + tagName)
147 print(
' Write at most', maxDisplays,
'event displays, requiring # RPC hits per sector >=', minRPCHits,
148 ' # Muids in event >=', minMuidHits)
150 print(
'bklm-display: exp=' + exp +
' run=' + run +
' input=' + inputName +
'. Analyze all events using ' + tagName)
151 print(
' Write at most', maxDisplays,
'event displays, requiring # RPC hits per sector >=', minRPCHits,
152 ' # Muids in event >=', minMuidHits)
154basf2.conditions.prepend_globaltag(tagName)
156main = basf2.create_path()
157main.add_module(
'RootInput', inputFileName=inputName)
158main.add_module(
'ProgressBar')
160eventDisplayer =
EventDisplayer(exp, run, eventPdfName, maxDisplays, minRPCHits, minMuidHits)
162main.add_module(
'KLMReconstructor')
163add_tracking_reconstruction(main)
164ext = main.add_module(
'Ext')
165ext.param(
'pdgCodes', [13])
166muid = main.add_module(
'Muid')
168main.add_module(eventDisplayer)
170basf2.process(main, max_event=maxCount)
171print(basf2.statistics)
def add_unpackers(path, components=None, writeKLMDigitRaws=False, addTOPRelations=False)