CbmRoot
Loading...
Searching...
No Matches
cbm::algo::Histo1D Class Reference

#include <Histo1D.h>

Collaboration diagram for cbm::algo::Histo1D:
[legend]

Public Member Functions

 Histo1D (uint32_t numBins, double minValue, double maxValue, const std::string &name="", const std::string &title="")
 Standard constructor.
 
 Histo1D (const Histo1D &)=default
 Copy constructor: needed for boost serialization of vector of Histo1D.
 
virtual ~Histo1D ()=default
 Destructor.
 
void Add (double value, double weight=1.)
 Add an entry to the histogram.
 
void Clear ()
 Clear histogram contents.
 
double Content (uint32_t bin) const
 Histogram content in a bin.
 
double NumEntries () const
 Number of entries.
 
double MaxValue () const
 Upper edge.
 
double Mean () const
 First moment of distribution.
 
double MinValue () const
 Lower edge.
 
const std::string & Name () const
 Histogram name.
 
const std::string & Title () const
 Histogram name.
 
uint32_t NumBins () const
 Number of bins.
 
Histo1Doperator+= (const Histo1D &other)
 Add another histogram to an existing one.
 
double Overflow () const
 Overflow.
 
double Underflow () const
 Underflow.
 
double Stddev () const
 Second moment of distribution.
 
std::string ToString () const
 Properties to string.
 

Private Member Functions

template<class Archive >
void serialize (Archive &ar, const unsigned int)
 
 Histo1D ()
 Default constructor: needed for boost serialization of vector of Histo1D, need copy ctor call after!
 

Private Attributes

std::string fName
 
std::string fTitle
 
uint32_t fNumBins
 
double fMinValue
 
double fMaxValue
 
std::vector< double > fContent = {}
 
double fUnderflow = 0
 
double fOverflow = 0
 
size_t fNumEntries = 0
 

Friends

class boost::serialization::access
 

Detailed Description

Author
Volker Friese v.fri.nosp@m.ese@.nosp@m.gsi.d.nosp@m.e
Since
15 June 2023

Lightweight one-dimensional histogram class

Definition at line 25 of file Histo1D.h.

Constructor & Destructor Documentation

◆ Histo1D() [1/3]

cbm::algo::Histo1D::Histo1D ( uint32_t numBins,
double minValue,
double maxValue,
const std::string & name = "",
const std::string & title = "" )

Standard constructor.

Parameters
numBinsNumber of bins
minValueLower edge of histogram range
maxValueUpper edge of histogram range
nameHistogram name
titleROOT convention: Histogram title; Axis X title; Axis Y title

Definition at line 20 of file Histo1D.cxx.

References fContent.

◆ Histo1D() [2/3]

cbm::algo::Histo1D::Histo1D ( const Histo1D & )
default

Copy constructor: needed for boost serialization of vector of Histo1D.

◆ ~Histo1D()

virtual cbm::algo::Histo1D::~Histo1D ( )
virtualdefault

Destructor.

◆ Histo1D() [3/3]

cbm::algo::Histo1D::Histo1D ( )
inlineprivate

Default constructor: needed for boost serialization of vector of Histo1D, need copy ctor call after!

Definition at line 143 of file Histo1D.h.

Member Function Documentation

◆ Add()

void cbm::algo::Histo1D::Add ( double value,
double weight = 1. )

Add an entry to the histogram.

Parameters
valueValue to be histogrammed
weightWeight for the entry

Definition at line 35 of file Histo1D.cxx.

References fContent, fMaxValue, fMinValue, fNumBins, fNumEntries, fOverflow, and fUnderflow.

◆ Clear()

void cbm::algo::Histo1D::Clear ( )

Clear histogram contents.

Definition at line 50 of file Histo1D.cxx.

References fContent, fNumBins, fNumEntries, fOverflow, and fUnderflow.

◆ Content()

double cbm::algo::Histo1D::Content ( uint32_t bin) const

Histogram content in a bin.

Parameters
binBin index
Returns
Histogram content. Zero if bin index is out of scope.

Definition at line 59 of file Histo1D.cxx.

References fContent, and fNumBins.

◆ MaxValue()

double cbm::algo::Histo1D::MaxValue ( ) const
inline

Upper edge.

Definition at line 69 of file Histo1D.h.

References fMaxValue.

◆ Mean()

double cbm::algo::Histo1D::Mean ( ) const

First moment of distribution.

Definition at line 69 of file Histo1D.cxx.

References fContent, fMaxValue, fMinValue, fNumBins, and x.

Referenced by Stddev(), and ToString().

◆ MinValue()

double cbm::algo::Histo1D::MinValue ( ) const
inline

