All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Aida2ROOT.cpp
Go to the documentation of this file.
1 // $Id: Aida2ROOT.cpp,v 1.3 2007/08/06 14:49:36 hmd Exp $
2 #ifdef __ICC
3 // disable icc remark #2259: non-pointer conversion from "X" to "Y" may lose significant bits
4 // TODO: To be removed, since it comes from ROOT TMathBase.h
5 #pragma warning(disable:2259)
6 #endif
7 #ifdef WIN32
8 // Disable warning
9 // warning C4996: 'sprintf': This function or variable may be unsafe.
10 // coming from TString.h
11 #pragma warning(disable:4996)
12 #endif
13 // ============================================================================
14 // Include files
15 // ============================================================================
16 // AIDA
17 // ============================================================================
18 #include "GaudiKernel/Kernel.h"
19 //-- to avoid that the class macro trick affects them
20 #include <string>
21 #include <vector>
23 #define class class GAUDI_API
24 #include "AIDA/IHistogram1D.h"
25 #include "AIDA/IHistogram2D.h"
26 #include "AIDA/IHistogram3D.h"
27 #include "AIDA/IProfile1D.h"
28 #include "AIDA/IProfile2D.h"
29 #undef class
30 // ============================================================================
31 // ROOT
32 // ============================================================================
33 #include "TH1D.h"
34 #include "TH2D.h"
35 #include "TH3D.h"
36 #include "TProfile.h"
37 #include "TProfile2D.h"
38 // ============================================================================
39 // GaudiKernel
40 // ============================================================================
42 // ============================================================================
43 // GaudiAlg
44 // ============================================================================
45 #include "GaudiUtils/Aida2ROOT.h"
46 // ============================================================================
52 // ============================================================================
53 // get the underlying pointer for 1D-histogram
54 // ============================================================================
55 TH1D* Gaudi::Utils::Aida2ROOT::aida2root ( AIDA::IHistogram1D* aida )
56 {
57  if ( 0 == aida ) { return 0 ; }
58  Gaudi::HistogramBase* base = dynamic_cast<Gaudi::HistogramBase*> ( aida ) ;
59  if ( 0 == base ) { return 0 ; }
60  return dynamic_cast<TH1D*>( base->representation() ) ;
61 }
62 // ============================================================================
63 // get the underlying pointer for 2D-histogram
64 // ============================================================================
65 TH2D* Gaudi::Utils::Aida2ROOT::aida2root ( AIDA::IHistogram2D* aida )
66 {
67  if ( 0 == aida ) { return 0 ; }
68  Gaudi::HistogramBase* base = dynamic_cast<Gaudi::HistogramBase*> ( aida ) ;
69  if ( 0 == base ) { return 0 ; }
70  return dynamic_cast<TH2D*>( base->representation() ) ;
71 }
72 // ============================================================================
73 // get the underlying pointer for 3D-histogram
74 // ============================================================================
75 TH3D* Gaudi::Utils::Aida2ROOT::aida2root ( AIDA::IHistogram3D* aida )
76 {
77  if ( 0 == aida ) { return 0 ; }
78  Gaudi::HistogramBase* base = dynamic_cast<Gaudi::HistogramBase*> ( aida ) ;
79  if ( 0 == base ) { return 0 ; }
80  return dynamic_cast<TH3D*>( base->representation() ) ;
81 }
82 // ============================================================================
83 // get the underlying pointer for 1D-profile
84 // ============================================================================
85 TProfile* Gaudi::Utils::Aida2ROOT::aida2root ( AIDA::IProfile1D* aida )
86 {
87  if ( 0 == aida ) { return 0 ; }
88  Gaudi::HistogramBase* base = dynamic_cast<Gaudi::HistogramBase*> ( aida ) ;
89  if ( 0 == base ) { return 0 ; }
90  return dynamic_cast<TProfile*>( base->representation() ) ;
91 }
92 // ============================================================================
93 // get the underlying pointer for 2D-profile
94 // ============================================================================
95 TProfile2D* Gaudi::Utils::Aida2ROOT::aida2root ( AIDA::IProfile2D* aida )
96 {
97  if ( 0 == aida ) { return 0 ; }
98  Gaudi::HistogramBase* base = dynamic_cast<Gaudi::HistogramBase*> ( aida ) ;
99  if ( 0 == base ) { return 0 ; }
100  return dynamic_cast<TProfile2D*>( base->representation() ) ;
101 }
102 // ============================================================================
103 // get root representation for other cases
104 // ============================================================================
105 TObject* Gaudi::Utils::Aida2ROOT::aida2root ( AIDA::IHistogram* aida )
106 {
107  if ( 0 == aida ) { return 0 ; }
108  Gaudi::HistogramBase* base = dynamic_cast<Gaudi::HistogramBase*> ( aida ) ;
109  if ( 0 == base ) { return 0 ; }
110  return base->representation() ;
111 }
112 // ============================================================================
113 // The END
114 // ============================================================================
static TH1D * aida2root(AIDA::IHistogram1D *aida)
get the underlying pointer for 1D-histogram
Definition: Aida2ROOT.cpp:55
Common base class for all histograms Use is solely functional to minimize dynamic_casts inside Histog...
Definition: HistogramBase.h:22
virtual TObject * representation() const =0
ROOT object implementation.