BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
Histogram2D Class Reference

Two dimensional histogram. More...

Inheritance diagram for Histogram2D:
[legend]
Collaboration diagram for Histogram2D:
[legend]

Public Types

enum  DataType { INTEGRAL , AVERAGE , STANDARD_ERROR , NENTRIES }
 

Public Member Functions

 Histogram2D (const IAxis &axis_x, const IAxis &axis_y)
 Constructor for 2D histogram with custom axes. More...
 
 Histogram2D (const OutputData< double > &data)
 Constructor for 2D histograms from basic OutputData object. More...
 
 Histogram2D (int nbinsx, const std::vector< double > &xbins, int nbinsy, const std::vector< double > &ybins)
 Constructor for variable bin size histograms. More...
 
 Histogram2D (int nbinsx, double xlow, double xup, int nbinsy, double ylow, double yup)
 Constructor for fix bin size histograms. More...
 
 Histogram2D (std::vector< std::vector< double >> data)
 Constructor for 2D histograms from numpy array (thanks to swig) More...
 
void addBinContent (size_t i, double value)
 Add the value to the bin. More...
 
void addContent (const std::vector< std::vector< double >> &data)
 Add to values in histograms channels from numpy array,. More...
 
PyObjectarray (DataType dataType=DataType::INTEGRAL) const
 Returns numpy array with bin content (accumulated values). More...
 
double binAverage (size_t binx, size_t biny) const
 Returns average value of the bin with given indices (for 2D histograms). More...
 
double binAverage (size_t i) const
 Returns average value in the bin with given index. More...
 
double binContent (size_t binx, size_t biny) const
 Returns content (accumulated value) of the 2D histogram bin. More...
 
double binContent (size_t i) const
 Returns content (accumulated value) of bin i. More...
 
double binError (size_t binx, size_t biny) const
 Returns error of the bin with given indices (for 2D histograms). More...
 
double binError (size_t i) const
 Returns error of the bin with given index. More...
 
int binNumberOfEntries (size_t binx, size_t biny) const
 Returns number of entries in the bin with given indices (for 2D histograms). More...
 
int binNumberOfEntries (size_t i) const
 Returns number of entries in the bin with given index. More...
 
Histogram2Dclone () const
 Returns clone of other histogram. More...
 
OutputData< double > * createOutputData (DataType dataType=DataType::INTEGRAL) const
 creates new OutputData with histogram's shape and values corresponding to DataType More...
 
Histogram2Dcrop (double xmin, double ymin, double xmax, double ymax)
 Creates new histogram by applying rectangular clip. More...
 
int fill (double x, double y, double weight=1.0)
 Increment bin with abscissa x and ordinate y with a weight. More...
 
size_t findGlobalBin (double x, double y) const
 Returns closest global bin index for given axes coordinates. More...
 
PyObjectgetArray (DataType dataType=DataType::INTEGRAL) const
 
OutputData< CumulativeValue > & getData ()
 
const OutputData< CumulativeValue > & getData () const
 
size_t getGlobalBin (size_t binx, size_t biny=0) const
 Returns global bin index for given axes indices. For 1D, just returns binx. More...
 
double getMaximum () const
 Returns histogram maximum value (maximum of binContent() over all bins) More...
 
size_t getMaximumBinIndex () const
 Returns globalbin index with maximum content. More...
 
double getMinimum () const
 Returns histogram minimum value (minimum of binContent() over all bins) More...
 
size_t getMinimumBinIndex () const
 Returns globalbin index with minimum content. More...
 
size_t getNbinsX () const
 Returns number of bins on x-axis. More...
 
size_t getNbinsY () const
 Returns number of bins on y-axis. More...
 
size_t getTotalNumberOfBins () const
 Returns total number of histogram bins. More...
 
double getXmax () const
 Returns x-axis max (upper edge of last bin). More...
 
double getXmin () const
 Returns x-axis min (lower edge of first bin). More...
 
double getYmax () const
 Returns y-axis max (upper edge of last bin) for 2D histograms. More...
 
double getYmin () const
 Returns y-axis min (lower edge of first bin) for 2D histograms. More...
 
bool hasSameDimensions (const IHistogram &other) const
 Returns true if object have same rank and number of axes bins. More...
 
bool hasSameShape (const IHistogram &other) const
 Returns true if objects a) have same dimensions b) bin boundaries of axes coincide. More...
 
double integral () const
 Returns integral of bins content (computed as a sum of all bin content). More...
 
void load (const std::string &filename)
 Loads histogram from file, the shape of array in file should match Following formats are available: *.txt, *.tif, *.int (*.txt.gz, *.tif.gz, *.int.gz) Only bin content will be loaded, histogram axes remain the same. More...
 
const IHistogramoperator+= (const IHistogram &right)
 addition-assignment operator for two histograms More...
 
Histogram1DprojectionX ()
 Project a 2D histogram into 1D histogram along X. More...
 
Histogram1DprojectionX (double ylow, double yup)
 Project a 2D histogram into 1D histogram along X. More...
 
Histogram1DprojectionX (double yvalue)
 Project a 2D histogram into 1D histogram along X. More...
 
Histogram1DprojectionY ()
 Project a 2D histogram into 1D histogram along Y. More...
 
Histogram1DprojectionY (double xlow, double xup)
 Project a 2D histogram into 1D histogram along Y. More...
 
Histogram1DprojectionY (double xvalue)
 Project a 2D histogram into 1D histogram along Y. More...
 
size_t rank () const
 Returns the number of histogram dimensions. More...
 
IHistogramrelativeDifferenceHistogram (const IHistogram &rhs)
 returns histogram representing relative difference of two histograms. More...
 
void reset ()
 Reset histogram content (axes remains) More...
 
void save (const std::string &filename)
 Saves histogram in file Following formats are available: *.txt, *.tif, *.int (*.txt.gz, *.tif.gz, *.int.gz) More...
 
void scale (double value)
 Multiply this histogram (every bin content value) by a constant. More...
 
void setBinContent (size_t i, double value)
 Sets content of the bin corresponding to the globalbin number. More...
 
void setContent (const std::vector< std::vector< double >> &data)
 Sets the values in histograms channels from numpy array,. More...
 
const IAxisxAxis () const
 returns x-axis More...
 
size_t xAxisIndex (size_t i) const
 Returns x-axis index for global bin index i. More...
 
double xAxisValue (size_t i)
 Returns the center of bin i of the x axis. More...
 
const IAxisyAxis () const
 returns y-axis for 2D histograms More...
 
size_t yAxisIndex (size_t i) const
 Returns y-axis index for global bin index i. More...
 
double yAxisValue (size_t i)
 Returns the center of bin i of the y axis. More...
 

Static Public Member Functions

