00001
00002
00003
00004
00005
00006
00007 #include <memory>
00008
00009
00010
00011 #include "TH1.h"
00012 #include "TH1D.h"
00013 #include "TH2D.h"
00014 #include "TH3D.h"
00015 #include "TH1F.h"
00016 #include "TH2F.h"
00017 #include "TH3F.h"
00018 #include "TProfile.h"
00019 #include "TProfile2D.h"
00020 #include "TBufferXML.h"
00021
00022
00023
00024 #include "AIDA/IHistogram1D.h"
00025 #include "AIDA/IHistogram2D.h"
00026 #include "AIDA/IHistogram3D.h"
00027 #include "AIDA/IProfile1D.h"
00028 #include "AIDA/IProfile2D.h"
00029
00030
00031
00032 #include "GaudiUtils/Aida2ROOT.h"
00033 #include "GaudiUtils/HistoXML.h"
00034
00040
00041 namespace
00042 {
00043
00045 template <class TYPE>
00046 struct _Xml
00047 {
00048 typedef std::auto_ptr<TYPE> H ;
00049
00050 H operator() ( const std::string& input ) const
00051 {
00052
00053 std::auto_ptr<TObject> obj ( TBufferXML::ConvertFromXML ( input.c_str() ) ) ;
00054 if ( 0 == obj.get() ) { return H() ; }
00055 H histo ( dynamic_cast<TYPE*>( obj.get() ) ) ;
00056 if ( 0 != histo.get() ) { obj.release() ; }
00057 return histo ;
00058 }
00059
00060 } ;
00061
00062 }
00063
00064
00065
00066
00067
00068
00069 std::ostream& Gaudi::Utils::Histos::toXml
00070 ( const TH1D& histo ,
00071 std::ostream& stream )
00072 {
00073
00074 const TObject* obj = &histo ;
00075
00076 TString s = TBufferXML::ConvertToXML ( const_cast<TObject*> ( obj ) ) ;
00077
00078 return stream << s ;
00079 }
00080
00081
00082
00083
00084
00085
00086 std::ostream& Gaudi::Utils::Histos::toXml
00087 ( const TH2D& histo ,
00088 std::ostream& stream )
00089 {
00090
00091 const TObject* obj = &histo ;
00092
00093 TString s = TBufferXML::ConvertToXML ( const_cast<TObject*> ( obj ) ) ;
00094
00095 return stream << s ;
00096 }
00097
00098
00099
00100
00101
00102
00103 std::ostream& Gaudi::Utils::Histos::toXml
00104 ( const TH3D& histo ,
00105 std::ostream& stream )
00106 {
00107
00108 const TObject* obj = &histo ;
00109
00110 TString s = TBufferXML::ConvertToXML ( const_cast<TObject*> ( obj ) ) ;
00111
00112 return stream << s ;
00113 }
00114
00115
00116
00117
00118
00119
00120 std::ostream& Gaudi::Utils::Histos::toXml
00121 ( const TH1F& histo ,
00122 std::ostream& stream )
00123 {
00124
00125 const TObject* obj = &histo ;
00126
00127 TString s = TBufferXML::ConvertToXML ( const_cast<TObject*> ( obj ) ) ;
00128
00129 return stream << s ;
00130 }
00131
00132
00133
00134
00135
00136
00137 std::ostream& Gaudi::Utils::Histos::toXml
00138 ( const TH2F& histo ,
00139 std::ostream& stream )
00140 {
00141
00142 const TObject* obj = &histo ;
00143
00144 TString s = TBufferXML::ConvertToXML ( const_cast<TObject*> ( obj ) ) ;
00145
00146 return stream << s ;
00147 }
00148
00149
00150
00151
00152
00153
00154 std::ostream& Gaudi::Utils::Histos::toXml
00155 ( const TH3F& histo ,
00156 std::ostream& stream )
00157 {
00158
00159 const TObject* obj = &histo ;
00160
00161 TString s = TBufferXML::ConvertToXML ( const_cast<TObject*> ( obj ) ) ;
00162
00163 return stream << s ;
00164 }
00165
00166
00167
00168
00169
00170
00171 std::ostream& Gaudi::Utils::Histos::toXml
00172 ( const TProfile& histo ,
00173 std::ostream& stream )
00174 {
00175
00176 const TObject* obj = &histo ;
00177
00178 TString s = TBufferXML::ConvertToXML ( const_cast<TObject*> ( obj ) ) ;
00179
00180 return stream << s ;
00181 }
00182
00183
00184
00185
00186
00187
00188 std::ostream& Gaudi::Utils::Histos::toXml
00189 ( const TProfile2D& histo ,
00190 std::ostream& stream )
00191 {
00192
00193 const TObject* obj = &histo ;
00194
00195 TString s = TBufferXML::ConvertToXML ( const_cast<TObject*> ( obj ) ) ;
00196
00197 return stream << s ;
00198 }
00199
00200
00201
00202
00203
00204
00205 std::ostream& Gaudi::Utils::Histos::toXml
00206 ( const AIDA::IHistogram1D& histo ,
00207 std::ostream& stream )
00208 {
00209
00210 AIDA::IHistogram1D* aida = const_cast<AIDA::IHistogram1D*> ( &histo ) ;
00211
00212 const TH1D* root = Gaudi::Utils::Aida2ROOT::aida2root ( aida ) ;
00213 if ( 0 == root ) { return stream ; }
00214
00215 return toXml ( *root , stream ) ;
00216 }
00217
00218
00219
00220
00221
00222
00223 std::ostream& Gaudi::Utils::Histos::toXml
00224 ( const AIDA::IHistogram2D& histo ,
00225 std::ostream& stream )
00226 {
00227
00228 AIDA::IHistogram2D* aida = const_cast<AIDA::IHistogram2D*> ( &histo ) ;
00229
00230 const TH2D* root = Gaudi::Utils::Aida2ROOT::aida2root ( aida ) ;
00231 if ( 0 == root ) { return stream ; }
00232
00233 return toXml ( *root , stream ) ;
00234 }
00235
00236
00237
00238
00239
00240
00241 std::ostream& Gaudi::Utils::Histos::toXml
00242 ( const AIDA::IHistogram3D& histo ,
00243 std::ostream& stream )
00244 {
00245
00246 AIDA::IHistogram3D* aida = const_cast<AIDA::IHistogram3D*> ( &histo ) ;
00247
00248 const TH3D* root = Gaudi::Utils::Aida2ROOT::aida2root ( aida ) ;
00249 if ( 0 == root ) { return stream ; }
00250
00251 return toXml ( *root , stream ) ;
00252 }
00253
00254
00255
00256
00257
00258
00259 std::ostream& Gaudi::Utils::Histos::toXml
00260 ( const AIDA::IProfile1D& histo ,
00261 std::ostream& stream )
00262 {
00263
00264 AIDA::IProfile1D* aida = const_cast<AIDA::IProfile1D*> ( &histo ) ;
00265
00266 const TProfile* root = Gaudi::Utils::Aida2ROOT::aida2root ( aida ) ;
00267 if ( 0 == root ) { return stream ; }
00268
00269 return toXml ( *root , stream ) ;
00270 }
00271
00272
00273
00274
00275
00276
00277 std::ostream& Gaudi::Utils::Histos::toXml
00278 ( const AIDA::IProfile2D& histo ,
00279 std::ostream& stream )
00280 {
00281
00282 AIDA::IProfile2D* aida = const_cast<AIDA::IProfile2D*> ( &histo ) ;
00283
00284 const TProfile2D* root = Gaudi::Utils::Aida2ROOT::aida2root ( aida ) ;
00285 if ( 0 == root ) { return stream ; }
00286
00287 return toXml ( *root , stream ) ;
00288 }
00289
00290
00291
00292
00293
00294
00295
00296 StatusCode Gaudi::Utils::Histos::fromXml
00297 ( TH1D& result , const std::string& input )
00298 {
00299
00300 result.Reset() ;
00301
00302 _Xml<TH1D> _xml ;
00303 std::auto_ptr<TH1D> histo = _xml ( input ) ;
00304 if ( 0 == histo.get() ) { return StatusCode::FAILURE ; }
00305
00306 result.Reset() ;
00307 histo->Copy ( result ) ;
00308
00309 return StatusCode::SUCCESS ;
00310 }
00311
00312
00313
00314
00315
00316
00317
00318 StatusCode Gaudi::Utils::Histos::fromXml
00319 ( TH2D& result , const std::string& input )
00320 {
00321
00322 result.Reset() ;
00323
00324 _Xml<TH2D> _xml ;
00325 std::auto_ptr<TH2D> histo = _xml ( input ) ;
00326 if ( 0 == histo.get() ) { return StatusCode::FAILURE ; }
00327
00328 result.Reset() ;
00329 histo->Copy ( result ) ;
00330
00331 return StatusCode::SUCCESS ;
00332 }
00333
00334
00335
00336
00337
00338
00339
00340 StatusCode Gaudi::Utils::Histos::fromXml
00341 ( TH3D& result , const std::string& input )
00342 {
00343
00344 result.Reset() ;
00345
00346 _Xml<TH3D> _xml ;
00347 std::auto_ptr<TH3D> histo = _xml ( input ) ;
00348 if ( 0 == histo.get() ) { return StatusCode::FAILURE ; }
00349
00350 result.Reset() ;
00351 histo->Copy ( result ) ;
00352
00353 return StatusCode::SUCCESS ;
00354 }
00355
00356
00357
00358
00359
00360
00361
00362 StatusCode Gaudi::Utils::Histos::fromXml
00363 ( TH1F& result , const std::string& input )
00364 {
00365
00366 result.Reset() ;
00367
00368 _Xml<TH1F> _xml ;
00369 std::auto_ptr<TH1F> histo = _xml ( input ) ;
00370 if ( 0 == histo.get() ) { return StatusCode::FAILURE ; }
00371
00372 result.Reset() ;
00373 histo->Copy ( result ) ;
00374
00375 return StatusCode::SUCCESS ;
00376 }
00377
00378
00379
00380
00381
00382
00383
00384 StatusCode Gaudi::Utils::Histos::fromXml
00385 ( TH2F& result , const std::string& input )
00386 {
00387
00388 result.Reset() ;
00389
00390 _Xml<TH2F> _xml ;
00391 std::auto_ptr<TH2F> histo = _xml ( input ) ;
00392 if ( 0 == histo.get() ) { return StatusCode::FAILURE ; }
00393
00394 result.Reset() ;
00395 histo->Copy ( result ) ;
00396
00397 return StatusCode::SUCCESS ;
00398 }
00399
00400
00401
00402
00403
00404
00405
00406 StatusCode Gaudi::Utils::Histos::fromXml
00407 ( TH3F& result , const std::string& input )
00408 {
00409
00410 result.Reset() ;
00411
00412 _Xml<TH3F> _xml ;
00413 std::auto_ptr<TH3F> histo = _xml ( input ) ;
00414 if ( 0 == histo.get() ) { return StatusCode::FAILURE ; }
00415
00416 result.Reset() ;
00417 histo->Copy ( result ) ;
00418
00419 return StatusCode::SUCCESS ;
00420 }
00421
00422
00423
00424
00425
00426
00427
00428 StatusCode Gaudi::Utils::Histos::fromXml
00429 ( TProfile& result , const std::string& input )
00430 {
00431
00432 result.Reset() ;
00433
00434 _Xml<TProfile> _xml ;
00435 std::auto_ptr<TProfile> histo = _xml ( input ) ;
00436 if ( 0 == histo.get() ) { return StatusCode::FAILURE ; }
00437
00438 result.Reset() ;
00439 histo->Copy ( result ) ;
00440
00441 return StatusCode::SUCCESS ;
00442 }
00443
00444
00445
00446
00447
00448
00449
00450 StatusCode Gaudi::Utils::Histos::fromXml
00451 ( TProfile2D& result , const std::string& input )
00452 {
00453
00454 result.Reset() ;
00455
00456 _Xml<TProfile2D> _xml ;
00457 std::auto_ptr<TProfile2D> histo = _xml ( input ) ;
00458 if ( 0 == histo.get() ) { return StatusCode::FAILURE ; }
00459
00460 result.Reset() ;
00461 histo->Copy ( result ) ;
00462
00463 return StatusCode::SUCCESS ;
00464 }
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474 StatusCode Gaudi::Utils::Histos::fromXml
00475 ( TH1D*& result , const std::string& input )
00476 {
00477 if ( 0 != result ) { return fromXml ( *result , input ) ; }
00478
00479 _Xml<TH1D> _xml ;
00480 std::auto_ptr<TH1D> histo = _xml ( input ) ;
00481 if ( 0 == histo.get() ) { return StatusCode::FAILURE ; }
00482
00483 result = histo.release() ;
00484
00485 return StatusCode::SUCCESS ;
00486 }
00487
00488
00489
00490
00491
00492
00493
00494 StatusCode Gaudi::Utils::Histos::fromXml
00495 ( TH2D*& result , const std::string& input )
00496 {
00497 if ( 0 != result ) { return fromXml ( *result , input ) ; }
00498
00499 _Xml<TH2D> _xml ;
00500 std::auto_ptr<TH2D> histo = _xml ( input ) ;
00501 if ( 0 == histo.get() ) { return StatusCode::FAILURE ; }
00502
00503 result = histo.release() ;
00504
00505 return StatusCode::SUCCESS ;
00506 }
00507
00508
00509
00510
00511
00512
00513
00514 StatusCode Gaudi::Utils::Histos::fromXml
00515 ( TH3D*& result , const std::string& input )
00516 {
00517 if ( 0 != result ) { return fromXml ( *result , input ) ; }
00518
00519 _Xml<TH3D> _xml ;
00520 std::auto_ptr<TH3D> histo = _xml ( input ) ;
00521 if ( 0 == histo.get() ) { return StatusCode::FAILURE ; }
00522
00523 result = histo.release() ;
00524
00525 return StatusCode::SUCCESS ;
00526 }
00527
00528
00529
00530
00531
00532
00533
00534
00535 StatusCode Gaudi::Utils::Histos::fromXml
00536 ( TProfile*& result , const std::string& input )
00537 {
00538 if ( 0 != result ) { return fromXml ( *result , input ) ; }
00539
00540 _Xml<TProfile> _xml ;
00541 std::auto_ptr<TProfile> histo = _xml ( input ) ;
00542 if ( 0 == histo.get() ) { return StatusCode::FAILURE ; }
00543
00544 result = histo.release() ;
00545
00546 return StatusCode::SUCCESS ;
00547 }
00548
00549
00550
00551
00552
00553
00554
00555 StatusCode Gaudi::Utils::Histos::fromXml
00556 ( TProfile2D*& result , const std::string& input )
00557 {
00558 if ( 0 != result ) { return fromXml ( *result , input ) ; }
00559
00560 _Xml<TProfile2D> _xml ;
00561 std::auto_ptr<TProfile2D> histo = _xml ( input ) ;
00562 if ( 0 == histo.get() ) { return StatusCode::FAILURE ; }
00563
00564 result = histo.release() ;
00565
00566 return StatusCode::SUCCESS ;
00567 }
00568
00569
00570
00571
00572
00573
00574
00575 StatusCode Gaudi::Utils::Histos::fromXml
00576 ( AIDA::IHistogram1D& result , const std::string& input )
00577 {
00578 TH1D* root = Gaudi::Utils::Aida2ROOT::aida2root ( &result ) ;
00579 if ( 0 == root ) { return StatusCode::FAILURE ; }
00580
00581 return fromXml ( *root , input ) ;
00582 }
00583
00584
00585
00586
00587
00588
00589
00590 StatusCode Gaudi::Utils::Histos::fromXml
00591 ( AIDA::IHistogram2D& result , const std::string& input )
00592 {
00593 TH2D* root = Gaudi::Utils::Aida2ROOT::aida2root ( &result ) ;
00594 if ( 0 == root ) { return StatusCode::FAILURE ; }
00595
00596 return fromXml ( *root , input ) ;
00597 }
00598
00599
00600
00601
00602
00603
00604
00605 StatusCode Gaudi::Utils::Histos::fromXml
00606 ( AIDA::IHistogram3D& result , const std::string& input )
00607 {
00608 TH3D* root = Gaudi::Utils::Aida2ROOT::aida2root ( &result ) ;
00609 if ( 0 == root ) { return StatusCode::FAILURE ; }
00610
00611 return fromXml ( *root , input ) ;
00612 }
00613
00614
00615
00616
00617
00618
00619
00620 StatusCode Gaudi::Utils::Histos::fromXml
00621 ( AIDA::IProfile1D& result , const std::string& input )
00622 {
00623 TProfile* root = Gaudi::Utils::Aida2ROOT::aida2root ( &result ) ;
00624 if ( 0 == root ) { return StatusCode::FAILURE ; }
00625
00626 return fromXml ( *root , input ) ;
00627 }
00628
00629
00630
00631
00632
00633
00634
00635 StatusCode Gaudi::Utils::Histos::fromXml
00636 ( AIDA::IProfile2D& result , const std::string& input )
00637 {
00638 TProfile2D* root = Gaudi::Utils::Aida2ROOT::aida2root ( &result ) ;
00639 if ( 0 == root ) { return StatusCode::FAILURE ; }
00640
00641 return fromXml ( *root , input ) ;
00642 }
00643
00644
00645