The Gaudi Framework  v30r3 (a5ef0a68)
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 {
61  template <typename Out, typename In>
62  Out* a2r_cast( In* aida )
63  {
64  using Base =
65  typename std::conditional<std::is_const<Out>::value, const Gaudi::HistogramBase, Gaudi::HistogramBase>::type;
66  auto base = dynamic_cast<Base*>( aida );
67  return base ? dynamic_cast<Out*>( base->representation() ) : nullptr;
68  }
69 }
70 // ============================================================================
71 // get the underlying pointer for 1D-histogram
72 // ============================================================================
73 TH1D* Gaudi::Utils::Aida2ROOT::aida2root( AIDA::IHistogram1D* aida ) { return a2r_cast<TH1D>( aida ); }
74 const TH1D* Gaudi::Utils::Aida2ROOT::aida2root( const AIDA::IHistogram1D* aida )
75 {
76  return a2r_cast<const TH1D>( aida );
77 }
78 // ============================================================================
79 // get the underlying pointer for 2D-histogram
80 // ============================================================================
81 TH2D* Gaudi::Utils::Aida2ROOT::aida2root( AIDA::IHistogram2D* aida ) { return a2r_cast<TH2D>( aida ); }
82 const TH2D* Gaudi::Utils::Aida2ROOT::aida2root( const AIDA::IHistogram2D* aida )
83 {
84  return a2r_cast<const TH2D>( aida );
85 }
86 // ============================================================================
87 // get the underlying pointer for 3D-histogram
88 // ============================================================================
89 TH3D* Gaudi::Utils::Aida2ROOT::aida2root( AIDA::IHistogram3D* aida ) { return a2r_cast<TH3D>( aida ); }
90 const TH3D* Gaudi::Utils::Aida2ROOT::aida2root( const AIDA::IHistogram3D* aida )
91 {
92  return a2r_cast<const TH3D>( aida );
93 }
94 // ============================================================================
95 // get the underlying pointer for 1D-profile
96 // ============================================================================
97 TProfile* Gaudi::Utils::Aida2ROOT::aida2root( AIDA::IProfile1D* aida ) { return a2r_cast<TProfile>( aida ); }
98 const TProfile* Gaudi::Utils::Aida2ROOT::aida2root( const AIDA::IProfile1D* aida )
99 {
100  return a2r_cast<const TProfile>( aida );
101 }
102 // ============================================================================
103 // get the underlying pointer for 2D-profile
104 // ============================================================================
105 TProfile2D* Gaudi::Utils::Aida2ROOT::aida2root( AIDA::IProfile2D* aida ) { return a2r_cast<TProfile2D>( aida ); }
106 const TProfile2D* Gaudi::Utils::Aida2ROOT::aida2root( const AIDA::IProfile2D* aida )
107 {
108  return a2r_cast<const TProfile2D>( aida );
109 }
110 // ============================================================================
111 // get root representation for other cases
112 // ============================================================================
113 TObject* Gaudi::Utils::Aida2ROOT::aida2root( AIDA::IHistogram* aida ) { return a2r_cast<TObject>( aida ); }
114 const TObject* Gaudi::Utils::Aida2ROOT::aida2root( const AIDA::IHistogram* aida )
115 {
116  return a2r_cast<const TObject>( aida );
117 }
118 // ============================================================================
119 // The END
120 // ============================================================================
static TH1D * aida2root(AIDA::IHistogram1D *aida)
get the underlying pointer for 1D-histogram
Definition: Aida2ROOT.cpp:73
Common base class for all histograms Use is solely functional to minimize dynamic_casts inside Histog...
Definition: HistogramBase.h:23