TupleCut.cxx
Go to the documentation of this file.
1 
12 // for truncation warning in debug mode
13 #ifdef _MSC_VER
14 #include "msdevstudio/MSconfig.h"
15 #endif
16 
17 #include "TupleCut.h"
18 
19 #include "datasrcs/DataSource.h"
20 
21 #include <algorithm>
22 
23 using namespace hippodraw;
24 
27  : m_column ( 0 ),
28  m_invert ( false ),
29  m_enabled ( true )
30 {
31 }
32 
33 void
35 setEnabled ( bool yes )
36 {
37  m_enabled = yes;
38 }
39 
40 bool
42 isEnabled () const
43 {
44  return m_enabled;
45 }
46 
47 bool TupleCut::acceptRow ( const DataSource * ntuple,
48  unsigned int i ) const
49 {
50  bool shouldBeAccepted = true;
51 
52  if ( m_enabled ) {
53  double value = ntuple -> valueAt ( i, m_column );
54  bool included = m_range.includes ( value );
55  shouldBeAccepted =
56  ( included && ! m_invert ) ||
57  ( !included && m_invert );
58  }
59 
60  return shouldBeAccepted;
61 }
62 
63 void TupleCut::setColumn( unsigned int column )
64 {
65  m_column = column;
66 }
67 
68 unsigned int
70 getColumn () const
71 {
72  return m_column;
73 }
74 
75 void
77 setRange ( const Range & range )
78 {
79  m_range = range;
80 }
81 
82 const Range &
84 getRange ( ) const
85 {
86  return m_range;
87 }
88 
89 void
91 setInversion ( bool state )
92 {
93  m_invert = state;
94 }
95 
96 bool
98 getInversion ( ) const
99 {
100  return m_invert;
101 }
102 
104 {
105  m_invert = m_invert ? false : true;
106 }
107 
108 const std::string &
110 getLabel () const
111 {
112  return m_label;
113 }
114 
115 void
117 setLabel ( const std::string & label )
118 {
119  m_label = label;
120 }
unsigned int i
void setEnabled(bool yes=true)
Sets the cut to be enabled, i.e.
Definition: TupleCut.cxx:35
void setRange(const Range &range)
Sets the range of the cut.
Definition: TupleCut.cxx:77
column
The column indices for 2 dimension data point tuple.
bool isEnabled() const
Returns the state of the cut&#39;s enable status.
Definition: TupleCut.cxx:42
TupleCut()
The default constructor.
Definition: TupleCut.cxx:26
bool acceptRow(const DataSource *source, unsigned int i) const
Returns true if the cut value at the index i is within the range.
Definition: TupleCut.cxx:47
bool includes(double value) const
Returns true if the argument value is inside the range.
Definition: Range.cxx:146
bool m_enabled
The enable flag.
Definition: TupleCut.h:70
std::string m_label
The label for the cut.
Definition: TupleCut.h:49
return yes
Definition: CanvasView.cxx:883
hippodraw::DataSource class interface.
bool m_invert
The inversion flag.
Definition: TupleCut.h:64
void toggleInverted()
Toggles the sense of the inversion flag.
Definition: TupleCut.cxx:103
unsigned int getColumn() const
Returns the column index used in the DataSource.
Definition: TupleCut.cxx:70
void setInversion(bool state)
Sets the inversion state to state.
Definition: TupleCut.cxx:91
Range m_range
The Range object used by the cut.
Definition: TupleCut.h:55
hippodraw::TupleCut class interface
const Range & getRange() const
Returns a reference to the range for each dimension.
Definition: TupleCut.cxx:84
Expresses a range of values.
Definition: Range.h:33
void setLabel(const std::string &label)
Sets the label for the cut.
Definition: TupleCut.cxx:117
bool getInversion() const
Returns the state of the inversion for the axis.
Definition: TupleCut.cxx:98
unsigned int m_column
The column index used by the cut.
Definition: TupleCut.h:59
void setColumn(unsigned int col)
Sets the column in the DataSource to be used.
Definition: TupleCut.cxx:63
const std::string & getLabel() const
Returns the label for the cut.
Definition: TupleCut.cxx:110
Base class for DataSource.
Definition: DataSource.h:55

Generated for HippoDraw Class Library by doxygen