| The Gaudi Framework v32r1 (f65d50dc)

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