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 ( )

Definition at line 5 of file PDFWeightsHelper.cc.

5  {
6 
7 }

Member Function Documentation

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

Definition at line 35 of file PDFWeightsHelper.cc.

References neigenvectors(), and transformation_.

Referenced by PDFWeightsTest::analyze().

35  {
36  const unsigned int nreplicas = transformation_.rows();
37  const unsigned int neigenvectors = transformation_.cols();
38 
39  Eigen::VectorXd inweightv(nreplicas);
40  for (unsigned int irep=0; irep<nreplicas; ++irep) {
41  inweightv[irep] = inweights[irep] - nomweight;
42  }
43 
44  Eigen::VectorXd outweightv = transformation_.transpose()*inweightv;
45 
46  for (unsigned int ieig=0; ieig<neigenvectors; ++ieig) {
47  outweights[ieig] = outweightv[ieig] + nomweight;
48  }
49 
50 }
unsigned int neigenvectors() const
Eigen::MatrixXd transformation_
void PDFWeightsHelper::Init ( unsigned int  nreplicas,
unsigned int  neigenvectors,
const edm::FileInPath incsv 
)

Definition at line 9 of file PDFWeightsHelper.cc.

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

Referenced by PDFWeightsTest::PDFWeightsTest().

9  {
10 
11  transformation_.resize(nreplicas,neigenvectors);
12 
13  std::ifstream instream(incsv.fullPath());
14  if (!instream.is_open()) {
15  throw cms::Exception("PDFWeightsHelper")
16  << "Could not open csv file" << incsv.relativePath();
17  }
18 
19 
20  for (unsigned int ireplica = 0; ireplica<nreplicas; ++ireplica) {
21  std::string linestr;
22  getline(instream,linestr);
23  std::istringstream line(linestr);
24  for (unsigned int ieigen = 0; ieigen<neigenvectors; ++ieigen) {
25  std::string valstr;
26  getline(line,valstr,',');
27  std::istringstream val(valstr);
28  val >> transformation_(ireplica,ieigen);
29  }
30 
31  }
32 
33 }
unsigned int neigenvectors() const
Eigen::MatrixXd transformation_
std::string fullPath() const
Definition: FileInPath.cc:197
std::string relativePath() const
Definition: FileInPath.cc:184
unsigned int PDFWeightsHelper::neigenvectors ( ) const
inline

Definition at line 19 of file PDFWeightsHelper.h.

References transformation_.

Referenced by DoMC2Hessian(), and Init().

19 { return transformation_.cols(); }
Eigen::MatrixXd transformation_

Member Data Documentation

Eigen::MatrixXd PDFWeightsHelper::transformation_
protected

Definition at line 23 of file PDFWeightsHelper.h.

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