The Gaudi Framework  master (82fdf313)
Loading...
Searching...
No Matches
Aida2ROOT.cpp
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2025 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// ============================================================================
17// Include files
18// ============================================================================
19#include <type_traits>
20// ============================================================================
21// AIDA
22// ============================================================================
23#include <AIDA/IHistogram1D.h>
24#include <AIDA/IHistogram2D.h>
25#include <AIDA/IHistogram3D.h>
26#include <AIDA/IProfile1D.h>
27#include <AIDA/IProfile2D.h>
28// ============================================================================
29// ROOT
30// ============================================================================
31#include <TH1D.h>
32#include <TH2D.h>
33#include <TH3D.h>
34#include <TProfile.h>
35#include <TProfile2D.h>
36// ============================================================================
37// GaudiKernel
38// ============================================================================
40// ============================================================================
42// ============================================================================
48
49namespace {
50 template <typename Out, typename In>
51 Out* a2r_cast( In* aida ) {
52 using Base = std::conditional_t<std::is_const_v<Out>, const Gaudi::HistogramBase, Gaudi::HistogramBase>;
53 auto base = dynamic_cast<Base*>( aida );
54 return base ? dynamic_cast<Out*>( base->representation() ) : nullptr;
55 }
56} // namespace
57// ============================================================================
58// get the underlying pointer for 1D-histogram
59// ============================================================================
60TH1D* Gaudi::Utils::Aida2ROOT::aida2root( AIDA::IHistogram1D* aida ) { return a2r_cast<TH1D>( aida ); }
61const TH1D* Gaudi::Utils::Aida2ROOT::aida2root( const AIDA::IHistogram1D* aida ) {
62 return a2r_cast<const TH1D>( aida );
63}
64// ============================================================================
65// get the underlying pointer for 2D-histogram
66// ============================================================================
67TH2D* Gaudi::Utils::Aida2ROOT::aida2root( AIDA::IHistogram2D* aida ) { return a2r_cast<TH2D>( aida ); }
68const TH2D* Gaudi::Utils::Aida2ROOT::aida2root( const AIDA::IHistogram2D* aida ) {
69 return a2r_cast<const TH2D>( aida );
70}
71// ============================================================================
72// get the underlying pointer for 3D-histogram
73// ============================================================================
74TH3D* Gaudi::Utils::Aida2ROOT::aida2root( AIDA::IHistogram3D* aida ) { return a2r_cast<TH3D>( aida ); }
75const TH3D* Gaudi::Utils::Aida2ROOT::aida2root( const AIDA::IHistogram3D* aida ) {
76 return a2r_cast<const TH3D>( aida );
77}
78// ============================================================================
79// get the underlying pointer for 1D-profile
80// ============================================================================
81TProfile* Gaudi::Utils::Aida2ROOT::aida2root( AIDA::IProfile1D* aida ) { return a2r_cast<TProfile>( aida ); }
82const TProfile* Gaudi::Utils::Aida2ROOT::aida2root( const AIDA::IProfile1D* aida ) {
83 return a2r_cast<const TProfile>( aida );
84}
85// ============================================================================
86// get the underlying pointer for 2D-profile
87// ============================================================================
88TProfile2D* Gaudi::Utils::Aida2ROOT::aida2root( AIDA::IProfile2D* aida ) { return a2r_cast<TProfile2D>( aida ); }
89const TProfile2D* Gaudi::Utils::Aida2ROOT::aida2root( const AIDA::IProfile2D* aida ) {
90 return a2r_cast<const TProfile2D>( aida );
91}
92// ============================================================================
93// get root representation for other cases
94// ============================================================================
95TObject* Gaudi::Utils::Aida2ROOT::aida2root( AIDA::IHistogram* aida ) { return a2r_cast<TObject>( aida ); }
96const TObject* Gaudi::Utils::Aida2ROOT::aida2root( const AIDA::IHistogram* aida ) {
97 return a2r_cast<const TObject>( aida );
98}
99// ============================================================================
100// The END
101// ============================================================================
Common base class for all histograms Use is solely functional to minimize dynamic_casts inside Histog...
static TH1D * aida2root(AIDA::IHistogram1D *aida)
get the underlying pointer for 1D-histogram
Definition Aida2ROOT.cpp:60