The Gaudi Framework  v32r2 (46d42edc)
Aida2ROOT.cpp
Go to the documentation of this file.
1 #ifdef __ICC
2 // disable icc remark #2259: non-pointer conversion from "X" to "Y" may lose significant bits
3 // TODO: To be removed, since it comes from ROOT TMathBase.h
4 # pragma warning( disable : 2259 )
5 #endif
6 #ifdef WIN32
7 // Disable warning
8 // warning C4996: 'sprintf': This function or variable may be unsafe.
9 // coming from TString.h
10 # pragma warning( disable : 4996 )
11 #endif
12 // ============================================================================
13 // Include files
14 // ============================================================================
15 #include <type_traits>
16 // ============================================================================
17 // AIDA
18 // ============================================================================
19 #include "GaudiKernel/Kernel.h"
20 //-- to avoid that the class macro trick affects them
22 #ifdef __clang__
23 # pragma clang diagnostic push
24 # pragma clang diagnostic ignored "-Wkeyword-macro"
25 #endif
26 #define class class GAUDI_API
27 #ifdef __clang__
28 # pragma clang diagnostic pop
29 #endif
30 #include "AIDA/IHistogram1D.h"
31 #include "AIDA/IHistogram2D.h"
32 #include "AIDA/IHistogram3D.h"
33 #include "AIDA/IProfile1D.h"
34 #include "AIDA/IProfile2D.h"
35 #undef class
36 // ============================================================================
37 // ROOT
38 // ============================================================================
39 #include "TH1D.h"
40 #include "TH2D.h"
41 #include "TH3D.h"
42 #include "TProfile.h"
43 #include "TProfile2D.h"
44 // ============================================================================
45 // GaudiKernel
46 // ============================================================================
48 // ============================================================================
49 // GaudiAlg
50 // ============================================================================
51 #include "GaudiUtils/Aida2ROOT.h"
52 // ============================================================================
59 namespace {
60  template <typename Out, typename In>
61  Out* a2r_cast( In* aida ) {
62  using Base = std::conditional_t<std::is_const_v<Out>, const Gaudi::HistogramBase, Gaudi::HistogramBase>;
63  auto base = dynamic_cast<Base*>( aida );
64  return base ? dynamic_cast<Out*>( base->representation() ) : nullptr;
65  }
66 } // namespace
67 // ============================================================================
68 // get the underlying pointer for 1D-histogram
69 // ============================================================================
70 TH1D* Gaudi::Utils::Aida2ROOT::aida2root( AIDA::IHistogram1D* aida ) { return a2r_cast<TH1D>( aida ); }
71 const TH1D* Gaudi::Utils::Aida2ROOT::aida2root( const AIDA::IHistogram1D* aida ) {
72  return a2r_cast<const TH1D>( aida );
73 }
74 // ============================================================================
75 // get the underlying pointer for 2D-histogram
76 // ============================================================================
77 TH2D* Gaudi::Utils::Aida2ROOT::aida2root( AIDA::IHistogram2D* aida ) { return a2r_cast<TH2D>( aida ); }
78 const TH2D* Gaudi::Utils::Aida2ROOT::aida2root( const AIDA::IHistogram2D* aida ) {
79  return a2r_cast<const TH2D>( aida );
80 }
81 // ============================================================================
82 // get the underlying pointer for 3D-histogram
83 // ============================================================================
84 TH3D* Gaudi::Utils::Aida2ROOT::aida2root( AIDA::IHistogram3D* aida ) { return a2r_cast<TH3D>( aida ); }
85 const TH3D* Gaudi::Utils::Aida2ROOT::aida2root( const AIDA::IHistogram3D* aida ) {
86  return a2r_cast<const TH3D>( aida );
87 }
88 // ============================================================================
89 // get the underlying pointer for 1D-profile
90 // ============================================================================
91 TProfile* Gaudi::Utils::Aida2ROOT::aida2root( AIDA::IProfile1D* aida ) { return a2r_cast<TProfile>( aida ); }
92 const TProfile* Gaudi::Utils::Aida2ROOT::aida2root( const AIDA::IProfile1D* aida ) {
93  return a2r_cast<const TProfile>( aida );
94 }
95 // ============================================================================
96 // get the underlying pointer for 2D-profile
97 // ============================================================================
98 TProfile2D* Gaudi::Utils::Aida2ROOT::aida2root( AIDA::IProfile2D* aida ) { return a2r_cast<TProfile2D>( aida ); }
99 const TProfile2D* Gaudi::Utils::Aida2ROOT::aida2root( const AIDA::IProfile2D* aida ) {
100  return a2r_cast<const TProfile2D>( aida );
101 }
102 // ============================================================================
103 // get root representation for other cases
104 // ============================================================================
105 TObject* Gaudi::Utils::Aida2ROOT::aida2root( AIDA::IHistogram* aida ) { return a2r_cast<TObject>( aida ); }
106 const TObject* Gaudi::Utils::Aida2ROOT::aida2root( const AIDA::IHistogram* aida ) {
107  return a2r_cast<const TObject>( aida );
108 }
109 // ============================================================================
110 // The END
111 // ============================================================================
static TH1D * aida2root(AIDA::IHistogram1D *aida)
get the underlying pointer for 1D-histogram
Definition: Aida2ROOT.cpp:70
Common base class for all histograms Use is solely functional to minimize dynamic_casts inside Histog...
Definition: HistogramBase.h:22