CMS 3D CMS Logo

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

#include <HcalPiecewiseLinearFunctor.h>

Inheritance diagram for HcalPiecewiseLinearFunctor:
AbsHcalFunctor

Public Member Functions

 HcalPiecewiseLinearFunctor ()
 
 HcalPiecewiseLinearFunctor (const std::vector< std::pair< double, double > > &points, bool leftExtrapolationLinear, bool rightExtrapolationLinear)
 
HcalPiecewiseLinearFunctor inverse () const
 
bool isStrictlyMonotonous () const
 
double operator() (double x) const override
 
double xmax () const override
 
double xmin () const override
 
 ~HcalPiecewiseLinearFunctor () 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

std::vector< double > abscissae_
 
bool leftExtrapolationLinear_
 
bool rightExtrapolationLinear_
 
std::vector< double > values_
 

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 17 of file HcalPiecewiseLinearFunctor.h.

Constructor & Destructor Documentation

◆ HcalPiecewiseLinearFunctor() [1/2]

HcalPiecewiseLinearFunctor::HcalPiecewiseLinearFunctor ( )

Definition at line 11 of file HcalPiecewiseLinearFunctor.cc.

Referenced by inverse().

◆ HcalPiecewiseLinearFunctor() [2/2]

HcalPiecewiseLinearFunctor::HcalPiecewiseLinearFunctor ( const std::vector< std::pair< double, double > > &  points,
bool  leftExtrapolationLinear,
bool  rightExtrapolationLinear 
)

Definition at line 14 of file HcalPiecewiseLinearFunctor.cc.

18  const std::size_t sz = points.size();
19  if (sz) {
20  std::vector<std::pair<double, double> > tmp(points);
21  std::sort(tmp.begin(), tmp.end());
22  abscissae_.reserve(sz);
23  values_.reserve(sz);
24  for (std::size_t i = 0; i < sz; ++i) {
25  abscissae_.push_back(tmp[i].first);
26  values_.push_back(tmp[i].second);
27  }
28  if (!isStrictlyIncreasing(abscissae_.begin(), abscissae_.end()))
29  throw cms::Exception(
30  "In HcalPiecewiseLinearFunctor constructor:"
31  " abscissae must not coincide");
32  }
33 }

References abscissae_, Exception, first, mps_fire::i, AbsHcalFunctor::isStrictlyIncreasing(), HLT_FULL_cff::points, edm::second(), jetUpdater_cfi::sort, createJobs::tmp, and values_.

◆ ~HcalPiecewiseLinearFunctor()

HcalPiecewiseLinearFunctor::~HcalPiecewiseLinearFunctor ( )
inlineoverride

Definition at line 40 of file HcalPiecewiseLinearFunctor.h.

40 {}

Member Function Documentation

◆ inverse()

HcalPiecewiseLinearFunctor HcalPiecewiseLinearFunctor::inverse ( ) const

Definition at line 65 of file HcalPiecewiseLinearFunctor.cc.

65  {
66  if (!isStrictlyMonotonous())
67  throw cms::Exception(
68  "In HcalPiecewiseLinearFunctor::inverse:"
69  " can't invert non-monotonous functor");
70  const std::size_t sz = abscissae_.size();
71  std::vector<std::pair<double, double> > points;
72  points.reserve(sz);
73  for (std::size_t i = 0; i < sz; ++i)
74  points.push_back(std::make_pair(values_[i], abscissae_[i]));
77  if (values_[0] > values_[sz - 1])
78  std::swap(l, r);
80 }

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

◆ isEqual()

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

Implements AbsHcalFunctor.

Definition at line 54 of file HcalPiecewiseLinearFunctor.h.

54  {
55  const HcalPiecewiseLinearFunctor& r = static_cast<const HcalPiecewiseLinearFunctor&>(other);
56  return abscissae_ == r.abscissae_ && values_ == r.values_ &&
57  leftExtrapolationLinear_ == r.leftExtrapolationLinear_ &&
58  rightExtrapolationLinear_ == r.rightExtrapolationLinear_;
59  }

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

◆ isStrictlyMonotonous()

bool HcalPiecewiseLinearFunctor::isStrictlyMonotonous ( ) const

Definition at line 61 of file HcalPiecewiseLinearFunctor.cc.

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

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

Referenced by inverse().

◆ operator()()

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

Implements AbsHcalFunctor.

Definition at line 35 of file HcalPiecewiseLinearFunctor.cc.

35  {
36  double result = 0.0;
37  const std::size_t sz = abscissae_.size();
38  if (sz) {
39  if (sz > 1) {
40  const std::size_t szm1 = sz - 1;
41  if (x >= abscissae_[szm1]) {
43  result = interpolateSimple(abscissae_[sz - 2], abscissae_[szm1], values_[sz - 2], values_[szm1], x);
44  else
45  result = values_[szm1];
46  } else if (x <= abscissae_[0]) {
49  else
50  result = values_[0];
51  } else {
52  const std::size_t cell = std::upper_bound(abscissae_.begin(), abscissae_.end(), x) - abscissae_.begin() - 1;
53  result = interpolateSimple(abscissae_[cell], abscissae_[cell + 1], values_[cell], values_[cell + 1], x);
54  }
55  } else
56  result = values_[0];
57  }
58  return result;
59 }