static IHistogramcreateFrom (const std::string &filename)
 create new histogram from file content More...
 
static IHistogramcreateFrom (const std::vector< std::vector< double >> &data)
 create new histogram from numpy array More...
 
static IHistogramcreateHistogram (const OutputData< double > &source)
 

Protected Member Functions

double binData (size_t i, DataType dataType) const
 returns data of requested type for globalbin number More...
 
void check_x_axis () const
 
void check_y_axis () const
 
void copyContentFrom (const IHistogram &other)
 Copy content (but not the axes) from other histogram. Dimensions should be the same. More...
 
Histogram1Dcreate_projectionX (int ybinlow, int ybinup)
 Creates projection along X. More...
 
Histogram1Dcreate_projectionY (int xbinlow, int xbinup)
 Creates projection along Y. More...
 
std::vector< double > getDataVector (DataType dataType) const
 returns vector of values of requested DataType More...
 
void init_from_data (const OutputData< double > &source)
 
template<typename T >
void initFromShape (const T &data)
 

Protected Attributes

OutputData< CumulativeValuem_data
 

Detailed Description

Two dimensional histogram.

Definition at line 24 of file Histogram2D.h.

Member Enumeration Documentation

◆ DataType

enum IHistogram::DataType
inherited
Enumerator
INTEGRAL 
AVERAGE 
STANDARD_ERROR 
NENTRIES 

Definition at line 29 of file IHistogram.h.

Constructor & Destructor Documentation

◆ Histogram2D() [1/5]

Histogram2D::Histogram2D ( int  nbinsx,
double  xlow,
double  xup,
int  nbinsy,
double  ylow,
double  yup 
)

Constructor for fix bin size histograms.

Parameters
nbinsxnumber of bins on X-axis
xlowlow edge of the first bin of X-axis
xupupper edge of the last bin of X-axis
nbinsynumber of bins on Y axis
ylowlow edge of the first bin of Y-axis
yupupper edge of the last bin of Y-axis

Definition at line 20 of file Histogram2D.cpp.

21 {
22  m_data.addAxis(FixedBinAxis("x-axis", nbinsx, xlow, xup));
23  m_data.addAxis(FixedBinAxis("y-axis", nbinsy, ylow, yup));
24 }
Axis with fixed bin size.
Definition: FixedBinAxis.h:23
OutputData< CumulativeValue > m_data
Definition: IHistogram.h:193
void addAxis(const IAxis &new_axis)
Definition: OutputData.h:295

References OutputData< T >::addAxis(), and IHistogram::m_data.

Referenced by clone(), and crop().

Here is the call graph for this function:

◆ Histogram2D() [2/5]

Histogram2D::Histogram2D ( int  nbinsx,
const std::vector< double > &  xbins,
int  nbinsy,
const std::vector< double > &  ybins 
)

Constructor for variable bin size histograms.

Parameters
nbinsxnumber of bins on X-axis
xbinsArray of size nbins+1 containing low-edges for each bin and upper edge of last bin.
nbinsynumber of bins on Y-axis
ybinsArray of size nbins+1 containing low-edges for each bin and upper edge of last bin.

Definition at line 26 of file Histogram2D.cpp.

28 {
29  m_data.addAxis(VariableBinAxis("x-axis", nbinsx, xbins));
30  m_data.addAxis(VariableBinAxis("y-axis", nbinsy, ybins));
31 }
Axis with variable bin size.

References OutputData< T >::addAxis(), and IHistogram::m_data.

Here is the call graph for this function:

◆ Histogram2D() [3/5]

Histogram2D::Histogram2D ( const IAxis axis_x,
const IAxis axis_y 
)

Constructor for 2D histogram with custom axes.

Definition at line 33 of file Histogram2D.cpp.

33 : IHistogram(axis_x, axis_y) {}

◆ Histogram2D() [4/5]

Histogram2D::Histogram2D ( const OutputData< double > &  data)

Constructor for 2D histograms from basic OutputData object.

Definition at line 35 of file Histogram2D.cpp.

36 {
37  init_from_data(data);
38 }
void init_from_data(const OutputData< double > &source)
Definition: IHistogram.cpp:288

References IHistogram::init_from_data().

Here is the call graph for this function:

◆ Histogram2D() [5/5]

Histogram2D::Histogram2D ( std::vector< std::vector< double >>  data)

Constructor for 2D histograms from numpy array (thanks to swig)

Definition at line 41 of file Histogram2D.cpp.

42 {
43  initFromShape(data);
44  this->setContent(data);
45 }
void setContent(const std::vector< std::vector< double >> &data)
Sets the values in histograms channels from numpy array,.
void initFromShape(const T &data)
Definition: Histogram2D.h:114

References initFromShape(), and setContent().

Here is the call graph for this function:

Member Function Documentation

◆ addBinContent()

void IHistogram::addBinContent ( size_t  i,
double  value 
)
inherited

Add the value to the bin.

Definition at line 151 of file IHistogram.cpp.

152 {
153  m_data[i].add(value);
154 }

References IHistogram::m_data.

Referenced by IHistogram::operator+=().

◆ addContent()

void Histogram2D::addContent ( const std::vector< std::vector< double >> &  data)

Add to values in histograms channels from numpy array,.

Definition at line 125 of file Histogram2D.cpp.

126 {
127  auto shape = ArrayUtils::getShape(data);
128  const size_t nrows = shape.first;
129  const size_t ncols = shape.second;
130 
131  if (nrows != m_data.axis(1).size() || ncols != m_data.axis(0).size()) {
132  std::ostringstream ostr;
133  ostr << "Histogram2D::addContent() -> Shape of input array [" << nrows << ", " << ncols
134  << "] doesn't mach histogram axes. "
135  << "X-axis size: " << m_data.axis(0).size()
136  << "Y-axis size: " << m_data.axis(1).size();
137  throw std::runtime_error(ostr.str());
138  }
139 
140  for (size_t row = 0; row < nrows; ++row) {
141  for (size_t col = 0; col < ncols; ++col) {
142  size_t globalbin = nrows - row - 1 + col * nrows;
143  m_data[globalbin].add(data[row][col]);
144  }
145  }
146 }
virtual size_t size() const =0
retrieve the number of bins
const IAxis & axis(size_t serial_number) const
returns axis with given serial number
Definition: OutputData.h:318
std::pair< size_t, size_t > getShape(const T &data)
Returns shape nrows, ncols of 2D array.
Definition: ArrayUtils.h:127

References OutputData< T >::axis(), ArrayUtils::getShape(), IHistogram::m_data, and IAxis::size().

Referenced by setContent().

Here is the call graph for this function:

◆ array()

PyObject * IHistogram::array ( DataType  dataType = DataType::INTEGRAL) const
inherited

