3 from PhysicsTools.Heppy.analyzers.core.Analyzer
import Analyzer
5 from FWCore.PythonUtilities.LumiList
import LumiList
6 from PhysicsTools.Heppy.utils.rltinfo
import RLTInfo
10 '''Apply a json filter, and creates an RLTInfo TTree.
11 See PhysicsTools.HeppyCore.utils.RLTInfo for more information
15 jsonFilter = cfg.Analyzer(
19 The path of the json file to be used is set as a component attribute.
21 The process function returns:
23 - the component is MC or
24 - if the run/lumi pair is in the JSON file
25 - if the json file was not set for this component
26 - False if the component is MC or embed (for H->tau tau),
27 and if the run/lumi pair is not in the JSON file.
30 def __init__(self, cfg_ana, cfg_comp, looperName):
31 super(JSONAnalyzer, self).
__init__(cfg_ana, cfg_comp, looperName)
33 if self.cfg_comp.json
is None:
34 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))
44 self.counters.addCounter(
'JSON')
45 self.
count = self.counters.counter(
'JSON')
46 self.count.register(
'All Lumis')
47 self.count.register(
'Passed Lumis')
50 self.readCollections( event.input )
51 evid = event.input.eventAuxiliary().id()
53 lumi = evid.luminosityBlock()
54 eventId = evid.event()
58 event.eventId = eventId
60 if self.cfg_comp.isMC:
66 self.count.inc(
'All Lumis')
67 if self.lumiList.contains(run,lumi):
68 self.count.inc(
'Passed Lumis')
69 self.rltInfo.add(
'dummy', run, lumi)
76 super(JSONAnalyzer, self).
write(setup)
77 self.rltInfo.write( self.dirName )