yoda is hosted by Hepforge, IPPP Durham
YODA - Yet more Objects for Data Analysis  1.7.2
YODA::Profile2D Class Reference

A two-dimensional profile histogram. More...

#include <Profile2D.h>

Inheritance diagram for YODA::Profile2D:
YODA::AnalysisObject

Public Types

typedef Profile2DAxis Axis
 Convenience typedefs. More...
 
typedef Axis::Bins Bins
 
typedef ProfileBin2D Bin
 
typedef Axis::Outflows Outflows
 
typedef std::tuple< double, double, double > FillType
 
typedef std::tuple< double, double > BinType
 
typedef std::shared_ptr< Profile2DPtr
 
- Public Types inherited from YODA::AnalysisObject
typedef std::map< std::string, std::string > Annotations
 Collection type for annotations, as a string-string map. More...
 

Public Member Functions

size_t dim () const
 Fill dimension of this data object. More...
 
Constructors
 Profile2D (const std::string &path="", const std::string &title="")
 Default constructor. More...
 
 Profile2D (size_t nbinsX, double lowerX, double upperX, size_t nbinsY, double lowerY, double upperY, const std::string &path="", const std::string &title="")
 Constructor giving range and number of bins. More...
 
 Profile2D (const std::vector< double > &xedges, const std::vector< double > &yedges, const std::string &path="", const std::string &title="")
 Constructor giving explicit bin edges in the direction of X and Y. More...
 
 Profile2D (const std::vector< Bin > &bins, const std::string &path="", const std::string &title="")
 Constructor accepting an explicit collection of bins. More...
 
 Profile2D (const Profile2D &p, const std::string &path="")
 A copy constructor with optional new path. More...
 
 Profile2D (const Scatter3D &s, const std::string &path="")
 Constructor from a Scatter3D's binning, with optional new path. More...
 
 Profile2D (const Histo2D &h, const std::string &path="")
 Constructor from a Histo2D's binning, with optional new path. More...
 
 Profile2D (const std::vector< ProfileBin2D > &bins, const Dbn3D &totalDbn, const Outflows &outflows, const std::string &path="", const std::string &title="")
 State-setting constructor. More...
 
Profile2Doperator= (const Profile2D &p2)
 Assignment operator. More...
 
Profile2D clone () const
 Make a copy on the stack. More...
 
Profile2Dnewclone () const
 Make a copy on the heap, via 'new'. More...
 
Modifiers
virtual void fill (double x, double y, double z, double weight=1.0, double fraction=1.0)
 Fill histo by value and weight. More...
 
virtual void fill (const FillType &xs, double weight=1.0, double fraction=1.0)
 
virtual void fillBin (size_t i, double z, double weight=1.0, double fraction=1.0)
 Fill histo x-y bin i with the given z value and weight. More...
 
void reset ()
 Reset the histogram. More...
 
void scaleW (double scalefactor)
 Rescale as if all fill weights had been different by a scalefactor. More...
 
void scaleZ (double scalefactor)
 Rescale as if all z values had been different by factor scalefactor. More...
 
void addBin (Axis::EdgePair1D xrange, Axis::EdgePair1D yrange)
 
void addBin (const Bin &bin)
 
void addBins (const Axis::Edges &xcuts, const Axis::Edges &ycuts)
 Bins addition operator. More...
 
void addBins (const Bins &bins)
 Bins addition operator. More...
 
void eraseBin (size_t index)
 
Bin accessors
double xMin () const
 Low x edge of this histo's axis. More...
 
double xMax () const
 High x edge of this histo's axis. More...
 
double yMin () const
 Low y edge of this histo's axis. More...
 
double yMax () const
 High y edge of this histo's axis. More...
 
std::vector< YODA::ProfileBin2D > & bins ()
 Access the bin vector (non-const) More...
 
const std::vector< YODA::ProfileBin2D > & bins () const
 Access the bin vector (const) More...
 
ProfileBin2Dbin (size_t index)
 Access a bin by index (non-const) More...
 
const ProfileBin2Dbin (size_t index) const
 Access a bin by index (const) More...
 
int binIndexAt (double x, double y)
 Access a bin index by coordinate. More...
 
int binIndexAt (const BinType &t)
 
const ProfileBin2DbinAt (double x, double y) const
 Access a bin by coordinate (const) More...
 
const ProfileBin2DbinAt (const BinType &t) const
 
size_t numBins () const
 Number of bins of this axis (not counting under/over flow) More...
 
size_t numBinsX () const
 Number of bins along the x axis. More...
 
size_t numBinsY () const
 Number of bins along the y axis. More...
 
Dbn3DtotalDbn ()
 Access summary distribution, including gaps and overflows (non-const version) More...
 
const Dbn3DtotalDbn () const
 Access summary distribution, including gaps and overflows (const version) More...
 
void setTotalDbn (const Dbn3D &dbn)
 Set summary distribution, including gaps and overflows. More...
 
