CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Attributes
PDFWeightsHelper Class Reference

#include <PDFWeightsHelper.h>

Public Member Functions

void DoMC2Hessian (double nomweight, const double *inweights, double *outweights) const
 
void Init (unsigned int nreplicas, unsigned int neigenvectors, const edm::FileInPath &incsv)
 
unsigned int neigenvectors () const
 
 PDFWeightsHelper ()
 

Protected Attributes

Eigen::MatrixXd transformation_
 

Detailed Description

Definition at line 10 of file PDFWeightsHelper.h.

Constructor & Destructor Documentation

◆ PDFWeightsHelper()

PDFWeightsHelper::PDFWeightsHelper ( )

Definition at line 5 of file PDFWeightsHelper.cc.

5 {}

Member Function Documentation

◆ DoMC2Hessian()

void PDFWeightsHelper::DoMC2Hessian ( double  nomweight,
const double *  inweights,
double *  outweights 
) const

Definition at line 28 of file PDFWeightsHelper.cc.

28  {
29  const unsigned int nreplicas = transformation_.rows();
30  const unsigned int neigenvectors = transformation_.cols();
31 
32  Eigen::VectorXd inweightv(nreplicas);
33  for (unsigned int irep = 0; irep < nreplicas; ++irep) {
34  inweightv[irep] = inweights[irep] - nomweight;
35  }
36 
37  Eigen::VectorXd outweightv = transformation_.transpose() * inweightv;
38 
39  for (unsigned int ieig = 0; ieig < neigenvectors; ++ieig) {
40  outweights[ieig] = outweightv[ieig] + nomweight;
41  }
42 }

References neigenvectors(), and transformation_.

Referenced by PDFWeightsTest::analyze().

◆ Init()

void PDFWeightsHelper::Init ( unsigned int  nreplicas,
unsigned int  neigenvectors,
const edm::FileInPath incsv 
)

Definition at line 7 of file PDFWeightsHelper.cc.

7  {
8  transformation_.resize(nreplicas, neigenvectors);
9 
10  std::ifstream instream(incsv.fullPath());
11  if (!instream.is_open()) {
12  throw cms::Exception("PDFWeightsHelper") << "Could not open csv file" << incsv.relativePath();
13  }
14 
15  for (unsigned int ireplica = 0; ireplica < nreplicas; ++ireplica) {
16  std::string linestr;
17  getline(instream, linestr);
18  std::istringstream line(linestr);
19  for (unsigned int ieigen = 0; ieigen < neigenvectors; ++ieigen) {
20  std::string valstr;
21  getline(line, valstr, ',');
22  std::istringstream val(valstr);
23  val >> transformation_(ireplica, ieigen);
24  }
25  }
26 }

References Exception, edm::FileInPath::fullPath(), mps_splice::line, neigenvectors(), edm::FileInPath::relativePath(), AlCaHLTBitMon_QueryRunRegistry::string, transformation_, and heppy_batch::val.

Referenced by PDFWeightsTest::PDFWeightsTest().

◆ neigenvectors()

unsigned int PDFWeightsHelper::neigenvectors ( ) const
inline

Definition at line 17 of file PDFWeightsHelper.h.

17 { return transformation_.cols(); }

References transformation_.

Referenced by DoMC2Hessian(), and Init().

Member Data Documentation

◆ transformation_

Eigen::MatrixXd PDFWeightsHelper::transformation_
protected

Definition at line 20 of file PDFWeightsHelper.h.

Referenced by DoMC2Hessian(), Init(), and neigenvectors().

PDFWeightsHelper::neigenvectors
unsigned int neigenvectors() const
Definition: PDFWeightsHelper.h:17
PDFWeightsHelper::transformation_
Eigen::MatrixXd transformation_
Definition: PDFWeightsHelper.h:20
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
heppy_batch.val
val
Definition: heppy_batch.py:351
Exception
Definition: hltDiff.cc:245
edm::FileInPath::relativePath
std::string relativePath() const
Definition: FileInPath.cc:157
mps_splice.line
line
Definition: mps_splice.py:76
riemannFit::VectorXd
Eigen::VectorXd VectorXd
Definition: FitUtils.h:12
edm::FileInPath::fullPath
std::string fullPath() const
Definition: FileInPath.cc:161