13 #include "msdevstudio/MSconfig.h"
33 using std::max_element;
34 using std::min_element;
46 m_data( binner.m_data ),
47 m_variance( binner.m_variance ),
48 m_min_entries ( binner.m_min_entries )
65 m_data.resize ( number + 2 );
74 return *min_element (
m_data.begin() + 1,
m_data.end ( ) - 1 );
79 return *max_element (
m_data.begin () + 1,
m_data.end () - 1 );
94 return static_cast <
int > ( std::accumulate (
m_data.begin()+1,
100 int retval = static_cast <
int > (
m_data[i+1] );
107 return static_cast <
int > (
m_data[0] );
112 return static_cast <
int > ( *(
m_data.end()-1) );
118 if ( i > 0 && i <= static_cast < int > (
m_variance.size() ) ) {
150 double total = std::accumulate (
m_data.begin() + 1,
154 std::vector<double>::const_iterator dit =
m_data.begin() + 1;
155 std::vector<double>::const_iterator vit =
m_variance.begin();
156 std::vector<double>::const_iterator first_non_zero =
m_data.begin() + 1;
157 std::vector<double>::const_iterator last_non_zero =
m_data.end() - 2;
161 while ( (*first_non_zero) == 0 ) {
164 while ( (*last_non_zero) == 0 ) {
169 swap ( first_non_zero, last_non_zero );
176 if ( last_non_zero < first_non_zero ) {
177 for (;dit !=
m_data.end()-1; dit ++ ) {
179 double half_width = 0.5 * width;
180 double y = factor * ( *dit / width );
181 double yerr = factor * ( sqrt( *vit++ ) / width );
188 ntuple -> addRow ( row );
196 for ( ; dit != first_non_zero; dit++ ) {
198 double half_width = 0.5 * width;
199 double y = factor * ( *dit / width );
200 double yerr = factor * ( sqrt( *vit++ ) / width );
207 ntuple -> addRow ( row );
214 for( ; dit != last_non_zero+1; dit++ ) {
216 double entries = *dit;
218 double var = sqrt(*vit);
220 if (dit == last_non_zero)
break;
227 double half_width = 0.5 * width;
229 double y = factor * ( entries / width );
230 double yerr = factor * ( var / width );
235 unsigned int numOfRows = ntuple->
rows();
236 unsigned int lastIndex = numOfRows-1;
237 vector <double> lastRow = ntuple -> getRow( lastIndex );
239 x = lastRow[
dp::X] + half_width;
243 / ( width + lastRow[dp::XERR] * 2 ) ;
246 ntuple -> eraseRow ( lastIndex );
254 ntuple -> addRow ( row );
260 for ( ; dit !=
m_data.end()-1; dit++ ) {
262 double half_width = 0.5 * width;
263 double y = factor * ( *dit / width );
264 double yerr = factor * ( sqrt( *vit++ ) / width );
271 ntuple -> addRow ( row );
285 unsigned int size = ntuple -> rows ();
288 for (
unsigned int i = 0; i <
size; i++ ) {
289 const vector < double > & row = ntuple -> getRow ( i );
virtual NTuple * createNTuple() const
Creates a NTuple.
virtual void fillDataSource(DataSource *ntuple) const
Fills the DataSource.
The class for the one-dimensional histogram binning.
virtual void accumulate(double x, double w=1.0, double i1=0.0, double i2=0.0)
Accumulates a data point x into a bin with weight w.
BinsBase * clone() const
The clone function returns an object of its own kind which is a copy of this object at this moment...
virtual void setMinEntries(int entries)
Set the minimum entries/bin.
The base class for the binner hierarchy.
double m_scale_factor
The scale factor.
std::vector< double > m_data
The array of binned data.
virtual void setBinContents(const DataSource *ntuple)
virtual NTuple * prepareNTuple(unsigned int rows) const
Prepares the NTuple.
virtual int getMinEntries()
Get the minimum entries/bin.
double m_moments[3]
The moments.
error on X or half bin width
hippodraw::DataPointTuple namespace interface
virtual void reset()
Resets the accumulation to zero.
double binWidth(int i) const
Returns the width of each bin.
The base class for the one-dimensional binner hierarchy.
A DataSource class implemented with std::vector to store the column data. ...
virtual ~Bins1DHist()
The destructor.
intp size(numeric::array arr)
double minBin()
Returns the value of the bin with the smallest value.
hippodraw::Bins1DHist class interface
hippodraw::NTuple class interface.
bool m_empty
A flag set to true, when no accumulation has yet occurred, otherwise is set false.
Base class for DataSource.
double maxBin()
Returns the value of the bin with the largest value.
std::vector< double > m_variance
The accumulated square of the weights.
int binNumber(double x)
Returns the number of the bin in which the x value is situated.
virtual double getLow(hippodraw::Axes::Type axis) const
Returns the low value of the bins on the specified axis.
bool m_is_scaling
A flag which is set true to enable scaling the output.
virtual unsigned int rows() const =0
Returns the number of rows.
Bins1DHist()
The default constructor.
bool m_values_dirty
A flag to indicate that the objects in m_values are not correct.
virtual int getNumberOfEntries() const
implementation from pure base
virtual int getUnderflow() const
implementation from pure base
void resize()
Resizes the internal arrays.
virtual int getOverflow() const
implementation from pure base
int m_min_entries
The minimum number of entries/bin.
A namespace to set the standard for indexing into 2 dimension data point tuple.