Returns numpy array with bin content (accumulated values).

Definition at line 226 of file IHistogram.cpp.

227 {
228  const std::unique_ptr<OutputData<double>> data(createOutputData(dataType));
229  return data->getArray();
230 }
OutputData< double > * createOutputData(DataType dataType=DataType::INTEGRAL) const
creates new OutputData with histogram's shape and values corresponding to DataType
Definition: IHistogram.cpp:343

References IHistogram::createOutputData().

Referenced by IHistogram::getArray().

Here is the call graph for this function:

◆ binAverage() [1/2]

double IHistogram::binAverage ( size_t  binx,
size_t  biny 
) const
inherited

Returns average value of the bin with given indices (for 2D histograms).

Definition at line 171 of file IHistogram.cpp.

172 {
173  return binAverage(getGlobalBin(binx, biny));
174 }
size_t getGlobalBin(size_t binx, size_t biny=0) const
Returns global bin index for given axes indices. For 1D, just returns binx.
Definition: IHistogram.cpp:86
double binAverage(size_t i) const
Returns average value in the bin with given index.
Definition: IHistogram.cpp:166

References IHistogram::binAverage(), and IHistogram::getGlobalBin().

Here is the call graph for this function:

◆ binAverage() [2/2]

double IHistogram::binAverage ( size_t  i) const
inherited

Returns average value in the bin with given index.

Definition at line 166 of file IHistogram.cpp.

167 {
168  return m_data[i].getAverage();
169 }

References IHistogram::m_data.

Referenced by IHistogram::binAverage(), and IHistogram::binData().

◆ binContent() [1/2]

double IHistogram::binContent ( size_t  binx,
size_t  biny 
) const
inherited

Returns content (accumulated value) of the 2D histogram bin.

Definition at line 141 of file IHistogram.cpp.

142 {
143  return binContent(getGlobalBin(binx, biny));
144 }
double binContent(size_t i) const
Returns content (accumulated value) of bin i.
Definition: IHistogram.cpp:136

References IHistogram::binContent(), and IHistogram::getGlobalBin().

Here is the call graph for this function:

◆ binContent() [2/2]

double IHistogram::binContent ( size_t  i) const
inherited

Returns content (accumulated value) of bin i.

Definition at line 136 of file IHistogram.cpp.

137 {
138  return m_data[i].getContent();
139 }

References IHistogram::m_data.

Referenced by IHistogram::binContent(), IHistogram::binData(), create_projectionX(), create_projectionY(), IHistogram::operator+=(), and IHistogram::relativeDifferenceHistogram().

◆ binData()

double IHistogram::binData ( size_t  i,
IHistogram::DataType  dataType 
) const
protectedinherited

returns data of requested type for globalbin number

Definition at line 305 of file IHistogram.cpp.

306 {
307  if (dataType == DataType::INTEGRAL) {
308  return binContent(i);
309  } else if (dataType == DataType::AVERAGE) {
310  return binAverage(i);
311  } else if (dataType == DataType::STANDARD_ERROR) {
312  return binError(i);
313  } else if (dataType == DataType::NENTRIES) {
314  return binNumberOfEntries(i);
315  } else
316  throw std::runtime_error("IHistogram::binData() -> Error. Unknown data type.");
317 }
double binError(size_t i) const
Returns error of the bin with given index.
Definition: IHistogram.cpp:156
int binNumberOfEntries(size_t i) const
Returns number of entries in the bin with given index.
Definition: IHistogram.cpp:176

References IHistogram::binAverage(), IHistogram::binContent(), IHistogram::binError(), and IHistogram::binNumberOfEntries().

Referenced by IHistogram::createOutputData(), and IHistogram::getDataVector().

Here is the call graph for this function:

◆ binError() [1/2]

double IHistogram::binError ( size_t  binx,
size_t  biny 
) const
inherited

Returns error of the bin with given indices (for 2D histograms).

Definition at line 161 of file IHistogram.cpp.

162 {
163  return binError(getGlobalBin(binx, biny));
164 }

References IHistogram::binError(), and IHistogram::getGlobalBin().

Here is the call graph for this function:

◆ binError() [2/2]

double IHistogram::binError ( size_t  i) const
inherited

Returns error of the bin with given index.

Definition at line 156 of file IHistogram.cpp.

157 {
158  return m_data[i].getRMS();
159 }

References IHistogram::m_data.

Referenced by IHistogram::binData(), and IHistogram::binError().

◆ binNumberOfEntries() [1/2]

int IHistogram::binNumberOfEntries ( size_t  binx,
size_t  biny 
) const
inherited

Returns number of entries in the bin with given indices (for 2D histograms).

Definition at line 181 of file IHistogram.cpp.

182 {
183  return binNumberOfEntries(getGlobalBin(binx, biny));
184 }

References IHistogram::binNumberOfEntries(), and IHistogram::getGlobalBin().

Here is the call graph for this function:

◆ binNumberOfEntries() [2/2]

int IHistogram::binNumberOfEntries ( size_t  i) const
inherited

Returns number of entries in the bin with given index.

Definition at line 176 of file IHistogram.cpp.

177 {
178  return m_data[i].getNumberOfEntries();
179 }

References IHistogram::m_data.

Referenced by IHistogram::binData(), and IHistogram::binNumberOfEntries().

◆ check_x_axis()

void IHistogram::check_x_axis ( ) const
protectedinherited

Definition at line 268 of file IHistogram.cpp.

269 {
270  if (rank() < 1) {
271  std::ostringstream message;
272  message << "IHistogram::check_x_axis() -> Error. X-xis does not exist. ";
273  message << "Rank of histogram " << rank() << "." << std::endl;
274  throw std::runtime_error(message.str());
275  }
276 }
virtual size_t rank() const =0
Returns number of histogram dimensions.

References IHistogram::rank().

Referenced by IHistogram::xAxis(), and IHistogram::xAxisValue().

Here is the call graph for this function:

◆ check_y_axis()

void IHistogram::check_y_axis ( ) const
protectedinherited

Definition at line 278 of file IHistogram.cpp.

279 {
280  if (rank() < 2) {
281  std::ostringstream message;
282  message << "IHistogram::check_y_axis() -> Error. Y-axis does not exist. ";
283  message << "Rank of histogram " << rank() << "." << std::endl;
284  throw std::runtime_error(message.str());
285  }
286 }

References IHistogram::rank().

Referenced by IHistogram::yAxis(), and IHistogram::yAxisValue().

Here is the call graph for this function:

◆ clone()

Histogram2D * Histogram2D::clone ( ) const
virtual

Returns clone of other histogram.

Implements IHistogram.

Definition at line 47 of file Histogram2D.cpp.

