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