All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 = typename std::conditional<std::is_const<Out>::value,
64  Gaudi::HistogramBase>::type;
65  auto base = dynamic_cast<Base*>( aida );
66  return base ? dynamic_cast<Out*>( base->representation() ) : nullptr;
67  }
68 }
69 // ============================================================================
70 // get the underlying pointer for 1D-histogram
71 // ============================================================================
72 TH1D* Gaudi::Utils::Aida2ROOT::aida2root ( AIDA::IHistogram1D* aida )
73 {
74  return a2r_cast<TH1D>( aida );
75 }
76 const TH1D* Gaudi::Utils::Aida2ROOT::aida2root ( const AIDA::IHistogram1D* aida )
77 {
78  return a2r_cast<const TH1D>( aida );
79 }
80 // ============================================================================
81 // get the underlying pointer for 2D-histogram
82 // ============================================================================
83 TH2D* Gaudi::Utils::Aida2ROOT::aida2root ( AIDA::IHistogram2D* aida )
84 {
85  return a2r_cast<TH2D>( aida );
86 }
87 const TH2D* Gaudi::Utils::Aida2ROOT::aida2root ( const AIDA::IHistogram2D* aida )
88 {
89  return a2r_cast<const TH2D>( aida );
90 }
91 // ============================================================================
92 // get the underlying pointer for 3D-histogram
93 // ============================================================================
94 TH3D* Gaudi::Utils::Aida2ROOT::aida2root ( AIDA::IHistogram3D* aida )
95 {
96  return a2r_cast<TH3D>( aida );
97 }
98 const TH3D* Gaudi::Utils::Aida2ROOT::aida2root (const AIDA::IHistogram3D* aida )
99 {
100  return a2r_cast<const TH3D>( aida );
101 }
102 // ============================================================================
103 // get the underlying pointer for 1D-profile
104 // ============================================================================
105 TProfile* Gaudi::Utils::Aida2ROOT::aida2root ( AIDA::IProfile1D* aida )
106 {
107  return a2r_cast<TProfile>( aida );
108 }
109 const TProfile* Gaudi::Utils::Aida2ROOT::aida2root ( const AIDA::IProfile1D* aida )
110 {
111  return a2r_cast<const TProfile>( aida );
112 }
113 // ============================================================================
114 // get the underlying pointer for 2D-profile
115 // ============================================================================
116 TProfile2D* Gaudi::Utils::Aida2ROOT::aida2root ( AIDA::IProfile2D* aida )
117 {
118  return a2r_cast<TProfile2D>( aida );
119 }
120 const TProfile2D* Gaudi::Utils::Aida2ROOT::aida2root ( const AIDA::IProfile2D* aida )
121 {
122  return a2r_cast<const TProfile2D>( aida );
123 }
124 // ============================================================================
125 // get root representation for other cases
126 // ============================================================================
127 TObject* Gaudi::Utils::Aida2ROOT::aida2root ( AIDA::IHistogram* aida )
128 {
129  return a2r_cast<TObject>(aida);
130 }
131 const TObject* Gaudi::Utils::Aida2ROOT::aida2root ( const AIDA::IHistogram* aida )
132 {
133  return a2r_cast<const TObject>(aida);
134 }
135 // ============================================================================
136 // The END
137 // ============================================================================
static TH1D * aida2root(AIDA::IHistogram1D *aida)
get the underlying pointer for 1D-histogram
Definition: Aida2ROOT.cpp:72
Common base class for all histograms Use is solely functional to minimize dynamic_casts inside Histog...
Definition: HistogramBase.h:22