48 {
49  return new Histogram2D(*this);
50 }
Histogram2D(int nbinsx, double xlow, double xup, int nbinsy, double ylow, double yup)
Constructor for fix bin size histograms.
Definition: Histogram2D.cpp:20

References Histogram2D().

Here is the call graph for this function:

◆ copyContentFrom()

void IHistogram::copyContentFrom ( const IHistogram other)
protectedinherited

Copy content (but not the axes) from other histogram. Dimensions should be the same.

Definition at line 331 of file IHistogram.cpp.

332 {
333  if (!hasSameDimensions(other))
334  throw std::runtime_error(
335  "IHistogram::copyContentFrom() -> Error. Can't copy the data of different shape.");
336  reset();
337  for (size_t i = 0; i < getTotalNumberOfBins(); ++i) {
338  m_data[i] = other.m_data[i];
339  }
340 }
size_t getTotalNumberOfBins() const
Returns total number of histogram bins.
Definition: IHistogram.cpp:39
void reset()
Reset histogram content (axes remains)
Definition: IHistogram.cpp:238
bool hasSameDimensions(const IHistogram &other) const
Returns true if object have same rank and number of axes bins.
Definition: IHistogram.cpp:358

References IHistogram::getTotalNumberOfBins(), IHistogram::hasSameDimensions(), IHistogram::m_data, and IHistogram::reset().

Referenced by IHistogram::load().

Here is the call graph for this function:

◆ create_projectionX()

Histogram1D * Histogram2D::create_projectionX ( int  ybinlow,
int  ybinup 
)
protected

Creates projection along X.

The projections is made by collecting the data in the range between [ybinlow, ybinup].

Definition at line 148 of file Histogram2D.cpp.

149 {
150  Histogram1D* result = new Histogram1D(this->xAxis());
151 
152  for (size_t index = 0; index < getTotalNumberOfBins(); ++index) {
153 
154  int ybin = static_cast<int>(yAxisIndex(index));
155 
156  if (ybin >= ybinlow && ybin <= ybinup) {
157  result->fill(xAxisValue(index), binContent(index));
158  }
159  }
160  return result;
161 }
One dimensional histogram.
Definition: Histogram1D.h:23
int fill(double x, double weight=1.0)
Increment bin with abscissa x with a weight.
Definition: Histogram1D.cpp:42
const IAxis & xAxis() const
returns x-axis
Definition: IHistogram.cpp:44
size_t yAxisIndex(size_t i) const
Returns y-axis index for global bin index i.
Definition: IHistogram.cpp:109
double xAxisValue(size_t i)
Returns the center of bin i of the x axis.
Definition: IHistogram.cpp:114

References IHistogram::binContent(), Histogram1D::fill(), IHistogram::getTotalNumberOfBins(), IHistogram::xAxis(), IHistogram::xAxisValue(), and IHistogram::yAxisIndex().

Referenced by projectionX().

Here is the call graph for this function:

◆ create_projectionY()

Histogram1D * Histogram2D::create_projectionY ( int  xbinlow,
int  xbinup 
)
protected

Creates projection along Y.

The projections is made by collecting the data in the range between [xbinlow, xbinup].

Definition at line 163 of file Histogram2D.cpp.

164 {
165  Histogram1D* result = new Histogram1D(this->yAxis());
166 
167  for (size_t index = 0; index < getTotalNumberOfBins(); ++index) {
168 
169  int xbin = static_cast<int>(xAxisIndex(index));
170 
171  if (xbin >= xbinlow && xbin <= xbinup) {
172  result->fill(yAxisValue(index), binContent(index));
173  }
174  }
175  return result;
176 }
const IAxis & yAxis() const
returns y-axis for 2D histograms
Definition: IHistogram.cpp:50
double yAxisValue(size_t i)
Returns the center of bin i of the y axis.
Definition: IHistogram.cpp:120
size_t xAxisIndex(size_t i) const
Returns x-axis index for global bin index i.
Definition: IHistogram.cpp:104

References IHistogram::binContent(), Histogram1D::fill(), IHistogram::getTotalNumberOfBins(), IHistogram::xAxisIndex(), IHistogram::yAxis(), and IHistogram::yAxisValue().

Referenced by projectionY().

Here is the call graph for this function:

◆ createFrom() [1/2]

IHistogram * IHistogram::createFrom ( const std::string &  filename)
staticinherited

create new histogram from file content

Definition at line 258 of file IHistogram.cpp.

259 {
261 }
static IHistogram * readIntensityData(const std::string &file_name)
Reads file and returns newly created Histogram object.
std::string filename(const std::string &path)
Returns path without directory part ("Foo/Bar/Doz.int.gz" -> "Doz.int.gz")

References FileSystemUtils::filename(), and IntensityDataIOFactory::readIntensityData().

Here is the call graph for this function:

◆ createFrom() [2/2]

IHistogram * IHistogram::createFrom ( const std::vector< std::vector< double >> &  data)
staticinherited

create new histogram from numpy array

Definition at line 263 of file IHistogram.cpp.

264 {
265  return new Histogram2D(data);
266 }
Two dimensional histogram.
Definition: Histogram2D.h:24

◆ createHistogram()

IHistogram * IHistogram::createHistogram ( const OutputData< double > &  source)
staticinherited

Definition at line 243 of file IHistogram.cpp.

244 {
245  if (source.rank() == 1) {
246  return new Histogram1D(source);
247  } else if (source.rank() == 2) {
248  return new Histogram2D(source);
249  } else {
250  std::ostringstream message;
251  message << "IHistogram::createHistogram(const OutputData<double>& source) -> Error. ";
252  message << "The rank of source " << source.rank() << " ";
253  message << "is not suitable for creation neither 1-dim nor 2-dim histograms.";
254  throw std::runtime_error(message.str());
255  }
256 }
size_t rank() const
Returns number of dimensions.
Definition: OutputData.h:56

References OutputData< T >::rank().

Referenced by DetectorMask::createHistogram(), and IntensityDataIOFactory::readIntensityData().

Here is the call graph for this function:

◆ createOutputData()

OutputData< double > * IHistogram::createOutputData ( IHistogram::DataType  dataType = DataType::INTEGRAL) const
inherited

creates new OutputData with histogram's shape and values corresponding to DataType

creates new OutputData with histogram's shape and put there values corresponding to DataType

Definition at line 343 of file IHistogram.cpp.

344 {
346  result->copyShapeFrom(m_data);
347  for (size_t i = 0; i < getTotalNumberOfBins(); ++i) {
348  (*result)[i] = binData(i, dataType);
349  }
350  return result;
351 }
double binData(size_t i, DataType dataType) const
returns data of requested type for globalbin number
Definition: IHistogram.cpp:305
void copyShapeFrom(const OutputData< U > &other)
Definition: OutputData.h:277

