The Gaudi Framework  v38r0 (2143aa4c)
GaudiHistos_2DProfVariableBinning.icpp
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 // ============================================================================
12 // book the 2D profile histogram (book on demand)
13 // ============================================================================
14 template <class PBASE>
15 AIDA::IProfile2D* GaudiHistos<PBASE>::bookProfile2D( const std::string& title, const HistoBinEdges& edgesX,
16  const HistoBinEdges& edgesY ) const {
17  //
18  if ( !produceHistos() ) { return 0; } // RETURN
19  //
20  // exist?
21  auto hist = profile2D( title );
22  // histogram is already booked
23  if ( hist ) { return hist; } // RETURN !!
24 
25  // propose the histogram ID
26  HistoID ID;
27  newHistoID( title, ID );
28 
29  // book histogram and return
30  return this->bookProfile2D( ID, title, edgesX, edgesY );
31 }
32 // ============================================================================
33 // book the 2D profile histogram with forced ID (book on demand)
34 // ============================================================================
35 template <class PBASE>
36 AIDA::IProfile2D* GaudiHistos<PBASE>::bookProfile2D( const HistoID& ID, const std::string& title,
37  const HistoBinEdges& edgesX, const HistoBinEdges& edgesY ) const {
38  //
39  if ( !produceHistos() ) { return 0; } // RETURN
40  //
41  // Check ID
42  if ( ID.undefined() ) {
43  this->Error( "Undefined Histogram ID : Title='" + title + "'" ).ignore();
44  return nullptr;
45  }
46  // exist?
47  auto hist = profile2D( ID );
48  // histogram is already booked
49  if ( hist ) { return hist; } // RETURN !!
50 
51  // Histogram title
52  const std::string& htitle = ( title.empty() ? "Unnamed 2D Profile Histogram ID=" + ID.idAsString() : title );
53 
54  // book the histogram
55  if ( ID.numeric() ) {
56  hist = this->histoSvc()->bookProf( histoPath(), ID.numericID(), htitle, edgesX, edgesY );
57  } else if ( ID.literal() ) {
58  hist = this->histoSvc()->bookProf( histoPath() + "/" + ID.literalID(), htitle, edgesX, edgesY );
59  }
60 
61  // test OK
62  if ( !hist ) {
63  this->Error( "IProfile2D* points to NULL! ID='" + ID.idAsString() + "' title='" + htitle + "'" ).ignore();
64  return nullptr;
65  } // RETURN !!
66 
67  // add histogram into histogram storages
68  m_profile2DMapID[ID] = hist;
69  m_profile2DMapTitle[title] = hist;
70 
71  // Declare to monitoring service
72  monitorHisto( Gaudi::Utils::Histos::toBase( hist ), ID );
73 
74  // printout and return
75  if ( this->msgLevel( MSG::DEBUG ) ) {
76  this->debug() << "Booked 2D Profile Histogram : ID='" << ID << "' Path=" << histoPath() << " Title='"
77  << Gaudi::Utils::Histos::htitle( hist ) << "'" << endmsg;
78  }
79  return hist;
80 }
81 // ============================================================================
82 // fill the 2D profile histogram (book on demand)
83 // ============================================================================
84 template <class PBASE>
85 AIDA::IProfile2D* GaudiHistos<PBASE>::profile2D( const double valueX, const double valueY, const double valueZ,
86  const std::string& title, const HistoBinEdges& edgesX,
87  const HistoBinEdges& edgesY, const double weight ) const {
88  AIDA::IProfile2D* h( nullptr );
89  if ( produceHistos() ) {
90  // retrieve or book the histogram
91  h = profile2D( title );
92  if ( !h ) { h = bookProfile2D( title, edgesX, edgesY ); }
93  // fill the histogram
94  h = fill( h, valueX, valueY, valueZ, weight, title );
95  }
96  return h;
97 }
98 // ============================================================================
99 // fill the 2D profile histogram with forced ID assignment (book on demand)
100 // ============================================================================
101 template <class PBASE>
102 AIDA::IProfile2D* GaudiHistos<PBASE>::profile2D( const double valueX, const double valueY, const double valueZ,
103  const HistoID& ID, const std::string& title,
104  const HistoBinEdges& edgesX, const HistoBinEdges& edgesY,
105  const double weight ) const {
106  AIDA::IProfile2D* h( nullptr );
107  if ( produceHistos() ) {
108  // retrieve or book the histogram
109  h = profile2D( ID );
110  if ( !h ) { h = bookProfile2D( ID, title, edgesX, edgesY ); }
111 
112  // fill the histogram
113  h = fill( h, valueX, valueY, valueZ, weight, title );
114  }
115  return h;
116 }
117 // ============================================================================
118 // The END
119 // ============================================================================
MSG::DEBUG
@ DEBUG
Definition: IMessageSvc.h:25
GaudiHistos::bookProfile2D
AIDA::IProfile2D * bookProfile2D(const std::string &title, const double lowX=0, const double highX=100, const unsigned long binsX=50, const double lowY=0, const double highY=100, const unsigned long binsY=50) const
book the 2D profile histogram
Definition: GaudiHistos_2DProfFixedBinning.icpp:15
std::string
STL class.
GaudiAlg::ID
Definition: GaudiHistoID.h:53
std::vector< double >
GaudiAlg::ID::numericID
NumericID numericID() const noexcept
Returns the numerical ID.
Definition: GaudiHistoID.h:82
Gaudi::Utils::Histos::toBase
GAUDI_API AIDA::IBaseHistogram * toBase(AIDA::IHistogram1D *histo)
Definition: Fill.cpp:165
AlgSequencer.h
h
Definition: AlgSequencer.py:31
GaudiAlg::ID::undefined
bool undefined() const noexcept
Is this ID undefined.
Definition: GaudiHistoID.h:78
Gaudi::Utils::Histos::htitle
GAUDI_API std::string htitle(const AIDA::IBaseHistogram *histo, const std::string &title="")
get the title
Definition: Fill.cpp:119
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:203
std::string::empty
T empty(T... args)
GaudiHistos::profile2D
AIDA::IProfile2D * profile2D(const double valueX, const double valueY, const double valueZ, const std::string &title, const double lowX, const double highX, const double lowY, const double highY, const unsigned long binsX=50, const unsigned long binsY=50, const double weight=1.0) const
fill the 2D profile histogram (book on demand)
Definition: GaudiHistos_2DProfFixedBinning.icpp:113
Gaudi::Utils::Histos::fill
GAUDI_API void fill(AIDA::IHistogram1D *histo, const double value, const double weight=1.0)
simple function to fill AIDA::IHistogram1D objects
Definition: Fill.cpp:45
GaudiAlg::ID::literalID
const LiteralID & literalID() const noexcept
Returns the ID as a LiteralID.
Definition: GaudiHistoID.h:80
GaudiAlg::ID::idAsString
GAUDI_API LiteralID idAsString() const
Return ID as string, for both numeric and literal IDs.
Definition: GaudiHistoID.cpp:30
GaudiAlg::ID::numeric
bool numeric() const noexcept
Is this ID numeric.
Definition: GaudiHistoID.h:74
GaudiAlg::ID::literal
bool literal() const noexcept
Is this ID numeric.
Definition: GaudiHistoID.h:76