Map3Projector.cxx
Go to the documentation of this file.
1 
12 #ifdef _MSC_VER
13 // Include max() and min() missing from Microsoft Visual C++.
14 #include "msdevstudio/MSconfig.h"
15 #include <math.h>
16 #endif //_MSC_VER
17 
18 #include "Map3Projector.h"
19 
20 #include "axes/AxisModelBase.h"
21 
23 #include "datasrcs/NTuple.h"
24 
25 #include <algorithm>
26 
27 #include <cmath>
28 
29 #include <cassert>
30 
31 using namespace hippodraw;
32 
33 #ifdef ITERATOR_MEMBER_DEFECT
34 using namespace std;
35 #else
36 using std::abs;
37 using std::max;
38 using std::max_element;
39 using std::min;
40 using std::min_element;
41 using std::string;
42 using std::vector;
43 #endif
44 
46  : NTupleProjector ( 3 )
47 {
48  m_binding_options.push_back ( "X" );
49  m_binding_options.push_back ( "Y" );
50  m_binding_options.push_back ( "Z" );
51  m_min_bindings = 3;
52  addPointReps();
53 }
54 
60 Map3Projector ( const Map3Projector & projector )
61  : ProjectorBase ( projector ),
62  NTupleProjector( projector )
63 {
64  addPointReps();
65 }
66 
68 {
69  return new Map3Projector( *this );
70 }
71 
73 {
74  unsigned int cols = m_ntuple->columns () - 1;
75 
76  if ( m_columns[0] > cols ) m_columns[0] = cols;
77  if ( m_columns[1] > cols ) m_columns[1] = cols;
78  if ( m_columns[2] > cols ) m_columns[2] = cols;
79 }
80 
86 {
87  Range range = dataRange ( m_columns[2] );
88 
89  return range;
90 }
91 
92 Range
95 {
96  assert ( axis == Axes::X || axis == Axes::Y || axis == Axes::Z );
97 
98  unsigned int index = 0;
99  if ( axis == Axes::Y ) index = 1;
100  if ( axis == Axes::Z ) index = 2;
101 
102  return dataRange ( m_columns[index] );
103 
104 }
105 
106 double
109 {
110  assert ( axis == Axes::X || axis == Axes::Y || axis == Axes::Z );
111 
112  unsigned int index = 0;
113  if ( axis == Axes::Y ) index = 1;
114  if ( axis == Axes::Z ) index = 2;
115 
116  return getPos ( m_columns[index] );
117 
118 }
119 
120 const string & Map3Projector::getZLabel () const
121 {
122  return m_ntuple->getLabelAt ( m_columns[2] );
123 }
124 
125 namespace dp = hippodraw::DataPoint3DTuple;
126 
132 double Map3Projector::getZValue ( double x, double y ) const
133 {
134 
135  double retval = 0;
136 
137  const Range & xr = m_x_axis->getRange ( true );
138  const Range & yr = m_y_axis->getRange ( true );
139 
140  double xe = xr.length() * 0.01;
141  double ye = yr.length() * 0.01;
142 
143  const vector < double > & xs = m_proj_values -> getColumn ( dp::X );
144  const vector < double > & ys = m_proj_values -> getColumn ( dp::Y );
145  const vector < double > & zs = m_proj_values -> getColumn ( dp::Z );
146  unsigned int size = xs.size();
147  for ( unsigned int i = 0; i < size; i++ ) {
148  if ( abs ( x - xs[i] ) < xe &&
149  abs ( y - ys[i] ) < ye ) retval = zs[i]; // last one
150  }
151 
152  return retval;
153 }
154 
156 {
157  m_pointreps.push_back ( "ColorSymbol" );
158 }
159 
160 DataSource *
162 createNTuple () const
163 {
164  unsigned int ix = m_columns [ 0 ];
165  unsigned int iy = m_columns [ 1 ];
166  unsigned int iz = m_columns [ 2 ];
167 
168  unsigned int columns = 3;
169  NTuple * ntuple = new NTuple ( columns );
170  vector < string > labels;
171  labels.push_back ( m_ntuple -> getLabelAt ( ix ) );
172  labels.push_back ( m_ntuple -> getLabelAt ( iy ) );
173  labels.push_back ( m_ntuple -> getLabelAt ( iz ) );
174  ntuple -> setLabels ( labels );
175 
176  fillProjectedValues ( ntuple );
177 
178  return ntuple;
179 }
180 
181 void
183 fillProjectedValues ( DataSource * ntuple, bool in_range ) const
184 {
185  ntuple -> clear ();
186 
187  unsigned int size = m_ntuple -> rows ();
188  ntuple -> reserve ( size );
189  vector < double > row ( 3 ); // an exception, no errors
190 
191  unsigned int ix = m_columns [ 0 ];
192  unsigned int iy = m_columns [ 1 ];
193  unsigned int iz = m_columns [ 2 ];
194 
195  for ( unsigned int i = 0; i < size; i++ ) {
196  if ( acceptRow ( i, m_cut_list ) == false ||
197  ( in_range == true && inRange ( i ) == false ) ) continue;
198 
199  row[dp::X] = m_ntuple -> valueAt ( i, ix );
200  row[dp::Y] = m_ntuple -> valueAt ( i, iy );
201  row[dp::Z] = m_ntuple -> valueAt ( i, iz );
202 
203  ntuple -> addRow ( row );
204  }
205 }
206 
207 void
210 {
211  if ( m_proj_values == 0 ) {
213  }
214  else {
216  }
217 
218  setDirty ( false );
219 }

Generated for HippoDraw Class Library by doxygen