References IHistogram::binData(), OutputData< T >::copyShapeFrom(), IHistogram::getTotalNumberOfBins(), and IHistogram::m_data.

Referenced by IHistogram::array(), HistoUtils::FindPeaks(), and IntensityDataIOFactory::writeIntensityData().

Here is the call graph for this function:

◆ crop()

Histogram2D * Histogram2D::crop ( double  xmin,
double  ymin,
double  xmax,
double  ymax 
)

Creates new histogram by applying rectangular clip.

Definition at line 99 of file Histogram2D.cpp.

100 {
101  const std::unique_ptr<IAxis> xaxis(xAxis().createClippedAxis(xmin, xmax));
102  const std::unique_ptr<IAxis> yaxis(yAxis().createClippedAxis(ymin, ymax));
103 
104  Histogram2D* result = new Histogram2D(*xaxis, *yaxis);
106  OutputData<CumulativeValue>::iterator it_result = result->m_data.begin();
107  while (it_origin != m_data.end()) {
108  double x = m_data.getAxisValue(it_origin.getIndex(), 0);
109  double y = m_data.getAxisValue(it_origin.getIndex(), 1);
110  if (result->xAxis().contains(x) && result->yAxis().contains(y)) {
111  *it_result = *it_origin;
112  ++it_result;
113  }
114  ++it_origin;
115  }
116  return result;
117 }
virtual bool contains(double value) const
Returns true if axis contains given point.
Definition: IAxis.cpp:37
iterator end()
Returns read/write iterator that points to the one past last element.
Definition: OutputData.h:93
iterator begin()
Returns read/write iterator that points to the first element.
Definition: OutputData.h:343
double getAxisValue(size_t global_index, size_t i_selected_axis) const
Returns the value of selected axis for given global_index.
Definition: OutputData.h:430

References Histogram2D(), OutputData< T >::begin(), IAxis::contains(), OutputData< T >::end(), OutputData< T >::getAxisValue(), IHistogram::m_data, IHistogram::xAxis(), and IHistogram::yAxis().

Here is the call graph for this function:

◆ fill()

int Histogram2D::fill ( double  x,
double  y,
double  weight = 1.0 
)

Increment bin with abscissa x and ordinate y with a weight.

Definition at line 52 of file Histogram2D.cpp.

53 {
54  if (!xAxis().contains(x))
55  return -1;
56  if (!yAxis().contains(y))
57  return -1;
58  size_t index = m_data.findGlobalIndex({x, y});
59  m_data[index].add(weight);
60  return (int)index;
61 }
size_t findGlobalIndex(const std::vector< double > &coordinates) const
Returns global index for specified axes values.
Definition: OutputData.h:416

References OutputData< T >::findGlobalIndex(), IHistogram::m_data, IHistogram::xAxis(), and IHistogram::yAxis().

Here is the call graph for this function:

◆ findGlobalBin()

size_t IHistogram::findGlobalBin ( double  x,
double  y 
) const
inherited

Returns closest global bin index for given axes coordinates.

Definition at line 95 of file IHistogram.cpp.

96 {
97  std::vector<double> coordinates;
98  coordinates.push_back(x);
99  if (rank() == 2)
100  coordinates.push_back(y);
101  return m_data.findGlobalIndex(coordinates);
102 }

References OutputData< T >::findGlobalIndex(), IHistogram::m_data, and IHistogram::rank().

Here is the call graph for this function:

◆ getArray()

PyObject * IHistogram::getArray ( DataType  dataType = DataType::INTEGRAL) const
inherited
Deprecated:
Use array() instead.

Definition at line 232 of file IHistogram.cpp.

233 {
234  return array(dataType);
235 }
PyObject * array(DataType dataType=DataType::INTEGRAL) const
Returns numpy array with bin content (accumulated values).
Definition: IHistogram.cpp:226

References IHistogram::array().

Here is the call graph for this function:

◆ getData() [1/2]

OutputData< CumulativeValue > & IHistogram::getData ( )
inherited

Definition at line 131 of file IHistogram.cpp.

132 {
133  return m_data;
134 }

References IHistogram::m_data.

◆ getData() [2/2]

const OutputData< CumulativeValue > & IHistogram::getData ( ) const
inherited

Definition at line 126 of file IHistogram.cpp.

127 {
128  return m_data;
129 }

References IHistogram::m_data.

Referenced by HistoUtils::getRelativeDifference().

◆ getDataVector()

std::vector< double > IHistogram::getDataVector ( IHistogram::DataType  dataType) const
protectedinherited

returns vector of values of requested DataType

Definition at line 320 of file IHistogram.cpp.

321 {
322  std::vector<double> result;
323  result.resize(getTotalNumberOfBins(), 0.0);
324  for (size_t index = 0; index < getTotalNumberOfBins(); ++index) {
325  result[index] = binData(index, dataType);
326  }
327  return result;
328 }

References IHistogram::binData(), and IHistogram::getTotalNumberOfBins().

Referenced by Histogram1D::binErrors(), and Histogram1D::binValues().

Here is the call graph for this function:

◆ getGlobalBin()

size_t IHistogram::getGlobalBin ( size_t  binx,
size_t  biny = 0 
) const
inherited

Returns global bin index for given axes indices. For 1D, just returns binx.

Definition at line 86 of file IHistogram.cpp.

87 {
88  std::vector<unsigned> axes_indices;
89  axes_indices.push_back(static_cast<unsigned>(binx));
90  if (rank() == 2)
91  axes_indices.push_back(static_cast<unsigned>(biny));
92  return m_data.toGlobalIndex(axes_indices);
93 }
size_t toGlobalIndex(const std::vector< unsigned > &axes_indices) const
Returns global index for specified indices of axes.
Definition: OutputData.h:392

References IHistogram::m_data, IHistogram::rank(), and OutputData< T >::toGlobalIndex().

Referenced by IHistogram::binAverage(), IHistogram::binContent(), IHistogram::binError(), and IHistogram::binNumberOfEntries().

Here is the call graph for this function:

◆ getMaximum()

double IHistogram::getMaximum ( ) const
inherited

Returns histogram maximum value (maximum of binContent() over all bins)

Definition at line 186 of file IHistogram.cpp.

187 {
189  return it->getContent();
190 }

References OutputData< T >::begin(), OutputData< T >::end(), and IHistogram::m_data.

Here is the call graph for this function:

◆ getMaximumBinIndex()

size_t IHistogram::getMaximumBinIndex ( ) const
inherited

Returns globalbin index with maximum content.

Definition at line 192 of file IHistogram.cpp.

193 {
195  return std::distance(m_data.begin(), it);
196 }

References OutputData< T >::begin(), OutputData< T >::end(), and IHistogram::m_data.