Whole histo data
double numEntries (bool includeoverflows=true) const
 Get the number of fills (fractional fills are possible) More...
 
double effNumEntries (bool includeoverflows=true) const
 Get the effective number of fills. More...
 
double sumW (bool includeoverflows=true) const
 Get sum of weights in histo. More...
 
double sumW2 (bool includeoverflows=true) const
 Get the sum of squared weights in histo. More...
 
double xMean (bool includeoverflows=true) const
 Get the mean x. More...
 
double yMean (bool includeoverflows=true) const
 Get the mean y. More...
 
double xVariance (bool includeoverflows=true) const
 Get the variance in x. More...
 
double yVariance (bool includeoverflows=true) const
 Get the variance in y. More...
 
double xStdDev (bool includeoverflows=true) const
 Get the standard deviation in x. More...
 
double yStdDev (bool includeoverflows=true) const
 Get the standard deviation in y. More...
 
double xStdErr (bool includeoverflows=true) const
 Get the standard error on <x> More...
 
double yStdErr (bool includeoverflows=true) const
 Get the standard error on <y> More...
 
double xRMS (bool includeoverflows=true) const
 Get the RMS in x. More...
 
double yRMS (bool includeoverflows=true) const
 Get the RMS in y. More...
 
Adding and subtracting histograms
Profile2Doperator+= (const Profile2D &toAdd)
 Add another profile to this one. More...
 
Profile2Doperator-= (const Profile2D &toSubtract)
 Subtract another profile from this one. More...
 
bool operator== (const Profile2D &other)
 
bool operator!= (const Profile2D &other)
 
- Public Member Functions inherited from YODA::AnalysisObject
 AnalysisObject ()
 Default constructor. More...
 
 AnalysisObject (const std::string &type, const std::string &path, const std::string &title="")
 Constructor giving a type, a path and an optional title. More...
 
 AnalysisObject (const std::string &type, const std::string &path, const AnalysisObject &ao, const std::string &title="")
 Constructor giving a type, a path, another AO to copy annotation from, and an optional title. More...
 
virtual ~AnalysisObject ()
 Default destructor. More...
 
virtual AnalysisObjectoperator= (const AnalysisObject &ao)
 Default copy assignment operator. More...
 
std::vector< std::string > annotations () const
 
bool hasAnnotation (const std::string &name) const
 Check if an annotation is defined. More...
 
const std::string & annotation (const std::string &name) const
 Get an annotation by name (as a string) More...
 
const std::string & annotation (const std::string &name, const std::string &defaultreturn) const
 Get an annotation by name (as a string) with a default in case the annotation is not found. More...
 
template<typename T >
const T annotation (const std::string &name) const
 Get an annotation by name (copied to another type) More...
 
template<typename T >
const T annotation (const std::string &name, const T &defaultreturn) const
 Get an annotation by name (copied to another type) with a default in case the annotation is not found. More...
 
void setAnnotation (const std::string &name, const std::string &value)
 Add or set a string-valued annotation by name. More...
 
void setAnnotation (const std::string &name, double value)
 Add or set a double-valued annotation by name. More...
 
void setAnnotation (const std::string &name, float value)
 Add or set a float-valued annotation by name. More...
 
void setAnnotation (const std::string &name, long double value)
 Add or set a long-double-valued annotation by name. More...
 
template<typename T >
void setAnnotation (const std::string &name, const T &value)
 Add or set an annotation by name (templated for remaining types) More...
 
void setAnnotations (const Annotations &anns)
 Set all annotations at once. More...
 
template<typename T >
void addAnnotation (const std::string &name, const T &value)
 Add or set an annotation by name. More...
 
void rmAnnotation (const std::string &name)
 Delete an annotation by name. More...
 
void clearAnnotations ()
 Delete an annotation by name. More...
 
const std::string title () const
 Get the AO title. More...
 
void setTitle (const std::string &title)
 Set the AO title. More...
 
const std::string path () const
 Get the AO path. More...
 
void setPath (const std::string &path)
 
const std::string name () const
 
virtual std::string type () const
 Get name of the analysis object type. More...
 

Detailed Description

A two-dimensional profile histogram.

Definition at line 31 of file Profile2D.h.

Member Typedef Documentation

◆ Axis

Convenience typedefs.

Definition at line 35 of file Profile2D.h.

◆ Bin

Definition at line 37 of file Profile2D.h.

◆ Bins

Definition at line 36 of file Profile2D.h.

◆ BinType

typedef std::tuple<double, double> YODA::Profile2D::BinType

Definition at line 41 of file Profile2D.h.

◆ FillType

typedef std::tuple<double, double, double> YODA::Profile2D::FillType

Definition at line 40 of file Profile2D.h.

◆ Outflows

Definition at line 38 of file Profile2D.h.

◆ Ptr

typedef std::shared_ptr<Profile2D> YODA::Profile2D::Ptr

