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.JSONAnalyzer.JSONAnalyzer Class Reference
Inheritance diagram for core.JSONAnalyzer.JSONAnalyzer:

Public Member Functions

def __init__
 
def beginLoop
 
def process
 
def write
 

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 
32  def __init__(self, cfg_ana, cfg_comp, looperName):
33  super(JSONAnalyzer, self).__init__(cfg_ana, cfg_comp, looperName)
34  if not cfg_comp.isMC:
35  if self.cfg_comp.json is None:
36  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))
37  self.lumiList = LumiList(os.path.expandvars(self.cfg_comp.json))
38  else:
39  self.lumiList = None
40 
41  self.useLumiBlocks = self.cfg_ana.useLumiBlocks if (hasattr(self.cfg_ana,'useLumiBlocks')) else False
42 
43  self.rltInfo = RLTInfo()

Member Function Documentation

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

Definition at line 44 of file JSONAnalyzer.py.

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

Definition at line 60 of file JSONAnalyzer.py.

References core.JSONAnalyzer.JSONAnalyzer.lumiList, core.Analyzer.Analyzer.readCollections(), 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().

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

Definition at line 87 of file JSONAnalyzer.py.

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

87 
88  def write(self, setup):
89  super(JSONAnalyzer, self).write(setup)
90  self.rltInfo.write( self.dirName )
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

Definition at line 40 of file JSONAnalyzer.py.

Referenced by core.SkimAnalyzerCount.SkimAnalyzerCount.process(), and core.JSONAnalyzer.JSONAnalyzer.process().