References abscissae_, interpolateSimple(), leftExtrapolationLinear_, mps_fire::result, rightExtrapolationLinear_, pfDeepBoostedJetPreprocessParams_cfi::upper_bound, values_, and x.

◆ serialize()

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

Definition at line 70 of file HcalPiecewiseLinearFunctor.h.

70  {
71  boost::serialization::base_object<AbsHcalFunctor>(*this);
73  }

References abscissae_, leftExtrapolationLinear_, rightExtrapolationLinear_, and values_.

◆ xmax()

double HcalPiecewiseLinearFunctor::xmax ( ) const
overridevirtual

Reimplemented from AbsHcalFunctor.

Definition at line 89 of file HcalPiecewiseLinearFunctor.cc.

89  {
90  double result = 0.0;
91  if (!abscissae_.empty())
92  result = abscissae_.back();
93  return result;
94 }

References abscissae_, and mps_fire::result.

Referenced by svgfig.XAxis::__repr__().

◆ xmin()

double HcalPiecewiseLinearFunctor::xmin ( ) const
overridevirtual

Reimplemented from AbsHcalFunctor.

Definition at line 82 of file HcalPiecewiseLinearFunctor.cc.

82  {
83  double result = 0.0;
84  if (!abscissae_.empty())
85  result = abscissae_[0];
86  return result;
87 }

References abscissae_, and mps_fire::result.

Referenced by svgfig.XAxis::__repr__(), svgfig.Axes::__repr__(), svgfig.HGrid::__repr__(), svgfig.Grid::__repr__(), and svgfig.Axes::SVG().

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Definition at line 67 of file HcalPiecewiseLinearFunctor.h.

Member Data Documentation

◆ abscissae_

std::vector<double> HcalPiecewiseLinearFunctor::abscissae_
private

◆ leftExtrapolationLinear_

bool HcalPiecewiseLinearFunctor::leftExtrapolationLinear_
private

Definition at line 64 of file HcalPiecewiseLinearFunctor.h.

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

◆ rightExtrapolationLinear_

bool HcalPiecewiseLinearFunctor::rightExtrapolationLinear_
private

Definition at line 65 of file HcalPiecewiseLinearFunctor.h.

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

◆ values_

std::vector<double> HcalPiecewiseLinearFunctor::values_
private
pfDeepBoostedJetPreprocessParams_cfi.upper_bound
upper_bound
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:16
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:21469
HcalPiecewiseLinearFunctor::abscissae_
std::vector< double > abscissae_
Definition: HcalPiecewiseLinearFunctor.h:62
HcalPiecewiseLinearFunctor::rightExtrapolationLinear_
bool rightExtrapolationLinear_
Definition: HcalPiecewiseLinearFunctor.h:65
HcalPiecewiseLinearFunctor::HcalPiecewiseLinearFunctor
HcalPiecewiseLinearFunctor()
Definition: HcalPiecewiseLinearFunctor.cc:11
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
HcalPiecewiseLinearFunctor::isStrictlyMonotonous
bool isStrictlyMonotonous() const
Definition: HcalPiecewiseLinearFunctor.cc:61
DDAxes::x
interpolateSimple
static double interpolateSimple(const double x0, const double x1, const double y0, const double y1, const double x)
Definition: HcalPiecewiseLinearFunctor.cc:6
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
HcalPiecewiseLinearFunctor
Definition: HcalPiecewiseLinearFunctor.h:17
HcalPiecewiseLinearFunctor::values_
std::vector< double > values_
Definition: HcalPiecewiseLinearFunctor.h:63
AbsHcalFunctor::isStrictlyIncreasing
static bool isStrictlyIncreasing(Iter begin, Iter const end)
Definition: AbsHcalFunctor.h:43
HcalPiecewiseLinearFunctor::leftExtrapolationLinear_
bool leftExtrapolationLinear_
Definition: HcalPiecewiseLinearFunctor.h:64
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
trackingPlots.other
other
Definition: trackingPlots.py:1464
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:125
mixed_calib_calo_ttbar_result.leftExtrapolationLinear
leftExtrapolationLinear
Definition: mixed_calib_calo_ttbar_result.py:10
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
alignCSCRings.r
r
Definition: alignCSCRings.py:93
Exception
Definition: hltDiff.cc:245
mps_fire.result
result
Definition: mps_fire.py:311
mixed_calib_calo_ttbar_result.rightExtrapolationLinear
rightExtrapolationLinear
Definition: mixed_calib_calo_ttbar_result.py:11