13 #include "msdevstudio/MSconfig.h"
30 #ifdef ITERATOR_MEMBER_DEFECT
36 using std::max_element;
38 using std::min_element;
39 using std::runtime_error;
46 NTupleProjector::NTupleProjector (
unsigned int columns )
49 m_columns ( columns, UINT_MAX ),
58 m_is_valid ( projector.m_is_valid ),
59 m_binding_options ( projector.m_binding_options ),
60 m_bindings ( projector.m_bindings),
61 m_columns ( projector.m_columns ),
62 m_ntuple ( projector.m_ntuple ),
63 m_min_bindings ( projector.m_min_bindings )
105 vector< string >::const_iterator first
110 std::string what = std::string(
"NTupleProjector::indexOfBindingOption: ")
111 + std::string(
"no such binding option: ") + axis;
112 throw runtime_error( what );
115 #ifdef DISTANCE_DEFECT
122 const std::vector < std::string > &
128 for (
size_t i = 0; i <
size; i++ ) {
134 const string label =
"nil";
164 if ( cut_list.empty() == false ) {
165 unsigned int size = cut_list.size();
168 const TupleCut * cut = cut_list[j++];
185 if ( label ==
"nil" ) {
189 m_ntuple -> throwIfInvalidLabel ( label );
198 const std::string & label )
209 size_t size = labels.size();
212 string what (
"NTupleProjector::setAxisBindings: " );
213 what +=
"insufficient number of labels";
214 throw runtime_error ( what );
218 for (
unsigned int i = 0; i < cols; i++ ) {
220 const string & label = labels[i];
224 const string nil (
"nil" );
233 assert ( ntuple != 0 );
268 assert ( !( data < 0 ) &&
270 assert ( !( error < 0 ) &&
277 for (
unsigned int row = 0; row <
size; row++ ) {
278 double value =
m_ntuple -> valueAt ( row, data );
279 double err =
m_ntuple -> valueAt ( row, error );
280 lo = min ( value - err, lo );
281 hi = max ( value + err, hi );
286 return Range ( lo, hi, pos );
294 assert ( !( column < 0 ) &&
298 bool isValid =
m_ntuple -> fillRange ( column, range );
306 assert ( !( data < 0 ) &&
308 assert ( !( error < 0 ) &&
311 double pos = DBL_MAX;
314 for (
unsigned int row = 0; row <
size; row++ ) {
315 double value =
m_ntuple -> valueAt ( row, data );
316 double err =
m_ntuple -> valueAt ( row, error );
318 double x = value - err;
320 pos = min ( x, pos );
323 if ( value != 0.0 ) pos = min ( 0.1 * value, pos );
336 assert ( !( column < 0 ) &&
339 double pos = DBL_MAX;
343 for (
unsigned int row = 0; row <
size; row++ ) {
344 double value =
m_ntuple -> valueAt ( row, column );
345 if ( value < pos && value > 0.0 ) pos = value;
358 CutList_t ::iterator first
376 for (
unsigned int i = 0; i <
size; i++ ) {
408 for (
unsigned int i = 0; i <
size; i++ ) {
412 if ( i == 0 ) axis_model =
m_x_axis;
413 else if ( i == 1 ) axis_model =
m_y_axis;
414 else if ( i == 2 ) axis_model =
m_z_axis;
415 if ( axis_model == 0 )
break;
419 double value =
m_ntuple -> valueAt ( row, column );
420 if ( range.
excludes ( value ) )
return false;
475 if ( tuple -> empty () ) {
486 for (
unsigned int i = 0; i <
size; i++ ) {
489 double value =
m_ntuple -> valueAt ( i, column );
498 return (sum / number);
520 ntuple -> reserve ( size );
530 for (
unsigned int i = 0; i <
size; i++ ) {
532 const vector < double > & row =
m_ntuple -> getRow ( i );
533 ntuple -> addRow ( row );
551 std::vector<double> & columnData)
const {
556 for (
size_t i = 0 ; i < nrows ; i++ ) {
558 columnData.push_back( coldata[i] );
568 vector < const TupleCut * > cut_list;
569 for (
unsigned int i = 0; i < tuple_cuts.size(); i++ ) {
570 const TupleCut & cut = tuple_cuts[i];
571 cut_list.push_back ( & cut );
void * data(numeric::array arr)
virtual int getOverflow() const
Returns the number of overflow.
virtual const std::string & getXLabel() const
Finds the X axis label of the plot.
AxisModelBase * m_x_axis
The AxisModel along the X axis.
column
The column indices for 2 dimension data point tuple.
AxisModelBase * m_z_axis
The AxisModel along the Z axis.
virtual NTuple * getNTupleAfterCuts() const
Template for projectors that can return subsets of the NTuple used by the DataRep.
virtual NTuple * createNTupleWith(const std::vector< TupleCut > &cut_list) const
Creates a NTuple from the projector's DataSource object using cut_list for not including rows that do...
An NTupleProjector is a projector that projects data from an DataSource object.
virtual void setYErrorOption(bool enable)
Sets whether the Y error options are to be enabled or not.
std::vector< const TupleCut * > CutList_t
The type of container for list of cuts.
virtual double getAverage(Axes::Type axis) const
Get the Average of all projected values on the specified axis.
std::vector< std::string > m_binding_options
The list of binding options for the Projector.
virtual int indexOf(const std::string &label) const
Returns the index of the label.
virtual void addCut(const TupleCut *cut)
Adds the cut to the list of cuts.
NTupleProjector(unsigned int columns)
The following constructor takes the number of columns that the projector is capable of binding with...
void setLabels(const std::vector< std::string > &v)
Assigns the label to each column from the vector of strings.
virtual void removeCut(const TupleCut *cut)
Removes the cut from the cut list.
void fillNTuple(NTuple *ntuple, const CutList_t &cut_list) const
Fills the DataSource source from the projectors DataSource object from rows that pass all the TupleCu...
bool acceptRow(unsigned int i, const CutList_t &cut_list) const
For row i of the column in the DataSource, returns true if all the cuts accept the row...
hippodraw::AxisModelBase class interface
virtual ~NTupleProjector()
The destructor.
virtual const Range & getRange(Axes::Type) const
Returns the Range along the specified axis.
virtual void update(const Observable *)
Responds to update message from the data source.
AxisModelBase * m_y_axis
The AxisModel along the Y axis.
bool m_is_valid
Set to false if any data is bound column is invalid.
double getPos(int column) const
Returns the minimum positive value on the specified column.
Range dataRangeWithError(int data, int error) const
Returns a range considering both data and error.
unsigned int m_min_bindings
The minimum number of columns that must be bound.
virtual const DataSource * getNTuple() const
Returns the DataSource used by the projector.
virtual const std::vector< std::string > & getAxisBindings() const
Returns the current axis bindings.
bool excludes(double value) const
Returns true if the argument value is outside the range.
virtual bool hasDataSourceBindings() const
Returns true.
virtual void notifyObservers() const
Notifies Observer objects of a change.
virtual const std::string & getYLabel(bool flag=false) const
Finds the Y axis label of the plot.
bool isNull() const
Returns true if the receiving objects is a null object.
virtual void setDirty(bool value=true)
Sets the dirty flag to value.
virtual const std::string & getNTupleName() const
Returns the name of the DataSource used by this projector.
A DataSource class implemented with std::vector to store the column data. ...
int getNumberOfEntries() const
Returns the number of entries in to the projected values list.
bool isDataValid() const
Returns true if all the data in the bound DataSource is valid.
virtual int getUnderflow() const
Returns the number of underflow.
intp size(numeric::array arr)
void removeObserver(Observer *)
Removes an Observer from the Observer list.
void setAxisBinding(int axis, const std::string &label)
Sets the axis binding for axis binding option to the column with label label.
hippodraw::NTupleProjector class interface
hippodraw::NTuple class interface.
virtual const std::vector< double > & getColumn(const std::string &name) const
Returns the data in the column with label name.
virtual const std::string & getLabelAt(unsigned int index) const
Returns the label for the column at index index.
Base class for DataSource.
virtual void setAxisBindings(const std::vector< std::string > &labels)
Sets the axis bindings, Sets, in the order of the binding options, the binding to the DataSource by l...
Part of an implementation of the Observable-Observer pattern based on the example in the GOF Patterns...
unsigned int indexOfBindingOption(const std::string &axis) const
Returns an index to the binding option.
std::vector< std::string > m_bindings
The list of current bindings.
const Range & getRange(bool scaled) const
Returns the range represented by this AxisModel.
virtual int indexOf(const std::string &label) const
Returns true if the specified column labeled label has been filled.
unsigned int columns() const
Returns the number of columns or data arrays available from this DataSource.
std::vector< unsigned int > m_columns
A vector containing indexes to the columns of the DataSource.
virtual void fillColumnAfterCuts(const std::string &column, std::vector< double > &columnData) const
Fill a vector with the data from the named column with the current set of cuts applied.
virtual const std::vector< std::string > & bindingOptions() const
Returns a vector of strings describing the binding options.
CutList_t m_cut_list
A list of cuts that filter the projection.
bool includes(double value) const
Returns true if the argument value is inside the range.
const DataSource * m_ntuple
The pointer to the data source being projected.
virtual void setNTuple(const DataSource *source)
Changes the DataSource used for the projections to source.
const std::vector< const TupleCut * > & getCutList() const
Returns the list of TupleCut objects used by this projector.
virtual bool isEmpty() const
Returns true if the data source used by this projector is empty.
virtual const std::string & getTitle() const
Finds the title of the plot.
hippodraw::TupleCut class interface
virtual bool inRange(int row) const
Checks if the entries in a given row are within the range of the axis model.
virtual void changedNTuple()=0
This function is called when the DataSource has been changed to a new one.
virtual void setXErrorOption(bool enable)
Sets whether the X error options are to be enabled or not.
virtual unsigned int rows() const =0
Returns the number of rows.
const std::string & getName() const
Returns the name of the data source.
virtual const std::vector< std::string > & getLabels() const
Returns the list of available labels.
Range dataRange(int column) const
Returns the range of data on the specified column.
double getPosWithError(int data, int error) const
Returns the minimum positive values considering both data and error.
The AxisModelBase class maintains the Range and scaling of an axis.
virtual void willDelete(const Observable *)
Responds to willDelete message from the observed data source.
The class expresses a cut on a DataSource, i.e.
NTuple * createEmptyNTuple() const
Creates an empty NTuple with same number of columns and labels as the project's DataSource.
virtual const std::string & getZLabel() const
Finds the Z axis label of the plot.
const std::string & title() const
Returns a const reference to the title of the data source.
Expresses a range of values.
The base class for the Projector hierarchy.