18 #include "TProfile2D.h"
19 #include "TBufferXML.h"
23 #include "AIDA/IHistogram1D.h"
24 #include "AIDA/IHistogram2D.h"
25 #include "AIDA/IHistogram3D.h"
26 #include "AIDA/IProfile1D.h"
27 #include "AIDA/IProfile2D.h"
31 #include "GaudiUtils/Aida2ROOT.h"
32 #include "GaudiUtils/HistoXML.h"
45 template <
typename TYPE>
46 std::unique_ptr<TYPE> _Xml(
const std::string& input )
49 std::unique_ptr<TObject> obj{ TBufferXML::ConvertFromXML ( input.c_str() ) } ;
50 TYPE* histo = ( obj ?
dynamic_cast<TYPE*
>( obj.get() ) :
nullptr );
55 return std::unique_ptr<TYPE>{ histo ? ( obj.release(), histo ) :
nullptr };
68 std::ostream& stream )
70 return stream << TBufferXML::ConvertToXML( &histo ) ;
80 std::ostream& stream )
82 return stream << TBufferXML::ConvertToXML( &histo ) ;
92 std::ostream& stream )
94 return stream << TBufferXML::ConvertToXML( &histo ) ;
103 (
const TH1F& histo ,
104 std::ostream& stream )
106 return stream << TBufferXML::ConvertToXML( &histo ) ;
115 (
const TH2F& histo ,
116 std::ostream& stream )
118 return stream << TBufferXML::ConvertToXML( &histo ) ;
127 (
const TH3F& histo ,
128 std::ostream& stream )
130 return stream << TBufferXML::ConvertToXML( &histo ) ;
139 (
const TProfile& histo ,
140 std::ostream& stream )
142 return stream << TBufferXML::ConvertToXML( &histo ) ;
151 (
const TProfile2D& histo ,
152 std::ostream& stream )
154 return stream << TBufferXML::ConvertToXML ( &histo ) ;
163 (
const AIDA::IHistogram1D& histo ,
164 std::ostream& stream )
176 (
const AIDA::IHistogram2D& histo ,
177 std::ostream& stream )
189 (
const AIDA::IHistogram3D& histo ,
190 std::ostream& stream )
202 (
const AIDA::IProfile1D& histo ,
203 std::ostream& stream )
215 (
const AIDA::IProfile2D& histo ,
216 std::ostream& stream )
229 ( TH1D& result ,
const std::string& input )
235 auto histo = _Xml<TH1D>( input ) ;
238 histo->Copy ( result ) ;
250 ( TH2D& result ,
const std::string& input )
255 auto histo = _Xml<TH2D>( input ) ;
258 histo->Copy ( result ) ;
270 ( TH3D& result ,
const std::string& input )
275 auto histo = _Xml<TH3D>( input ) ;
278 histo->Copy ( result ) ;
290 ( TH1F& result ,
const std::string& input )
295 auto histo = _Xml<TH1F>( input ) ;
298 histo->Copy ( result ) ;
310 ( TH2F& result ,
const std::string& input )
315 auto histo = _Xml<TH2F>( input ) ;
318 histo->Copy ( result ) ;
330 ( TH3F& result ,
const std::string& input )
335 auto histo =_Xml<TH3F>( input ) ;
338 histo->Copy ( result ) ;
350 ( TProfile& result ,
const std::string& input )
355 auto histo = _Xml<TProfile>( input ) ;
358 histo->Copy ( result ) ;
370 ( TProfile2D& result ,
const std::string& input )
375 auto histo = _Xml<TProfile2D>( input ) ;
378 histo->Copy ( result ) ;
392 ( TH1D*& result ,
const std::string& input )
394 if ( result ) {
return fromXml ( *result , input ) ; }
396 auto histo = _Xml<TH1D>( input ) ;
399 result = histo.release() ;
411 ( TH2D*& result ,
const std::string& input )
413 if ( result ) {
return fromXml ( *result , input ) ; }
415 auto histo = _Xml<TH2D>( input ) ;
418 result = histo.release() ;
430 ( TH3D*& result ,
const std::string& input )
432 if ( result ) {
return fromXml ( *result , input ) ; }
434 auto histo = _Xml<TH3D>( input ) ;
437 result = histo.release() ;
450 ( TProfile*& result ,
const std::string& input )
452 if ( result ) {
return fromXml ( *result , input ) ; }
454 auto histo = _Xml<TProfile>( input ) ;
457 result = histo.release() ;
469 ( TProfile2D*& result ,
const std::string& input )
471 if ( result ) {
return fromXml ( *result , input ) ; }
473 auto histo = _Xml<TProfile2D>( input ) ;
476 result = histo.release() ;
488 ( AIDA::IHistogram1D& result ,
const std::string& input )
501 ( AIDA::IHistogram2D& result ,
const std::string& input )
514 ( AIDA::IHistogram3D& result ,
const std::string& input )
527 ( AIDA::IProfile1D& result ,
const std::string& input )
540 ( AIDA::IProfile2D& result ,
const std::string& input )
This class is used for returning status codes from appropriate routines.
static TH1D * aida2root(AIDA::IHistogram1D *aida)
get the underlying pointer for 1D-histogram
GAUDI_API std::ostream & toXml(const TH1D &histo, std::ostream &stream)
stream the ROOT histogram into output stream as XML
GAUDI_API StatusCode fromXml(TH1D &result, const std::string &input)
parse the histogram from standard ROOT XML