13 #include "msdevstudio/MSconfig.h" 33 using std::max_element;
34 using std::min_element;
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 );
A namespace to set the standard for indexing into 2 dimension data point tuple.
bool m_empty
A flag set to true, when no accumulation has yet occurred, otherwise is set false.
Bins1DHist()
The default constructor.
virtual NTuple * createNTuple() const
Creates a NTuple.
virtual int getOverflow() const
implementation from pure base
BinsBase * clone() const
The clone function returns an object of its own kind which is a copy of this object at this moment...
int m_min_entries
The minimum number of entries/bin.
The base class for the one-dimensional binner hierarchy.
virtual ~Bins1DHist()
The destructor.
double binWidth(int i) const
Returns the width of each bin.
double m_scale_factor
The scale factor.
bool m_values_dirty
A flag to indicate that the objects in m_values are not correct.
virtual int getUnderflow() const
implementation from pure base
hippodraw::NTuple class interface.
Base class for DataSource.
intp size(numeric::array arr)
double m_moments[3]
The moments.
void resize()
Resizes the internal arrays.
A DataSource class implemented with std::vector<double> to store the column data. ...
virtual void setBinContents(const DataSource *ntuple)
virtual double getLow(hippodraw::Axes::Type axis) const
Returns the low value of the bins on the specified axis.
The class for the one-dimensional histogram binning.
std::vector< double > m_variance
The accumulated square of the weights.
virtual void fillDataSource(DataSource *ntuple) const
Fills the DataSource.
hippodraw::DataPointTuple namespace interface
std::vector< double > m_data
The array of binned data.
virtual void reset()
Resets the accumulation to zero.
The base class for the binner hierarchy.
double maxBin()
Returns the value of the bin with the largest value.
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.
virtual unsigned int rows() const =0
Returns the number of rows.
error on X or half bin width
double minBin()
Returns the value of the bin with the smallest value.
virtual int getNumberOfEntries() const
implementation from pure base
hippodraw::Bins1DHist class interface
int binNumber(double x)
Returns the number of the bin in which the x value is situated.
virtual NTuple * prepareNTuple(unsigned int rows) const
Prepares the NTuple.
virtual int getMinEntries()
Get the minimum entries/bin.
virtual void setMinEntries(int entries)
Set the minimum entries/bin.
bool m_is_scaling
A flag which is set true to enable scaling the output.