CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
PiecewiseScalingPolynomial Class Reference

#include <PiecewiseScalingPolynomial.h>

Public Member Functions

bool operator!= (const PiecewiseScalingPolynomial &r) const
 
double operator() (const double x) const
 
bool operator== (const PiecewiseScalingPolynomial &r) const
 
 PiecewiseScalingPolynomial ()
 
 PiecewiseScalingPolynomial (const std::vector< std::vector< double > > &coeffs, const std::vector< double > &limits)
 

Private Member Functions

template<class Archive >
void load (Archive &ar, const unsigned)
 
template<class Archive >
void save (Archive &ar, const unsigned) const
 
bool validate () const
 

Private Attributes

std::vector< std::vector< double > > coeffs_
 
std::vector< double > limits_
 

Friends

class boost::serialization::access
 

Detailed Description

Definition at line 9 of file PiecewiseScalingPolynomial.h.

Constructor & Destructor Documentation

PiecewiseScalingPolynomial::PiecewiseScalingPolynomial ( )
inline

Definition at line 12 of file PiecewiseScalingPolynomial.h.

12 {}
PiecewiseScalingPolynomial::PiecewiseScalingPolynomial ( const std::vector< std::vector< double > > &  coeffs,
const std::vector< double > &  limits 
)

Definition at line 5 of file PiecewiseScalingPolynomial.cc.

References Exception, and validate().

8  : coeffs_(coeffs),
9  limits_(limits)
10 {
11  if (!validate()) throw cms::Exception(
12  "Invalid PiecewiseScalingPolynomial constructor arguments");
13 }
std::vector< std::vector< double > > coeffs_

Member Function Documentation

template<class Archive >
void PiecewiseScalingPolynomial::load ( Archive &  ar,
const unsigned   
)
inlineprivate

Definition at line 66 of file PiecewiseScalingPolynomial.h.

References Exception, limits_, and validate().

Referenced by MatrixToProcess.MatrixToProcess::getProcess(), and MatrixToProcess.MatrixToProcess::listAll().

67  {
68  ar & coeffs_ & limits_;
69  if (!validate()) throw cms::Exception(
70  "In PiecewiseScalingPolynomial::load: invalid data");
71  }
std::vector< std::vector< double > > coeffs_
bool PiecewiseScalingPolynomial::operator!= ( const PiecewiseScalingPolynomial r) const
inline

Definition at line 46 of file PiecewiseScalingPolynomial.h.

References alignCSCRings::r, and validate().

47  {return !(*this == r);}
double PiecewiseScalingPolynomial::operator() ( const double  x) const
inline

Definition at line 18 of file PiecewiseScalingPolynomial.h.

References a, EnergyCorrector::c, coeffs_, limits_, Scenarios_cff::scale, mitigatedMETSequence_cff::U, eostools::which(), and x.

19  {
20  double scale(0.0);
21  if (x > 0.0)
22  {
23  const unsigned nLimits(limits_.size());
24  if (nLimits)
25  {
26  const double* limits(&limits_[0]);
27  unsigned which(0U);
28  for (; which<nLimits; ++which)
29  if (x < limits[which])
30  break;
31  const std::vector<double>& c(coeffs_[which]);
32  const double* a = &c[0];
33  for (int deg = c.size()-1; deg >= 0; --deg)
34  {
35  scale *= x;
36  scale += a[deg];
37  }
38  }
39  }
40  return scale*x;
41  }
std::vector< std::vector< double > > coeffs_
double a
Definition: hdecay.h:121
def which(cmd)
Definition: eostools.py:335
bool PiecewiseScalingPolynomial::operator== ( const PiecewiseScalingPolynomial r) const
inline

Definition at line 43 of file PiecewiseScalingPolynomial.h.

References coeffs_, and limits_.

44  {return coeffs_ == r.coeffs_ && limits_ == r.limits_;}
std::vector< std::vector< double > > coeffs_
template<class Archive >
void PiecewiseScalingPolynomial::save ( Archive &  ar,
const unsigned   
) const
inlineprivate

Definition at line 58 of file PiecewiseScalingPolynomial.h.

References Exception, limits_, and validate().

Referenced by Vispa.Main.TabController.TabController::allowClose(), Vispa.Main.TabController.TabController::checkModificationTimestamp(), and SpecificationBuilder_cfi.Specification::saveAll().

59  {
60  if (!validate()) throw cms::Exception(
61  "In PiecewiseScalingPolynomial::save: invalid data");
62  ar & coeffs_ & limits_;
63  }
std::vector< std::vector< double > > coeffs_
bool PiecewiseScalingPolynomial::validate ( ) const
private

Definition at line 15 of file PiecewiseScalingPolynomial.cc.

References coeffs_, relativeConstraints::empty, mps_fire::i, limits_, and findQualityFiles::size.

Referenced by load(), operator!=(), PiecewiseScalingPolynomial(), and save().

16 {
17  const std::size_t nLimits(limits_.size());
18  if (!nLimits)
19  return false;
20  if (nLimits >= static_cast<std::size_t>(UINT_MAX))
21  return false;
22  if (limits_[0] <= 0.0)
23  return false;
24  for (std::size_t i=0; i<nLimits-1; ++i)
25  if (!(limits_[i] < limits_[i+1]))
26  return false;
27  if (coeffs_.size() != nLimits + 1)
28  return false;
29  for (std::size_t i=0; i<=nLimits; ++i)
30  {
31  if (coeffs_[i].empty())
32  return false;
33  if (coeffs_[i].size() >= static_cast<std::size_t>(INT_MAX))
34  return false;
35  }
36  return true;
37 }
size
Write out results.
std::vector< std::vector< double > > coeffs_

Friends And Related Function Documentation

friend class boost::serialization::access
friend

Definition at line 55 of file PiecewiseScalingPolynomial.h.

Member Data Documentation

std::vector<std::vector<double> > PiecewiseScalingPolynomial::coeffs_
private

Definition at line 52 of file PiecewiseScalingPolynomial.h.

Referenced by operator()(), operator==(), and validate().

std::vector<double> PiecewiseScalingPolynomial::limits_
private

Definition at line 53 of file PiecewiseScalingPolynomial.h.

Referenced by load(), operator()(), operator==(), save(), and validate().