CMS 3D CMS Logo

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

#include <HcalInterpolatedTableFunctor.h>

Inheritance diagram for HcalInterpolatedTableFunctor:
AbsHcalFunctor

Public Member Functions

 HcalInterpolatedTableFunctor ()
 
 HcalInterpolatedTableFunctor (const std::vector< double > &values, double xmin, double xmax, bool leftExtrapolationLinear, bool rightExtrapolationLinear)
 
HcalPiecewiseLinearFunctor inverse () const
 
bool isStrictlyMonotonous () const
 
double operator() (double x) const override
 
double xmax () const override
 
double xmin () const override
 
 ~HcalInterpolatedTableFunctor () override
 
- Public Member Functions inherited from AbsHcalFunctor
bool operator!= (const AbsHcalFunctor &r) const
 
bool operator== (const AbsHcalFunctor &r) const
 
virtual ~AbsHcalFunctor ()
 

Protected Member Functions

bool isEqual (const AbsHcalFunctor &other) const override
 

Private Member Functions

template<class Archive >
void serialize (Archive &ar, unsigned)
 

Private Attributes

bool leftExtrapolationLinear_
 
bool rightExtrapolationLinear_
 
std::vector< double > values_
 
double xmax_
 
double xmin_
 

Friends

class boost::serialization::access
 

Additional Inherited Members

- Static Protected Member Functions inherited from AbsHcalFunctor
template<class Iter >
static bool isStrictlyDecreasing (Iter begin, Iter const end)
 
template<class Iter >
static bool isStrictlyIncreasing (Iter begin, Iter const end)
 

Detailed Description

Definition at line 10 of file HcalInterpolatedTableFunctor.h.

Constructor & Destructor Documentation

◆ HcalInterpolatedTableFunctor() [1/2]

HcalInterpolatedTableFunctor::HcalInterpolatedTableFunctor ( )

Definition at line 11 of file HcalInterpolatedTableFunctor.cc.

◆ HcalInterpolatedTableFunctor() [2/2]

HcalInterpolatedTableFunctor::HcalInterpolatedTableFunctor ( const std::vector< double > &  values,
double  xmin,
double  xmax,
bool  leftExtrapolationLinear,
bool  rightExtrapolationLinear 
)

Definition at line 14 of file HcalInterpolatedTableFunctor.cc.

19  : values_(values),
20  xmin_(ixmin),
21  xmax_(ixmax),
24  if (values_.size() < 2)
25  throw cms::Exception(
26  "In HcalInterpolatedTableFunctor constructor:"
27  " insufficient number of points");
28  if (xmin_ >= xmax_)
29  throw cms::Exception(
30  "In HcalInterpolatedTableFunctor constructor:"
31  " invalid min and/or max coordinates");
32 }

References Exception, values_, xmax_, and xmin_.

◆ ~HcalInterpolatedTableFunctor()

HcalInterpolatedTableFunctor::~HcalInterpolatedTableFunctor ( )
inlineoverride

Definition at line 32 of file HcalInterpolatedTableFunctor.h.

32 {}

Member Function Documentation

◆ inverse()

HcalPiecewiseLinearFunctor HcalInterpolatedTableFunctor::inverse ( ) const

Definition at line 64 of file HcalInterpolatedTableFunctor.cc.

64  {
65  if (!isStrictlyMonotonous())
66  throw cms::Exception(
67  "In HcalInterpolatedTableFunctor::inverse:"
68  " can't invert non-monotonous functor");
69  const std::size_t sz = values_.size();
70  const std::size_t szm1 = sz - 1;
71  const double step = (xmax_ - xmin_) / szm1;
72  std::vector<std::pair<double, double> > points;
73  points.reserve(sz);
74  for (std::size_t i = 0; i < sz; ++i) {
75  const double x = (i == szm1 ? xmax_ : xmin_ + step * i);
76  points.push_back(std::make_pair(values_[i], x));
77  }
80  if (values_[0] > values_[sz - 1])
81  std::swap(l, r);
83 }

References Exception, mps_fire::i, isStrictlyMonotonous(), cmsLHEtoEOSManager::l, leftExtrapolationLinear_, HLT_FULL_cff::points, alignCSCRings::r, rightExtrapolationLinear_, std::swap(), values_, x, xmax_, and xmin_.

◆ isEqual()

bool HcalInterpolatedTableFunctor::isEqual ( const AbsHcalFunctor other) const
inlineoverrideprotectedvirtual

Implements AbsHcalFunctor.

Definition at line 46 of file HcalInterpolatedTableFunctor.h.

46  {
47  const HcalInterpolatedTableFunctor& r = static_cast<const HcalInterpolatedTableFunctor&>(other);
48  return values_ == r.values_ && xmin_ == r.xmin_ && xmax_ == r.xmax_ &&
49  leftExtrapolationLinear_ == r.leftExtrapolationLinear_ &&
50  rightExtrapolationLinear_ == r.rightExtrapolationLinear_;
51  }

References leftExtrapolationLinear_, trackingPlots::other, alignCSCRings::r, rightExtrapolationLinear_, values_, xmax_, and xmin_.

◆ isStrictlyMonotonous()

bool HcalInterpolatedTableFunctor::isStrictlyMonotonous ( ) const

Definition at line 60 of file HcalInterpolatedTableFunctor.cc.

60  {
61  return isStrictlyIncreasing(values_.begin(), values_.end()) || isStrictlyDecreasing(values_.begin(), values_.end());
62 }

