CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
core.JSONAnalyzer.JSONAnalyzer Class Reference
Inheritance diagram for core.JSONAnalyzer.JSONAnalyzer:

Public Member Functions

def __init__ (self, cfg_ana, cfg_comp, looperName)
 
def beginLoop (self, setup)
 
def process (self, event)
 
def write (self, setup)
 

Public Attributes

 count
 
 lumiList
 
 rltInfo
 
 useLumiBlocks
 

Detailed Description

Apply a json filter, and creates an RLTInfo TTree.
See PhysicsTools.HeppyCore.utils.RLTInfo for more information

example:

jsonFilter = cfg.Analyzer(
  "JSONAnalyzer",
  )

The path of the json file to be used is set as a component attribute.

The process function returns:
  - True if
     - the component is MC or
     - if the run/lumi pair is in the JSON file
     - if the json file was not set for this component
  - False if the component is MC or embed (for H->tau tau),
      and if the run/lumi pair is not in the JSON file.

Definition at line 10 of file JSONAnalyzer.py.

Constructor & Destructor Documentation

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

Definition at line 31 of file JSONAnalyzer.py.

31  def __init__(self, cfg_ana, cfg_comp, looperName):
32  super(JSONAnalyzer, self).__init__(cfg_ana, cfg_comp, looperName)
33  if not cfg_comp.isMC:
34  if self.cfg_comp.json is None:
35  raise ValueError('component {cname} is not MC, and contains no JSON file. Either remove the JSONAnalyzer for your path or set the "json" attribute of this component'.format(cname=cfg_comp.name))
36  self.lumiList = LumiList(os.path.expandvars(self.cfg_comp.json))
37  else:
38  self.lumiList = None
39 
40  self.useLumiBlocks = self.cfg_ana.useLumiBlocks if (hasattr(self.cfg_ana,'useLumiBlocks')) else False
41 
42  self.rltInfo = RLTInfo()
43 
def __init__(self, cfg_ana, cfg_comp, looperName)
Definition: JSONAnalyzer.py:31

Member Function Documentation

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

Definition at line 44 of file JSONAnalyzer.py.

44  def beginLoop(self, setup):
45  super(JSONAnalyzer,self).beginLoop(setup)
46  self.counters.addCounter('JSON')
47  self.count = self.counters.counter('JSON')
48  self.count.register('All Events')
49  self.count.register('Passed Events')
50 
51  if self.useLumiBlocks and not self.cfg_comp.isMC and not self.lumiList is None:
52  lumis = Lumis(self.cfg_comp.files)
53  for lumi in lumis:
54  lumiid = lumi.luminosityBlockAuxiliary().id()
55  run, lumi = lumiid.run(), lumiid.luminosityBlock()
56  if self.lumiList.contains(run,lumi):
57  self.rltInfo.add('dummy', run, lumi)
58 
59 
def core.JSONAnalyzer.JSONAnalyzer.process (   self,
  event 
)

Definition at line 60 of file JSONAnalyzer.py.

References triggerObjects_cff.id, core.JSONAnalyzer.JSONAnalyzer.lumiList, core.Analyzer.Analyzer.readCollections(), and core.JSONAnalyzer.JSONAnalyzer.useLumiBlocks.

60  def process(self, event):
61  self.readCollections( event.input )
62  evid = event.input.eventAuxiliary().id()
63  run = evid.run()
64  lumi = evid.luminosityBlock()
65  eventId = evid.event()
66 
67  event.run = run
68  event.lumi = lumi
69  event.eventId = eventId
70 
71  if self.cfg_comp.isMC:
72  return True
73 
74  if self.lumiList is None:
75  return True
76 
77  self.count.inc('All Events')
78  if self.lumiList.contains(run,lumi):
79  self.count.inc('Passed Events')
80  if not self.useLumiBlocks:
81  self.rltInfo.add('dummy', run, lumi)
82  return True
83  else:
84  return False
85 
86 
def core.JSONAnalyzer.JSONAnalyzer.write (   self,
  setup 
)

Definition at line 87 of file JSONAnalyzer.py.

References addOnTests.testit.dirName, analyzer.Analyzer.dirName, MuonIsolationDQM.dirName, MuIsoValidation.dirName, V0Validator.dirName, VariablePlotter::SubDirectory.dirName, and VariablePlotter::Directory.dirName.

87  def write(self, setup):
88  super(JSONAnalyzer, self).write(setup)
89  self.rltInfo.write( self.dirName )
90 
91 

Member Data Documentation

core.JSONAnalyzer.JSONAnalyzer.count

Definition at line 47 of file JSONAnalyzer.py.

core.JSONAnalyzer.JSONAnalyzer.lumiList

Definition at line 36 of file JSONAnalyzer.py.

Referenced by core.JSONAnalyzer.JSONAnalyzer.process().

core.JSONAnalyzer.JSONAnalyzer.rltInfo

Definition at line 42 of file JSONAnalyzer.py.

core.JSONAnalyzer.JSONAnalyzer.useLumiBlocks