00001 #include "AIDA_Profile2D.h"
00002 #include "EvenBinAxis.h"
00003 #include "VariableBinAxis.h"
00004 #include "ProfileBin2D.h"
00005 #include "AIDA/IAnnotation.h"
00006 #include <typeinfo>
00007 #include <cmath>
00008 #include <set>
00009 #include "AnnotationNumberFormater.h"
00010
00011 static const unsigned int numberOfExtraBins = 2;
00012 static const std::string meanXKey = "MeanX";
00013 static const std::string rmsXKey = "RmsX";
00014 static const std::string meanYKey = "MeanY";
00015 static const std::string rmsYKey = "RmsY";
00016 static const std::string extra_entriesKey = "Extra Entries";
00017 static const std::string emptyString = "";
00018
00019
00020 Anaphe::AIDA_Histogram_native::AIDA_Profile2D::AIDA_Profile2D( const std::string& title,
00021 int numberOfBinsX,
00022 double lowEdgeX,
00023 double highEdgeX,
00024 int numberOfBinsY,
00025 double lowEdgeY,
00026 double highEdgeY ):
00027 Anaphe::AIDA_Histogram_native::AIDA_BaseHistogram( title, "IProfile2D", 2 ),
00028 m_axisX( new EvenBinAxis( std::abs( numberOfBinsX ), lowEdgeX, highEdgeX ) ),
00029 m_axisY( new EvenBinAxis( std::abs( numberOfBinsY ), lowEdgeY, highEdgeY ) ),
00030 m_bins( std::abs( numberOfBinsX ) + numberOfExtraBins, std::vector< ProfileBin2D* >( std::abs( numberOfBinsY ) + numberOfExtraBins, 0 ) ),
00031 m_validStatistics( false )
00032 {
00033 for ( unsigned int i = 0; i < m_bins.size(); ++i )
00034 for ( unsigned int j = 0; j < m_bins[0].size(); ++j )
00035 m_bins[i][j] = new Anaphe::AIDA_Histogram_native::ProfileBin2D;
00036
00038 AIDA::IAnnotation& annotation = annotationNoUpdate();
00039 annotation.addItem( meanXKey, emptyString, false );
00040 annotation.addItem( rmsXKey, emptyString, false );
00041 annotation.addItem( meanYKey, emptyString, false );
00042 annotation.addItem( rmsYKey, emptyString, false );
00043 annotation.addItem( extra_entriesKey, emptyString, false );
00044 }
00045
00046 Anaphe::AIDA_Histogram_native::AIDA_Profile2D::AIDA_Profile2D( const std::string& title,
00047 const std::vector< double >& edgesX,
00048 const std::vector< double >& edgesY ):
00049 Anaphe::AIDA_Histogram_native::AIDA_BaseHistogram( title, "IProfile2D", 2 ),
00050 m_axisX( new VariableBinAxis( edgesX ) ),
00051 m_axisY( new VariableBinAxis( edgesY ) ),
00052 m_bins( edgesX.size() - 1 + numberOfExtraBins, std::vector< ProfileBin2D* >( edgesY.size() - 1 + numberOfExtraBins, 0 ) ),
00053 m_validStatistics( false )
00054 {
00055 for ( unsigned int i = 0; i < m_bins.size(); ++i )
00056 for ( unsigned int j = 0; j < m_bins[0].size(); ++j )
00057 m_bins[i][j] = new Anaphe::AIDA_Histogram_native::ProfileBin2D;
00058
00060 AIDA::IAnnotation& annotation = annotationNoUpdate();
00061 annotation.addItem( meanXKey, emptyString, false );
00062 annotation.addItem( rmsXKey, emptyString, false );
00063 annotation.addItem( meanYKey, emptyString, false );
00064 annotation.addItem( rmsYKey, emptyString, false );
00065 annotation.addItem( extra_entriesKey, emptyString, false );
00066 }
00067
00068
00069 Anaphe::AIDA_Histogram_native::AIDA_Profile2D::AIDA_Profile2D( const Anaphe::AIDA_Histogram_native::AIDA_Profile2D& h ):
00070 Anaphe::AIDA_Histogram_native::AIDA_BaseHistogram( h.title(), "IProfile2D", 2 ),
00071 m_axisX( 0 ),
00072 m_axisY( 0 ),
00073 m_bins( h.m_bins.size(), std::vector< ProfileBin2D* >( h.m_bins[0].size(), 0 ) ),
00074 m_validStatistics( false )
00075 {
00076
00077 const AIDA::IAxis& otherAxisX = h.xAxis();
00078 if ( otherAxisX.isFixedBinning() ) {
00079 m_axisX = new EvenBinAxis( otherAxisX.bins(),
00080 otherAxisX.lowerEdge(),
00081 otherAxisX.upperEdge() );
00082 }
00083 else {
00084 std::vector< double > edges( otherAxisX.bins() + 1 );
00085 for ( int i = 0; i < otherAxisX.bins(); ++i ) edges[i] = otherAxisX.binLowerEdge( i );
00086 edges.back() = otherAxisX.upperEdge();
00087 m_axisX = new VariableBinAxis( edges );
00088 };
00089 const AIDA::IAxis& otherAxisY = h.yAxis();
00090 if ( otherAxisY.isFixedBinning() ) {
00091 m_axisY = new EvenBinAxis( otherAxisY.bins(),
00092 otherAxisY.lowerEdge(),
00093 otherAxisY.upperEdge() );
00094 }
00095 else {
00096 std::vector< double > edges( otherAxisY.bins() + 1 );
00097 for ( int i = 0; i < otherAxisY.bins(); ++i ) edges[i] = otherAxisY.binLowerEdge( i );
00098 edges.back() = otherAxisY.upperEdge();
00099 m_axisY = new VariableBinAxis( edges );
00100 }
00101
00102
00103 for ( unsigned int i = 0; i < m_bins.size(); ++i )
00104 for ( unsigned int j = 0; j < m_bins[0].size(); ++j )
00105 m_bins[i][j] = new ProfileBin2D( *( h.m_bins[i][j] ) );
00106
00108 AIDA::IAnnotation& annotation = annotationNoUpdate();
00109 std::set< std::string > existingAnnotationItems;
00110 for ( int item = 0; item < annotation.size(); ++item ) {
00111 existingAnnotationItems.insert( annotation.key( item ) );
00112 }
00113 const AIDA::IAnnotation& otherAnnotation = h.annotation();
00114 for ( int itemNew = 0; itemNew < otherAnnotation.size(); ++itemNew ) {
00115 const std::string& key = otherAnnotation.key( itemNew );
00116 if ( existingAnnotationItems.find( key ) == existingAnnotationItems.end() ) {
00117 annotation.addItem( key, otherAnnotation.value( itemNew ), false );
00118 }
00119 }
00120
00121 }
00122
00123
00124 Anaphe::AIDA_Histogram_native::AIDA_Profile2D::AIDA_Profile2D( const AIDA::IProfile2D& h ):
00125 Anaphe::AIDA_Histogram_native::AIDA_BaseHistogram( h.title(), "IProfile2D", 2 ),
00126 m_axisX( 0 ),
00127 m_axisY( 0 ),
00128 m_bins( h.xAxis().bins() + numberOfExtraBins, std::vector< ProfileBin2D* >( h.yAxis().bins() + numberOfExtraBins, 0 ) ),
00129 m_validStatistics( false )
00130 {
00131
00132 const AIDA::IAxis& otherAxisX = h.xAxis();
00133 if ( otherAxisX.isFixedBinning() ) {
00134 m_axisX = new EvenBinAxis( otherAxisX.bins(),
00135 otherAxisX.lowerEdge(),
00136 otherAxisX.upperEdge() );
00137 }
00138 else {
00139 std::vector< double > edges( otherAxisX.bins() + 1 );
00140 for ( int i = 0; i < otherAxisX.bins(); ++i ) edges[i] = otherAxisX.binLowerEdge( i );
00141 edges.back() = otherAxisX.upperEdge();
00142 m_axisX = new VariableBinAxis( edges );
00143 };
00144 const AIDA::IAxis& otherAxisY = h.yAxis();
00145 if ( otherAxisY.isFixedBinning() ) {
00146 m_axisY = new EvenBinAxis( otherAxisY.bins(),
00147 otherAxisY.lowerEdge(),
00148 otherAxisY.upperEdge() );
00149 }
00150 else {
00151 std::vector< double > edges( otherAxisY.bins() + 1 );
00152 for ( int i = 0; i < otherAxisY.bins(); ++i ) edges[i] = otherAxisY.binLowerEdge( i );
00153 edges.back() = otherAxisY.upperEdge();
00154 m_axisY = new VariableBinAxis( edges );
00155 }
00156
00157
00158 for ( unsigned int iBin = 0; iBin < m_bins.size(); ++iBin ) {
00159 for ( unsigned int jBin = 0; jBin < m_bins[0].size(); ++jBin ) {
00160 m_bins[iBin][jBin]->set( h.binEntries( iBin - numberOfExtraBins, jBin - numberOfExtraBins ),
00161 h.binHeight( iBin - numberOfExtraBins, jBin - numberOfExtraBins ),
00162 h.binError( iBin - numberOfExtraBins, jBin - numberOfExtraBins ),
00163 h.binRms( iBin - numberOfExtraBins, jBin - numberOfExtraBins ),
00164 h.binMeanX( iBin - numberOfExtraBins, jBin - numberOfExtraBins ),
00165 h.binMeanY( iBin - numberOfExtraBins, jBin - numberOfExtraBins ) );
00166 }
00167 }
00168
00170 AIDA::IAnnotation& annotation = annotationNoUpdate();
00171 std::set< std::string > existingAnnotationItems;
00172 for ( int item = 0; item < annotation.size(); ++item ) {
00173 existingAnnotationItems.insert( annotation.key( item ) );
00174 }
00175 const AIDA::IAnnotation& otherAnnotation = h.annotation();
00176 for ( int itemNew = 0; itemNew < otherAnnotation.size(); ++itemNew ) {
00177 const std::string& key = otherAnnotation.key( itemNew );
00178 if ( existingAnnotationItems.find( key ) == existingAnnotationItems.end() ) {
00179 annotation.addItem( key, otherAnnotation.value( itemNew ), false );
00180 }
00181 }
00182
00183 }
00184
00185
00186 Anaphe::AIDA_Histogram_native::AIDA_Profile2D::~AIDA_Profile2D()
00187 {
00188 if ( m_axisX ) delete m_axisX;
00189 if ( m_axisY ) delete m_axisY;
00190 for ( unsigned int i = 0; i < m_bins.size(); ++i ) {
00191 for ( unsigned int j = 0; j < m_bins[0].size(); ++j )
00192 if ( m_bins[i][j] ) delete m_bins[i][j];
00193 }
00194 }
00195
00196
00197 bool
00198 Anaphe::AIDA_Histogram_native::AIDA_Profile2D::reset()
00199 {
00200 for ( unsigned int i = 0; i < m_bins.size(); ++i )
00201 for ( unsigned int j = 0; j < m_bins[0].size(); ++j )
00202 m_bins[i][j]->reset();
00203 setUpToDate( false );
00204 m_validStatistics = false;
00205 return true;
00206 }
00207
00208
00209 int
00210 Anaphe::AIDA_Histogram_native::AIDA_Profile2D::entries() const
00211 {
00212 calculateStatistics();
00213 return m_entries;
00214 }
00215
00216
00217 int
00218 Anaphe::AIDA_Histogram_native::AIDA_Profile2D::allEntries() const
00219 {
00220 return ( entries() + extraEntries() );
00221 }
00222
00223
00224 int
00225 Anaphe::AIDA_Histogram_native::AIDA_Profile2D::extraEntries() const
00226 {
00227 calculateStatistics();
00228 return m_extraEntries;
00229 }
00230
00231
00232 void
00233 Anaphe::AIDA_Histogram_native::AIDA_Profile2D::updateAnnotation() const
00234 {
00235 Anaphe::AIDA_Histogram_native::AIDA_BaseHistogram::updateAnnotation();
00236 const AIDA::IAnnotation& anno = annotationNoUpdate();
00237 AIDA::IAnnotation& annotation = const_cast< AIDA::IAnnotation& >( anno );
00238
00239 annotation.setValue( meanXKey, anaphe_annotationNumberFormater.formatDouble( meanX() ) );
00240 annotation.setValue( rmsXKey, anaphe_annotationNumberFormater.formatDouble( rmsX() ) );
00241 annotation.setValue( meanYKey, anaphe_annotationNumberFormater.formatDouble( meanY() ) );
00242 annotation.setValue( rmsYKey, anaphe_annotationNumberFormater.formatDouble( rmsY() ) );
00243 annotation.setValue( extra_entriesKey, anaphe_annotationNumberFormater.formatInteger( extraEntries() ) );
00244 }
00245
00246
00247 double
00248 Anaphe::AIDA_Histogram_native::AIDA_Profile2D::sumBinHeights() const
00249 {
00250 calculateStatistics();
00251 return m_sumBinHeights;
00252 }
00253
00254
00255 double
00256 Anaphe::AIDA_Histogram_native::AIDA_Profile2D::sumExtraBinHeights() const
00257 {
00258 calculateStatistics();
00259 return m_sumExtraBinHeights;
00260 }
00261
00262
00263 double
00264 Anaphe::AIDA_Histogram_native::AIDA_Profile2D::sumAllBinHeights() const
00265 {
00266 return ( sumBinHeights() + sumExtraBinHeights() );
00267 }
00268
00269
00270 double
00271 Anaphe::AIDA_Histogram_native::AIDA_Profile2D::minBinHeight() const
00272 {
00273 calculateStatistics();
00274 return m_minHeight;
00275 }
00276
00277
00278 double
00279 Anaphe::AIDA_Histogram_native::AIDA_Profile2D::maxBinHeight() const
00280 {
00281 calculateStatistics();
00282 return m_maxHeight;
00283 }
00284
00285
00286 bool
00287 Anaphe::AIDA_Histogram_native::AIDA_Profile2D::fill( double x, double y, double z, double weight )
00288 {
00289 const int binIndexX = m_axisX->coordToIndex( x );
00290 const int binIndexY = m_axisY->coordToIndex( y );
00291 m_bins[binIndexX + numberOfExtraBins][binIndexY + numberOfExtraBins]->fill( weight, x, y, z );
00292 setUpToDate( false );
00293 m_validStatistics = false;
00294 return true;
00295 }
00296
00297
00298 double
00299 Anaphe::AIDA_Histogram_native::AIDA_Profile2D::binMeanX( int indexX, int indexY ) const
00300 {
00301 unsigned int realIndexX = indexX + numberOfExtraBins;
00302 if ( realIndexX < 0 || realIndexX>= m_bins.size() ) return 0;
00303 unsigned int realIndexY = indexY + numberOfExtraBins;
00304 if ( realIndexY < 0 || realIndexY>= m_bins[0].size() ) return 0;
00305
00306 const ProfileBin2D& bin = *( m_bins[ realIndexX ][ realIndexY ] );
00307 return bin.centreOfGravityX();
00308 }
00309
00310
00311 double
00312 Anaphe::AIDA_Histogram_native::AIDA_Profile2D::binMeanY( int indexX, int indexY ) const
00313 {
00314 unsigned int realIndexX = indexX + numberOfExtraBins;
00315 if ( realIndexX < 0 || realIndexX>= m_bins.size() ) return 0;
00316 unsigned int realIndexY = indexY + numberOfExtraBins;
00317 if ( realIndexY < 0 || realIndexY>= m_bins[0].size() ) return 0;
00318
00319 const ProfileBin2D& bin = *( m_bins[ realIndexX ][ realIndexY ] );
00320 return bin.centreOfGravityY();
00321 }
00322
00323
00324 int
00325 Anaphe::AIDA_Histogram_native::AIDA_Profile2D::binEntries( int indexX, int indexY ) const
00326 {
00327 unsigned int realIndexX = indexX + numberOfExtraBins;
00328 if ( realIndexX < 0 || realIndexX>= m_bins.size() ) return 0;
00329 unsigned int realIndexY = indexY + numberOfExtraBins;
00330 if ( realIndexY < 0 || realIndexY>= m_bins[0].size() ) return 0;
00331 return m_bins[realIndexX][realIndexY]->entries();
00332 }
00333
00334
00335 int
00336 Anaphe::AIDA_Histogram_native::AIDA_Profile2D::binEntriesX( int index ) const
00337 {
00338 unsigned int realIndex = index + numberOfExtraBins;
00339 if ( realIndex < 0 || realIndex>= m_bins.size() ) return 0;
00340 int e = 0;
00341 for ( unsigned int j = 0; j < m_bins[0].size(); ++j ) {
00342 const ProfileBin2D& bin = *( m_bins[ realIndex ][j] );
00343 e += bin.entries();
00344 }
00345 return e;
00346 }
00347
00348
00349 int
00350 Anaphe::AIDA_Histogram_native::AIDA_Profile2D::binEntriesY( int index ) const
00351 {
00352 unsigned int realIndex = index + numberOfExtraBins;
00353 if ( realIndex < 0 || realIndex>= m_bins[0].size() ) return 0;
00354 int e = 0;
00355 for ( unsigned int j = 0; j < m_bins.size(); ++j ) {
00356 const ProfileBin2D& bin = *( m_bins[j][ realIndex ] );
00357 e += bin.entries();
00358 }
00359 return e;
00360 }
00361
00362
00363 double
00364 Anaphe::AIDA_Histogram_native::AIDA_Profile2D::binHeight( int indexX, int indexY ) const
00365 {
00366 unsigned int realIndexX = indexX + numberOfExtraBins;
00367 if ( realIndexX < 0 || realIndexX>= m_bins.size() ) return 0;
00368 unsigned int realIndexY = indexY + numberOfExtraBins;
00369 if ( realIndexY < 0 || realIndexY>= m_bins[0].size() ) return 0;
00370 return m_bins[realIndexX][realIndexY]->value();
00371 }
00372
00373
00374 double
00375 Anaphe::AIDA_Histogram_native::AIDA_Profile2D::binHeightX( int index ) const
00376 {
00377 unsigned int realIndex = index + numberOfExtraBins;
00378 if ( realIndex < 0 || realIndex>= m_bins.size() ) return 0;
00379 double e = 0;
00380 for ( unsigned int j = 0; j < m_bins[0].size(); ++j ) {
00381 const ProfileBin2D& bin = *( m_bins[ realIndex ][j] );
00382 e += bin.value();
00383 }
00384 return e;
00385 }
00386
00387
00388 double
00389 Anaphe::AIDA_Histogram_native::AIDA_Profile2D::binHeightY( int index ) const
00390 {
00391 unsigned int realIndex = index + numberOfExtraBins;
00392 if ( realIndex < 0 || realIndex>= m_bins[0].size() ) return 0;
00393 double e = 0;
00394 for ( unsigned int j = 0; j < m_bins.size(); ++j ) {
00395 const ProfileBin2D& bin = *( m_bins[j][ realIndex ] );
00396 e += bin.value();
00397 }
00398 return e;
00399 }
00400
00401
00402 double
00403 Anaphe::AIDA_Histogram_native::AIDA_Profile2D::binError( int indexX, int indexY ) const
00404 {
00405 unsigned int realIndexX = indexX + numberOfExtraBins;
00406 if ( realIndexX < 0 || realIndexX>= m_bins.size() ) return 0;
00407 unsigned int realIndexY = indexY + numberOfExtraBins;
00408 if ( realIndexY < 0 || realIndexY>= m_bins[0].size() ) return 0;
00409 return m_bins[realIndexX][realIndexY]->error();
00410 }
00411
00412
00413 double
00414 Anaphe::AIDA_Histogram_native::AIDA_Profile2D::binRms( int indexX, int indexY ) const
00415 {
00416 unsigned int realIndexX = indexX + numberOfExtraBins;
00417 if ( realIndexX < 0 || realIndexX>= m_bins.size() ) return 0;
00418 unsigned int realIndexY = indexY + numberOfExtraBins;
00419 if ( realIndexY < 0 || realIndexY>= m_bins[0].size() ) return 0;
00420 return m_bins[realIndexX][realIndexY]->spread();
00421 }
00422
00423
00424 double
00425 Anaphe::AIDA_Histogram_native::AIDA_Profile2D::meanX() const
00426 {
00427 calculateStatistics();
00428 return m_meanX;
00429 }
00430
00431
00432 double
00433 Anaphe::AIDA_Histogram_native::AIDA_Profile2D::rmsX() const
00434 {
00435 calculateStatistics();
00436 return m_rmsX;
00437 }
00438
00439
00440 double
00441 Anaphe::AIDA_Histogram_native::AIDA_Profile2D::meanY() const
00442 {
00443 calculateStatistics();
00444 return m_meanY;
00445 }
00446
00447
00448 double
00449 Anaphe::AIDA_Histogram_native::AIDA_Profile2D::rmsY() const
00450 {
00451 calculateStatistics();
00452 return m_rmsY;
00453 }
00454
00455
00456 bool
00457 Anaphe::AIDA_Histogram_native::AIDA_Profile2D::calculateStatistics() const
00458 {
00459 if ( m_validStatistics ) return true;
00460
00461
00462 m_sumBinHeights = 0;
00463 double swx = 0;
00464 double swxx = 0;
00465 double swy = 0;
00466 double swyy = 0;
00467 m_entries = 0;
00468 m_sumExtraBinHeights = 0;
00469 m_extraEntries = 0;
00470 m_maxHeight = m_minHeight = m_bins[numberOfExtraBins][numberOfExtraBins]->value();
00471 for ( unsigned int i = 0; i < m_bins.size(); ++i ) {
00472 for ( unsigned int j = 0; j < m_bins[0].size(); ++j ) {
00473 const ProfileBin2D& bin = *( m_bins[i][j] );
00474 if ( i < numberOfExtraBins || j < numberOfExtraBins ) {
00475 m_extraEntries += bin.entries();
00476 m_sumExtraBinHeights += bin.value();
00477 }
00478 else {
00479 const double binMeanX = bin.centreOfGravityX();
00480 const double binMeanY = bin.centreOfGravityY();
00481 const double binHeight = bin.value();
00482 m_entries += bin.entries();
00483 m_sumBinHeights += binHeight;
00484 swx += binMeanX * binHeight;
00485 swxx += binMeanX * binMeanX * binHeight;
00486 swy += binMeanY * binHeight;
00487 swyy += binMeanY * binMeanY * binHeight;
00488 if ( m_maxHeight < binHeight ) m_maxHeight = binHeight;
00489 if ( m_minHeight > binHeight ) m_minHeight = binHeight;
00490 }
00491 }
00492 }
00493
00494 if ( m_sumBinHeights == 0 ) {
00495 m_meanX = m_rmsX = m_meanY = m_rmsY = 0;
00496 }
00497 else {
00498 m_meanX = swx / m_sumBinHeights;
00499 m_rmsX = std::sqrt( std::abs( swxx / m_sumBinHeights - m_meanX * m_meanX ) );
00500 m_meanY = swy / m_sumBinHeights;
00501 m_rmsY = std::sqrt( std::abs( swyy / m_sumBinHeights - m_meanY * m_meanY ) );
00502 }
00503
00504
00505 m_validStatistics = true;
00506 return m_validStatistics;
00507 }
00508
00509
00510
00511 const AIDA::IAxis&
00512 Anaphe::AIDA_Histogram_native::AIDA_Profile2D::xAxis() const
00513 {
00514 return *m_axisX;
00515 }
00516
00517 const AIDA::IAxis&
00518 Anaphe::AIDA_Histogram_native::AIDA_Profile2D::yAxis() const
00519 {
00520 return *m_axisY;
00521 }
00522
00523
00524 int
00525 Anaphe::AIDA_Histogram_native::AIDA_Profile2D::coordToIndexX( double coord ) const
00526 {
00527 return m_axisX->coordToIndex( coord );
00528 }
00529
00530
00531 int
00532 Anaphe::AIDA_Histogram_native::AIDA_Profile2D::coordToIndexY( double coord ) const
00533 {
00534 return m_axisY->coordToIndex( coord );
00535 }
00536
00537
00538 bool
00539 Anaphe::AIDA_Histogram_native::AIDA_Profile2D::add( const AIDA::IProfile2D & h )
00540 {
00541
00542 const AIDA::IAxis& otherAxisX = h.xAxis();
00543 const AIDA::IAxis& myAxisX = *m_axisX;
00544 if ( otherAxisX.bins() != myAxisX.bins() ) return false;
00545 for ( int iBin = 0; iBin < myAxisX.bins(); ++iBin ) {
00546 const double otherLowEdge = otherAxisX.binLowerEdge( iBin );
00547 const double myLowEdge = myAxisX.binLowerEdge( iBin );
00548 if ( otherLowEdge != myLowEdge ) return false;
00549 }
00550 if ( otherAxisX.upperEdge() != myAxisX.upperEdge() ) return false;
00551
00552 const AIDA::IAxis& otherAxisY = h.yAxis();
00553 const AIDA::IAxis& myAxisY = *m_axisY;
00554 if ( otherAxisY.bins() != myAxisY.bins() ) return false;
00555 for ( int iBin = 0; iBin < myAxisY.bins(); ++iBin ) {
00556 const double otherLowEdge = otherAxisY.binLowerEdge( iBin );
00557 const double myLowEdge = myAxisY.binLowerEdge( iBin );
00558 if ( otherLowEdge != myLowEdge ) return false;
00559 }
00560 if ( otherAxisY.upperEdge() != myAxisY.upperEdge() ) return false;
00561
00562
00563
00564
00565
00566 try {
00567 const Anaphe::AIDA_Histogram_native::AIDA_Profile2D& other = dynamic_cast<const Anaphe::AIDA_Histogram_native::AIDA_Profile2D&>( h );
00568 return increment( other );
00569 }
00570 catch( std::bad_cast ) {
00571 Anaphe::AIDA_Histogram_native::AIDA_Profile2D * transformed = new Anaphe::AIDA_Histogram_native::AIDA_Profile2D( h );
00572 bool ret = increment( *transformed );
00573 delete transformed;
00574 return ret;
00575 }
00576 }
00577
00578
00579 bool
00580 Anaphe::AIDA_Histogram_native::AIDA_Profile2D::increment( const AIDA_Profile2D& h )
00581 {
00582 for ( unsigned int i = 0; i < m_bins.size(); ++i ) {
00583 for ( unsigned int j = 0; j < m_bins[0].size(); ++j ) {
00584 m_bins[i][j]->increment( *( h.m_bins[i][j] ) );
00585 }
00586 }
00587 setUpToDate( false );
00588 m_validStatistics = false;
00589 return true;
00590 }
00591
00592
00593 bool
00594 Anaphe::AIDA_Histogram_native::AIDA_Profile2D::setBinContents( int binIndexX,
00595 int binIndexY,
00596 int entries,
00597 double height,
00598 double error,
00599 double spread,
00600 double centreX,
00601 double centreY )
00602 {
00603 unsigned int realIndexX = binIndexX + numberOfExtraBins;
00604 if ( realIndexX < 0 || realIndexX >= m_bins.size() ) return false;
00605 unsigned int realIndexY = binIndexY + numberOfExtraBins;
00606 if ( realIndexY < 0 || realIndexY >= m_bins[0].size() ) return false;
00607 setUpToDate( false );
00608 m_validStatistics = false;
00609 return m_bins[ realIndexX ][realIndexY]->set( entries, height, error, spread, centreX, centreY );
00610 }