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 11 of file PiecewiseScalingPolynomial.h.

Constructor & Destructor Documentation

◆ PiecewiseScalingPolynomial() [1/2]

PiecewiseScalingPolynomial::PiecewiseScalingPolynomial ( )
inline

Definition at line 13 of file PiecewiseScalingPolynomial.h.

13 {}

◆ PiecewiseScalingPolynomial() [2/2]

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

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

Member Function Documentation

◆ load()

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

Definition at line 60 of file PiecewiseScalingPolynomial.h.

References coeffs_, Exception, limits_, and validate().

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

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

◆ operator!=()

bool PiecewiseScalingPolynomial::operator!= ( const PiecewiseScalingPolynomial r) const
inline

Definition at line 42 of file PiecewiseScalingPolynomial.h.

References alignCSCRings::r.

42 { return !(*this == r); }

◆ operator()()

double PiecewiseScalingPolynomial::operator() ( const double  x) const
inline

Definition at line 17 of file PiecewiseScalingPolynomial.h.

References a, DummyCfis::c, coeffs_, TH2PolyOfflineMaps::limits, limits_, isotrackNtupler::scale, mitigatedMETSequence_cff::U, eostools::which(), and x.

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

◆ operator==()

bool PiecewiseScalingPolynomial::operator== ( const PiecewiseScalingPolynomial r) const
inline

Definition at line 38 of file PiecewiseScalingPolynomial.h.

References coeffs_, limits_, and alignCSCRings::r.

38  {
39  return coeffs_ == r.coeffs_ && limits_ == r.limits_;
40  }
std::vector< std::vector< double > > coeffs_

◆ save()

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

Definition at line 53 of file PiecewiseScalingPolynomial.h.

References coeffs_, Exception, limits_, and validate().

Referenced by SpecificationBuilder_cfi.Specification::saveAll().

53  {
54  if (!validate())
55  throw cms::Exception("In PiecewiseScalingPolynomial::save: invalid data");
56  ar & coeffs_ & limits_;
57  }
std::vector< std::vector< double > > coeffs_

◆ validate()

bool PiecewiseScalingPolynomial::validate ( ) const
private

Definition at line 12 of file PiecewiseScalingPolynomial.cc.

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

Referenced by load(), PiecewiseScalingPolynomial(), and save().

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

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Definition at line 50 of file PiecewiseScalingPolynomial.h.

Member Data Documentation

◆ coeffs_

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

Definition at line 47 of file PiecewiseScalingPolynomial.h.

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

◆ limits_

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

Definition at line 48 of file PiecewiseScalingPolynomial.h.

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