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 60 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().

60 ):
61  for m in modules:
62  m.beginFile(inputFile, outputFile, inputTree, wrappedOutputTree)
63 
64  t0 = time.time()
65  tlast = t0
66  doneEvents = 0
67  acceptedEvents = 0
68  entries = inputTree.entries
69  if eventRange:
70  entries = len(eventRange)
71  if maxEvents > 0:
72  entries = min(entries, maxEvents)
73 
74  for ie, i in enumerate(range(entries) if eventRange == None else eventRange):
75  if maxEvents > 0 and ie >= maxEvents:
76  break
77  e = Event(inputTree, i)
78  clearExtraBranches(inputTree)
79  doneEvents += 1
80  ret = True
81  for m in modules:
82  ret = m.analyze(e)
83  if not ret:
84  break
85  if ret:
86  acceptedEvents += 1
87  if (ret or not filterOutput) and wrappedOutputTree != None:
88  wrappedOutputTree.fill()
89  if progress:
90  if ie > 0 and ie % progress[0] == 0:
91  t1 = time.time()
92  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" % (
93  ie, entries, ie / float(0.01 * entries),
94  t1 - t0, (progress[0] / 1000.) / (max(t1 - tlast, 1e-9)),
95  ie / 1000. / (max(t1 - t0, 1e-9)),
96  acceptedEvents, doneEvents,
97  acceptedEvents / (0.01 * doneEvents)))
98  tlast = t1
99  for m in modules:
100  m.endFile(inputFile, outputFile, inputTree, wrappedOutputTree)
101  return (doneEvents, acceptedEvents, time.time() - t0)