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;
44 using namespace hippodraw;
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++ ) {
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++ ) {
571 cut_list.push_back ( & cut );
Part of an implementation of the Observable-Observer pattern based on the example in the GOF Patterns...
virtual int getOverflow() const
Returns the number of overflow.
virtual const std::string & getXLabel() const
Finds the X axis label of the plot.
double getPos(int column) const
Returns the minimum positive value on the specified column.
virtual void setXErrorOption(bool enable)
Sets whether the X error options are to be enabled or not.
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...
virtual void setNTuple(const DataSource *source)
Changes the DataSource used for the projections to source.
virtual void changedNTuple()=0
This function is called when the DataSource has been changed to a new one.
AxisModelBase * m_x_axis
The AxisModel along the X axis.
virtual const DataSource * getNTuple() const
Returns the DataSource used by the projector.
virtual void notifyObservers() const
Notifies Observer objects of a change.
CutList_t m_cut_list
A list of cuts that filter the projection.
virtual const std::string & getTitle() const
Finds the title of the plot.
virtual ~NTupleProjector()
The destructor.
virtual bool inRange(int row) const
Checks if the entries in a given row are within the range of the axis model.
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...
unsigned int indexOfBindingOption(const std::string &axis) const
Returns an index to the binding option.
virtual const Range & getRange(Axes::Type) const
Returns the Range along the specified axis.
std::vector< unsigned int > m_columns
A vector containing indexes to the columns of the DataSource.
virtual int getUnderflow() const
Returns the number of underflow.
void * data(numeric::array arr)
double getPosWithError(int data, int error) const
Returns the minimum positive values considering both data and error.
Range dataRange(int column) const
Returns the range of data on the specified column.
column
The column indices for 2 dimension data point tuple.
bool isNull() const
Returns true if the receiving objects is a null object.
void setLabels(const std::vector< std::string > &v)
Assigns the label to each column from the vector of strings.
const std::string & title() const
Returns a const reference to the title of the data source.
An NTupleProjector is a projector that projects data from an DataSource object.
virtual const std::string & getYLabel(bool flag=false) const
Finds the Y axis label of the plot.
The class expresses a cut on a DataSource, i.e.
int getNumberOfEntries() const
Returns the number of entries in to the projected values list.
bool includes(double value) const
Returns true if the argument value is inside the range.
virtual void setDirty(bool value=true)
Sets the dirty flag to value.
std::vector< const TupleCut * > CutList_t
The type of container for list of cuts.
AxisModelBase * m_z_axis
The AxisModel along the Z axis.
virtual const std::vector< double > & getColumn(const std::string &name) const
Returns the data in the column with label name.
hippodraw::NTuple class interface.
virtual NTuple * getNTupleAfterCuts() const
Template for projectors that can return subsets of the NTuple used by the DataRep.
void removeObserver(Observer *)
Removes an Observer from the Observer list.
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...
virtual const std::vector< std::string > & getLabels() const
Returns the list of available labels.
virtual int indexOf(const std::string &label) const
Returns the index of the label.
virtual const std::string & getZLabel() const
Finds the Z axis label of the plot.
intp size(numeric::array arr)
const DataSource * m_ntuple
The pointer to the data source being projected.
std::vector< std::string > m_binding_options
The list of binding options for the Projector.
The AxisModelBase class maintains the Range and scaling of an axis.
NTupleProjector(unsigned int columns)
The following constructor takes the number of columns that the projector is capable of binding with...
std::vector< std::string > m_bindings
The list of current bindings.
virtual void willDelete(const Observable *)
Responds to willDelete message from the observed data source.
const std::vector< const TupleCut * > & getCutList() const
Returns the list of TupleCut objects used by this projector.
A DataSource class implemented with std::vector<double> to store the column data. ...
bool excludes(double value) const
Returns true if the argument value is outside the range.
The base class for the Projector hierarchy.
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...
virtual const std::string & getNTupleName() const
Returns the name of the DataSource used by this projector.
hippodraw::TupleCut class interface
hippodraw::AxisModelBase class interface
virtual unsigned int rows() const =0
Returns the number of rows.
virtual bool isEmpty() const
Returns true if the data source used by this projector is empty.
bool isDataValid() const
Returns true if all the data in the bound DataSource is valid.
virtual int indexOf(const std::string &label) const
Returns true if the specified column labeled label has been filled.
const Range & getRange(bool scaled) const
Returns the range represented by this AxisModel.
unsigned int columns() const
Returns the number of columns or data arrays available from this DataSource.
Range dataRangeWithError(int data, int error) const
Returns a range considering both data and error.
virtual const std::vector< std::string > & bindingOptions() const
Returns a vector of strings describing the binding options.
virtual void setYErrorOption(bool enable)
Sets whether the Y error options are to be enabled or not.
virtual const std::vector< std::string > & getAxisBindings() const
Returns the current axis bindings.
Expresses a range of values.
virtual double getAverage(Axes::Type axis) const
Get the Average of all projected values on the specified axis.
virtual void addCut(const TupleCut *cut)
Adds the cut to the list of cuts.
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.
AxisModelBase * m_y_axis
The AxisModel along the Y axis.
unsigned int m_min_bindings
The minimum number of columns that must be bound.
bool m_is_valid
Set to false if any data is bound column is invalid.
virtual const std::string & getLabelAt(unsigned int index) const
Returns the label for the column at index index.
const std::string & getName() const
Returns the name of the data source.
virtual bool hasDataSourceBindings() const
Returns true.
virtual void update(const Observable *)
Responds to update message from the data source.
hippodraw::NTupleProjector class interface
NTuple * createEmptyNTuple() const
Creates an empty NTuple with same number of columns and labels as the project's DataSource.
void setAxisBinding(int axis, const std::string &label)
Sets the axis binding for axis binding option to the column with label label.
virtual void removeCut(const TupleCut *cut)
Removes the cut from the cut list.
Base class for DataSource.