3 from PhysicsTools.Heppy.analyzers.core.Analyzer
import Analyzer
5 from FWCore.PythonUtilities.LumiList
import LumiList
6 from PhysicsTools.Heppy.utils.rltinfo
import RLTInfo
8 from DataFormats.FWLite
import Lumis
11 '''Apply a json filter, and creates an RLTInfo TTree.
12 See PhysicsTools.HeppyCore.utils.RLTInfo for more information
16 jsonFilter = cfg.Analyzer(
20 The path of the json file to be used is set as a component attribute.
22 The process function returns:
24 - the component is MC or
25 - if the run/lumi pair is in the JSON file
26 - if the json file was not set for this component
27 - False if the component is MC or embed (for H->tau tau),
28 and if the run/lumi pair is not in the JSON file.
31 def __init__(self, cfg_ana, cfg_comp, looperName):
32 super(JSONAnalyzer, self).
__init__(cfg_ana, cfg_comp, looperName)
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))
40 self.
useLumiBlocks = self.cfg_ana.useLumiBlocks
if (hasattr(self.cfg_ana,
'useLumiBlocks'))
else False
46 self.counters.addCounter(
'JSON')
48 self.
count.register(
'All Events')
49 self.
count.register(
'Passed Events')
52 lumis = Lumis(self.cfg_comp.files)
54 lumiid = lumi.luminosityBlockAuxiliary().
id()
55 run, lumi = lumiid.run(), lumiid.luminosityBlock()
61 self.readCollections( event.input )
62 evid = event.input.eventAuxiliary().
id()
64 lumi = evid.luminosityBlock()
65 eventId = evid.event()
69 event.eventId = eventId
71 if self.cfg_comp.isMC:
77 self.
count.inc(
'All Events')
79 self.
count.inc(
'Passed Events')
88 super(JSONAnalyzer, self).
write(setup)