Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

AIDA_Cloud3D.cpp

Go to the documentation of this file.
00001 #include "AIDA_Cloud3D.h"
00002 #include "AIDA_Histogram3D.h"
00003 #include "AIDA/IAnnotation.h"
00004 #include "AIDA/IAxis.h"
00005 #include <cmath>
00006 #include <set>
00007 #include "AnnotationNumberFormater.h"
00008 #include "EdgeCalculator.h"
00009 
00010 static const std::string meanXKey = "MeanX";
00011 static const std::string rmsXKey = "RmsX";
00012 static const std::string meanYKey = "MeanY";
00013 static const std::string rmsYKey = "RmsY";
00014 static const std::string meanZKey = "MeanZ";
00015 static const std::string rmsZKey = "RmsZ";
00016 static const std::string emptyString = "";
00017 
00018 
00019 Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::AIDA_Cloud3D( const std::string& title ):
00020   Anaphe::AIDA_Histogram_native::AIDA_BaseHistogram( title, "ICloud3D", 3 ),
00021   m_cacheSize( Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::defaultCacheSize ),
00022   m_elements(),
00023   m_sumOfWeights( 0 ),
00024   m_sumOfWeightTimesValueX( 0 ),
00025   m_sumOfWeightTimesValueY( 0 ),
00026   m_sumOfWeightTimesValueZ( 0 ),
00027   m_sumOfWeightTimesSquaredValueX( 0 ),
00028   m_sumOfWeightTimesSquaredValueY( 0 ),
00029   m_sumOfWeightTimesSquaredValueZ( 0 ),
00030   m_lowEdgeX( 0 ),
00031   m_lowEdgeY( 0 ),
00032   m_lowEdgeZ( 0 ),
00033   m_highEdgeX( 0 ),
00034   m_highEdgeY( 0 ),
00035   m_highEdgeZ( 0 ),
00036   m_histo( 0 )
00037 {
00038   setCacheSize( m_cacheSize );
00039 
00041   AIDA::IAnnotation& annotation = annotationNoUpdate();
00042   annotation.addItem( meanXKey, emptyString, false );
00043   annotation.addItem( rmsXKey, emptyString, false );
00044   annotation.addItem( meanYKey, emptyString, false );
00045   annotation.addItem( rmsYKey, emptyString, false );
00046   annotation.addItem( meanZKey, emptyString, false );
00047   annotation.addItem( rmsZKey, emptyString, false );
00048 }
00049 
00050 
00051 Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::AIDA_Cloud3D( const AIDA_Cloud3D& h ):
00052   Anaphe::AIDA_Histogram_native::AIDA_BaseHistogram( h.title(), "ICloud3D", 3 ),
00053   m_cacheSize( h.m_cacheSize ),
00054   m_elements( h.m_elements ),
00055   m_sumOfWeights( h.m_sumOfWeights ),
00056   m_sumOfWeightTimesValueX( h.m_sumOfWeightTimesValueX ),
00057   m_sumOfWeightTimesValueY( h.m_sumOfWeightTimesValueY ),
00058   m_sumOfWeightTimesValueZ( h.m_sumOfWeightTimesValueZ ),
00059   m_sumOfWeightTimesSquaredValueX( h.m_sumOfWeightTimesSquaredValueX ),
00060   m_sumOfWeightTimesSquaredValueY( h.m_sumOfWeightTimesSquaredValueY ),
00061   m_sumOfWeightTimesSquaredValueZ( h.m_sumOfWeightTimesSquaredValueZ ),
00062   m_lowEdgeX( h.m_lowEdgeX ),
00063   m_lowEdgeY( h.m_lowEdgeY ),
00064   m_lowEdgeZ( h.m_lowEdgeZ ),
00065   m_highEdgeX( h.m_highEdgeX ),
00066   m_highEdgeY( h.m_highEdgeY ),
00067   m_highEdgeZ( h.m_highEdgeZ ),
00068   m_histo( 0 )
00069 {
00070   if ( h.m_histo ) {
00071     m_histo = new Anaphe::AIDA_Histogram_native::AIDA_Histogram3D( * ( dynamic_cast<const Anaphe::AIDA_Histogram_native::AIDA_Histogram3D*>( h.m_histo ) ) );
00072   }
00073 
00075   AIDA::IAnnotation& annotation = annotationNoUpdate();
00076   std::set< std::string > existingAnnotationItems;
00077   for ( int item = 0; item < annotation.size(); ++item ) {
00078       existingAnnotationItems.insert( annotation.key( item ) );
00079   }
00080   const AIDA::IAnnotation& otherAnnotation = h.annotation();
00081   for ( int itemNew = 0; itemNew < otherAnnotation.size(); ++itemNew ) {
00082       const std::string& key = otherAnnotation.key( itemNew );
00083       if ( existingAnnotationItems.find( key ) == existingAnnotationItems.end() ) {
00084           annotation.addItem( key, otherAnnotation.value( itemNew ), false );
00085       }
00086   }
00087 }
00088 
00089 
00090 Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::AIDA_Cloud3D( const AIDA::ICloud3D& h ):
00091   Anaphe::AIDA_Histogram_native::AIDA_BaseHistogram( h.title(), "ICloud3D", 3 ),
00092   m_cacheSize( Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::defaultCacheSize ),
00093   m_elements(),
00094   m_sumOfWeights( 0 ),
00095   m_sumOfWeightTimesValueX( 0 ),
00096   m_sumOfWeightTimesValueY( 0 ),
00097   m_sumOfWeightTimesValueZ( 0 ),
00098   m_sumOfWeightTimesSquaredValueX( 0 ),
00099   m_sumOfWeightTimesSquaredValueY( 0 ),
00100   m_sumOfWeightTimesSquaredValueZ( 0 ),
00101   m_lowEdgeX( 0 ),
00102   m_lowEdgeY( 0 ),
00103   m_lowEdgeZ( 0 ),
00104   m_highEdgeX( 0 ),
00105   m_highEdgeY( 0 ),
00106   m_highEdgeZ( 0 ),
00107   m_histo( 0 )
00108 {
00109   if ( h.isConverted() ) {
00110     AIDA::ICloud3D& c = const_cast<AIDA::ICloud3D&>( h );
00111     const AIDA::IHistogram3D& histo = c.histogram();
00112     m_histo = new Anaphe::AIDA_Histogram_native::AIDA_Histogram3D( histo );
00113   }
00114   else {
00115     setCacheSize( m_cacheSize );    
00116     for ( int i = 0; i < h.entries(); ++i ) this->fill( h.valueX( i ), h.valueY( i ), h.valueZ( i ), h.weight( i ) );
00117   }
00118 
00120   AIDA::IAnnotation& annotation = annotationNoUpdate();
00121   std::set< std::string > existingAnnotationItems;
00122   for ( int item = 0; item < annotation.size(); ++item ) {
00123       existingAnnotationItems.insert( annotation.key( item ) );
00124   }
00125   const AIDA::IAnnotation& otherAnnotation = h.annotation();
00126   for ( int itemNew = 0; itemNew < otherAnnotation.size(); ++itemNew ) {
00127       const std::string& key = otherAnnotation.key( itemNew );
00128       if ( existingAnnotationItems.find( key ) == existingAnnotationItems.end() ) {
00129           annotation.addItem( key, otherAnnotation.value( itemNew ), false );
00130       }
00131   }
00132 }
00133 
00134 
00135 Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::~AIDA_Cloud3D()
00136 {
00137   if ( m_histo ) delete m_histo;
00138 }
00139 
00140 
00141 void
00142 Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::updateAnnotation() const
00143 {
00144   Anaphe::AIDA_Histogram_native::AIDA_BaseHistogram::updateAnnotation();
00145   const AIDA::IAnnotation& anno = annotationNoUpdate();
00146   AIDA::IAnnotation& annotation = const_cast< AIDA::IAnnotation& >( anno );
00147 
00148   annotation.setValue( meanXKey, anaphe_annotationNumberFormater.formatDouble( meanX() ) );
00149   annotation.setValue( rmsXKey, anaphe_annotationNumberFormater.formatDouble( rmsX() ) );
00150   annotation.setValue( meanYKey, anaphe_annotationNumberFormater.formatDouble( meanY() ) );
00151   annotation.setValue( rmsYKey, anaphe_annotationNumberFormater.formatDouble( rmsY() ) );
00152   annotation.setValue( meanZKey, anaphe_annotationNumberFormater.formatDouble( meanZ() ) );
00153   annotation.setValue( rmsZKey, anaphe_annotationNumberFormater.formatDouble( rmsZ() ) );
00154 }
00155 
00156 
00157 bool
00158 Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::reset()
00159 {
00160   if ( m_histo ) {
00161     delete m_histo;
00162     m_histo = 0;
00163   }
00164   m_elements.clear();
00165   setCacheSize( m_cacheSize );
00166   m_sumOfWeights = 0;
00167   m_sumOfWeightTimesValueX = m_sumOfWeightTimesValueY = m_sumOfWeightTimesValueZ = 0;
00168   m_sumOfWeightTimesSquaredValueX = m_sumOfWeightTimesSquaredValueY = m_sumOfWeightTimesSquaredValueZ = 0;
00169   m_lowEdgeX = m_lowEdgeY = m_lowEdgeZ = 0;
00170   m_highEdgeX = m_highEdgeY = m_highEdgeZ = 0;
00171   return true;
00172 }
00173 
00174 
00175 int
00176 Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::entries() const
00177 {
00178   if ( m_histo ) {
00179     return m_histo->entries();
00180   }
00181   else {
00182     return m_elements.size();
00183   }
00184 }
00185 
00186 
00187 double
00188 Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::sumOfWeights() const
00189 {
00190   if ( m_histo ) {
00191     return m_histo->sumBinHeights();
00192   }
00193   else {
00194     return m_sumOfWeights;
00195   }
00196 }
00197 
00198 
00199 bool
00200 Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::convertToHistogram()
00201 {
00202   if ( m_histo || m_elements.size() < 2 ) return false;
00203   double lowEdgeX, highEdgeX;
00204   edgeCalculator.calculateEdges( m_lowEdgeX, m_highEdgeX, Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::defaultNumberOfBins, lowEdgeX, highEdgeX );
00205   double lowEdgeY, highEdgeY;
00206   edgeCalculator.calculateEdges( m_lowEdgeY, m_highEdgeY, Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::defaultNumberOfBins, lowEdgeY, highEdgeY );
00207   double lowEdgeZ, highEdgeZ;
00208   edgeCalculator.calculateEdges( m_lowEdgeZ, m_highEdgeZ, Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::defaultNumberOfBins, lowEdgeZ, highEdgeZ );
00209   Anaphe::AIDA_Histogram_native::AIDA_Histogram3D* p =
00210     new Anaphe::AIDA_Histogram_native::AIDA_Histogram3D( title() + " (supporting histogram)",
00211                                                          Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::defaultNumberOfBins,
00212                                                          lowEdgeX, highEdgeX,
00213                                                          Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::defaultNumberOfBins,
00214                                                          lowEdgeY, highEdgeY,
00215                                                          Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::defaultNumberOfBins,
00216                                                          lowEdgeZ, highEdgeZ );
00217   p->setName( name() + "_supportingHistogram" );
00218   m_histo = p;
00219   for ( unsigned int i = 0; i < m_elements.size(); ++i ) m_histo->fill( m_elements[i].x, m_elements[i].y,  m_elements[i].z, m_elements[i].w );
00220   m_elements.clear();
00221   return true;
00222 }
00223 
00224 
00225 bool
00226 Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::isConverted() const
00227 {
00228   return ( m_histo != 0 );
00229 }
00230 
00231 
00232 bool
00233 Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::scale( double scaleFactor )
00234 {
00235   if ( m_histo ) return m_histo->scale( scaleFactor );
00236   else {
00237     for ( unsigned int i = 0; i < m_elements.size(); ++i ) {
00238       m_elements[i].w *= scaleFactor;
00239     }
00240     m_sumOfWeights *= scaleFactor;
00241     m_sumOfWeightTimesValueX *= scaleFactor;
00242     m_sumOfWeightTimesValueY *= scaleFactor;
00243     m_sumOfWeightTimesValueZ *= scaleFactor;
00244     m_sumOfWeightTimesSquaredValueX *= scaleFactor;
00245     m_sumOfWeightTimesSquaredValueY *= scaleFactor;
00246     m_sumOfWeightTimesSquaredValueZ *= scaleFactor;
00247     return true;
00248   }
00249 }
00250 
00251 
00252 bool
00253 Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::fill( double x, double y, double z, double weight )
00254 {
00255   if ( m_histo ) return m_histo->fill( x, y, z, weight );
00256   else {
00257     if ( m_elements.empty() ) {
00258       m_lowEdgeX = m_highEdgeX = x;
00259       m_lowEdgeY = m_highEdgeY = y;
00260       m_lowEdgeZ = m_highEdgeZ = z;
00261     }
00262     else {
00263       if ( m_lowEdgeX > x ) m_lowEdgeX = x;
00264       if ( m_highEdgeX < x ) m_highEdgeX = x;
00265       if ( m_lowEdgeY > y ) m_lowEdgeY = y;
00266       if ( m_highEdgeY < y ) m_highEdgeY = y;
00267       if ( m_lowEdgeZ > z ) m_lowEdgeZ = z;
00268       if ( m_highEdgeZ < z ) m_highEdgeZ = z;
00269     }
00270     m_elements.push_back( Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::Cloud3DElement( x, y, z, weight ) );
00271     m_sumOfWeights += weight;
00272     m_sumOfWeightTimesValueX += weight * x;
00273     m_sumOfWeightTimesValueY += weight * y;
00274     m_sumOfWeightTimesValueZ += weight * z;
00275     m_sumOfWeightTimesSquaredValueX += weight * x * x;
00276     m_sumOfWeightTimesSquaredValueY += weight * y * y;
00277     m_sumOfWeightTimesSquaredValueZ += weight * z * z;
00278     if ( m_elements.size() >= m_cacheSize ) convertToHistogram();
00279     return true;
00280   }
00281 }
00282 
00283 
00284 double
00285 Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::lowerEdgeX() const
00286 {
00287   if ( m_histo ) return m_histo->xAxis().lowerEdge();
00288   else return m_lowEdgeX;
00289 }
00290 
00291 
00292 double
00293 Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::lowerEdgeY() const
00294 {
00295   if ( m_histo ) return m_histo->yAxis().lowerEdge();
00296   else return m_lowEdgeY;
00297 }
00298 
00299 
00300 double
00301 Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::lowerEdgeZ() const
00302 {
00303   if ( m_histo ) return m_histo->zAxis().lowerEdge();
00304   else return m_lowEdgeZ;
00305 }
00306 
00307 
00308 double
00309 Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::upperEdgeX() const
00310 {
00311   if ( m_histo ) return m_histo->xAxis().upperEdge();
00312   else return m_highEdgeX;
00313 }
00314 
00315 
00316 double
00317 Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::upperEdgeY() const
00318 {
00319   if ( m_histo ) return m_histo->yAxis().upperEdge();
00320   else return m_highEdgeY;
00321 }
00322 
00323 
00324 double
00325 Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::upperEdgeZ() const
00326 {
00327   if ( m_histo ) return m_histo->zAxis().upperEdge();
00328   else return m_highEdgeZ;
00329 }
00330 
00331 
00332 double
00333 Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::valueX( int index ) const
00334 {
00335   if ( m_histo || index < 0 ) return 0;
00336   if ( static_cast< unsigned int >( index ) >= m_elements.size() ) return 0;
00337   return m_elements[index].x;
00338 }
00339 
00340 
00341 double
00342 Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::valueY( int index ) const
00343 {
00344   if ( m_histo || index < 0 ) return 0;
00345   if ( static_cast< unsigned int >( index ) >= m_elements.size() ) return 0;
00346   return m_elements[index].y;
00347 }
00348 
00349 
00350 double
00351 Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::valueZ( int index ) const
00352 {
00353   if ( m_histo || index < 0 ) return 0;
00354   if ( static_cast< unsigned int >( index ) >= m_elements.size() ) return 0;
00355   return m_elements[index].z;
00356 }
00357 
00358 
00359 double
00360 Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::weight( int index ) const
00361 {
00362   if ( m_histo || index < 0 ) return 0;
00363   if ( static_cast< unsigned int >( index ) >= m_elements.size() ) return 0;
00364   return m_elements[index].w;
00365 }
00366 
00367 
00368 double
00369 Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::meanX() const
00370 {
00371   if ( m_histo ) return m_histo->meanX();
00372   else if ( m_sumOfWeights ) {
00373     return ( m_sumOfWeightTimesValueX / m_sumOfWeights );
00374   }
00375   else return 0;
00376 }
00377 
00378 
00379 double
00380 Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::meanY() const
00381 {
00382   if ( m_histo ) return m_histo->meanY();
00383   else if ( m_sumOfWeights ) {
00384     return ( m_sumOfWeightTimesValueY / m_sumOfWeights );
00385   }
00386   else return 0;
00387 }
00388 
00389 
00390 double
00391 Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::meanZ() const
00392 {
00393   if ( m_histo ) return m_histo->meanZ();
00394   else if ( m_sumOfWeights ) {
00395     return ( m_sumOfWeightTimesValueZ / m_sumOfWeights );
00396   }
00397   else return 0;
00398 }
00399 
00400 
00401 double
00402 Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::rmsX() const
00403 {
00404   if ( m_histo ) return m_histo->rmsX();
00405   else if ( m_sumOfWeights ) {
00406     return std::sqrt(std::abs( m_sumOfWeightTimesSquaredValueX * m_sumOfWeights - m_sumOfWeightTimesValueX*m_sumOfWeightTimesValueX))/std::abs(m_sumOfWeights);
00407   }
00408   else return 0;
00409 }
00410 
00411 
00412 double
00413 Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::rmsY() const
00414 {
00415   if ( m_histo ) return m_histo->rmsY();
00416   else if ( m_sumOfWeights ) {
00417     return std::sqrt(std::abs( m_sumOfWeightTimesSquaredValueY * m_sumOfWeights - m_sumOfWeightTimesValueY*m_sumOfWeightTimesValueY))/std::abs(m_sumOfWeights);
00418   }
00419   else return 0;
00420 }
00421 
00422 
00423 double
00424 Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::rmsZ() const
00425 {
00426   if ( m_histo ) return m_histo->rmsZ();
00427   else if ( m_sumOfWeights ) {
00428     return std::sqrt(std::abs( m_sumOfWeightTimesSquaredValueZ * m_sumOfWeights - m_sumOfWeightTimesValueZ*m_sumOfWeightTimesValueZ))/std::abs(m_sumOfWeights);
00429   }
00430   else return 0;
00431 }
00432 
00433 
00434 bool
00435 Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::convert( int nBinsX, double lowerEdgeX, double upperEdgeX,
00436                                                       int nBinsY, double lowerEdgeY, double upperEdgeY,
00437                                                       int nBinsZ, double lowerEdgeZ, double upperEdgeZ )
00438 {
00439   if ( m_histo ) return false;
00440   Anaphe::AIDA_Histogram_native::AIDA_Histogram3D* p = new Anaphe::AIDA_Histogram_native::AIDA_Histogram3D( title() + " (supporting histogram)",
00441                                                                                                             nBinsX, lowerEdgeX, upperEdgeX,
00442                                                                                                             nBinsY, lowerEdgeY, upperEdgeY,
00443                                                                                                             nBinsZ, lowerEdgeZ, upperEdgeZ );
00444   p->setName( name() + "_supportingHistogram" );
00445   m_histo = p;
00446   for ( unsigned int i = 0; i < m_elements.size(); ++i ) m_histo->fill( m_elements[i].x, m_elements[i].y, m_elements[i].z, m_elements[i].w );
00447   m_elements.clear();
00448   return true;
00449 }
00450 
00451 
00452 bool
00453 Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::convert( const std::vector< double >& binEdgeX, const std::vector< double >& binEdgeY, const std::vector< double >& binEdgeZ )
00454 {
00455   if ( m_histo ) return false;
00456   Anaphe::AIDA_Histogram_native::AIDA_Histogram3D* p = new Anaphe::AIDA_Histogram_native::AIDA_Histogram3D( title() + " (supporting histogram)",
00457                                                                                                             binEdgeX, binEdgeY, binEdgeZ );
00458   p->setName( name() + "_supportingHistogram" );
00459   m_histo = p;
00460   for ( unsigned int i = 0; i < m_elements.size(); ++i ) m_histo->fill( m_elements[i].x, m_elements[i].y, m_elements[i].z, m_elements[i].w );
00461   m_elements.clear();
00462   return true;
00463 }
00464 
00465 
00466 bool
00467 Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::fillHistogram( AIDA::IHistogram3D& hist ) const
00468 {
00469   if ( m_histo ) {
00470     AIDA::IHistogram3D& h = *m_histo;
00471     for ( int ib = -2; ib < h.yAxis().bins(); ++ib ) {
00472       int i = ib;
00473       if ( ib == -2 ) i = static_cast<int>( AIDA::IAxis::OVERFLOW_BIN );
00474       else if ( ib == -1 ) i = static_cast<int>( AIDA::IAxis::UNDERFLOW_BIN );
00475 
00476       for ( int jb = -2; jb < h.yAxis().bins(); ++jb ) {
00477         int j = ib;
00478         if ( jb == -2 ) j = static_cast<int>( AIDA::IAxis::OVERFLOW_BIN );
00479         else if ( jb == -1 ) j = static_cast<int>( AIDA::IAxis::UNDERFLOW_BIN );
00480 
00481         for ( int kb = -2; kb < h.zAxis().bins(); ++kb ) {
00482           int k = ib;
00483           if ( kb == -2 ) j = static_cast<int>( AIDA::IAxis::OVERFLOW_BIN );
00484           else if ( kb == -1 ) j = static_cast<int>( AIDA::IAxis::UNDERFLOW_BIN );
00485 
00486           const int entries = h.binEntries( i, j, k );
00487           if ( entries == 0 ) continue;
00488           const double newCentreX = h.binMeanX( i, j, k );
00489           const double newCentreY = h.binMeanY( i, j, k );
00490           const double newCentreZ = h.binMeanY( i, j, k );
00491           const double newValue = h.binHeight( i, j, k );
00492           if ( entries == 1 ) hist.fill( newCentreX, newCentreY, newCentreZ, newValue );
00493           else {
00494             double newError = h.binError( i, j, k );
00495             const double w1 =
00496               ( 2 * newValue - std::sqrt( ( 4 * entries * newError * newError - newValue * newValue ) / ( entries - 1 ) ) ) / ( 2 * entries );
00497             const double w2 = newValue - ( entries - 1 ) * w1;
00498             for ( int ie = 0; ie < entries - 1; ++ie ) {
00499               hist.fill( newCentreX, newCentreY, newCentreZ, w1 );
00500             }
00501             hist.fill( newCentreX, newCentreY, newCentreZ, w2 );
00502           }
00503         }
00504       }
00505     }
00506   }
00507   else {
00508     for ( std::vector< Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::Cloud3DElement >::const_iterator iElement = m_elements.begin();
00509           iElement != m_elements.end(); ++iElement ) {
00510       hist.fill( iElement->x, iElement->y, iElement->z, iElement->w );
00511     }
00512   }
00513   return true;
00514 }
00515 
00516 
00517 const AIDA::IHistogram3D&
00518 Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::histogram() const
00519 {
00520   if ( ! m_histo ) const_cast<Anaphe::AIDA_Histogram_native::AIDA_Cloud3D*>(this)->convertToHistogram();
00521   return *m_histo;
00522 }
00523 
00524 
00525 bool
00526 Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::setCacheSize( unsigned int newCacheSize )
00527 {
00528   m_cacheSize = newCacheSize;
00529   if ( m_cacheSize != static_cast<unsigned int>( -1 ) ) m_elements.reserve( newCacheSize );
00530   return true;
00531 }
00532 
00533 
00534 unsigned int
00535 Anaphe::AIDA_Histogram_native::AIDA_Cloud3D::cacheSize() const
00536 {
00537   return m_cacheSize;
00538 }

Generated on Tue Nov 19 12:32:16 2002 for AIDA_Histogram_native by doxygen1.2.16