CMS 3D CMS Logo

Classes | Functions
eventloop Namespace Reference

Classes

class  Module
 

Functions

def eventLoop (modules, inputFile, outputFile, inputTree, wrappedOutputTree, maxEvents=-1, eventRange=None, progress=(10000, sys.stdout), filterOutput=True)
 

Function Documentation

◆ eventLoop()

def eventloop.eventLoop (   modules,
  inputFile,
  outputFile,
  inputTree,
  wrappedOutputTree,
  maxEvents = -1,
  eventRange = None,
  progress = (10000, sys.stdout),
  filterOutput = True 
)

Definition at line 58 of file eventloop.py.

References treeReaderArrayTools.clearExtraBranches(), nano_mu_digi_cff.float, SiStripPI.max, SiStripPI.min, FastTimerService_cff.range, and writeEcalDQMStatus.write.

Referenced by eventloop.Module.addObjectList().

58 ):
59  for m in modules:
60  m.beginFile(inputFile, outputFile, inputTree, wrappedOutputTree)
61 
62  t0 = time.time()
63  tlast = t0
64  doneEvents = 0
65  acceptedEvents = 0
66  entries = inputTree.entries
67  if eventRange:
68  entries = len(eventRange)
69  if maxEvents > 0:
70  entries = min(entries, maxEvents)
71 
72  for ie, i in enumerate(range(entries) if eventRange == None else eventRange):
73  if maxEvents > 0 and ie >= maxEvents:
74  break
75  e = Event(inputTree, i)
76  clearExtraBranches(inputTree)
77  doneEvents += 1
78  ret = True
79  for m in modules:
80  ret = m.analyze(e)
81  if not ret:
82  break
83  if ret:
84  acceptedEvents += 1
85  if (ret or not filterOutput) and wrappedOutputTree != None:
86  wrappedOutputTree.fill()
87  if progress:
88  if ie > 0 and ie % progress[0] == 0:
89  t1 = time.time()
90  progress[1].write("Processed %8d/%8d entries, %5.2f%% (elapsed time %7.1fs, curr speed %8.3f kHz, avg speed %8.3f kHz), accepted %8d/%8d events (%5.2f%%)\n" % (
91  ie, entries, ie / float(0.01 * entries),
92  t1 - t0, (progress[0] / 1000.) / (max(t1 - tlast, 1e-9)),
93  ie / 1000. / (max(t1 - t0, 1e-9)),
94  acceptedEvents, doneEvents,
95  acceptedEvents / (0.01 * doneEvents)))
96  tlast = t1
97  for m in modules:
98  m.endFile(inputFile, outputFile, inputTree, wrappedOutputTree)
99  return (doneEvents, acceptedEvents, time.time() - t0)