Here is the call graph for this function:

◆ getMinimum()

double IHistogram::getMinimum ( ) const
inherited

Returns histogram minimum value (minimum of binContent() over all bins)

Definition at line 198 of file IHistogram.cpp.

199 {
201  return it->getContent();
202 }

References OutputData< T >::begin(), OutputData< T >::end(), and IHistogram::m_data.

Here is the call graph for this function:

◆ getMinimumBinIndex()

size_t IHistogram::getMinimumBinIndex ( ) const
inherited

Returns globalbin index with minimum content.

Definition at line 204 of file IHistogram.cpp.

205 {
206  return std::distance(m_data.begin(), std::min_element(m_data.begin(), m_data.end()));
207 }

References OutputData< T >::begin(), OutputData< T >::end(), and IHistogram::m_data.

Here is the call graph for this function:

◆ getNbinsX()

size_t IHistogram::getNbinsX ( ) const
inherited

Returns number of bins on x-axis.

Definition at line 66 of file IHistogram.cpp.

67 {
68  return xAxis().size();
69 }

References IAxis::size(), and IHistogram::xAxis().

Here is the call graph for this function:

◆ getNbinsY()

size_t IHistogram::getNbinsY ( ) const
inherited

Returns number of bins on y-axis.

Definition at line 81 of file IHistogram.cpp.

82 {
83  return yAxis().size();
84 }

References IAxis::size(), and IHistogram::yAxis().

Here is the call graph for this function:

◆ getTotalNumberOfBins()

size_t IHistogram::getTotalNumberOfBins ( ) const
inherited

Returns total number of histogram bins.

For 2D histograms the result will be the product of bin numbers along X and Y axes.

Definition at line 39 of file IHistogram.cpp.

40 {
41  return m_data.getAllocatedSize();
42 }
size_t getAllocatedSize() const
Returns total size of data buffer (product of bin number in every dimension).
Definition: OutputData.h:59

References OutputData< T >::getAllocatedSize(), and IHistogram::m_data.

Referenced by IHistogram::copyContentFrom(), create_projectionX(), create_projectionY(), IHistogram::createOutputData(), IHistogram::getDataVector(), IHistogram::integral(), IHistogram::operator+=(), IHistogram::relativeDifferenceHistogram(), and IHistogram::scale().

Here is the call graph for this function:

◆ getXmax()

double IHistogram::getXmax ( ) const
inherited

Returns x-axis max (upper edge of last bin).

Definition at line 61 of file IHistogram.cpp.

62 {
63  return xAxis().upperBound();
64 }
virtual double upperBound() const =0
Returns value of last point of axis.

References IAxis::upperBound(), and IHistogram::xAxis().

Here is the call graph for this function:

◆ getXmin()

double IHistogram::getXmin ( ) const
inherited

Returns x-axis min (lower edge of first bin).

Definition at line 56 of file IHistogram.cpp.

57 {
58  return xAxis().lowerBound();
59 }
virtual double lowerBound() const =0
Returns value of first point of axis.

References IAxis::lowerBound(), and IHistogram::xAxis().

Here is the call graph for this function:

◆ getYmax()

double IHistogram::getYmax ( ) const
inherited

Returns y-axis max (upper edge of last bin) for 2D histograms.

Definition at line 76 of file IHistogram.cpp.

77 {
78  return yAxis().upperBound();
79 }

References IAxis::upperBound(), and IHistogram::yAxis().

Here is the call graph for this function:

◆ getYmin()

double IHistogram::getYmin ( ) const
inherited

Returns y-axis min (lower edge of first bin) for 2D histograms.

Definition at line 71 of file IHistogram.cpp.

72 {
73  return yAxis().lowerBound();
74 }

References IAxis::lowerBound(), and IHistogram::yAxis().

Here is the call graph for this function:

◆ hasSameDimensions()

bool IHistogram::hasSameDimensions ( const IHistogram other) const
inherited

Returns true if object have same rank and number of axes bins.

Definition at line 358 of file IHistogram.cpp.

359 {
360  return m_data.hasSameDimensions(other.m_data);
361 }
bool hasSameDimensions(const OutputData< U > &right) const
Returns true if object have same dimensions and number of axes bins.
Definition: OutputData.h:575

References OutputData< T >::hasSameDimensions(), and IHistogram::m_data.

Referenced by IHistogram::copyContentFrom(), IHistogram::operator+=(), and IHistogram::relativeDifferenceHistogram().

Here is the call graph for this function:

◆ hasSameShape()

bool IHistogram::hasSameShape ( const IHistogram other) const
inherited

Returns true if objects a) have same dimensions b) bin boundaries of axes coincide.

Definition at line 353 of file IHistogram.cpp.

354 {
355  return m_data.hasSameShape(other.m_data);
356 }
bool hasSameShape(const OutputData< U > &right) const
Returns true if objects a) have same dimensions b) bin boundaries of axes coincide.
Definition: OutputData.h:592

References OutputData< T >::hasSameShape(), and IHistogram::m_data.

Here is the call graph for this function:

◆ init_from_data()

void IHistogram::init_from_data ( const OutputData< double > &  source)
protectedinherited

Definition at line 288 of file IHistogram.cpp.

289 {
290  if (rank() != source.rank()) {
291  std::ostringstream message;
292  message << "IHistogram::IHistogram(const OutputData<double>& data) -> Error. ";
293  message << "The dimension of this histogram " << rank() << " ";
294  message << "is differ from the dimension of source " << m_data.rank() << std::endl;
295  throw std::runtime_error(message.str());
296  }
297 
298  m_data.copyShapeFrom(source);
299  for (size_t i = 0; i < source.getAllocatedSize(); ++i) {
300  m_data[i].add(source[i]);
301  }
302 }

References OutputData< T >::copyShapeFrom(), OutputData< T >::getAllocatedSize(), IHistogram::m_data, OutputData< T >::rank(), and IHistogram::rank().

Referenced by Histogram1D::Histogram1D(), and Histogram2D().

Here is the call graph for this function:

◆ initFromShape()

template<typename T >
void Histogram2D::initFromShape ( const T &  data)
protected

Definition at line 114 of file Histogram2D.h.

115 {
116  auto shape = ArrayUtils::getShape(data);
117  const size_t nrows = shape.first;
118  const size_t ncols = shape.second;
119 
120  if (nrows == 0 || ncols == 0)
121  throw std::runtime_error("Histogram2D::Histogram2D() -> Error. "
122  "Not a two-dimensional numpy array");
123 
124  m_data.addAxis(FixedBinAxis("x-axis", ncols, 0.0, static_cast<double>(ncols)));
125  m_data.addAxis(FixedBinAxis("y-axis", nrows, 0.0, static_cast<double>(nrows)));
126 }

