The Gaudi Framework  v29r0 (ff2e7097)
GaudiHistos_2DProfVariableBinning.icpp
Go to the documentation of this file.
1 // ============================================================================
2 // book the 2D profile histogram (book on demand)
3 // ============================================================================
4 template <class PBASE>
5 AIDA::IProfile2D* GaudiHistos<PBASE>::bookProfile2D( const std::string& title, const HistoBinEdges& edgesX,
6  const HistoBinEdges& edgesY ) const
7 {
8  //
9  if ( !produceHistos() ) {
10  return 0;
11  } // RETURN
12  //
13  // exist?
14  auto hist = profile2D( title );
15  // histogram is already booked
16  if ( hist ) {
17  return hist;
18  } // RETURN !!
19 
20  // propose the histogram ID
21  HistoID ID;
22  newHistoID( title, ID );
23 
24  // book histogram and return
25  return this->bookProfile2D( ID, title, edgesX, edgesY );
26 }
27 // ============================================================================
28 // book the 2D profile histogram with forced ID (book on demand)
29 // ============================================================================
30 template <class PBASE>
31 AIDA::IProfile2D* GaudiHistos<PBASE>::bookProfile2D( const HistoID& ID, const std::string& title,
32  const HistoBinEdges& edgesX, const HistoBinEdges& edgesY ) const
33 {
34  //
35  if ( !produceHistos() ) {
36  return 0;
37  } // RETURN
38  //
39  // Check ID
40  if ( ID.undefined() ) {
41  this->Error( "Undefined Histogram ID : Title='" + title + "'" );
42  return nullptr;
43  }
44  // exist?
45  auto hist = profile2D( ID );
46  // histogram is already booked
47  if ( hist ) {
48  return hist;
49  } // 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 + "'" );
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 {
89  AIDA::IProfile2D* h( nullptr );
90  if ( produceHistos() ) {
91  // retrieve or book the histogram
92  h = profile2D( title );
93  if ( !h ) {
94  h = bookProfile2D( title, edgesX, edgesY );
95  }
96  // fill the histogram
97  h = fill( h, valueX, valueY, valueZ, weight, title );
98  }
99  return h;
100 }
101 // ============================================================================
102 // fill the 2D profile histogram with forced ID assignment (book on demand)
103 // ============================================================================
104 template <class PBASE>
105 AIDA::IProfile2D* GaudiHistos<PBASE>::profile2D( const double valueX, const double valueY, const double valueZ,
106  const HistoID& ID, const std::string& title,
107  const HistoBinEdges& edgesX, const HistoBinEdges& edgesY,
108  const double weight ) const
109 {
110  AIDA::IProfile2D* h( nullptr );
111  if ( produceHistos() ) {
112  // retrieve or book the histogram
113  h = profile2D( ID );
114  if ( !h ) {
115  h = bookProfile2D( ID, title, edgesX, edgesY );
116  }
117 
118  // fill the histogram
119  h = fill( h, valueX, valueY, valueZ, weight, title );
120  }
121  return h;
122 }
123 // ============================================================================
124 // The END
125 // ============================================================================
GAUDI_API std::string htitle(const AIDA::IBaseHistogram *histo, const std::string &title="")
get the title
Definition: Fill.cpp:126
T empty(T...args)
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
NumericID numericID() const noexcept
Returns the numerical ID.
Definition: GaudiHistoID.h:74
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:35
STL class.
bool literal() const noexcept
Is this ID numeric.
Definition: GaudiHistoID.h:68
const LiteralID & literalID() const noexcept
Returns the ID as a LiteralID.
Definition: GaudiHistoID.h:72
GAUDI_API LiteralID idAsString() const
Return ID as string, for both numeric and literal IDs.
bool numeric() const noexcept
Is this ID numeric.
Definition: GaudiHistoID.h:66
GAUDI_API AIDA::IBaseHistogram * toBase(AIDA::IHistogram1D *histo)
Definition: Fill.cpp:180
bool undefined() const noexcept
Is this ID undefined.
Definition: GaudiHistoID.h:70
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)
ID class for Histogram and Ntuples.
Definition: GaudiHistoID.h:44
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209