47import EventInspectorLookback
49from optparse
import OptionParser
52parser = OptionParser()
53parser.add_option(
'-i',
'--inputfile',
54 dest=
'infilename', default=
'',
55 help=
'Input [S]ROOT filename [no default]')
56parser.add_option(
'-e',
'--experiment',
57 dest=
'eNumber', default=
'',
58 help=
'Experiment number [no default]')
59parser.add_option(
'-r',
'--run',
60 dest=
'rNumber', default=
'',
61 help=
'Run number [no default]')
62parser.add_option(
'-m',
'--mode',
63 dest=
'mode', default=
'',
64 help=
'Lookback-window mode [no default]')
65parser.add_option(
'-w',
'--windowValues',
66 dest=
'window', nargs=3, type=
"int",
67 help=
'Lookback-window values (min, max, step) [no default]')
68parser.add_option(
'-t',
'--tagName',
69 dest=
'tagName', default=
'data_reprocessing_prompt',
70 help=
'Conditions-database global-tag name [data_reprocessing_prompt]')
71(options, args) = parser.parse_args()
73tagName = options.tagName
75modes = {
"coarse-start": 0,
"coarse-width": 1,
"fine-start": 2,
"fine-width": 3}
76if options.mode.isdecimal():
77 mode = int(options.mode)
79 mode = modes[options.mode]
if options.mode
in modes
else -1
80if (mode < 0)
or (mode >= 4):
81 print(f
"Illegal lookback-window mode {options.mode}; use one of {modes}")
84if options.window
is None:
85 print(
"Required lookback-window values (-w min max step) not present")
87if (options.window[0] < 0)
or (options.window[1] < options.window[0])
or (options.window[2] <= 0):
88 if options.window[0] < 0:
89 print(f
"Lookback-window min value {options.window[0]} cannot be negative")
90 if options.window[1] < options.window[0]:
91 print(f
"Lookback-window max value {options.window[1]} cannot be less than min value {options.window[0]}")
92 if options.window[2] <= 0:
93 print(f
"Lookback-window step value {options.window[2]} must be positive definite")
95window = options.window
97inputName = re.sub(
r"HLT.\.f0....",
"HLT*.f*", options.infilename)
98fileList = glob.glob(inputName)
100 print(f
"No file(s) match {inputName}")
103if not options.eNumber.isdecimal():
104 print(f
"Experiment number ({options.eNumber}) is not valid")
106exp = f
'{int(options.eNumber):04d}'
107if not options.rNumber.isdecimal():
108 print(f
"Run number ({options.rNumber}) is not valid")
110run = f
'{int(options.rNumber):05d}'
112histName = f
'bklmHists-e{exp}r{run}.root'
113pdfName = f
'bklmPlots-e{exp}r{run}.pdf'
115print(
'bklm-windowstart: exp=' + exp +
' run=' + run +
' input=' + inputName +
'. Analyze all events using ' + tagName)
117basf2.conditions.prepend_globaltag(tagName)
119main = basf2.create_path()
120if inputName.find(
".sroot") >= 0:
121 main.add_module(
'SeqRootInput', inputFileNames=fileList)
123 main.add_module(
'RootInput', inputFileName=inputName)
124main.add_module(
'ProgressBar')
128main.add_module(
'KLMReconstructor')
129main.add_module(eventInspector)
132print(basf2.statistics)
def add_unpackers(path, components=None, writeKLMDigitRaws=False, addTOPRelations=False)