References OutputData< T >::addAxis(), ArrayUtils::getShape(), and IHistogram::m_data.

Referenced by Histogram2D().

Here is the call graph for this function:

◆ integral()

double IHistogram::integral ( ) const
inherited

Returns integral of bins content (computed as a sum of all bin content).

Definition at line 216 of file IHistogram.cpp.

217 {
218  double result(0.0);
219  for (size_t index = 0; index < getTotalNumberOfBins(); ++index) {
220  result += m_data[index].getContent();
221  }
222  return result;
223 }

References IHistogram::getTotalNumberOfBins(), and IHistogram::m_data.

Here is the call graph for this function:

◆ load()

void IHistogram::load ( const std::string &  filename)
inherited

Loads histogram from file, the shape of array in file should match Following formats are available: *.txt, *.tif, *.int (*.txt.gz, *.tif.gz, *.int.gz) Only bin content will be loaded, histogram axes remain the same.

Definition at line 394 of file IHistogram.cpp.

395 {
396  const std::unique_ptr<IHistogram> hist(IntensityDataIOFactory::readIntensityData(filename));
397  copyContentFrom(*hist);
398 }
void copyContentFrom(const IHistogram &other)
Copy content (but not the axes) from other histogram. Dimensions should be the same.
Definition: IHistogram.cpp:331

References IHistogram::copyContentFrom(), FileSystemUtils::filename(), and IntensityDataIOFactory::readIntensityData().

Here is the call graph for this function:

◆ operator+=()

const IHistogram & IHistogram::operator+= ( const IHistogram right)
inherited

addition-assignment operator for two histograms

Definition at line 363 of file IHistogram.cpp.

364 {
365  if (!hasSameDimensions(right))
366  throw std::runtime_error(
367  "IHistogram::operator+=() -> Error. Histograms have different dimension");
368  for (size_t i = 0; i < getTotalNumberOfBins(); ++i)
369  addBinContent(i, right.binContent(i));
370  return *this;
371 }
void addBinContent(size_t i, double value)
Add the value to the bin.
Definition: IHistogram.cpp:151

References IHistogram::addBinContent(), IHistogram::binContent(), IHistogram::getTotalNumberOfBins(), and IHistogram::hasSameDimensions().

Here is the call graph for this function:

◆ projectionX() [1/3]

Histogram1D * Histogram2D::projectionX ( )

Project a 2D histogram into 1D histogram along X.

The projection is made from all bins along y-axis.

Definition at line 63 of file Histogram2D.cpp.

64 {
65  return create_projectionX(0, static_cast<int>(xAxis().size()) - 1);
66 }
Histogram1D * create_projectionX(int ybinlow, int ybinup)
Creates projection along X.

References create_projectionX(), and IHistogram::xAxis().

Here is the call graph for this function:

◆ projectionX() [2/3]

Histogram1D * Histogram2D::projectionX ( double  ylow,
double  yup 
)

Project a 2D histogram into 1D histogram along X.

The projection is made from all y-bins corresponding to ordinate between ylow and yup.

Parameters
ylowlower edje on y-axis
yupupper edje on y-axis

Definition at line 74 of file Histogram2D.cpp.

75 {
76  int ybinlow = static_cast<int>(yAxis().findClosestIndex(ylow));
77  int ybinup = static_cast<int>(yAxis().findClosestIndex(yup));
78  return create_projectionX(ybinlow, ybinup);
79 }
virtual size_t findClosestIndex(double value) const =0
find bin index which is best match for given value

References create_projectionX(), IAxis::findClosestIndex(), and IHistogram::yAxis().

Here is the call graph for this function:

◆ projectionX() [3/3]

Histogram1D * Histogram2D::projectionX ( double  yvalue)

Project a 2D histogram into 1D histogram along X.

The projection is made from the y-bin closest to given ordinate yvalue.

Parameters
yvaluethe value on y-axis at which projection is taken

Definition at line 68 of file Histogram2D.cpp.

69 {
70  int ybin_selected = static_cast<int>(yAxis().findClosestIndex(yvalue));
71  return create_projectionX(ybin_selected, ybin_selected);
72 }

References create_projectionX(), IAxis::findClosestIndex(), and IHistogram::yAxis().

Here is the call graph for this function:

◆ projectionY() [1/3]

Histogram1D * Histogram2D::projectionY ( )

Project a 2D histogram into 1D histogram along Y.

The projection is made from all bins along x-axis.

Definition at line 81 of file Histogram2D.cpp.

82 {
83  return create_projectionY(0, static_cast<int>(xAxis().size()) - 1);
84 }
Histogram1D * create_projectionY(int xbinlow, int xbinup)
Creates projection along Y.

References create_projectionY(), and IHistogram::xAxis().

Here is the call graph for this function:

◆ projectionY() [2/3]

Histogram1D * Histogram2D::projectionY ( double  xlow,
double  xup 
)

Project a 2D histogram into 1D histogram along Y.

The projection is made from all x-bins corresponding to abscissa between xlow and xup.

Parameters
xlowlower edje on x-axis
xupupper edje on x-axis

Definition at line 92 of file Histogram2D.cpp.

93 {
94  int xbinlow = static_cast<int>(xAxis().findClosestIndex(xlow));
95  int xbinup = static_cast<int>(xAxis().findClosestIndex(xup));
96  return create_projectionY(xbinlow, xbinup);
97 }

References create_projectionY(), IAxis::findClosestIndex(), and IHistogram::xAxis().

Here is the call graph for this function:

◆ projectionY() [3/3]

Histogram1D * Histogram2D::projectionY ( double  xvalue)

Project a 2D histogram into 1D histogram along Y.

The projection is made from the x-bin closest to given abscissa xvalue.

Parameters
xvaluethe value on x-axis at which projection is taken

Definition at line 86 of file Histogram2D.cpp.

87 {
88  int xbin_selected = static_cast<int>(xAxis().findClosestIndex(xvalue));
89  return create_projectionY(xbin_selected, xbin_selected);
90 }

References create_projectionY(), IAxis::findClosestIndex(), and IHistogram::xAxis().

Here is the call graph for this function:

◆ rank()

size_t Histogram2D::rank ( ) const
inlinevirtual

Returns the number of histogram dimensions.

Implements IHistogram.

Definition at line 58 of file Histogram2D.h.

58 { return 2; }

◆ relativeDifferenceHistogram()

IHistogram * IHistogram::relativeDifferenceHistogram ( const IHistogram rhs)
inherited

returns histogram representing relative difference of two histograms.

Definition at line 373 of file IHistogram.cpp.

