00001
00012 #ifdef HAVE_CONFIG_H
00013 #include "config.h"
00014 #else
00015 #ifdef _MSC_VER
00016 #include "msdevstudio/MSconfig.h"
00017 #endif
00018 #endif
00019
00020 #include "ProjectorBase.h"
00021 #include "ProjectorHelper.h"
00022
00023 #include "axes/AxisModelBase.h"
00024 #include "datasrcs/DataSource.h"
00025
00026 #include <algorithm>
00027
00028 #include <cassert>
00029
00030 using namespace hippodraw;
00031
00032 #ifdef ITERATOR_MEMBER_DEFECT
00033 using namespace std;
00034 #else
00035 using std::find;
00036 using std::string;
00037 using std::vector;
00038 using std::distance;
00039 #endif
00040
00041 ProjectorBase::ProjectorBase ()
00042 : m_isDirty ( true ),
00043 m_proj_values ( 0 ),
00044 m_x_axis ( 0 ),
00045 m_y_axis ( 0 ),
00046 m_z_axis ( 0 )
00047 {
00048 }
00049
00050 ProjectorBase::ProjectorBase ( const ProjectorBase & p )
00051 : m_isDirty ( true ),
00052 m_proj_values ( 0 ),
00053 m_x_axis ( p.m_x_axis ),
00054 m_y_axis ( p.m_y_axis ),
00055 m_z_axis ( p.m_z_axis )
00056 {
00057 }
00058
00059 ProjectorBase::~ProjectorBase ()
00060 {
00061 if ( m_proj_values != 0 ) delete m_proj_values;
00062 }
00063
00064
00065 void ProjectorBase::prepareValues ()
00066 {
00067 setDirty ( false );
00068 }
00069
00070 bool ProjectorBase::isDirty () const
00071 {
00072 return m_isDirty;
00073 }
00074
00075 void ProjectorBase::setDirty ( bool value )
00076 {
00077 m_isDirty = value;
00078
00079 if ( value == true ) notifyObservers ();
00080 }
00081
00082 void
00083 ProjectorBase::
00084 setAxisBinding ( const std::string & axis,
00085 const std::string & label )
00086 {
00087 assert ( false );
00088 }
00089
00090 void
00091 ProjectorBase::
00092 setAxisBindings ( const std::vector < std::string > & bindings )
00093 {
00094 assert ( false );
00095 }
00096
00097 const vector < string > &
00098 ProjectorBase::
00099 getAxisBindings () const
00100 {
00101 assert ( false );
00102 static vector < string > dummy;
00103
00104 return dummy;
00105 }
00106
00107 void
00108 ProjectorBase::
00109 matrixTranspose ( bool )
00110 {
00111
00112 }
00113
00114 int
00115 ProjectorBase::
00116 getNumberOfBins ( hippodraw::Axes::Type ) const
00117 {
00118 return 0;
00119 }
00120
00121 bool ProjectorBase::isAxisBinned ( const std::string & ) const
00122 {
00123 return false;
00124 }
00125
00126 bool ProjectorBase::isValueBinned () const
00127 {
00128 return false;
00129 }
00130
00131 void
00132 ProjectorBase::
00133 setRange ( hippodraw::Axes::Type axis, bool )
00134 {
00135
00136 assert ( axis == Axes::X || axis == Axes::Y || axis == Axes::Z );
00137
00138 if ( axis == Axes::Z ) assert ( m_z_axis != 0 );
00139
00140 setDirty ( true );
00141 }
00142
00143 const Range &
00144 ProjectorBase::
00145 getRange ( hippodraw::Axes::Type axis ) const
00146 {
00147
00148 assert ( axis == Axes::X || axis == Axes::Y || axis == Axes::Z );
00149
00150 if ( axis == Axes::X ) {
00151 return m_x_axis->getRange (false);
00152 }
00153 if ( axis == Axes::Y ) {
00154 return m_y_axis->getRange (false);
00155 }
00156
00157 assert ( m_z_axis != 0 );
00158 return m_z_axis->getRange (false);
00159 }
00160
00161 Range
00162 ProjectorBase::
00163 preferredRange ( hippodraw::Axes::Type axis ) const
00164 {
00165 Range range = dataRangeOn ( axis );
00166
00167 if ( range.length() == 0.0 ) {
00168 double low = range.low ();
00169
00170 if ( axis == Axes::Y &&
00171 low == 0.0 ) {
00172 range.setHigh ( 1.0 );
00173 }
00174 else {
00175 range.setLow ( low - 1. );
00176 range.setHigh ( low + 1. );
00177 }
00178 }
00179
00180 return range;
00181 }
00182
00183 void
00184 ProjectorBase::
00185 setAxisModel ( hippodraw::Axes::Type axis,
00186 AxisModelBase * axis_model )
00187 {
00188 assert ( axis == Axes::X || axis == Axes::Y || axis == Axes::Z );
00189
00190 if ( axis == Axes::X ) {
00191 m_x_axis = axis_model;
00192 }
00193 if ( axis == Axes::Y ) {
00194 m_y_axis = axis_model;
00195 }
00196
00197 if ( axis == Axes::Z ) {
00198 m_z_axis = axis_model;
00199 }
00200 }
00201
00202 AxisModelBase *
00203 ProjectorBase::
00204 getAxisModel ( hippodraw::Axes::Type axis ) const
00205 {
00206 assert ( axis == Axes::X || axis == Axes::Y || axis == Axes::Z );
00207
00208 if ( axis == Axes::X ) {
00209 return m_x_axis;
00210 }
00211
00212 if ( axis == Axes::Y ) {
00213 return m_y_axis;
00214 }
00215
00216 return m_z_axis;
00217 }
00218
00219 void
00220 ProjectorBase::
00221 setNumberOfBins ( hippodraw::Axes::Type axis, unsigned int number )
00222 {
00223 }
00224
00225 void
00226 ProjectorBase::
00227 setBinWidth ( hippodraw::Axes::Type, double )
00228 {
00229 }
00230
00231
00232 void ProjectorBase::setBinWidth ( const std::string & axis,
00233 int parm,
00234 bool dragging )
00235 {
00236 }
00237
00238 void ProjectorBase::setOffset ( const std::string & axis,
00239 int parm,
00240 bool dragging )
00241 {
00242 }
00243
00244 void
00245 ProjectorBase::
00246 setOffset ( hippodraw::Axes::Type, double )
00247 {
00248 }
00249
00250 void
00251 ProjectorBase::
00252 reset ( )
00253 {
00254 }
00255
00256 double
00257 ProjectorBase::
00258 getOffset ( hippodraw::Axes::Type ) const
00259 {
00260 return 0.0;
00261 }
00262
00266 double
00267 ProjectorBase::
00268 getAverage ( hippodraw::Axes::Type ) const
00269 {
00270
00271 return 0.0;
00272 }
00273
00277 double
00278 ProjectorBase::
00279 getRMS ( hippodraw::Axes::Type axis )
00280 {
00281 ProjectorHelper helper( getProjectedValues() );
00282
00283 double rms = 0.0;
00284
00285 if ( axis == Axes::X )
00286 rms = helper.stdCoord();
00287
00288 return rms;
00289 }
00290
00292 const std::string & ProjectorBase::getZLabel () const
00293 {
00294 return m_z_label;
00295 }
00296
00297 double
00298 ProjectorBase::
00299 getBinWidth ( hippodraw::Axes::Type ) const
00300 {
00301 return 0.0;
00302 }
00303
00304
00305 double ProjectorBase::getZValue ( double x, double y ) const
00306 {
00307 return 0.0;
00308 }
00309
00310 void
00311 ProjectorBase::
00312 addValues ( const std::vector < double > & v )
00313 {
00314
00315 }
00316
00317 const vector <string> & ProjectorBase::getPointReps() const
00318 {
00319 return m_pointreps;
00320 }
00321
00322 NTuple *
00323 ProjectorBase::
00324 getNTupleAfterCuts() const
00325 {
00326 return 0;
00327 }
00328
00329 bool
00330 ProjectorBase::
00331 wantsScaleFactor ( const std::string & ) const
00332 {
00333 return false;
00334 }
00335
00336 const DataSource *
00337 ProjectorBase::
00338 getProjectedValues () const
00339 {
00340 return m_proj_values;
00341 }
00342
00343 const DataSource *
00344 ProjectorBase::
00345 createOldStyleNTuple () const
00346 {
00347 ProjectorBase * projector = const_cast < ProjectorBase * > ( this );
00348 projector -> prepareValues ();
00349
00350 return getProjectedValues ();
00351 }
00352
00353 void
00354 ProjectorBase::
00355 normalizeTo ( double number )
00356 {
00357
00358 }
00359
00360 void
00361 ProjectorBase::
00362 setNormalizing ( bool on )
00363 {
00364
00365 }
00366
00367 void
00368 ProjectorBase::
00369 update ( const Observable * )
00370 {
00371
00372 }
00373
00374 void
00375 ProjectorBase::
00376 normalizeTo ( const ProjectorBase * )
00377 {
00378
00379 }