Definition at line 42 of file Profile2D.h.

Constructor & Destructor Documentation

◆ Profile2D() [1/8]

YODA::Profile2D::Profile2D ( const std::string &  path = "",
const std::string &  title = "" 
)
inline

Default constructor.

Definition at line 49 of file Profile2D.h.

Referenced by clone(), newclone(), and Profile2D().

50  : AnalysisObject("Profile2D", path, title),
51  _axis()
52  { }
AnalysisObject()
Default constructor.
const std::string path() const
Get the AO path.
const std::string title() const
Get the AO title.

◆ Profile2D() [2/8]

YODA::Profile2D::Profile2D ( size_t  nbinsX,
double  lowerX,
double  upperX,
size_t  nbinsY,
double  lowerY,
double  upperY,
const std::string &  path = "",
const std::string &  title = "" 
)
inline

Constructor giving range and number of bins.

Definition at line 56 of file Profile2D.h.

59  : AnalysisObject("Profile2D", path, title),
60  _axis(nbinsX, std::make_pair(lowerX, upperX), nbinsY, std::make_pair(lowerY, upperY))
61  { }
AnalysisObject()
Default constructor.
const std::string path() const
Get the AO path.
const std::string title() const
Get the AO title.

◆ Profile2D() [3/8]

YODA::Profile2D::Profile2D ( const std::vector< double > &  xedges,
const std::vector< double > &  yedges,
const std::string &  path = "",
const std::string &  title = "" 
)
inline

Constructor giving explicit bin edges in the direction of X and Y.

Definition at line 65 of file Profile2D.h.

67  : AnalysisObject("Profile2D", path, title),
68  _axis(xedges, yedges)
69  { }
AnalysisObject()
Default constructor.
const std::string path() const
Get the AO path.
const std::string title() const
Get the AO title.

◆ Profile2D() [4/8]

YODA::Profile2D::Profile2D ( const std::vector< Bin > &  bins,
const std::string &  path = "",
const std::string &  title = "" 
)
inline

Constructor accepting an explicit collection of bins.

Definition at line 73 of file Profile2D.h.

References YODA::AnalysisObject::path(), and Profile2D().

75  : AnalysisObject("Profile2D", path, title),
76  _axis(bins)
77  { }
AnalysisObject()
Default constructor.
const std::string path() const
Get the AO path.
const std::string title() const
Get the AO title.

◆ Profile2D() [5/8]

YODA::Profile2D::Profile2D ( const Profile2D p,
const std::string &  path = "" 
)

A copy constructor with optional new path.

A copy constructor with optional new path

Todo:
Also allow title setting from the constructor?

Definition at line 154 of file Profile2D.cc.

155  : AnalysisObject("Profile2D",
156  (path.size() == 0) ? p.path() : path,
157  p, p.title()),
158  _axis(p._axis)
159  { }
AnalysisObject()
Default constructor.
const std::string path() const
Get the AO path.

◆ Profile2D() [6/8]

YODA::Profile2D::Profile2D ( const Scatter3D s,
const std::string &  path = "" 
)

Constructor from a Scatter3D's binning, with optional new path.

A constructor from a Scatter3D's binning, with optional new path

Todo:
Also allow title setting from the constructor?

Definition at line 163 of file Profile2D.cc.

References bins(), and YODA::Scatter3D::points().

164  : AnalysisObject("Profile2D",
165  (path.size() == 0) ? s.path() : path,
166  s, s.title())
167  {
168  Bins bins;
169  for (const Scatter3D::Point& p : s.points()) {
170  bins.push_back(ProfileBin2D(p.xMin(), p.yMin(), p.xMax(), p.yMax()));
171  }
172  _axis = Profile2DAxis(bins);
173  }
AnalysisObject()
Default constructor.
const std::string path() const
Get the AO path.
Axis::Bins Bins
Definition: Profile2D.h:36
std::vector< YODA::ProfileBin2D > & bins()
Access the bin vector (non-const)
Definition: Profile2D.h:245
Axis2D< ProfileBin2D, Dbn3D > Profile2DAxis
Convenience typedef.
Definition: Profile2D.h:24
Point3D Point
Types of the native Point3D collection.
Definition: Scatter3D.h:28

◆ Profile2D() [7/8]

YODA::Profile2D::Profile2D ( const Histo2D h,
const std::string &  path = "" 
)

Constructor from a Histo2D's binning, with optional new path.

Constructor from a Histo2D's binning, with optional new path

Todo:
Also allow title setting from the constructor?

Definition at line 177 of file Profile2D.cc.

References bins(), and YODA::Histo2D::bins().