374 {
375  if (!hasSameDimensions(rhs))
376  throw std::runtime_error("IHistogram::relativeDifferenceHistogram() -> Error. "
377  "Histograms have different dimensions");
378 
379  IHistogram* result = this->clone();
380  result->reset();
381 
382  for (size_t i = 0; i < getTotalNumberOfBins(); ++i) {
383  double diff = Numeric::GetRelativeDifference(binContent(i), rhs.binContent(i));
384  result->setBinContent(i, diff);
385  }
386  return result;
387 }
Base class for 1D and 2D histograms holding values of double type.
Definition: IHistogram.h:27
void setBinContent(size_t i, double value)
Sets content of the bin corresponding to the globalbin number.
Definition: IHistogram.cpp:146
virtual IHistogram * clone() const =0
double GetRelativeDifference(double a, double b)
Returns the safe relative difference, which is 2(|a-b|)/(|a|+|b|) except in special cases.
Definition: Numeric.cpp:29

References IHistogram::binContent(), IHistogram::clone(), Numeric::GetRelativeDifference(), IHistogram::getTotalNumberOfBins(), IHistogram::hasSameDimensions(), IHistogram::reset(), and IHistogram::setBinContent().

Here is the call graph for this function:

◆ reset()

void IHistogram::reset ( )
inherited

Reset histogram content (axes remains)

Definition at line 238 of file IHistogram.cpp.

239 {
241 }
The cumulative value with average and rms on-the-flight calculations.
void setAllTo(const T &value)
Sets content of output data to specific value.
Definition: OutputData.h:476

References IHistogram::m_data, and OutputData< T >::setAllTo().

Referenced by IHistogram::copyContentFrom(), IHistogram::relativeDifferenceHistogram(), and setContent().

Here is the call graph for this function:

◆ save()

void IHistogram::save ( const std::string &  filename)
inherited

Saves histogram in file Following formats are available: *.txt, *.tif, *.int (*.txt.gz, *.tif.gz, *.int.gz)

Definition at line 389 of file IHistogram.cpp.

390 {
392 }
static void writeIntensityData(const IHistogram &histogram, const std::string &file_name)
Writes histogram in file.

References FileSystemUtils::filename(), and IntensityDataIOFactory::writeIntensityData().

Here is the call graph for this function:

◆ scale()

void IHistogram::scale ( double  value)
inherited

Multiply this histogram (every bin content value) by a constant.

Definition at line 209 of file IHistogram.cpp.

210 {
211  for (size_t index = 0; index < getTotalNumberOfBins(); ++index) {
212  m_data[index].setContent(value * m_data[index].getContent());
213  }
214 }

References IHistogram::getTotalNumberOfBins(), and IHistogram::m_data.

Here is the call graph for this function:

◆ setBinContent()

void IHistogram::setBinContent ( size_t  i,
double  value 
)
inherited

Sets content of the bin corresponding to the globalbin number.

Definition at line 146 of file IHistogram.cpp.

147 {
148  m_data[i].setContent(value);
149 }

References IHistogram::m_data.

Referenced by IHistogram::relativeDifferenceHistogram().

◆ setContent()

void Histogram2D::setContent ( const std::vector< std::vector< double >> &  data)

Sets the values in histograms channels from numpy array,.

Definition at line 119 of file Histogram2D.cpp.

120 {
121  reset();
122  addContent(data);
123 }
void addContent(const std::vector< std::vector< double >> &data)
Add to values in histograms channels from numpy array,.

References addContent(), and IHistogram::reset().

Referenced by Histogram2D().

Here is the call graph for this function:

◆ xAxis()

const IAxis & IHistogram::xAxis ( ) const
inherited

returns x-axis

Definition at line 44 of file IHistogram.cpp.

45 {
46  check_x_axis();
47  return m_data.axis(0);
48 }
void check_x_axis() const
Definition: IHistogram.cpp:268

References OutputData< T >::axis(), IHistogram::check_x_axis(), and IHistogram::m_data.

Referenced by Histogram1D::binCenters(), create_projectionX(), Histogram1D::crop(), crop(), Histogram1D::fill(), fill(), HistoUtils::FindPeaks(), IHistogram::getNbinsX(), IHistogram::getXmax(), IHistogram::getXmin(), projectionX(), and projectionY().

Here is the call graph for this function:

◆ xAxisIndex()

size_t IHistogram::xAxisIndex ( size_t  i) const
inherited

Returns x-axis index for global bin index i.

Definition at line 104 of file IHistogram.cpp.

105 {
106  return m_data.getAxisBinIndex(i, 0);
107 }
size_t getAxisBinIndex(size_t global_index, size_t i_selected_axis) const
Returns axis bin index for given global index.
Definition: OutputData.h:370

References OutputData< T >::getAxisBinIndex(), and IHistogram::m_data.

Referenced by create_projectionY().

Here is the call graph for this function:

◆ xAxisValue()

double IHistogram::xAxisValue ( size_t  i)
inherited

Returns the center of bin i of the x axis.

Definition at line 114 of file IHistogram.cpp.

115 {
116  check_x_axis();
117  return m_data.getAxisValue(i, 0);
118 }

References IHistogram::check_x_axis(), OutputData< T >::getAxisValue(), and IHistogram::m_data.

Referenced by create_projectionX().

Here is the call graph for this function:

◆ yAxis()

const IAxis & IHistogram::yAxis ( ) const
inherited

returns y-axis for 2D histograms

Definition at line 50 of file IHistogram.cpp.

51 {
52  check_y_axis();
53  return m_data.axis(1);
54 }
void check_y_axis() const
Definition: IHistogram.cpp:278

References OutputData< T >::axis(), IHistogram::check_y_axis(), and IHistogram::m_data.

Referenced by create_projectionY(), crop(), fill(), HistoUtils::FindPeaks(), IHistogram::getNbinsY(), IHistogram::getYmax(), IHistogram::getYmin(), and projectionX().

Here is the call graph for this function:

◆ yAxisIndex()

size_t IHistogram::yAxisIndex ( size_t  i) const
inherited

Returns y-axis index for global bin index i.

Definition at line 109 of file IHistogram.cpp.

110 {
111  return m_data.getAxisBinIndex(i, 1);
112 }

References OutputData< T >::getAxisBinIndex(), and IHistogram::m_data.

Referenced by create_projectionX().

Here is the call graph for this function:

◆ yAxisValue()

double IHistogram::yAxisValue ( size_t  i)
inherited

Returns the center of bin i of the y axis.

Definition at line 120 of file IHistogram.cpp.

121 {
122  check_y_axis();
123  return m_data.getAxisValue(i, 1);
124 }

References IHistogram::check_y_axis(), OutputData< T >::getAxisValue(), and IHistogram::m_data.

Referenced by create_projectionY().

Here is the call graph for this function:

Member Data Documentation

◆ m_data


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