References AbsHcalFunctor::isStrictlyDecreasing(), AbsHcalFunctor::isStrictlyIncreasing(), and values_.

Referenced by inverse().

◆ operator()()

double HcalInterpolatedTableFunctor::operator() ( double  x) const
overridevirtual

Implements AbsHcalFunctor.

Definition at line 34 of file HcalInterpolatedTableFunctor.cc.

34  {
35  double result = 0.0;
36  const std::size_t sz = values_.size();
37  const std::size_t szm1 = sz - 1;
38  const double step = (xmax_ - xmin_) / szm1;
39 
40  if (x >= xmax_) {
42  result = interpolateStep(xmax_ - step, step, values_[sz - 2], values_[szm1], x);
43  else
44  result = values_[szm1];
45  } else if (x <= xmin_) {
48  else
49  result = values_[0];
50  } else {
51  const std::size_t ux = static_cast<std::size_t>((x - xmin_) / step);
52  if (ux >= szm1)
53  return values_[szm1];
54  result = interpolateStep(ux * step + xmin_, step, values_[ux], values_[ux + 1], x);
55  }
56 
57  return result;
58 }

References interpolateStep(), leftExtrapolationLinear_, mps_fire::result, rightExtrapolationLinear_, values_, x, xmax_, and xmin_.

◆ serialize()

template<class Archive >
void HcalInterpolatedTableFunctor::serialize ( Archive &  ar,
unsigned   
)
inlineprivate

Definition at line 63 of file HcalInterpolatedTableFunctor.h.

63  {
64  boost::serialization::base_object<AbsHcalFunctor>(*this);
66  }

References leftExtrapolationLinear_, rightExtrapolationLinear_, values_, xmax_, and xmin_.

◆ xmax()

double HcalInterpolatedTableFunctor::xmax ( ) const
inlineoverridevirtual

Reimplemented from AbsHcalFunctor.

Definition at line 36 of file HcalInterpolatedTableFunctor.h.

36 { return xmax_; }

References xmax_.

Referenced by svgfig.XAxis::__repr__().

◆ xmin()

double HcalInterpolatedTableFunctor::xmin ( ) const
inlineoverridevirtual

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Definition at line 60 of file HcalInterpolatedTableFunctor.h.

Member Data Documentation

◆ leftExtrapolationLinear_

bool HcalInterpolatedTableFunctor::leftExtrapolationLinear_
private

Definition at line 57 of file HcalInterpolatedTableFunctor.h.

Referenced by inverse(), isEqual(), operator()(), and serialize().

◆ rightExtrapolationLinear_

bool HcalInterpolatedTableFunctor::rightExtrapolationLinear_
private

Definition at line 58 of file HcalInterpolatedTableFunctor.h.

Referenced by inverse(), isEqual(), operator()(), and serialize().

◆ values_

std::vector<double> HcalInterpolatedTableFunctor::values_
private

◆ xmax_

double HcalInterpolatedTableFunctor::xmax_
private

◆ xmin_

double HcalInterpolatedTableFunctor::xmin_
private
mps_fire.i
i
Definition: mps_fire.py:428
AbsHcalFunctor::isStrictlyDecreasing
static bool isStrictlyDecreasing(Iter begin, Iter const end)
Definition: AbsHcalFunctor.h:56
HLT_FULL_cff.points
points
Definition: HLT_FULL_cff.py:21455
step
step
Definition: StallMonitor.cc:94
HcalInterpolatedTableFunctor
Definition: HcalInterpolatedTableFunctor.h:10
HcalInterpolatedTableFunctor::xmin_
double xmin_
Definition: HcalInterpolatedTableFunctor.h:55
interpolateStep
static double interpolateStep(const double x0, const double step, const double y0, const double y1, const double x)
Definition: HcalInterpolatedTableFunctor.cc:6
HcalInterpolatedTableFunctor::leftExtrapolationLinear_
bool leftExtrapolationLinear_
Definition: HcalInterpolatedTableFunctor.h:57
DDAxes::x
HcalPiecewiseLinearFunctor
Definition: HcalPiecewiseLinearFunctor.h:17
AbsHcalFunctor::isStrictlyIncreasing
static bool isStrictlyIncreasing(Iter begin, Iter const end)
Definition: AbsHcalFunctor.h:43
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
HcalInterpolatedTableFunctor::values_
std::vector< double > values_
Definition: HcalInterpolatedTableFunctor.h:54
trackingPlots.other
other
Definition: trackingPlots.py:1467
HcalInterpolatedTableFunctor::xmax_
double xmax_
Definition: HcalInterpolatedTableFunctor.h:56
mixed_calib_calo_ttbar_result.leftExtrapolationLinear
leftExtrapolationLinear
Definition: mixed_calib_calo_ttbar_result.py:10
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
alignCSCRings.r
r
Definition: alignCSCRings.py:93
Exception
Definition: hltDiff.cc:246
HcalInterpolatedTableFunctor::rightExtrapolationLinear_
bool rightExtrapolationLinear_
Definition: HcalInterpolatedTableFunctor.h:58
mps_fire.result
result
Definition: mps_fire.py:311
cms::Exception
Definition: Exception.h:70
mixed_calib_calo_ttbar_result.rightExtrapolationLinear
rightExtrapolationLinear
Definition: mixed_calib_calo_ttbar_result.py:11
HcalInterpolatedTableFunctor::isStrictlyMonotonous
bool isStrictlyMonotonous() const
Definition: HcalInterpolatedTableFunctor.cc:60