178  : AnalysisObject("Profile2D", (path.size() == 0) ? h.path() : path, h, h.title())
179  {
180  Bins bins;
181  for (const HistoBin2D& b : h.bins()) {
182  bins.push_back(ProfileBin2D(b.xMin(), b.yMin(), b.xMax(), b.yMax()));
183  }
184  _axis = Profile2DAxis(bins);
185  }
AnalysisObject()
Default constructor.
const std::string path() const
Get the AO path.
Axis::Bins Bins
Definition: Profile2D.h:36
std::vector< YODA::ProfileBin2D > & bins()
Access the bin vector (non-const)
Definition: Profile2D.h:245
Axis2D< ProfileBin2D, Dbn3D > Profile2DAxis
Convenience typedef.
Definition: Profile2D.h:24

◆ Profile2D() [8/8]

YODA::Profile2D::Profile2D ( const std::vector< ProfileBin2D > &  bins,
const Dbn3D totalDbn,
const Outflows outflows,
const std::string &  path = "",
const std::string &  title = "" 
)
inline

State-setting constructor.

Mainly intended for internal persistency use.

Definition at line 95 of file Profile2D.h.

99  : AnalysisObject("Profile2D", path, title),
100  _axis(bins, totalDbn, outflows)
101  { }
AnalysisObject()
Default constructor.
const std::string path() const
Get the AO path.
Dbn3D & totalDbn()
Access summary distribution, including gaps and overflows (non-const version)
Definition: Profile2D.h:278
const std::string title() const
Get the AO title.

Member Function Documentation

◆ addBin() [1/2]

void YODA::Profile2D::addBin ( Axis::EdgePair1D  xrange,
Axis::EdgePair1D  yrange 
)
inline
Todo:
TODO
Todo:
TODO

Definition at line 184 of file Profile2D.h.

184  {
185  _axis.addBin(xrange, yrange);
186  }

◆ addBin() [2/2]

void YODA::Profile2D::addBin ( const Bin bin)
inline

Definition at line 191 of file Profile2D.h.

191  {
192  _axis.addBin(bin);
193  }
ProfileBin2D & bin(size_t index)
Access a bin by index (non-const)
Definition: Profile2D.h:252

◆ addBins() [1/2]

void YODA::Profile2D::addBins ( const Axis::Edges xcuts,
const Axis::Edges ycuts 
)
inline

Bins addition operator.

Add multiple bins from edge cuts without resetting

Definition at line 198 of file Profile2D.h.

198  {
199  _axis.addBins(xcuts, ycuts);
200  }

◆ addBins() [2/2]

void YODA::Profile2D::addBins ( const Bins bins)
inline

Bins addition operator.

Add multiple bins without resetting

Definition at line 206 of file Profile2D.h.

206  {
207  _axis.addBins(bins);
208  }
std::vector< YODA::ProfileBin2D > & bins()
Access the bin vector (non-const)
Definition: Profile2D.h:245

◆ bin() [1/2]

ProfileBin2D& YODA::Profile2D::bin ( size_t  index)
inline

Access a bin by index (non-const)

Definition at line 252 of file Profile2D.h.

Referenced by YODA::divide(), YODA::mkScatter(), and scaleZ().

252 { return _axis.bins()[index]; }

◆ bin() [2/2]

const ProfileBin2D& YODA::Profile2D::bin ( size_t  index) const
inline

Access a bin by index (const)

Definition at line 255 of file Profile2D.h.

255 { return _axis.bins()[index]; }

◆ binAt() [1/2]

const ProfileBin2D& YODA::Profile2D::binAt ( double  x,
double  y 
) const
inline

Access a bin by coordinate (const)

Definition at line 262 of file Profile2D.h.

262 { return _axis.binAt(x, y); }

◆ binAt() [2/2]

const ProfileBin2D& YODA::Profile2D::binAt ( const BinType t) const
inline

Definition at line 264 of file Profile2D.h.

264 { return _axis.binAt(std::get<0>(t), std::get<1>(t)); }

◆ binIndexAt() [1/2]

int YODA::Profile2D::binIndexAt ( double  x,
double  y 
)
inline

Access a bin index by coordinate.

Definition at line 258 of file Profile2D.h.

258 { return _axis.binIndexAt(x, y); }

◆ binIndexAt() [2/2]

int YODA::Profile2D::binIndexAt ( const BinType t)
inline

Definition at line 259 of file Profile2D.h.

259 { return _axis.binIndexAt(std::get<0>(t), std::get<1>(t)); }

◆ bins() [1/2]

std::vector<YODA::ProfileBin2D>& YODA::Profile2D::bins ( )
inline

Access the bin vector (non-const)

Definition at line 245 of file Profile2D.h.

Referenced by YODA::Histo2D::Histo2D(), Profile2D(), and scaleZ().

245 { return _axis.bins(); }

◆ bins() [2/2]

const std::vector<YODA::ProfileBin2D>& YODA::Profile2D::bins ( ) const
inline

Access the bin vector (const)

Definition at line 248 of file Profile2D.h.

248 { return _axis.bins(); }

◆ clone()

Profile2D YODA::Profile2D::clone ( ) const
inline

