CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes
core.SkimAnalyzerCount.SkimAnalyzerCount Class Reference
Inheritance diagram for core.SkimAnalyzerCount.SkimAnalyzerCount:

Public Member Functions

def __init__
 
def beginLoop
 
def declareHandles
 
def process
 

Public Attributes

 count
 
 counterHandle
 
 useLumiBlocks
 

Detailed Description

Definition at line 10 of file SkimAnalyzerCount.py.

Constructor & Destructor Documentation

def core.SkimAnalyzerCount.SkimAnalyzerCount.__init__ (   self,
  cfg_ana,
  cfg_comp,
  looperName 
)

Definition at line 15 of file SkimAnalyzerCount.py.

15 
16  def __init__(self, cfg_ana, cfg_comp, looperName):
17  super(SkimAnalyzerCount, self).__init__(cfg_ana, cfg_comp, looperName)
18  self.useLumiBlocks = self.cfg_ana.useLumiBlocks if (hasattr(self.cfg_ana,'useLumiBlocks')) else False

Member Function Documentation

def core.SkimAnalyzerCount.SkimAnalyzerCount.beginLoop (   self,
  setup 
)

Definition at line 24 of file SkimAnalyzerCount.py.

24 
25  def beginLoop(self, setup):
26  super(SkimAnalyzerCount,self).beginLoop(setup)
27 
28  self.counters.addCounter('SkimReport')
29  self.count = self.counters.counter('SkimReport')
30  self.count.register('All Events')
31  if self.cfg_comp.isMC:
32  self.count.register('Sum Weights')
33 
34  if not self.useLumiBlocks:
35  #print 'Will actually count events instead of accessing lumi blocks'
36  return True
37 
38  print 'Counting the total events before the skim by accessing luminosity blocks'
39  lumis = Lumis(self.cfg_comp.files)
40  totalEvents=0
41 
42  for lumi in lumis:
43  if lumi.getByLabel('prePathCounter',self.counterHandle):
44  totalEvents+=self.counterHandle.product().value
45  else:
46  self.useLumiBlocks = False
47  break
48 
49 
50  if self.useLumiBlocks:
51  self.count.inc('All Events',totalEvents)
52  if self.cfg_comp.isMC:
53  self.count.inc('Sum Weights',totalEvents)
54  print 'Done -> proceeding with the analysis'
55  else:
56  print 'Failed -> will have to actually count events (this can happen if the input dataset is not a CMG one)'
57 
58 
def core.SkimAnalyzerCount.SkimAnalyzerCount.declareHandles (   self)

Definition at line 19 of file SkimAnalyzerCount.py.

19 
20  def declareHandles(self):
21  super(SkimAnalyzerCount, self).declareHandles()
22  self.counterHandle = Handle("edm::MergeableCounter")
23  self.mchandles['GenInfo'] = AutoHandle( ('generator','',''), 'GenEventInfoProduct' )
def core.SkimAnalyzerCount.SkimAnalyzerCount.process (   self,
  event 
)

Definition at line 59 of file SkimAnalyzerCount.py.

References core.Analyzer.Analyzer.mchandles, core.Analyzer.Analyzer.readCollections(), core.SkimAnalyzerCount.SkimAnalyzerCount.useLumiBlocks, and core.JSONAnalyzer.JSONAnalyzer.useLumiBlocks.

Referenced by ConfigBuilder.ConfigBuilder.addExtraStream(), ConfigBuilder.ConfigBuilder.completeInputCommand(), ConfigBuilder.ConfigBuilder.doNotInlineEventContent(), ConfigBuilder.ConfigBuilder.PrintAllModules.leave(), ConfigBuilder.ConfigBuilder.prepare_HLT(), ConfigBuilder.ConfigBuilder.prepare_LHE(), ConfigBuilder.ConfigBuilder.prepare_PATFILTER(), ConfigBuilder.ConfigBuilder.prepare_VALIDATION(), ConfigBuilder.ConfigBuilder.renameHLTprocessInSequence(), ConfigBuilder.ConfigBuilder.renameInputTagsInSequence(), and ConfigBuilder.ConfigBuilder.scheduleSequence().

59 
60  def process(self, event):
61  if not self.useLumiBlocks:
62  self.readCollections( event.input )
63  self.count.inc('All Events')
64  if self.cfg_comp.isMC:
65  self.count.inc('Sum Weights', self.mchandles['GenInfo'].product().weight())
66  return True
Definition: weight.py:1

Member Data Documentation

core.SkimAnalyzerCount.SkimAnalyzerCount.count

Definition at line 28 of file SkimAnalyzerCount.py.

core.SkimAnalyzerCount.SkimAnalyzerCount.counterHandle

Definition at line 21 of file SkimAnalyzerCount.py.

core.SkimAnalyzerCount.SkimAnalyzerCount.useLumiBlocks

Definition at line 17 of file SkimAnalyzerCount.py.

Referenced by core.SkimAnalyzerCount.SkimAnalyzerCount.process().