48 from EventInspector
import *
52 from optparse
import Option, OptionValueError, OptionParser
55 parser = OptionParser()
56 parser.add_option(
'-i',
'--inputfile',
57 dest=
'infilename', default=
'',
58 help=
'Input [S]ROOT filename [no default]')
59 parser.add_option(
'-e',
'--experiment',
60 dest=
'eNumber', default=
'',
61 help=
'Experiment number [no default]')
62 parser.add_option(
'-r',
'--run',
63 dest=
'rNumber', default=
'',
64 help=
'Run number [no default]')
65 parser.add_option(
'-n',
'--nEvents',
66 dest=
'nEvents', default=
'',
67 help=
'Max # of analyzed events [no default]')
68 parser.add_option(
'-s',
'--singleEntry', type=
"int",
69 dest=
'singleEntry', default=0,
70 help=
'Select events with any (0) or exactly one (1) or more than one (2) entries/channel [0]')
71 parser.add_option(
'--verbosity', type=
"int",
72 dest=
'verbosity', default=0,
73 help=
'How many histograms to save (0=minimal, 1=all) [0]')
74 parser.add_option(
'-d',
'--displays', type=
"int",
75 dest=
'displays', default=0,
76 help=
'Max # of displayed events [0]')
77 parser.add_option(
'-v',
'--view', type=
"int",
78 dest=
'view', default=2,
79 help=
'View event displays using one-dimensional (1) or two-dimensional (2) hits [2]')
80 parser.add_option(
'-m',
'--minRPCHits', type=
"int",
81 dest=
'minRPCHits', default=4,
82 help=
'Min # of RPC hits in any one sector to display the event [4]')
83 parser.add_option(
'-l',
'--legacyTimes', type=
"int",
84 dest=
'legacyTimes', default=0,
85 help=
'Perform legacy time calculations (1) or not (0) for BKLMHit1ds,2ds [0]')
86 parser.add_option(
'-t',
'--tagName',
87 dest=
'tagName', default=
'data_reprocessing_prompt',
88 help=
'Conditions-database global-tag name [data_reprocessing_prompt]')
89 (options, args) = parser.parse_args()
91 singleEntry = options.singleEntry
92 if singleEntry < 0
or singleEntry > 2:
96 if options.nEvents !=
'':
97 maxCount = int(options.nEvents)
99 print(
"Maximum number of events to analyze is", maxCount,
" - nothing to do.")
102 verbosity = options.verbosity
106 maxDisplays = options.displays
108 minRPCHits = options.minRPCHits
110 legacyTimes = options.legacyTimes
112 tagName = options.tagName
117 if options.infilename !=
'':
118 inputName = re.sub(
"HLT.\.f0....",
"HLT*.f*", options.infilename)
119 fileList = glob.glob(inputName)
120 if len(fileList) == 0:
121 print(
"No file(s) match {0}".format(inputName))
123 if options.eNumber !=
'':
124 if not options.eNumber.isdecimal():
125 print(
"Experiment number ({0}) is not valid".format(options.eNumber))
127 exp =
'{0:04d}'.format(int(options.eNumber))
129 eStart = inputName.find(
'/e') + 2
131 print(
"Input filename does not contain the required experiment number")
133 eEnd = inputName.find(
'/', eStart)
134 exp = inputName[eStart:eEnd]
135 if not exp.isdecimal():
136 print(
"Input filename's experiment number ({0}) is not valid".format(exp))
138 if options.rNumber !=
'':
139 if not options.rNumber.isdecimal():
140 print(
"Run number ({0}) is not valid".format(options.rNumber))
142 run =
'{0:05d}'.format(int(options.rNumber))
144 rStart = inputName.find(
'/r') + 2
146 print(
"Input filename does not contain the required run number")
148 rEnd = inputName.find(
'/', rStart)
149 run = inputName[rStart:rEnd]
150 if not run.isdecimal():
151 print(
"Input filename's run number ({0}) is not valid".format(run))
153 if len(inputName) == 0:
154 inputName =
'/ghi/fs01/belle2/bdata/Data/Raw/e{0}/r{1}/sub00/*.{0}.{1}.HLT*.f*.root'.format(exp, run)
155 fileList = glob.glob(inputName)
156 if len(fileList) == 0:
157 print(
"No file(s) found for experiment <{0}> run <{1}>".format(options.eNumber, options.rNumber))
160 suffix =
'' if singleEntry == 0
else '-singleEntry' if singleEntry == 1
else '-multipleEntries'
161 histName =
'bklmHists-e{0}r{1}{2}.root'.format(exp, run, suffix)
162 pdfName =
'bklmPlots-e{0}r{1}{2}.pdf'.format(exp, run, suffix)
163 eventPdfName =
'bklmEvents{3}D-e{0}r{1}{2}.pdf'.format(exp, run, suffix, view)
166 print(
'bklm-dst: exp=' + exp +
' run=' + run +
' input=' + inputName +
'. Analyze', maxCount,
'events using ' + tagName)
168 print(
'bklm-dst: exp=' + exp +
' run=' + run +
' input=' + inputName +
'. Analyze all events using ' + tagName)
172 use_central_database(tagName)
175 if inputName.find(
".sroot") >= 0:
176 main.add_module(
'SeqRootInput', inputFileNames=inputName)
178 main.add_module(
'RootInput', inputFileName=inputName)
179 main.add_module(
'ProgressBar')
181 eventInspector =
EventInspector(exp, run, histName, pdfName, eventPdfName, verbosity,
182 maxDisplays, minRPCHits, legacyTimes, singleEntry, view)
184 main.add_module(
'KLMReconstructor')
185 main.add_module(eventInspector)
187 process(main, max_event=maxCount)