The Gaudi Framework  v36r1 (3e2fb5a8)
P2D.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 #include "GaudiPI.h"
24 #include <GaudiCommonSvc/P2D.h>
25 #include <GaudiKernel/DataObject.h>
27 #include <TH2D.h>
28 #include <TProfile2D.h>
29 
30 namespace Gaudi {
31  template <>
33  return className == "AIDA::IProfile2D"
34  ? const_cast<AIDA::IProfile2D*>( static_cast<const AIDA::IProfile2D*>( this ) )
35  : className == "AIDA::IProfile"
36  ? const_cast<AIDA::IProfile*>( static_cast<const AIDA::IProfile*>( this ) )
37  : className == "AIDA::IBaseHistogram"
38  ? const_cast<AIDA::IBaseHistogram*>( static_cast<const AIDA::IBaseHistogram*>( this ) )
39  : nullptr;
40  }
41 
42  template <>
44  int rBin = m_rep->GetBin( rIndexX( idX ), rIndexY( idY ) );
45  return int( m_rep->GetBinEntries( rBin ) + 0.5 );
46  }
47 
48  template <>
50  TProfile2D* imp = dynamic_cast<TProfile2D*>( rep );
51  if ( !imp ) throw std::runtime_error( "Cannot adopt native histogram representation." );
52  m_rep.reset( imp );
53  m_xAxis.initialize( m_rep->GetXaxis(), true );
54  m_yAxis.initialize( m_rep->GetYaxis(), true );
55  setTitle( m_rep->GetTitle() );
56  }
57 } // namespace Gaudi
58 
60  const Edges& eY, double /* zlow */, double /* zup */ ) {
61  // Not implemented in ROOT! Can only use TProfile2D with no z-limits
62  auto p = new Profile2D( new TProfile2D( title.c_str(), title.c_str(), eX.size() - 1, &eX.front(), eY.size() - 1,
63  &eY.front() /*,zlow,zup */ ) );
64  return {p, p};
65 }
66 
68  double xup, int binsY, double ylow, double yup,
69  double zlow, double zup ) {
70  auto p =
71  new Profile2D( new TProfile2D( title.c_str(), title.c_str(), binsX, xlow, xup, binsY, ylow, yup, zlow, zup ) );
72  return {p, p};
73 }
74 
75 std::pair<DataObject*, AIDA::IProfile2D*> Gaudi::createProf2D( const AIDA::IProfile2D& hist ) {
76  auto h = getRepresentation<AIDA::IProfile2D, TProfile2D>( hist );
77  auto n = ( h ? new Profile2D( new TProfile2D( *h ) ) : nullptr );
78  return {n, n};
79 }
80 
81 Gaudi::Profile2D::Profile2D( TProfile2D* rep ) {
82  m_classType = "IProfile2D";
83  rep->SetDirectory( nullptr );
84  adoptRepresentation( rep );
85  m_sumEntries = 0;
86 }
std::string
STL class.
std::pair
P2D.h
ObjectFactory.h
Gaudi::Generic2D::cast
void * cast(const std::string &className) const override
Introspection method.
HistogramUtility.h
Gaudi::Profile2D::Profile2D
Profile2D()
Default Constructor.
Definition: P2D.h:30
Gaudi::Generic2D< AIDA::IProfile2D, TProfile2D >::adoptRepresentation
void adoptRepresentation(TObject *rep) override
Adopt ROOT histogram representation.
std::string::c_str
T c_str(T... args)
AlgSequencer.h
h
Definition: AlgSequencer.py:26
Gaudi::Generic2D< AIDA::IProfile2D, TProfile2D >::m_classType
std::string m_classType
class type
Definition: Generic2D.h:164
GaudiPython.Bindings.nullptr
nullptr
Definition: Bindings.py:74
std::runtime_error
STL class.
Gaudi
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1
GaudiPluginService.cpluginsvc.n
n
Definition: cpluginsvc.py:221
DataObject.h
GaudiPI.h
Gaudi::Generic2D< AIDA::IProfile2D, TProfile2D >::m_sumEntries
int m_sumEntries
cache sumEntries (allEntries) when setting contents since Root can't compute by himself
Definition: Generic2D.h:166
Gaudi::Generic2D
Definition: Generic2D.h:46
Gaudi::createProf2D
std::pair< DataObject *, AIDA::IProfile2D * > createProf2D(const AIDA::IProfile2D &hist)
Copy constructor.