| The Gaudi Framework v30r0 (c919700c)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

P2D.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 #include "GaudiPI.h"
13 #include <GaudiCommonSvc/HistogramUtility.h>
14 #include <GaudiCommonSvc/P2D.h>
15 #include <GaudiKernel/DataObject.h>
16 #include <GaudiKernel/ObjectFactory.h>
17 #include <TH2D.h>
18 #include <TProfile2D.h>
19
20 namespace Gaudi
21 {
22 template <>
23 void* Generic2D<AIDA::IProfile2D, TProfile2D>::cast( const std::string& className ) const
24 {
25 if ( className == "AIDA::IProfile2D" )
26 return const_cast<AIDA::IProfile2D*>( (AIDA::IProfile2D*)this );
27 else if ( className == "AIDA::IProfile" )
28 return const_cast<AIDA::IProfile*>( (AIDA::IProfile*)this );
29 else if ( className == "AIDA::IBaseHistogram" )
30 return const_cast<AIDA::IBaseHistogram*>( (AIDA::IBaseHistogram*)this );
31 return nullptr;
32 }
33
34 template <>
35 int Generic2D<AIDA::IProfile2D, TProfile2D>::binEntries( int idX, int idY ) const
36 {
37 int rBin = m_rep->GetBin( rIndexX( idX ), rIndexY( idY ) );
38 return int( m_rep->GetBinEntries( rBin ) + 0.5 );
39 }
40
41 template <>
42 void Generic2D<AIDA::IProfile2D, TProfile2D>::adoptRepresentation( TObject* rep )
43 {
44 TProfile2D* imp = dynamic_cast<TProfile2D*>( rep );
45 if ( !imp ) throw std::runtime_error( "Cannot adopt native histogram representation." );
46 m_rep.reset( imp );
47 m_xAxis.initialize( m_rep->GetXaxis(), true );
48 m_yAxis.initialize( m_rep->GetYaxis(), true );
49 setTitle( m_rep->GetTitle() );
50 }
51 }
52
53 std::pair<DataObject*, AIDA::IProfile2D*> Gaudi::createProf2D( const std::string& title, const Edges& eX,
54 const Edges& eY, double /* zlow */, double /* zup */ )
55 {
56 // Not implemented in ROOT! Can only use TProfile2D with no z-limits
57 auto p = new Profile2D( new TProfile2D( title.c_str(), title.c_str(), eX.size() - 1, &eX.front(), eY.size() - 1,
58 &eY.front() /*,zlow,zup */ ) );
59 return {p, p};
60 }
61
62 std::pair<DataObject*, AIDA::IProfile2D*> Gaudi::createProf2D( const std::string& title, int binsX, double xlow,
63 double xup, int binsY, double ylow, double yup,
64 double zlow, double zup )
65 {
66 auto p =
67 new Profile2D( new TProfile2D( title.c_str(), title.c_str(), binsX, xlow, xup, binsY, ylow, yup, zlow, zup ) );
68 return {p, p};
69 }
70
71 std::pair<DataObject*, AIDA::IProfile2D*> Gaudi::createProf2D( const AIDA::IProfile2D& hist )
72 {
73 auto h = getRepresentation<AIDA::IProfile2D, TProfile2D>( hist );
74 auto n = ( h ? new Profile2D( new TProfile2D( *h ) ) : nullptr );
75 return {n, n};
76 }
77
78 Gaudi::Profile2D::Profile2D( TProfile2D* rep )
79 {
80 m_classType = "IProfile2D";
81 rep->SetDirectory( nullptr );
82 adoptRepresentation( rep );
83 m_sumEntries = 0;
84 }
Gaudi::Profile2D
AIDA implementation for 2 D profiles using ROOT TProfile2D.
Definition: P2D.h:18
ObjectFactory.h
Gaudi::Edges
std::vector< double > Edges
Definition: GaudiPI.h:18
GaudiPI.h
std::string
STL class.
Gaudi::Generic2D::adoptRepresentation
void adoptRepresentation(TObject *rep) override
Adopt ROOT histogram representation.
GaudiPluginService.cpluginsvc.n
n
Definition: cpluginsvc.py:228
P2D.h
std::runtime_error
STL class.
Gaudi::Generic2D::binEntries
int binEntries(int indexX, int indexY) const override
The number of entries (ie the number of times fill was called for this bin).
std::pair
Gaudi::createProf2D
std::pair< DataObject *, AIDA::IProfile2D * > createProf2D(const AIDA::IProfile2D &hist)
Copy constructor.
std::string::c_str
T c_str(T...args)
Gaudi::Generic2D::cast
void * cast(const std::string &className) const override
Introspection method.
HistogramUtility.h
Gaudi::Profile2D::Profile2D
Profile2D()
Default Constructor.
Definition: P2D.h:22
Gaudi
Helper functions to set/get the application return code.
Definition: __init__.py:1
DataObject.h