The Gaudi Framework  v36r10 (fc05264c)
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"
23 #include <Gaudi/MonitoringHub.h>
25 #include <GaudiCommonSvc/P2D.h>
26 #include <GaudiKernel/DataObject.h>
28 
30 
31 #include <TH2D.h>
32 #include <TProfile2D.h>
33 
34 namespace Gaudi {
35  template <>
37  return className == "AIDA::IProfile2D"
38  ? const_cast<AIDA::IProfile2D*>( static_cast<const AIDA::IProfile2D*>( this ) )
39  : className == "AIDA::IProfile" ? const_cast<AIDA::IProfile*>( static_cast<const AIDA::IProfile*>( this ) )
40  : className == "AIDA::IBaseHistogram"
41  ? const_cast<AIDA::IBaseHistogram*>( static_cast<const AIDA::IBaseHistogram*>( this ) )
42  : nullptr;
43  }
44 
45  template <>
47  int rBin = m_rep->GetBin( rIndexX( idX ), rIndexY( idY ) );
48  return int( m_rep->GetBinEntries( rBin ) + 0.5 );
49  }
50 
51  template <>
53  TProfile2D* imp = dynamic_cast<TProfile2D*>( rep );
54  if ( !imp ) throw std::runtime_error( "Cannot adopt native histogram representation." );
55  m_rep.reset( imp );
56  m_xAxis.initialize( m_rep->GetXaxis(), true );
57  m_yAxis.initialize( m_rep->GetYaxis(), true );
58  setTitle( m_rep->GetTitle() );
59  }
60 } // namespace Gaudi
61 
63  const std::string& title, const Edges& eX,
64  const Edges& eY, double /* zlow */, double /* zup */ ) {
65  // Not implemented in ROOT! Can only use TProfile2D with no z-limits
66  auto p = new Profile2D( new TProfile2D( title.c_str(), title.c_str(), eX.size() - 1, &eX.front(), eY.size() - 1,
67  &eY.front() /*,zlow,zup */ ) );
68  svcLocator->monitoringHub().registerEntity( "", path, "histogram:ProfileHistogram:double", *p );
69  return { p, p };
70 }
71 
73  const std::string& title, int binsX, double xlow,
74  double xup, int binsY, double ylow, double yup,
75  double zlow, double zup ) {
76  auto p =
77  new Profile2D( new TProfile2D( title.c_str(), title.c_str(), binsX, xlow, xup, binsY, ylow, yup, zlow, zup ) );
78  svcLocator->monitoringHub().registerEntity( "", path, "histogram:ProfileHistogram:double", *p );
79  return { p, p };
80 }
81 
83  const AIDA::IProfile2D& hist ) {
84  auto h = getRepresentation<AIDA::IProfile2D, TProfile2D>( hist );
85  auto n = ( h ? new Profile2D( new TProfile2D( *h ) ) : nullptr );
86  if ( n ) { svcLocator->monitoringHub().registerEntity( "", path, "histogram:ProfileHistogram:double", *n ); }
87  return { n, n };
88 }
89 
91 
92 Gaudi::Profile2D::Profile2D( TProfile2D* rep ) {
93  m_classType = "IProfile2D";
94  rep->SetDirectory( nullptr );
95  adoptRepresentation( rep );
96  m_sumEntries = 0;
97 }
ISvcLocator::monitoringHub
Gaudi::Monitoring::Hub & monitoringHub()
Definition: ISvcLocator.cpp:26
std::string
STL class.
MonitoringHub.h
std::pair
ISvcLocator
Definition: ISvcLocator.h:46
std::unique_ptr::get
T get(T... args)
P2D.h
ObjectFactory.h
jsonFromLHCbLog.json
dictionary json
Definition: jsonFromLHCbLog.py:87
Gaudi::Generic2D::cast
void * cast(const std::string &className) const override
Introspection method.
Utils.h
HistogramUtility.h
Gaudi::Profile2D::Profile2D
Profile2D()
Default Constructor.
Definition: P2D.h:32
Gaudi::svcLocator
GAUDI_API ISvcLocator * svcLocator()
std::string::c_str
T c_str(T... args)
AlgSequencer.h
h
Definition: AlgSequencer.py:32
GaudiPython.HistoUtils.path
path
Definition: HistoUtils.py:961
GaudiPython.Bindings.nullptr
nullptr
Definition: Bindings.py:93
Gaudi::Monitoring::Hub::registerEntity
void registerEntity(std::string c, std::string n, std::string t, T &ent)
Definition: MonitoringHub.h:163
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
Gaudi::Profile2D::toJSON
nlohmann::json toJSON() const
dumps Histogram to json data
Definition: P2D.cpp:90
Gaudi::Generic2D< AIDA::IProfile2D, TProfile2D >::m_rep
std::unique_ptr< TProfile2D > m_rep
Reference to underlying implementation.
Definition: Generic2D.h:162
DataObject.h
GaudiPI.h
Gaudi::Generic2D
Definition: Generic2D.h:46
Gaudi::createProf2D
std::pair< DataObject *, AIDA::IProfile2D * > createProf2D(ISvcLocator *svcLocator, const std::string &path, const AIDA::IProfile2D &hist)
Copy constructor.