Lower edge.

Definition at line 77 of file Histo1D.h.

References fMinValue.

◆ Name()

const std::string & cbm::algo::Histo1D::Name ( ) const
inline

Histogram name.

Definition at line 81 of file Histo1D.h.

References fName.

◆ NumBins()

uint32_t cbm::algo::Histo1D::NumBins ( ) const
inline

Number of bins.

Definition at line 89 of file Histo1D.h.

References fNumBins.

◆ NumEntries()

double cbm::algo::Histo1D::NumEntries ( ) const
inline

Number of entries.

Definition at line 65 of file Histo1D.h.

References fNumEntries.

◆ operator+=()

Histo1D & cbm::algo::Histo1D::operator+= ( const Histo1D & other)

Add another histogram to an existing one.

Parameters
otherHistogram object to be added

Definition at line 85 of file Histo1D.cxx.

References fContent, fMaxValue, fMinValue, fNumBins, fNumEntries, fOverflow, and fUnderflow.

◆ Overflow()

double cbm::algo::Histo1D::Overflow ( ) const
inline

Overflow.

Definition at line 98 of file Histo1D.h.

References fOverflow.

◆ serialize()

template<class Archive >
void cbm::algo::Histo1D::serialize ( Archive & ar,
const unsigned int  )
inlineprivate

Definition at line 129 of file Histo1D.h.

References fContent, fMaxValue, fMinValue, fName, fNumBins, fNumEntries, fOverflow, fTitle, and fUnderflow.

◆ Stddev()

double cbm::algo::Histo1D::Stddev ( ) const

Second moment of distribution.

Definition at line 101 of file Histo1D.cxx.

References fContent, fMaxValue, fMinValue, fNumBins, Mean(), sqrt(), and x.

Referenced by ToString().

◆ Title()

const std::string & cbm::algo::Histo1D::Title ( ) const
inline

Histogram name.

Definition at line 85 of file Histo1D.h.

References fTitle.

◆ ToString()

std::string cbm::algo::Histo1D::ToString ( ) const

Properties to string.

Definition at line 117 of file Histo1D.cxx.

References fMaxValue, fMinValue, fName, fNumBins, fNumEntries, fOverflow, fTitle, fUnderflow, Mean(), and Stddev().

◆ Underflow()

double cbm::algo::Histo1D::Underflow ( ) const
inline

Underflow.

Definition at line 102 of file Histo1D.h.

References fUnderflow.

Friends And Related Symbol Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Definition at line 127 of file Histo1D.h.

Member Data Documentation

◆ fContent

std::vector<double> cbm::algo::Histo1D::fContent = {}
private

Content

Definition at line 122 of file Histo1D.h.

Referenced by Add(), Clear(), Content(), Histo1D(), Mean(), operator+=(), serialize(), and Stddev().

◆ fMaxValue

double cbm::algo::Histo1D::fMaxValue
private

Definition at line 119 of file Histo1D.h.

Referenced by Add(), MaxValue(), Mean(), operator+=(), serialize(), Stddev(), and ToString().

◆ fMinValue

double cbm::algo::Histo1D::fMinValue
private

Definition at line 118 of file Histo1D.h.

Referenced by Add(), Mean(), MinValue(), operator+=(), serialize(), Stddev(), and ToString().

◆ fName

std::string cbm::algo::Histo1D::fName
private

Properties (no need for const if no accessors, avoid really complicated boost serialization)

Definition at line 115 of file Histo1D.h.

Referenced by Name(), serialize(), and ToString().

◆ fNumBins

uint32_t cbm::algo::Histo1D::fNumBins
private

Definition at line 117 of file Histo1D.h.

Referenced by Add(), Clear(), Content(), Mean(), NumBins(), operator+=(), serialize(), Stddev(), and ToString().

◆ fNumEntries

size_t cbm::algo::Histo1D::fNumEntries = 0
private

Definition at line 125 of file Histo1D.h.

Referenced by Add(), Clear(), NumEntries(), operator+=(), serialize(), and ToString().

◆ fOverflow

double cbm::algo::Histo1D::fOverflow = 0
private

Definition at line 124 of file Histo1D.h.

Referenced by Add(), Clear(), operator+=(), Overflow(), serialize(), and ToString().

◆ fTitle

std::string cbm::algo::Histo1D::fTitle
private

Definition at line 116 of file Histo1D.h.

Referenced by serialize(), Title(), and ToString().

◆ fUnderflow

double cbm::algo::Histo1D::fUnderflow = 0
private

Definition at line 123 of file Histo1D.h.

Referenced by Add(), Clear(), operator+=(), serialize(), ToString(), and Underflow().


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