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