ProfileResult.cc
Go to the documentation of this file.
1 #include <atm/ProfileResult.h>
2 #include <utl/TabulatedFunctionErrors.h>
3 #include <cmath>
4 
5 using namespace utl;
6 using namespace std;
7 
8 
9 namespace atm {
10 
11  ProfileResult::ProfileResult(const utl::TabulatedFunctionErrors& profile,
12  const Binning bX, const Binning bY) :
13  fProfile(profile),
14  fBinningX(bX),
15  fBinningY(bY)
16  { }
17 
18 
19  double
20  ProfileResult::Y(const double x)
21  const
22  {
23  const double xx = (fBinningX == eLog) ? log(x) : x;
24  return (fBinningY == eLog) ? exp(fProfile.Y(xx)) : fProfile.Y(xx);
25  }
26 
27 
28  double
30  const
31  {
32  const unsigned int n = fProfile.GetNPoints();
33  const double value = n ? fProfile[n-1].X() : fProfile[0].X();
34  return (fBinningX == eLog) ? exp(value) : value;
35  }
36 
37 
38  double
40  const
41  {
42  return (fBinningX == eLog) ? exp(fProfile[0].X()) : fProfile[0].X();
43  }
44 
45 
46  bool
48  const
49  {
50  return fProfile.IsInValidRange(fBinningX == eLog ? log(x) : x);
51  }
52 
53 
54  vector<double>
56  const
57  {
58  if (fBinningX == eLinear)
59  return vector<double>(fProfile.XBegin(), fProfile.XEnd());
60  else {
61  vector<double> xv;
62  xv.reserve(fProfile.GetNPoints());
63  for (const auto& x : fProfile.XRange())
64  xv.push_back(exp(x));
65  return xv;
66  }
67  }
68 
69 
70  vector<double>
72  const
73  {
74  if (fBinningY == eLinear)
75  return vector<double>(fProfile.YBegin(), fProfile.YEnd());
76  else {
77  vector<double> yv;
78  yv.reserve(fProfile.GetNPoints());
79  for (const auto& y : fProfile.YRange())
80  yv.push_back(exp(y));
81  return yv;
82  }
83  }
84 
85 }
unsigned int GetNPoints() const
ArrayIterator XEnd()
end of array of X
bool IsInValidRange(const double x) const
double Y(const double x) const
Get the Y value (coordinate) for given X (ordinate)
std::vector< double > GetYValues() const
ArrayIterator YBegin()
begin of array of Y
Binning
Specify whether data are tabulated on log or linear scale.
Definition: ProfileResult.h:29
double MinX() const
Return the minimum value for X (ordinate) stored in the profile.
ArrayIterator XBegin()
begin of array of X
std::vector< double > GetXValues() const
utl::TabulatedFunctionErrors fProfile
Definition: ProfileResult.h:65
bool IsInValidRange(const double x) const
returns true, if the X (ordinate) is in the range covered by the results
ArrayIterator YEnd()
end of array of Y
double Y(const double x) const
Get or interpolate the Y value that corresponds to parameter x.
double MaxX() const
Return the maximum value for X (ordinate) stored in the profile.

, generated on Tue Sep 26 2023.