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

A two-dimensional profile histogram. More...

#include <Profile2D.h>

Inheritance diagram for YODA::Profile2D:
YODA::AnalysisObject YODA::Fillable YODA::Binned

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...
 
size_t fillDim () 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...
 
Bin adding and removing
Todo:
TODO
Todo:
TODO
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...
 
bool sameBinning (const Profile2D &p2)
 Check if binning is the same as different Profile2D. More...
 
void rmBin (size_t index)
 
Bin accessors
const std::vector< double > xEdges () const
 
const std::vector< double > yEdges () const
 
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 the mean x. More...
 
double yStdErr (bool includeoverflows=true) const
 Get the standard error on the mean 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...
 
void parseVariations ()
 
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...
 
- Public Member Functions inherited from YODA::Fillable
virtual ~Fillable ()=default
 Virtual destructor for inheritance. More...
 
- Public Member Functions inherited from YODA::Binned
virtual ~Binned ()=default
 Virtual destructor for inheritance. More...
 
void eraseBin (size_t index)
 

Detailed Description

A two-dimensional profile histogram.

Definition at line 32 of file Profile2D.h.

Member Typedef Documentation

◆ Axis

Convenience typedefs.

Definition at line 36 of file Profile2D.h.

◆ Bin

Definition at line 38 of file Profile2D.h.

◆ Bins

Definition at line 37 of file Profile2D.h.

◆ BinType

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

Definition at line 42 of file Profile2D.h.

◆ FillType

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

Definition at line 41 of file Profile2D.h.

◆ Outflows

Definition at line 39 of file Profile2D.h.

◆ Ptr

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

Definition at line 43 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 50 of file Profile2D.h.

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

51  : AnalysisObject("Profile2D", path, title),
52  _axis()
53  { }
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 57 of file Profile2D.h.

60  : AnalysisObject("Profile2D", path, title),
61  _axis(nbinsX, std::make_pair(lowerX, upperX), nbinsY, std::make_pair(lowerY, upperY))
62  { }
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 66 of file Profile2D.h.

68  : AnalysisObject("Profile2D", path, title),
69  _axis(xedges, yedges)
70  { }
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 74 of file Profile2D.h.

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

76  : AnalysisObject("Profile2D", path, title),
77  _axis(bins)
78  { }
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:37
std::vector< YODA::ProfileBin2D > & bins()
Access the bin vector (non-const)
Definition: Profile2D.h:275
Axis2D< ProfileBin2D, Dbn3D > Profile2DAxis
Convenience typedef.
Definition: Profile2D.h:25
Point3D Point
Types of the native Point3D collection.
Definition: Scatter3D.h:29

◆ 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:37
std::vector< YODA::ProfileBin2D > & bins()
Access the bin vector (non-const)
Definition: Profile2D.h:275
Axis2D< ProfileBin2D, Dbn3D > Profile2DAxis
Convenience typedef.
Definition: Profile2D.h:25

◆ 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 96 of file Profile2D.h.

100  : AnalysisObject("Profile2D", path, title),
101  _axis(bins, totalDbn, outflows)
102  { }
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:308
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

Definition at line 195 of file Profile2D.h.

195  {
196  _axis.addBin(xrange, yrange);
197  }

◆ addBin() [2/2]

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

Definition at line 202 of file Profile2D.h.

202  {
203  _axis.addBin(bin);
204  }
ProfileBin2D & bin(size_t index)
Access a bin by index (non-const)
Definition: Profile2D.h:282

◆ 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 209 of file Profile2D.h.

209  {
210  _axis.addBins(xcuts, ycuts);
211  }

◆ addBins() [2/2]

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

Bins addition operator.

Add multiple bins without resetting

Definition at line 217 of file Profile2D.h.

217  {
218  _axis.addBins(bins);
219  }
std::vector< YODA::ProfileBin2D > & bins()
Access the bin vector (non-const)
Definition: Profile2D.h:275

