| The Gaudi Framework v32r1 (f65d50dc)

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