LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
evwgh::WeightCalc Class Referenceabstract

#include "WeightCalc.h"

Inheritance diagram for evwgh::WeightCalc:
evwgh::GenieWeightCalc

Public Member Functions

virtual void Configure (fhicl::ParameterSet const &pset)=0
 
virtual std::vector< std::vector< double > > GetWeight (art::Event &e)=0
 
void SetName (std::string name)
 
std::string GetName ()
 

Static Public Member Functions

static std::vector< std::vector< double > > MultiGaussianSmearing (std::vector< double > const &centralValues, std::vector< std::vector< double >> const &inputCovarianceMatrix, int n_multisims, CLHEP::RandGaussQ &GaussRandom)
 Applies Gaussian smearing to a set of data. More...
 
static std::vector< double > MultiGaussianSmearing (std::vector< double > const &centralValue, TMatrixD *const &inputCovarianceMatrix, std::vector< double > rand)
 Over load of the above function that only returns a single varied parameter set. More...
 
static std::vector< double > MultiGaussianSmearing (std::vector< double > const &centralValue, TMatrixD *const &LowerTriangleCovarianceMatrix, bool isDecomposed, std::vector< double > rand)
 

Private Attributes

std::string fName
 

Detailed Description

Definition at line 18 of file WeightCalc.h.

Member Function Documentation

virtual void evwgh::WeightCalc::Configure ( fhicl::ParameterSet const &  pset)
pure virtual

Implemented in evwgh::GenieWeightCalc.

std::string evwgh::WeightCalc::GetName ( )
inline

Definition at line 24 of file WeightCalc.h.

References fName, MultiGaussianSmearing(), and lar::dump::vector().

Referenced by evwgh::GenieWeightCalc::Configure().

24 {return fName;}
std::string fName
Definition: WeightCalc.h:54
virtual std::vector<std::vector<double> > evwgh::WeightCalc::GetWeight ( art::Event e)
pure virtual

Implemented in evwgh::GenieWeightCalc.

Referenced by evwgh::Weight_t::GetWeight().

static std::vector<std::vector<double> > evwgh::WeightCalc::MultiGaussianSmearing ( std::vector< double > const &  centralValues,
std::vector< std::vector< double >> const &  inputCovarianceMatrix,
int  n_multisims,
CLHEP::RandGaussQ &  GaussRandom 
)
static

Applies Gaussian smearing to a set of data.

Parameters
centralValuesthe values to be smeared
inputCovarianceMatrixcovariance matrix for smearing
n_multisimsnumber of sets of smeared values to be produced
Returns
a set of n_multisims value sets smeared from the central value

If centralValues is of dimension N, inputCovarianceMatrix needs to be NxN, and each of the returned data sets will be also of dimension N.

Referenced by GetName().

std::vector< double > evwgh::WeightCalc::MultiGaussianSmearing ( std::vector< double > const &  centralValue,
TMatrixD *const &  inputCovarianceMatrix,
std::vector< double >  rand 
)
static

Over load of the above function that only returns a single varied parameter set.

Definition at line 106 of file WeightCalc.cxx.

References col, and art::errors::StdException.

107  {
108 
109  //compute the smeared central values
110  std::vector<double> smearedCentralValues;
111 
112  //
113  //perform Choleskey Decomposition
114  //
115  // Best description I have found
116  // is in the PDG (Monte Carlo techniques, Algorithms, Gaussian distribution)
117  //
118  // http://pdg.lbl.gov/2016/reviews/rpp2016-rev-monte-carlo-techniques.pdf (Page 5)
119  //
120  //
121  TDecompChol dc = TDecompChol(*(inputCovarianceMatrix));
122  if(!dc.Decompose())
123  {
125  << "Cannot decompose covariance matrix to begin smearing.";
126  return smearedCentralValues;
127  }
128 
129  //Get upper triangular matrix. This maintains the relations in the
130  //covariance matrix, but simplifies the structure.
131  TMatrixD U = dc.GetU();
132 
133 
134  for(unsigned int col = 0; col < centralValue.size(); ++col)
135  {
136  //find the weight of each col of the upper triangular cov. matrix
137  double weightFromU = 0.;
138 
139  for(unsigned int row = 0; row < col+1; ++row)
140  {
141  weightFromU += U(row,col)*rand[row];
142  }
143 
144  //multiply this weight by each col of the central values to obtain
145  //the gaussian smeared and constrained central values
146  // smearedCentralValues.push_back(weightFromU * centralValue[col]);
147  smearedCentralValues.push_back(weightFromU + centralValue[col]);
148  }
149  return smearedCentralValues;
150  } // WeightCalc::MultiGaussianSmearing() - Gives a single set of smeared parameters
Int_t col[ntarg]
Definition: Style.C:29
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::vector< double > evwgh::WeightCalc::MultiGaussianSmearing ( std::vector< double > const &  centralValue,
TMatrixD *const &  LowerTriangleCovarianceMatrix,
bool  isDecomposed,
std::vector< double >  rand 
)
static

Definition at line 163 of file WeightCalc.cxx.

References col, and art::errors::StdException.

164  {
165 
166  //compute the smeared central values
167  std::vector<double> smearedCentralValues;
168 
169  // This guards against accidentally
170  if(!isDecomposed){
172  << "Must supply the decomposed lower triangular covariance matrix.";
173  return smearedCentralValues;
174  }
175 
176 
177  for(unsigned int col = 0; col < centralValue.size(); ++col)
178  {
179  //find the weight of each col of the upper triangular cov. matrix
180  double weightFromU = 0.;
181 
182  for(unsigned int row = 0; row < col+1; ++row)
183  {
184  weightFromU += LowerTriangleCovarianceMatrix[0][row][col]*rand[row];
185  }
186 
187  //multiply this weight by each col of the central values to obtain
188  //the gaussian smeared and constrained central values
189  // smearedCentralValues.push_back(weightFromU * centralValue[col]);
190  smearedCentralValues.push_back(weightFromU + centralValue[col]);
191  }
192  return smearedCentralValues;
193  } // WeightCalc::MultiGaussianSmearing() - Gives a single set of smeared parameters
Int_t col[ntarg]
Definition: Style.C:29
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
void evwgh::WeightCalc::SetName ( std::string  name)
inline

Definition at line 23 of file WeightCalc.h.

References fName.

23 {fName=name;}
std::string fName
Definition: WeightCalc.h:54

Member Data Documentation

std::string evwgh::WeightCalc::fName
private

Definition at line 54 of file WeightCalc.h.

Referenced by GetName(), and SetName().


The documentation for this class was generated from the following files: