138 lines
5.7 KiB
C++
Executable File
138 lines
5.7 KiB
C++
Executable File
#ifndef POSITION_BINNING_H
|
|
#define POSITION_BINNING_H
|
|
|
|
#include <vector>
|
|
#include "blitz/array.h"
|
|
|
|
// class for a linear binning without under- or overflow bins
|
|
class LowerAndUpperBoundBinning {
|
|
public:
|
|
// Constructor: create binning with num_bins bins and
|
|
// an upper boundary of maximum (the lower boundary is always chosen as 0)
|
|
// the spacing between bins is always linear
|
|
LowerAndUpperBoundBinning(int num_bins, double maximum);
|
|
|
|
// return the bin index, that includes the value position
|
|
int bin(double position) const;
|
|
// return the spacing between the bin borders
|
|
double stepsize() const;
|
|
// getter for the number of bins
|
|
int numBins() const;
|
|
// returns the index for the first bin (0)
|
|
int binIndexMin() const;
|
|
// returns the index for the last bin (num_bins - 1)
|
|
int binIndexMax() const;
|
|
// return a vector containing the edges of the bins
|
|
std::vector<double> binBorders() const;
|
|
|
|
private:
|
|
int num_bins_;
|
|
double stepsize_;
|
|
};
|
|
|
|
// class for a linear binning with an overflow but no underflow bin
|
|
class LowerBoundBinningWithOverflow {
|
|
public:
|
|
// Constructor: creates a linear binning between 0 and maximum with num_bins_excluding_overflow
|
|
// (number of bins without the overflow bin)
|
|
LowerBoundBinningWithOverflow(int num_bins_excluding_overflow,
|
|
double maximum);
|
|
|
|
// return the bin index, that includes the value position
|
|
int bin(double position) const;
|
|
// return the spacing between the bin borders
|
|
double stepsize() const;
|
|
// returns the number of bins including the overflow bin
|
|
int numBinsWithOverflow() const;
|
|
// returns the number of bins excluding the overflow bin
|
|
int numBinsWithoutOverflow() const;
|
|
// returns the index for the first bin (0)
|
|
int binIndexMin() const;
|
|
// returns the index for the last bin (i.e. the overflow bin)
|
|
int binIndexMax() const;
|
|
// return the values of the borders of the bins (the overflow bin does not have an upper boundary)
|
|
std::vector<double> binBorders() const;
|
|
|
|
private:
|
|
int num_bins_;
|
|
double stepsize_;
|
|
};
|
|
|
|
// class for a linear binning with an under- and overflow bin
|
|
class BinningWithOverAndUnderflow {
|
|
public:
|
|
// Constructor: creates a linear binning between 0 and maximum with num_bins_excluding_overflow
|
|
// (number of bins without the overflow and underflow bin)
|
|
BinningWithOverAndUnderflow(int num_bins_excluding_overunderflow,
|
|
double maximum);
|
|
|
|
// return the bin index, that includes the value position
|
|
int bin(double position) const;
|
|
// return the spacing between the bin borders
|
|
double stepsize() const;
|
|
// returns the number of bins including both the overflow and underflow bin
|
|
int numBinsWithOverUnderflow() const;
|
|
// returns the number of bins excluding both the overflow and underflow bin
|
|
int numBinsWithoutOverUnderflow() const;
|
|
// returns the index for the first (underflow) bin (-1)
|
|
int binIndexMin() const;
|
|
// returns the index for the last bin (i.e. the overflow bin)
|
|
int binIndexMax() const;
|
|
// return the values of the borders of the bins (the overflow bin does not have an upper
|
|
// and the underflow bin does not have a lower boundary)
|
|
std::vector<double> binBorders() const;
|
|
|
|
private:
|
|
int num_bins_;
|
|
double stepsize_;
|
|
};
|
|
|
|
// class for handling the segmentation of a cylindrical domain
|
|
class CylinderBinning {
|
|
public:
|
|
// Constructor: takes the number of bins for the radial direction,
|
|
// the radius of the cylinder,
|
|
// the number of bins in azimuthal direction,
|
|
// the number of bins in longitudinal (i.e. z) direction,
|
|
// the height of the cylinder
|
|
// creates a LowerBoundBinninigWithOverflow for the radial direction (no boundary at r=0),
|
|
// a LowerAndUpperBoundBinning for the azimuthal direction (no boundary at all),
|
|
// and a BinningWithOverAndUnderflow in longitudinal direction
|
|
CylinderBinning(int num_bins_radial,
|
|
double radius,
|
|
int num_bins_azimuthal,
|
|
int num_bins_longitudinal,
|
|
double height);
|
|
|
|
// return a blitz::TinyVector containing the indeces for each of the three binnings
|
|
// (bin_r, bin_azimuthal, bin_longitudinal), in which the blitz::TinyVector cylinder_position
|
|
// (containing (r, phi,z)) is contained in
|
|
blitz::TinyVector<int, 3> bin(
|
|
const blitz::TinyVector<double, 3>& cylinder_position) const;
|
|
// return a blitz::TinyVector with the spacings of the three binnings
|
|
// (spacing_radial, spacing_azimuthal, spacing_longitudinal)
|
|
blitz::TinyVector<double, 3> stepsize() const;
|
|
|
|
// return a blitz::TinyVector with the number of bins of each binning (excludes all over- and underflow bins)
|
|
// (numBins_radial, numBins_azimuthal, numBins_longitudinal)
|
|
blitz::TinyVector<int, 3> numBins() const;
|
|
// return a blitz::TinyVector with the number of bins of each binning (includes all over- and underflow bins)
|
|
// (numBins_radial, numBins_azimuthal, numBins_longitudinal)
|
|
blitz::TinyVector<int, 3> numBinsIncludingOverUnderflow() const;
|
|
// return a blitz::TinyVector with the indices of the first bins of each binning
|
|
// (binIndexMin_radial, binIndexMin_azimuthal, binIndexMin_longitudinal)
|
|
// includes the underflow bin in longitudinal direction
|
|
blitz::TinyVector<int, 3> binIndexMin() const;
|
|
// return a blitz::TinyVector with the indices of the last bins of each binning
|
|
// (binIndexMin_radial, binIndexMin_azimuthal, binIndexMin_longitudinal)
|
|
// includes the overflow bin in radial and longitudinal direction
|
|
blitz::TinyVector<int, 3> binIndexMax() const;
|
|
|
|
// binnings for each of the three directions (radial, azimuthal, longitudinal)
|
|
const LowerBoundBinningWithOverflow radial_binning;
|
|
const LowerAndUpperBoundBinning azimuth_binning;
|
|
const BinningWithOverAndUnderflow longitudinal_binning;
|
|
};
|
|
|
|
#endif /* POSITION_BINNING_H */
|