Make a copy on the stack.

Definition at line 113 of file Profile2D.h.

References Profile2D().

113  {
114  return Profile2D(*this);
115  }
Profile2D(const std::string &path="", const std::string &title="")
Default constructor.
Definition: Profile2D.h:49

◆ dim()

size_t YODA::Profile2D::dim ( ) const
inlinevirtual

Fill dimension of this data object.

Implements YODA::AnalysisObject.

Definition at line 126 of file Profile2D.h.

References fill().

126 { return 2; }

◆ effNumEntries()

double YODA::Profile2D::effNumEntries ( bool  includeoverflows = true) const

Get the effective number of fills.

Definition at line 60 of file Profile2D.cc.

Referenced by setTotalDbn().

60  {
61  if (includeoverflows) return totalDbn().effNumEntries();
62  double n = 0;
63  for (const Bin& b : bins()) n += b.effNumEntries();
64  return n;
65  }
Dbn3D & totalDbn()
Access summary distribution, including gaps and overflows (non-const version)
Definition: Profile2D.h:278
std::vector< YODA::ProfileBin2D > & bins()
Access the bin vector (non-const)
Definition: Profile2D.h:245
double effNumEntries() const
Effective number of entries .
Definition: Dbn3D.h:239
ProfileBin2D Bin
Definition: Profile2D.h:37

◆ eraseBin()

void YODA::Profile2D::eraseBin ( size_t  index)
inline
Todo:
TODO

Definition at line 220 of file Profile2D.h.

220  {
221  _axis.eraseBin(index);
222  }

◆ fill() [1/2]

void YODA::Profile2D::fill ( double  x,
double  y,
double  z,
double  weight = 1.0,
double  fraction = 1.0 
)
virtual

Fill histo by value and weight.

Unify this with Histo2D's version, when binning and inheritance are reworked

Todo:
Replace try block with a check that there is a bin at x, y
Todo:
Reinstate! With outflow axis bin lookup

Definition at line 15 of file Profile2D.cc.

References YODA::inRange().

Referenced by dim(), and fill().

15  {
16  if ( std::isnan(x) ) throw RangeError("X is NaN");
17  if ( std::isnan(y) ) throw RangeError("Y is NaN");
18  if ( std::isnan(z) ) throw RangeError("Z is NaN");
19 
20  // Fill the overall distribution
21  _axis.totalDbn().fill(x, y, z, weight, fraction);
22 
23  // Fill the bins and overflows
25  if (inRange(x, _axis.xMin(), _axis.xMax()) && inRange(y, _axis.yMin(), _axis.yMax())) {
26  try {
28  _binAt(x, y).fill(x, y, z, weight, fraction);
29  } catch (const RangeError& re) { }
30  }
32  // else {
33  // size_t ix(0), iy(0);
34  // if (x < _axis.xMin()) ix = -1; else if (x >= _axis.xMax()) ix = 1;
35  // if (y < _axis.yMin()) iy = -1; else if (y >= _axis.yMax()) iy = 1;
36  // _axis.outflow(ix, iy).fill(x, y, z, weight, fraction);
37  // }
38 
39  // Lock the axis now that a fill has happened
40  _axis._setLock(true);
41  }
bool inRange(NUM value, NUM low, NUM high, RangeBoundary lowbound=CLOSED, RangeBoundary highbound=OPEN)
Determine if value is in the range low to high, for floating point numbers.
Definition: MathUtils.h:155

◆ fill() [2/2]

virtual void YODA::Profile2D::fill ( const FillType xs,
double  weight = 1.0,
double  fraction = 1.0 
)
inlinevirtual

Definition at line 134 of file Profile2D.h.

References fill(), and fillBin().

134  {
135  fill(std::get<0>(xs), std::get<1>(xs), std::get<2>(xs), weight, fraction);
136  }
virtual void fill(double x, double y, double z, double weight=1.0, double fraction=1.0)
Fill histo by value and weight.
Definition: Profile2D.cc:15

◆ fillBin()

void YODA::Profile2D::fillBin ( size_t  i,
double  z,
double  weight = 1.0,
double  fraction = 1.0 
)
virtual

Fill histo x-y bin i with the given z value and weight.

Definition at line 44 of file Profile2D.cc.

Referenced by fill().

44  {
45  pair<double, double> mid = bin(i).xyMid();
46  fill(mid.first, mid.second, z, weight, fraction);
47  }
virtual void fill(double x, double y, double z, double weight=1.0, double fraction=1.0)
Fill histo by value and weight.
Definition: Profile2D.cc:15
std::pair< double, double > xyMid() const
The geometric centre of the bin.
Definition: Bin2D.h:179
ProfileBin2D & bin(size_t index)
Access a bin by index (non-const)
Definition: Profile2D.h:252

◆ newclone()

Profile2D* YODA::Profile2D::newclone ( ) const
inlinevirtual

