1 from PhysicsTools.Heppy.analyzers.core.Analyzer
import Analyzer
2 from PhysicsTools.Heppy.analyzers.core.AutoHandle
import AutoHandle
8 def __init__(self, cfg_ana, cfg_comp, looperName ):
9 super(PDFWeightsAnalyzer,self).
__init__(cfg_ana,cfg_comp,looperName)
10 self.
doPDFWeights = hasattr(self.cfg_ana,
"PDFWeights")
and len(self.cfg_ana.PDFWeights) > 0
11 self.
doPDFVars = hasattr(self.cfg_ana,
"doPDFVars")
and self.cfg_ana.doPDFVars ==
True
23 self.mchandles[
'pdfstuff'] = AutoHandle(
'generator',
'GenEventInfoProduct' )
26 super(PDFWeightsAnalyzer,self).
beginLoop(setup)
29 from ROOT
import PdfWeightProducerTool
32 for pdf
in self.cfg_ana.PDFWeights:
33 self.pdfWeightTool.addPdfSet(pdf+
".LHgrid")
34 self.pdfWeightTool.beginJob()
38 self.pdfWeightTool.processEvent(self.
genInfo)
40 for pdf
in self.cfg_ana.PDFWeights:
41 ws = self.pdfWeightTool.getWeights(pdf+
".LHgrid")
42 event.pdfWeights[pdf] = [w
for w
in ws]
45 self.readCollections( event.input )
48 if not self.cfg_comp.isMC:
52 self.
genInfo = self.mchandles[
'pdfstuff'].product()
56 event.pdf_x1 = self.genInfo.pdf().x.first
57 event.pdf_x2 = self.genInfo.pdf().x.second
58 event.pdf_id1 = self.genInfo.pdf().id.first
59 event.pdf_id2 = self.genInfo.pdf().id.second
60 event.pdf_scale = self.genInfo.pdf().scalePDF
64 setattr(PDFWeightsAnalyzer,
"defaultConfig",
65 cfg.Analyzer(PDFWeightsAnalyzer,