| The Gaudi Framework v32r1 (f65d50dc)

GaudiHistos_2DProfFixedBinning.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 double lowX, const double highX,
6 const unsigned long binsX, const double lowY, const double highY,
7 const unsigned long binsY ) const {
8 //
9 if ( !produceHistos() ) { return 0; } // RETURN
10 //
11 // exist?
12 auto hist = profile2D( title );
13 // histogram is already booked
14 if ( 0 != hist ) { return hist; } // RETURN !!
15
16 // propose the histogram ID
17 HistoID ID;
18 newHistoID( title, ID );
19
20 // book histogram and return
21 return this->bookProfile2D( ID, title, lowX, highX, binsX, lowY, highY, binsY );
22 }
23 // ============================================================================
24 // book the 2D profile histogram with forced ID (book on demand)
25 // ============================================================================
26 template <class PBASE>
27 AIDA::IProfile2D* GaudiHistos<PBASE>::bookProfile2D( const HistoID& ID, const std::string& title, const double lowX,
28 const double highX, const unsigned long binsX, const double lowY,
29 const double highY, const unsigned long binsY ) const {
30 //
31 if ( !produceHistos() ) { return 0; } // RETURN
32 //
33 // Check ID
34 if ( ID.undefined() ) {
35 this->Error( "Undefined Histogram ID : Title='" + title + "'" ).ignore();
36 return nullptr;
37 }
38 // exist?
39 auto hist = profile2D( ID );
40 // histogram is already booked
41 if ( 0 != hist ) { return hist; } // RETURN !!
42
43 // Histogram title
44 const std::string& htitle = ( title.empty() ? "Unnamed 2D Profile Histogram ID=" + ID.idAsString() : title );
45
46 // book the histogram
47 if ( ID.numeric() ) {
48 hist = this->histoSvc()->bookProf( histoPath(), ID.numericID(), htitle, binsX, lowX, highX, binsY, lowY, highY );
49 } else if ( ID.literal() ) {
50 hist = this->histoSvc()->bookProf( histoPath() + "/" + ID.literalID(), htitle, binsX, lowX, highX, binsY, lowY,
51 highY );
52 }
53
54 // test OK
55 if ( 0 == hist ) {
56 this->Error( "IProfile2D* points to NULL! ID='" + ID.idAsString() + "' title='" + htitle + "'" ).ignore();
57 return 0;
58 } // RETURN !!
59
60 // add histogram into histogram storages
61 m_profile2DMapID[ID] = hist;
62 m_profile2DMapTitle[title] = hist;
63
64 // Declare to monitoring service
65 monitorHisto( Gaudi::Utils::Histos::toBase( hist ), ID );
66
67 // printout and return
68 if ( this->msgLevel( MSG::DEBUG ) ) {
69 this->debug() << "Booked 2D Profile Histogram : ID='" << ID << "' Path=" << histoPath() << " Title='"
70 << Gaudi::Utils::Histos::htitle( hist ) << "'" << endmsg;
71 }
72 return hist;
73 }
74 // ============================================================================
75 // fill the 2D profile histogram with the value and weight
76 // ============================================================================
77 template <class PBASE>
78 AIDA::IProfile2D* GaudiHistos<PBASE>::fill( AIDA::IProfile2D* histo, const double valueX, const double valueY,
79 const double valueZ, const double weight, const std::string& title ) const {
80 if ( 0 == histo ) { return 0; } // RETURN
81 //
82 if ( !checkForNaN() ) {
83 Gaudi::Utils::Histos::fill( histo, valueX, valueY, valueZ, weight );
84 } else if ( std::isfinite( valueX ) && std::isfinite( valueY ) && std::isfinite( valueZ ) &&
85 std::isfinite( weight ) ) {
86 Gaudi::Utils::Histos::fill( histo, valueX, valueY, valueZ, weight );
87 } else if ( std::isnan( valueX ) || std::isnan( valueY ) || std::isnan( valueZ ) || std::isnan( weight ) ) {
88 this->Warning( "fill():: 'NaN' value is skipped from the histogram '" +
89 Gaudi::Utils::Histos::htitle( histo, title ) + "'" )
90 .ignore();
91 } else {
92 this->Warning( "fill():: 'Infinite' value is skipped from the histogram '" +
93 Gaudi::Utils::Histos::htitle( histo, title ) + "'" )
94 .ignore();
95 }
96 // return
97 return histo;
98 }
99 // ============================================================================
100 // fill the 2D profile histogram (book on demand)
101 // ============================================================================
102 template <class PBASE>
103 AIDA::IProfile2D* GaudiHistos<PBASE>::profile2D( const double valueX, const double valueY, const double valueZ,
104 const std::string& title, const double lowX, const double highX,
105 const double lowY, const double highY, const unsigned long binsX,
106 const unsigned long binsY, const double weight ) const {
107 AIDA::IProfile2D* h = nullptr;
108 if ( produceHistos() ) {
109 // retrieve or book the histogram
110 h = profile2D( title );
111 if ( 0 == h ) { h = bookProfile2D( title, lowX, highX, binsX, lowY, highY, binsY ); }
112 // fill the histogram
113 h = fill( h, valueX, valueY, valueZ, weight, title );
114 }
115 return h;
116 }
117 // ============================================================================
118 // fill the 2D profile histogram with forced ID assignment (book on demand)
119 // ============================================================================
120 template <class PBASE>
121 AIDA::IProfile2D* GaudiHistos<PBASE>::profile2D( const double valueX, const double valueY, const double valueZ,
122 const HistoID& ID, const std::string& title, const double lowX,
123 const double highX, const double lowY, const double highY,
124 const unsigned long binsX, const unsigned long binsY,
125 const double weight ) const {
126 AIDA::IProfile2D* h = nullptr;
127 if ( produceHistos() ) {
128 // retrieve or book the histogram
129 h = profile2D( ID );
130 if ( 0 == h ) { h = bookProfile2D( ID, title, lowX, highX, binsX, lowY, highY, binsY ); }
131 // fill the histogram
132 h = fill( h, valueX, valueY, valueZ, weight, title );
133 }
134 return h;
135 }
136 // ============================================================================
137 // The END
138 // ============================================================================
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
GaudiHistos::fill
AIDA::IHistogram1D * fill(AIDA::IHistogram1D *histo, const double value, const double weight, const std::string &title="") const
fill the 1D histogram with the value and weight
Definition: GaudiHistos_1DFixedBinning.icpp:79
std::isfinite
T isfinite(T... args)
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
std::isnan
T isnan(T... args)
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