Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v38r1p1 (ae26267b)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 "AIDA/IHistogram1D.h"
30 #include "AIDA/IHistogram2D.h"
31 #include "AIDA/IHistogram3D.h"
32 #include "AIDA/IProfile1D.h"
33 #include "AIDA/IProfile2D.h"
34 // ============================================================================
35 // ROOT
36 // ============================================================================
37 #include "TH1D.h"
38 #include "TH2D.h"
39 #include "TH3D.h"
40 #include "TProfile.h"
41 #include "TProfile2D.h"
42 // ============================================================================
43 // GaudiKernel
44 // ============================================================================
46 // ============================================================================
47 // GaudiAlg
48 // ============================================================================
49 #include "GaudiUtils/Aida2ROOT.h"
50 // ============================================================================
57 namespace {
58  template <typename Out, typename In>
59  Out* a2r_cast( In* aida ) {
60  using Base = std::conditional_t<std::is_const_v<Out>, const Gaudi::HistogramBase, Gaudi::HistogramBase>;
61  auto base = dynamic_cast<Base*>( aida );
62  return base ? dynamic_cast<Out*>( base->representation() ) : nullptr;
63  }
64 } // namespace
65 // ============================================================================
66 // get the underlying pointer for 1D-histogram
67 // ============================================================================
68 TH1D* Gaudi::Utils::Aida2ROOT::aida2root( AIDA::IHistogram1D* aida ) { return a2r_cast<TH1D>( aida ); }
69 const TH1D* Gaudi::Utils::Aida2ROOT::aida2root( const AIDA::IHistogram1D* aida ) {
70  return a2r_cast<const TH1D>( aida );
71 }
72 // ============================================================================
73 // get the underlying pointer for 2D-histogram
74 // ============================================================================
75 TH2D* Gaudi::Utils::Aida2ROOT::aida2root( AIDA::IHistogram2D* aida ) { return a2r_cast<TH2D>( aida ); }
76 const TH2D* Gaudi::Utils::Aida2ROOT::aida2root( const AIDA::IHistogram2D* aida ) {
77  return a2r_cast<const TH2D>( aida );
78 }
79 // ============================================================================
80 // get the underlying pointer for 3D-histogram
81 // ============================================================================
82 TH3D* Gaudi::Utils::Aida2ROOT::aida2root( AIDA::IHistogram3D* aida ) { return a2r_cast<TH3D>( aida ); }
83 const TH3D* Gaudi::Utils::Aida2ROOT::aida2root( const AIDA::IHistogram3D* aida ) {
84  return a2r_cast<const TH3D>( aida );
85 }
86 // ============================================================================
87 // get the underlying pointer for 1D-profile
88 // ============================================================================
89 TProfile* Gaudi::Utils::Aida2ROOT::aida2root( AIDA::IProfile1D* aida ) { return a2r_cast<TProfile>( aida ); }
90 const TProfile* Gaudi::Utils::Aida2ROOT::aida2root( const AIDA::IProfile1D* aida ) {
91  return a2r_cast<const TProfile>( aida );
92 }
93 // ============================================================================
94 // get the underlying pointer for 2D-profile
95 // ============================================================================
96 TProfile2D* Gaudi::Utils::Aida2ROOT::aida2root( AIDA::IProfile2D* aida ) { return a2r_cast<TProfile2D>( aida ); }
97 const TProfile2D* Gaudi::Utils::Aida2ROOT::aida2root( const AIDA::IProfile2D* aida ) {
98  return a2r_cast<const TProfile2D>( aida );
99 }
100 // ============================================================================
101 // get root representation for other cases
102 // ============================================================================
103 TObject* Gaudi::Utils::Aida2ROOT::aida2root( AIDA::IHistogram* aida ) { return a2r_cast<TObject>( aida ); }
104 const TObject* Gaudi::Utils::Aida2ROOT::aida2root( const AIDA::IHistogram* aida ) {
105  return a2r_cast<const TObject>( aida );
106 }
107 // ============================================================================
108 // The END
109 // ============================================================================
Aida2ROOT.h
Gaudi::Utils::Aida2ROOT::aida2root
static TH1D * aida2root(AIDA::IHistogram1D *aida)
get the underlying pointer for 1D-histogram
Definition: Aida2ROOT.cpp:68
Gaudi::HistogramBase
Definition: HistogramBase.h:32
HistogramBase.h
check_ParticleID.base
base
Definition: check_ParticleID.py:24