Make a copy on the heap, via 'new'.

Implements YODA::AnalysisObject.

Definition at line 118 of file Profile2D.h.

References Profile2D().

118  {
119  return new Profile2D(*this);
120  }
Profile2D(const std::string &path="", const std::string &title="")
Default constructor.
Definition: Profile2D.h:49

◆ numBins()

size_t YODA::Profile2D::numBins ( ) const
inline

Number of bins of this axis (not counting under/over flow)

Definition at line 268 of file Profile2D.h.

Referenced by YODA::divide(), and YODA::mkScatter().

268 { return _axis.bins().size(); }

◆ numBinsX()

size_t YODA::Profile2D::numBinsX ( ) const
inline

Number of bins along the x axis.

Definition at line 271 of file Profile2D.h.

271 { return _axis.numBinsX(); }

◆ numBinsY()

size_t YODA::Profile2D::numBinsY ( ) const
inline

Number of bins along the y axis.

Definition at line 274 of file Profile2D.h.

274 { return _axis.numBinsY(); }

◆ numEntries()

double YODA::Profile2D::numEntries ( bool  includeoverflows = true) const

Get the number of fills (fractional fills are possible)

Definition at line 52 of file Profile2D.cc.

Referenced by setTotalDbn().

52  {
53  if (includeoverflows) return totalDbn().numEntries();
54  unsigned long n = 0;
55  for (const Bin& b : bins()) n += b.numEntries();
56  return n;
57  }
Dbn3D & totalDbn()
Access summary distribution, including gaps and overflows (non-const version)
Definition: Profile2D.h:278
double numEntries() const
Number of entries (number of times fill was called, ignoring weights)
Definition: Dbn3D.h:234
std::vector< YODA::ProfileBin2D > & bins()
Access the bin vector (non-const)
Definition: Profile2D.h:245
ProfileBin2D Bin
Definition: Profile2D.h:37

◆ operator!=()

bool YODA::Profile2D::operator!= ( const Profile2D other)
inline

Definition at line 379 of file Profile2D.h.

References operator==().

379  {
380  return ! operator == (other);
381  }
bool operator==(const Profile2D &other)
Definition: Profile2D.h:375

◆ operator+=()

Profile2D& YODA::Profile2D::operator+= ( const Profile2D toAdd)
inline

Add another profile to this one.

Definition at line 362 of file Profile2D.h.

References YODA::AnalysisObject::hasAnnotation(), and YODA::AnalysisObject::rmAnnotation().

362  {
363  if (hasAnnotation("ScaledBy")) rmAnnotation("ScaledBy");
364  _axis += toAdd._axis;
365  return *this;
366  }
void rmAnnotation(const std::string &name)
Delete an annotation by name.
bool hasAnnotation(const std::string &name) const
Check if an annotation is defined.

◆ operator-=()

Profile2D& YODA::Profile2D::operator-= ( const Profile2D toSubtract)
inline

Subtract another profile from this one.

Definition at line 369 of file Profile2D.h.

References YODA::AnalysisObject::hasAnnotation(), and YODA::AnalysisObject::rmAnnotation().

369  {
370  if (hasAnnotation("ScaledBy")) rmAnnotation("ScaledBy");
371  _axis -= toSubtract._axis;
372  return *this;
373  }
void rmAnnotation(const std::string &name)
Delete an annotation by name.
bool hasAnnotation(const std::string &name) const
Check if an annotation is defined.

◆ operator=()

Profile2D& YODA::Profile2D::operator= ( const Profile2D p2)
inline

Assignment operator.

Definition at line 105 of file Profile2D.h.

References YODA::AnalysisObject::operator=().

105  {
106  AnalysisObject::operator = (p2); //< AO treatment of paths etc.
107  _axis = p2._axis;
108  return *this;
109  }
virtual AnalysisObject & operator=(const AnalysisObject &ao)
Default copy assignment operator.

◆ operator==()

bool YODA::Profile2D::operator== ( const Profile2D other)
inline

Definition at line 375 of file Profile2D.h.

Referenced by operator!=().

375  {
376  return _axis == other._axis;
377  }

◆ reset()

void YODA::Profile2D::reset ( )
inlinevirtual

Reset the histogram.

Keep the binning but reset the statistics

Implements YODA::AnalysisObject.

Definition at line 145 of file Profile2D.h.

145  {
146  _axis.reset();
147  }

◆ scaleW()

void YODA::Profile2D::scaleW ( double  scalefactor)
inline

Rescale as if all fill weights had been different by a scalefactor.

Todo:
Is this ScaledBy annotation needed?

Definition at line 150 of file Profile2D.h.

References YODA::AnalysisObject::setAnnotation().

150  {
152  setAnnotation("ScaledBy", annotation<double>("ScaledBy", 1.0) * scalefactor);
153  _axis.scaleW(scalefactor);
154  }
void setAnnotation(const std::string &name, const std::string &value)
Add or set a string-valued annotation by name.

