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.

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

References Exception, and validate().

Member Function Documentation

◆ load()

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

Definition at line 60 of file PiecewiseScalingPolynomial.h.

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

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

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

◆ operator!=()

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

Definition at line 42 of file PiecewiseScalingPolynomial.h.

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

References alignCSCRings::r.

◆ operator()()

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

Definition at line 17 of file PiecewiseScalingPolynomial.h.

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  }

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

◆ operator==()

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

Definition at line 38 of file PiecewiseScalingPolynomial.h.

38  {
39  return coeffs_ == r.coeffs_ && limits_ == r.limits_;
40  }

References coeffs_, limits_, and alignCSCRings::r.

◆ save()

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

Definition at line 53 of file PiecewiseScalingPolynomial.h.

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

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

Referenced by SpecificationBuilder_cfi.Specification::saveAll().

◆ validate()

bool PiecewiseScalingPolynomial::validate ( ) const
private

Definition at line 12 of file PiecewiseScalingPolynomial.cc.

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 }

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

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

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

mps_fire.i
i
Definition: mps_fire.py:428
L1EGammaCrystalsEmulatorProducer_cfi.scale
scale
Definition: L1EGammaCrystalsEmulatorProducer_cfi.py:10
DDAxes::x
PiecewiseScalingPolynomial::limits_
std::vector< double > limits_
Definition: PiecewiseScalingPolynomial.h:48
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
a
double a
Definition: hdecay.h:119
PiecewiseScalingPolynomial::validate
bool validate() const
Definition: PiecewiseScalingPolynomial.cc:12
alignCSCRings.r
r
Definition: alignCSCRings.py:93
TH2PolyOfflineMaps.limits
limits
Definition: TH2PolyOfflineMaps.py:45
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
Exception
Definition: hltDiff.cc:245
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
PiecewiseScalingPolynomial::coeffs_
std::vector< std::vector< double > > coeffs_
Definition: PiecewiseScalingPolynomial.h:47
eostools.which
def which(cmd)
Definition: eostools.py:336
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443