The Gaudi Framework  v33r0 (d5ea422b)
Aida2ROOT.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifdef __ICC
12 // disable icc remark #2259: non-pointer conversion from "X" to "Y" may lose significant bits
13 // TODO: To be removed, since it comes from ROOT TMathBase.h
14 # pragma warning( disable : 2259 )
15 #endif
16 #ifdef WIN32
17 // Disable warning
18 // warning C4996: 'sprintf': This function or variable may be unsafe.
19 // coming from TString.h
20 # pragma warning( disable : 4996 )
21 #endif
22 // ============================================================================
23 // Include files
24 // ============================================================================
25 #include <type_traits>
26 // ============================================================================
27 // AIDA
28 // ============================================================================
29 #include "GaudiKernel/Kernel.h"
30 //-- to avoid that the class macro trick affects them
32 #ifdef __clang__
33 # pragma clang diagnostic push
34 # pragma clang diagnostic ignored "-Wkeyword-macro"
35 #endif
36 #define class class GAUDI_API
37 #ifdef __clang__
38 # pragma clang diagnostic pop
39 #endif
40 #include "AIDA/IHistogram1D.h"
41 #include "AIDA/IHistogram2D.h"
42 #include "AIDA/IHistogram3D.h"
43 #include "AIDA/IProfile1D.h"
44 #include "AIDA/IProfile2D.h"
45 #undef class
46 // ============================================================================
47 // ROOT
48 // ============================================================================
49 #include "TH1D.h"
50 #include "TH2D.h"
51 #include "TH3D.h"
52 #include "TProfile.h"
53 #include "TProfile2D.h"
54 // ============================================================================
55 // GaudiKernel
56 // ============================================================================
58 // ============================================================================
59 // GaudiAlg
60 // ============================================================================
61 #include "GaudiUtils/Aida2ROOT.h"
62 // ============================================================================
69 namespace {
70  template <typename Out, typename In>
71  Out* a2r_cast( In* aida ) {
72  using Base = std::conditional_t<std::is_const_v<Out>, const Gaudi::HistogramBase, Gaudi::HistogramBase>;
73  auto base = dynamic_cast<Base*>( aida );
74  return base ? dynamic_cast<Out*>( base->representation() ) : nullptr;
75  }
76 } // namespace
77 // ============================================================================
78 // get the underlying pointer for 1D-histogram
79 // ============================================================================
80 TH1D* Gaudi::Utils::Aida2ROOT::aida2root( AIDA::IHistogram1D* aida ) { return a2r_cast<TH1D>( aida ); }
81 const TH1D* Gaudi::Utils::Aida2ROOT::aida2root( const AIDA::IHistogram1D* aida ) {
82  return a2r_cast<const TH1D>( aida );
83 }
84 // ============================================================================
85 // get the underlying pointer for 2D-histogram
86 // ============================================================================
87 TH2D* Gaudi::Utils::Aida2ROOT::aida2root( AIDA::IHistogram2D* aida ) { return a2r_cast<TH2D>( aida ); }
88 const TH2D* Gaudi::Utils::Aida2ROOT::aida2root( const AIDA::IHistogram2D* aida ) {
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 ) { return a2r_cast<TH3D>( aida ); }
95 const TH3D* Gaudi::Utils::Aida2ROOT::aida2root( const AIDA::IHistogram3D* aida ) {
96  return a2r_cast<const TH3D>( aida );
97 }
98 // ============================================================================
99 // get the underlying pointer for 1D-profile
100 // ============================================================================
101 TProfile* Gaudi::Utils::Aida2ROOT::aida2root( AIDA::IProfile1D* aida ) { return a2r_cast<TProfile>( aida ); }
102 const TProfile* Gaudi::Utils::Aida2ROOT::aida2root( const AIDA::IProfile1D* aida ) {
103  return a2r_cast<const TProfile>( aida );
104 }
105 // ============================================================================
106 // get the underlying pointer for 2D-profile
107 // ============================================================================
108 TProfile2D* Gaudi::Utils::Aida2ROOT::aida2root( AIDA::IProfile2D* aida ) { return a2r_cast<TProfile2D>( aida ); }
109 const TProfile2D* Gaudi::Utils::Aida2ROOT::aida2root( const AIDA::IProfile2D* aida ) {
110  return a2r_cast<const TProfile2D>( aida );
111 }
112 // ============================================================================
113 // get root representation for other cases
114 // ============================================================================
115 TObject* Gaudi::Utils::Aida2ROOT::aida2root( AIDA::IHistogram* aida ) { return a2r_cast<TObject>( aida ); }
116 const TObject* Gaudi::Utils::Aida2ROOT::aida2root( const AIDA::IHistogram* aida ) {
117  return a2r_cast<const TObject>( aida );
118 }
119 // ============================================================================
120 // The END
121 // ============================================================================
static TH1D * aida2root(AIDA::IHistogram1D *aida)
get the underlying pointer for 1D-histogram
Definition: Aida2ROOT.cpp:80
Common base class for all histograms Use is solely functional to minimize dynamic_casts inside Histog...
Definition: HistogramBase.h:32