CMS 3D CMS Logo

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__ (self, cfg_ana, cfg_comp, looperName)
 
def beginLoop (self, setup)
 
def declareHandles (self)
 
def process (self, event)
 

Public Attributes

 count
 
 counterHandle
 
 useLumiBlocks
 
 verbose
 

Detailed Description

Definition at line 11 of file SkimAnalyzerCount.py.

Constructor & Destructor Documentation

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

Definition at line 16 of file SkimAnalyzerCount.py.

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
19  self.verbose = getattr(self.cfg_ana, 'verbose', False)
20 
def __init__(self, cfg_ana, cfg_comp, looperName)

Member Function Documentation

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

Definition at line 26 of file SkimAnalyzerCount.py.

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

Definition at line 21 of file SkimAnalyzerCount.py.

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

Definition at line 61 of file SkimAnalyzerCount.py.

References triggerObjects_cff.id, core.Analyzer.Analyzer.mchandles, edm.print(), core.Analyzer.Analyzer.readCollections(), writedatasetfile.run, core.SkimAnalyzerCount.SkimAnalyzerCount.useLumiBlocks, core.JSONAnalyzer.JSONAnalyzer.useLumiBlocks, core.SkimAnalyzerCount.SkimAnalyzerCount.verbose, CSCTFanalyzer.verbose, VisualizationOptions.verbose, L1TdeStage2EMTF.verbose, heppy::Davismt2.verbose, L1TStage2uGMTMuon.verbose, DQMGenericTnPClient.verbose, L1TStage2EMTF.verbose, dqmTnP::AbstractFitter.verbose, L1TStage2uGMT.verbose, L1TStage2MuonComp.verbose, L1TStage2RegionalMuonCandComp.verbose, confdbOfflineConverter.OfflineConverter.verbose, L1TStage2OMTF.verbose, MuonMillepedeAlgorithm.verbose, DeviationsFromFileSensor2D.verbose, L1TStage2BMTF.verbose, L1TCaloLayer1.verbose, L1TCaloLayer1RawToDigi.verbose, HIPAlignmentAlgorithm.verbose, L1TCaloLayer1Validator.verbose, FFTJetCorrectionESProducer< CT >.verbose, FFTJetLookupTableESProducer< CT >.verbose, o2olib.O2OJobMgr.verbose, L1TStage2uGTCaloLayer2Comp.verbose, OpticalObject.verbose, L1TdeStage2CaloLayer2.verbose, and HltDiff.verbose.

61  def process(self, event):
62  if self.verbose:
63  print("\nProcessing run:lumi:event %d:%d:%d" % (
64  event.input.eventAuxiliary().id().run(),
65  event.input.eventAuxiliary().id().luminosityBlock(),
66  event.input.eventAuxiliary().id().event()))
67  if not self.useLumiBlocks:
68  self.readCollections( event.input )
69  self.count.inc('All Events')
70  if self.cfg_comp.isMC:
71  self.count.inc('Sum Weights', self.mchandles['GenInfo'].product().weight())
72  return True

Member Data Documentation

core.SkimAnalyzerCount.SkimAnalyzerCount.count

Definition at line 30 of file SkimAnalyzerCount.py.

core.SkimAnalyzerCount.SkimAnalyzerCount.counterHandle

Definition at line 23 of file SkimAnalyzerCount.py.

core.SkimAnalyzerCount.SkimAnalyzerCount.useLumiBlocks