The Gaudi Framework  v36r9p1 (5c15b2bb)
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" ? const_cast<AIDA::IProfile*>( static_cast<const AIDA::IProfile*>( this ) )
36  : className == "AIDA::IBaseHistogram"
37  ? const_cast<AIDA::IBaseHistogram*>( static_cast<const AIDA::IBaseHistogram*>( this ) )
38  : nullptr;
39  }
40 
41  template <>
43  int rBin = m_rep->GetBin( rIndexX( idX ), rIndexY( idY ) );
44  return int( m_rep->GetBinEntries( rBin ) + 0.5 );
45  }
46 
47  template <>
49  TProfile2D* imp = dynamic_cast<TProfile2D*>( rep );
50  if ( !imp ) throw std::runtime_error( "Cannot adopt native histogram representation." );
51  m_rep.reset( imp );
52  m_xAxis.initialize( m_rep->GetXaxis(), true );
53  m_yAxis.initialize( m_rep->GetYaxis(), true );
54  setTitle( m_rep->GetTitle() );
55  }
56 } // namespace Gaudi
57 
59  const Edges& eY, double /* zlow */, double /* zup */ ) {
60  // Not implemented in ROOT! Can only use TProfile2D with no z-limits
61  auto p = new Profile2D( new TProfile2D( title.c_str(), title.c_str(), eX.size() - 1, &eX.front(), eY.size() - 1,
62  &eY.front() /*,zlow,zup */ ) );
63  return { p, p };
64 }
65 
67  double xup, int binsY, double ylow, double yup,
68  double zlow, double zup ) {
69  auto p =
70  new Profile2D( new TProfile2D( title.c_str(), title.c_str(), binsX, xlow, xup, binsY, ylow, yup, zlow, zup ) );
71  return { p, p };
72 }
73 
74 std::pair<DataObject*, AIDA::IProfile2D*> Gaudi::createProf2D( const AIDA::IProfile2D& hist ) {
75  auto h = getRepresentation<AIDA::IProfile2D, TProfile2D>( hist );
76  auto n = ( h ? new Profile2D( new TProfile2D( *h ) ) : nullptr );
77  return { n, n };
78 }
79 
80 Gaudi::Profile2D::Profile2D( TProfile2D* rep ) {
81  m_classType = "IProfile2D";
82  rep->SetDirectory( nullptr );
83  adoptRepresentation( rep );
84  m_sumEntries = 0;
85 }
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:32
Gaudi::Generic2D< AIDA::IProfile2D, TProfile2D >::m_classType
std::string m_classType
class type
Definition: Generic2D.h:164
GaudiPython.Bindings.nullptr
nullptr
Definition: Bindings.py:93
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:235
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.