2 from PhysicsTools.Heppy.analyzers.core.Analyzer
import Analyzer
4 from FWCore.PythonUtilities.LumiList
import LumiList
5 from PhysicsTools.Heppy.utils.rltinfo
import RLTInfo
9 '''Apply a json filter, and creates an RLTInfo TTree.
10 See PhysicsTools.HeppyCore.utils.RLTInfo for more information
14 jsonFilter = cfg.Analyzer(
18 The path of the json file to be used is set as a component attribute.
20 The process function returns:
22 - the component is MC or
23 - if the run/lumi pair is in the JSON file
24 - if the json file was not set for this component
25 - False if the component is MC or embed (for H->tau tau),
26 and if the run/lumi pair is not in the JSON file.
29 def __init__(self, cfg_ana, cfg_comp, looperName):
30 super(JSONAnalyzer, self).
__init__(cfg_ana, cfg_comp, looperName)
32 if self.cfg_comp.json
is None:
33 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))
43 self.counters.addCounter(
'JSON')
44 self.
count = self.counters.counter(
'JSON')
45 self.count.register(
'All Lumis')
46 self.count.register(
'Passed Lumis')
49 self.readCollections( event.input )
50 evid = event.input.eventAuxiliary().id()
52 lumi = evid.luminosityBlock()
53 eventId = evid.event()
57 event.eventId = eventId
59 if self.cfg_comp.isMC:
65 self.count.inc(
'All Lumis')
66 if self.lumiList.contains(run,lumi):
67 self.count.inc(
'Passed Lumis')
68 self.rltInfo.add(
'dummy', run, lumi)
75 super(JSONAnalyzer, self).
write(setup)
76 self.rltInfo.write( self.dirName )