◆ scaleZ()

void YODA::Profile2D::scaleZ ( double  scalefactor)
inline

Rescale as if all z values had been different by factor scalefactor.

Todo:
Need to rescale overflows too, when they exist.

Definition at line 157 of file Profile2D.h.

References bin(), bins(), and YODA::ProfileBin2D::scaleZ().

157  {
158  _axis.totalDbn().scaleZ(scalefactor);
160  // _axis.overflow().scaleZ(scalefactor);
161  // _axis.underflow().scaleZ(scalefactor);
162  for (size_t i = 0; i < bins().size(); ++i)
163  bin(i).scaleZ(scalefactor);
164  }
ProfileBin2D & bin(size_t index)
Access a bin by index (non-const)
Definition: Profile2D.h:252
std::vector< YODA::ProfileBin2D > & bins()
Access the bin vector (non-const)
Definition: Profile2D.h:245
void scaleZ(double az)
Definition: ProfileBin2D.h:100

◆ setTotalDbn()

void YODA::Profile2D::setTotalDbn ( const Dbn3D dbn)
inline

Set summary distribution, including gaps and overflows.

Definition at line 284 of file Profile2D.h.

References effNumEntries(), numEntries(), sumW(), sumW2(), xMean(), xVariance(), yMean(), and yVariance().

284 { _axis.setTotalDbn(dbn); }

◆ sumW()

double YODA::Profile2D::sumW ( bool  includeoverflows = true) const

Get sum of weights in histo.

Definition at line 68 of file Profile2D.cc.

Referenced by setTotalDbn().

68  {
69  if (includeoverflows) return _axis.totalDbn().sumW2();
70  double sumw = 0;
71  for (const Bin& b : bins()) sumw += b.sumW();
72  return sumw;
73  }
std::vector< YODA::ProfileBin2D > & bins()
Access the bin vector (non-const)
Definition: Profile2D.h:245
ProfileBin2D Bin
Definition: Profile2D.h:37

◆ sumW2()

double YODA::Profile2D::sumW2 ( bool  includeoverflows = true) const

Get the sum of squared weights in histo.

Definition at line 76 of file Profile2D.cc.

Referenced by setTotalDbn().

76  {
77  if (includeoverflows) return _axis.totalDbn().sumW2();
78  double sumw2 = 0;
79  for (const Bin& b : bins()) sumw2 += b.sumW2();
80  return sumw2;
81  }
std::vector< YODA::ProfileBin2D > & bins()
Access the bin vector (non-const)
Definition: Profile2D.h:245
ProfileBin2D Bin
Definition: Profile2D.h:37

◆ totalDbn() [1/2]

Dbn3D& YODA::Profile2D::totalDbn ( )
inline

Access summary distribution, including gaps and overflows (non-const version)

Definition at line 278 of file Profile2D.h.

278 { return _axis.totalDbn(); }

◆ totalDbn() [2/2]

const Dbn3D& YODA::Profile2D::totalDbn ( ) const
inline

Access summary distribution, including gaps and overflows (const version)

Definition at line 281 of file Profile2D.h.

281 { return _axis.totalDbn(); }

◆ xMax()

double YODA::Profile2D::xMax ( ) const
inline

High x edge of this histo's axis.

Definition at line 234 of file Profile2D.h.

234 { return _axis.xMax(); }

◆ xMean()

double YODA::Profile2D::xMean ( bool  includeoverflows = true) const

Get the mean x.

Definition at line 86 of file Profile2D.cc.

References YODA::Dbn3D::xMean().

Referenced by setTotalDbn().

86  {
87  if (includeoverflows) return _axis.totalDbn().xMean();
88  Dbn3D dbn;
89  for (const ProfileBin2D& b : bins()) dbn += b.dbn();
90  return dbn.xMean();
91  }
std::vector< YODA::ProfileBin2D > & bins()
Access the bin vector (non-const)
Definition: Profile2D.h:245

◆ xMin()

double YODA::Profile2D::xMin ( ) const
inline

Low x edge of this histo's axis.

Definition at line 231 of file Profile2D.h.

231 { return _axis.xMin(); }

◆ xRMS()

double YODA::Profile2D::xRMS ( bool  includeoverflows = true) const

Get the RMS in x.

Definition at line 134 of file Profile2D.cc.

References YODA::Dbn3D::xRMS().

Referenced by yStdDev().

134  {
135  if (includeoverflows) return _axis.totalDbn().xRMS();
136  Dbn3D dbn;
137  for (const ProfileBin2D& b : bins()) dbn += b.dbn();
138  return dbn.xRMS();
139  }
std::vector< YODA::ProfileBin2D > & bins()
Access the bin vector (non-const)
Definition: Profile2D.h:245

◆ xStdDev()

double YODA::Profile2D::xStdDev ( bool  includeoverflows = true) const
inline

Get the standard deviation in x.