◆ bin() [1/2]

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

Access a bin by index (non-const)

Definition at line 282 of file Profile2D.h.

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

282 { 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 285 of file Profile2D.h.

285 { 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 292 of file Profile2D.h.

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

◆ binAt() [2/2]

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

Definition at line 294 of file Profile2D.h.

294 { 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 288 of file Profile2D.h.

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

◆ binIndexAt() [2/2]

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

Definition at line 289 of file Profile2D.h.

289 { 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 275 of file Profile2D.h.

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

275 { return _axis.bins(); }

◆ bins() [2/2]

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

Access the bin vector (const)

Definition at line 278 of file Profile2D.h.

278 { return _axis.bins(); }

◆ clone()

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

Make a copy on the stack.

Definition at line 114 of file Profile2D.h.

References Profile2D().

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

◆ dim()

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

Fill dimension of this data object.

Todo:
Change this to the total dimension (in v2)

Implements YODA::AnalysisObject.

Definition at line 129 of file Profile2D.h.

129 { return 2; }

◆ effNumEntries()

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

Get the effective number of fills.

Implements YODA::Fillable.

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:308
std::vector< YODA::ProfileBin2D > & bins()
Access the bin vector (non-const)
Definition: Profile2D.h:275
double effNumEntries() const
Effective number of entries .
Definition: Dbn3D.h:239
ProfileBin2D Bin
Definition: Profile2D.h:38

◆ 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 fill(), and fillDim().

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:156

◆ fill() [2/2]

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

Definition at line 140 of file Profile2D.h.

References fill(), and fillBin().

140  {
141  fill(std::get<0>(xs), std::get<1>(xs), std::get<2>(xs), weight, fraction);
142  }
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:187
ProfileBin2D & bin(size_t index)
Access a bin by index (non-const)
Definition: Profile2D.h:282

◆ fillDim()

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

Fill dimension of this data object.

Implements YODA::Fillable.

Definition at line 132 of file Profile2D.h.

References fill().

132 { return 2; }

◆ newclone()

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

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

Implements YODA::AnalysisObject.

Definition at line 119 of file Profile2D.h.

References Profile2D().

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

◆ numBins()

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

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

Implements YODA::Binned.

Definition at line 298 of file Profile2D.h.

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

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

◆ numBinsX()

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

Number of bins along the x axis.

Definition at line 301 of file Profile2D.h.

301 { return _axis.numBinsX(); }

◆ numBinsY()

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

Number of bins along the y axis.

Definition at line 304 of file Profile2D.h.

304 { return _axis.numBinsY(); }

◆ numEntries()

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

Get the number of fills (fractional fills are possible)

Implements YODA::Fillable.

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:308
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:275
ProfileBin2D Bin
Definition: Profile2D.h:38

◆ operator!=()

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

Definition at line 409 of file Profile2D.h.

References operator==().

409  {
410  return ! operator == (other);
411  }
bool operator==(const Profile2D &other)
Definition: Profile2D.h:405

◆ operator+=()

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

Add another profile to this one.

Definition at line 392 of file Profile2D.h.

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

392  {
393  if (hasAnnotation("ScaledBy")) rmAnnotation("ScaledBy");
394  _axis += toAdd._axis;
395  return *this;
396  }
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 399 of file Profile2D.h.

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

399  {
400  if (hasAnnotation("ScaledBy")) rmAnnotation("ScaledBy");
401  _axis -= toSubtract._axis;
402  return *this;
403  }
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 106 of file Profile2D.h.

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

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

◆ operator==()

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

Definition at line 405 of file Profile2D.h.

Referenced by operator!=().

405  {
406  return _axis == other._axis;
407  }

◆ reset()

void YODA::Profile2D::reset ( )
inlinevirtual

Reset the histogram.

Keep the binning but reset the statistics

Implements YODA::AnalysisObject.

Definition at line 151 of file Profile2D.h.

151  {
152  _axis.reset();
153  }

◆ rmBin()

void YODA::Profile2D::rmBin ( size_t  index)
inlinevirtual
Todo:
TODO

Implements YODA::Binned.

Definition at line 236 of file Profile2D.h.

236  {
237  _axis.eraseBin(index);
238  }

◆ sameBinning()

bool YODA::Profile2D::sameBinning ( const Profile2D p2)
inline

Check if binning is the same as different Profile2D.

Definition at line 222 of file Profile2D.h.

222  {
223  return _axis == p2._axis;
224  }

◆ scaleW()

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

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

Todo:
Is this ScaledBy annotation needed?

Implements YODA::Fillable.

Definition at line 156 of file Profile2D.h.

References YODA::AnalysisObject::setAnnotation().

156  {
158  setAnnotation("ScaledBy", annotation<double>("ScaledBy", 1.0) * scalefactor);
159  _axis.scaleW(scalefactor);
160  }
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 163 of file Profile2D.h.

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

163  {
164  _axis.totalDbn().scaleZ(scalefactor);
166  // _axis.overflow().scaleZ(scalefactor);
167  // _axis.underflow().scaleZ(scalefactor);
168  for (size_t i = 0; i < bins().size(); ++i)
169  bin(i).scaleZ(scalefactor);
170  }
ProfileBin2D & bin(size_t index)
Access a bin by index (non-const)
Definition: Profile2D.h:282
std::vector< YODA::ProfileBin2D > & bins()
Access the bin vector (non-const)
Definition: Profile2D.h:275
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 314 of file Profile2D.h.

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

314 { _axis.setTotalDbn(dbn); }

◆ sumW()

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

Get sum of weights in histo.

Implements YODA::Fillable.

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:275
ProfileBin2D Bin
Definition: Profile2D.h:38

◆ sumW2()

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

Get the sum of squared weights in histo.

Implements YODA::Fillable.

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:275
ProfileBin2D Bin
Definition: Profile2D.h:38

◆ totalDbn() [1/2]

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

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

Definition at line 308 of file Profile2D.h.

308 { 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 311 of file Profile2D.h.

311 { return _axis.totalDbn(); }

◆ xEdges()

const std::vector<double> YODA::Profile2D::xEdges ( ) const
inline

All bin edges on this histo's x axis

Note
This only returns the finite edges, i.e. -inf and +inf are removed
Todo:
Make the +-inf stripping controllable by a default-valued bool arg

Definition at line 250 of file Profile2D.h.

250 { return _axis.xEdges(); }

◆ xMax()

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

High x edge of this histo's axis.

Definition at line 264 of file Profile2D.h.

264 { 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:275

◆ xMin()

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

Low x edge of this histo's axis.

Todo:
Add xMins, xMaxs, xMids, xFoci, and y-versions

Definition at line 261 of file Profile2D.h.

261 { 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:275

◆ xStdDev()

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

Get the standard deviation in x.

Definition at line 364 of file Profile2D.h.

References xVariance().

364  {
365  return std::sqrt(xVariance(includeoverflows));
366  }
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 the mean 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:275

◆ 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:275

◆ yEdges()

const std::vector<double> YODA::Profile2D::yEdges ( ) const
inline

All bin edges on this histo's y axis

Note
This only returns the finite edges, i.e. -inf and +inf are removed
Todo:
Make the +-inf stripping controllable by a default-valued bool arg

Definition at line 256 of file Profile2D.h.

256 { return _axis.yEdges(); }

◆ yMax()

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

High y edge of this histo's axis.

Definition at line 271 of file Profile2D.h.

271 { 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:275

◆ yMin()

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

Low y edge of this histo's axis.

Definition at line 268 of file Profile2D.h.

268 { 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:275

◆ yStdDev()

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

Get the standard deviation in y.

Definition at line 369 of file Profile2D.h.

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

369  {
370  return std::sqrt(yVariance(includeoverflows));
371  }
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 the mean 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:275

◆ 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:275

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