CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
heppy::PdfWeightProducerTool Class Reference

#include <PdfWeightProducerTool.h>

Public Member Functions

void addPdfSet (const std::string &name)
 
void beginJob ()
 
const std::vector< double > & getWeights (const std::string &name) const
 
 PdfWeightProducerTool ()
 
void processEvent (const GenEventInfoProduct &pdfstuff)
 

Private Attributes

std::vector< std::string > pdfs_
 
std::map< std::string, std::vector< double > > weights_
 

Detailed Description

Definition at line 16 of file PdfWeightProducerTool.h.

Constructor & Destructor Documentation

◆ PdfWeightProducerTool()

heppy::PdfWeightProducerTool::PdfWeightProducerTool ( )
inline

Definition at line 18 of file PdfWeightProducerTool.h.

18 {}

Member Function Documentation

◆ addPdfSet()

void heppy::PdfWeightProducerTool::addPdfSet ( const std::string &  name)

Definition at line 18 of file PdfWeightProducerTool.cc.

References Skims_PA_cff::name, pdfs_, and weights_.

18  {
19  pdfs_.push_back(name);
20  weights_[name] = std::vector<double>();
21  }
std::vector< std::string > pdfs_
std::map< std::string, std::vector< double > > weights_

◆ beginJob()

void heppy::PdfWeightProducerTool::beginJob ( void  )

Definition at line 23 of file PdfWeightProducerTool.cc.

References mps_fire::i, LHAPDF::initPDFSet(), dqmiodumpmetadata::n, and pdfs_.

23  {
24  for (unsigned int i = 0, n = pdfs_.size(); i < n; ++i) {
25  LHAPDF::initPDFSet(i + 1, pdfs_[i]);
26  }
27  }
std::vector< std::string > pdfs_
void initPDFSet(int nset, int setid, int member=0)

◆ getWeights()

const std::vector< double > & heppy::PdfWeightProducerTool::getWeights ( const std::string &  name) const

Definition at line 56 of file PdfWeightProducerTool.cc.

References cms::cuda::assert(), Skims_PA_cff::name, and weights_.

56  {
57  std::map<std::string, std::vector<double> >::const_iterator match = weights_.find(name);
58  assert(match != weights_.end());
59  return match->second;
60  }
std::map< std::string, std::vector< double > > weights_
assert(be >=bs)
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10

◆ processEvent()

void heppy::PdfWeightProducerTool::processEvent ( const GenEventInfoProduct pdfstuff)

Definition at line 29 of file PdfWeightProducerTool.cc.

References mps_fire::i, gen::PdfInfo::id, globals_cff::id1, globals_cff::id2, dqmiolumiharvest::j, dqmiodumpmetadata::n, LHAPDF::numberPDF(), GenEventInfoProduct::pdf(), pdfs_, gen::PdfInfo::scalePDF, LHAPDF::usePDFMember(), hltDeepSecondaryVertexTagInfosPFPuppi_cfi::weights, weights_, gen::PdfInfo::x, LHAPDF::xfx(), and gen::PdfInfo::xPDF.

29  {
30  float Q = pdfstuff.pdf()->scalePDF;
31 
32  int id1 = pdfstuff.pdf()->id.first;
33  double x1 = pdfstuff.pdf()->x.first;
34  double pdf1 = pdfstuff.pdf()->xPDF.first;
35 
36  int id2 = pdfstuff.pdf()->id.second;
37  double x2 = pdfstuff.pdf()->x.second;
38  double pdf2 = pdfstuff.pdf()->xPDF.second;
39 
40  for (unsigned int i = 0, n = pdfs_.size(); i < n; ++i) {
41  std::vector<double> &weights = weights_[pdfs_[i]];
42  unsigned int nweights = 1;
43  if (LHAPDF::numberPDF(i + 1) > 1)
44  nweights += LHAPDF::numberPDF(i + 1);
45  weights.resize(nweights);
46 
47  for (unsigned int j = 0; j < nweights; ++j) {
48  LHAPDF::usePDFMember(i + 1, j);
49  double newpdf1 = LHAPDF::xfx(i + 1, x1, Q, id1) / x1;
50  double newpdf2 = LHAPDF::xfx(i + 1, x2, Q, id2) / x2;
51  weights[j] = newpdf1 / pdf1 * newpdf2 / pdf2;
52  }
53  }
54  }
std::vector< std::string > pdfs_
std::pair< double, double > x
Definition: PdfInfo.h:13
std::map< std::string, std::vector< double > > weights_
std::pair< double, double > xPDF
Definition: PdfInfo.h:14
int numberPDF(int nset)
std::pair< int, int > id
Definition: PdfInfo.h:12
const PDF * pdf() const
double xfx(int nset, double x, double Q, int fl)
double scalePDF
Definition: PdfInfo.h:15
void usePDFMember(int nset, int member)

Member Data Documentation

◆ pdfs_

std::vector<std::string> heppy::PdfWeightProducerTool::pdfs_
private

Definition at line 25 of file PdfWeightProducerTool.h.

Referenced by addPdfSet(), beginJob(), and processEvent().

◆ weights_

std::map<std::string, std::vector<double> > heppy::PdfWeightProducerTool::weights_
private

Definition at line 26 of file PdfWeightProducerTool.h.

Referenced by addPdfSet(), getWeights(), and processEvent().