Definition at line 334 of file Profile2D.h.

References xVariance().

334  {
335  return std::sqrt(xVariance(includeoverflows));
336  }
double xVariance(bool includeoverflows=true) const
Get the variance in x.
Definition: Profile2D.cc:102

◆ xStdErr()

double YODA::Profile2D::xStdErr ( bool  includeoverflows = true) const

Get the standard error on <x>

Definition at line 118 of file Profile2D.cc.

References YODA::Dbn3D::xStdErr().

Referenced by yStdDev().

118  {
119  if (includeoverflows) return _axis.totalDbn().xStdErr();
120  Dbn3D dbn;
121  for (const ProfileBin2D& b : bins()) dbn += b.dbn();
122  return dbn.xStdErr();
123  }
std::vector< YODA::ProfileBin2D > & bins()
Access the bin vector (non-const)
Definition: Profile2D.h:245

◆ xVariance()

double YODA::Profile2D::xVariance ( bool  includeoverflows = true) const

Get the variance in x.

Definition at line 102 of file Profile2D.cc.

References YODA::Dbn3D::xVariance().

Referenced by setTotalDbn(), and xStdDev().

102  {
103  if (includeoverflows) return _axis.totalDbn().xVariance();
104  Dbn3D dbn;
105  for (const ProfileBin2D& b : bins()) dbn += b.dbn();
106  return dbn.xVariance();
107  }
std::vector< YODA::ProfileBin2D > & bins()
Access the bin vector (non-const)
Definition: Profile2D.h:245

◆ yMax()

double YODA::Profile2D::yMax ( ) const
inline

High y edge of this histo's axis.

Definition at line 241 of file Profile2D.h.

241 { return _axis.yMax(); }

◆ yMean()

double YODA::Profile2D::yMean ( bool  includeoverflows = true) const

Get the mean y.

Definition at line 94 of file Profile2D.cc.

References YODA::Dbn3D::yMean().

Referenced by setTotalDbn().

94  {
95  if (includeoverflows) return _axis.totalDbn().yMean();
96  Dbn3D dbn;
97  for (const ProfileBin2D& b : bins()) dbn += b.dbn();
98  return dbn.yMean();
99  }
std::vector< YODA::ProfileBin2D > & bins()
Access the bin vector (non-const)
Definition: Profile2D.h:245

◆ yMin()

double YODA::Profile2D::yMin ( ) const
inline

Low y edge of this histo's axis.

Definition at line 238 of file Profile2D.h.

238 { return _axis.yMin(); }

◆ yRMS()

double YODA::Profile2D::yRMS ( bool  includeoverflows = true) const

Get the RMS in y.

Definition at line 142 of file Profile2D.cc.

References YODA::Dbn3D::yRMS().

Referenced by yStdDev().

142  {
143  if (includeoverflows) return _axis.totalDbn().yRMS();
144  Dbn3D dbn;
145  for (const ProfileBin2D& b : bins()) dbn += b.dbn();
146  return dbn.yRMS();
147  }
std::vector< YODA::ProfileBin2D > & bins()
Access the bin vector (non-const)
Definition: Profile2D.h:245

◆ yStdDev()

double YODA::Profile2D::yStdDev ( bool  includeoverflows = true) const
inline

Get the standard deviation in y.

Definition at line 339 of file Profile2D.h.

References xRMS(), xStdErr(), yRMS(), yStdErr(), and yVariance().

339  {
340  return std::sqrt(yVariance(includeoverflows));
341  }
double yVariance(bool includeoverflows=true) const
Get the variance in y.
Definition: Profile2D.cc:110

◆ yStdErr()

double YODA::Profile2D::yStdErr ( bool  includeoverflows = true) const

Get the standard error on <y>

Definition at line 126 of file Profile2D.cc.

References YODA::Dbn3D::yStdErr().

Referenced by yStdDev().

126  {
127  if (includeoverflows) return _axis.totalDbn().yStdErr();
128  Dbn3D dbn;
129  for (const ProfileBin2D& b : bins()) dbn += b.dbn();
130  return dbn.yStdErr();
131  }
std::vector< YODA::ProfileBin2D > & bins()
Access the bin vector (non-const)
Definition: Profile2D.h:245

◆ yVariance()

double YODA::Profile2D::yVariance ( bool  includeoverflows = true) const

Get the variance in y.

Definition at line 110 of file Profile2D.cc.

References YODA::Dbn3D::yVariance().

Referenced by setTotalDbn(), and yStdDev().

110  {
111  if (includeoverflows) return _axis.totalDbn().yVariance();
112  Dbn3D dbn;
113  for (const ProfileBin2D& b : bins()) dbn += b.dbn();
114  return dbn.yVariance();
115  }
std::vector< YODA::ProfileBin2D > & bins()
Access the bin vector (non-const)
Definition: Profile2D.h:245

The documentation for this class was generated from the following files: