| The Gaudi Framework v30r0 (c919700c)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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 //
10 if ( !produceHistos() ) {
11 return nullptr;
12 } // RETURN
13 //
14 // exist?
15 auto hist = profile1D( title );
16 // histogram is already booked
17 if ( hist ) {
18 return hist;
19 } // RETURN !!
20
21 // propose the histogram ID
22 HistoID ID;
23 newHistoID( title, ID );
24
25 // Book the histo and return
26 return this->bookProfile1D( ID, title, low, high, bins, opt, lowY, highY );
27 }
28 // ============================================================================
29 // book the 1D profile histogram with forced ID (book on demand)
30 // ============================================================================
31 template <class PBASE>
32 AIDA::IProfile1D* GaudiHistos<PBASE>::bookProfile1D( const HistoID& ID, const std::string& title, const double low,
33 const double high, const unsigned long bins,
34 const std::string& opt, const double lowY,
35 const double highY ) const
36 {
37 //
38 if ( !produceHistos() ) {
39 return nullptr;
40 } // RETURN
41 //
42 // Check ID
43 if ( ID.undefined() ) {
44 this->Error( "Undefined Histogram ID : Title='" + title + "'" ).ignore();
45 return nullptr;
46 }
47
48 // exist?
49 auto hist = profile1D( ID );
50 // histogram is already booked
51 if ( hist ) {
52 return hist;
53 } // RETURN !!
54
55 // Histogram title
56 const std::string& htitle = ( title.empty() ? "Unnamed 1D Profile Histogram ID=" + ID.idAsString() : title );
57
58 // book the histogram
59 if ( ID.numeric() ) {
60 hist = this->histoSvc()->bookProf( histoPath(), ID.numericID(), htitle, bins, low, high, lowY, highY, opt );
61 } else if ( ID.literal() ) {
62 hist = this->histoSvc()->bookProf( histoPath() + "/" + ID.literalID(), htitle, bins, low, high, lowY, highY, opt );
63 }
64
65 // test ok
66 if ( !hist ) {
67 this->Error( "IProfile1D* points to NULL! ID='" + ID.idAsString() + "' title='" + htitle + "'" ).ignore();
68 return nullptr;
69 } // RETURN !!
70
71 // add histogram into histogram storages
72 m_profile1DMapID[ID] = hist;
73 m_profile1DMapTitle[title] = hist;
74
75 // Declare to monitoring service
76 monitorHisto( Gaudi::Utils::Histos::toBase( hist ), ID );
77
78 // printout and return
79 if ( this->msgLevel( MSG::DEBUG ) ) {
80 this->debug() << "Booked 1D Profile Histogram : ID='" << ID << "' Path=" << histoPath() << " Title='"
81 << Gaudi::Utils::Histos::htitle( hist ) << "'" << endmsg;
82 }
83 return hist;
84 }
85 // ============================================================================
86 // fill the 1D profile histogram with the value and weight
87 // ============================================================================
88 template <class PBASE>
89 AIDA::IProfile1D* GaudiHistos<PBASE>::fill( AIDA::IProfile1D* histo, const double valueX, const double valueY,
90 const double weight, const std::string& title ) const
91 {
92 //
93 if ( !histo ) {
94 return nullptr;
95 } // RETURN
96 //
97 if ( !checkForNaN() ) {
98 Gaudi::Utils::Histos::fill( histo, valueX, valueY, weight );
99 } else if ( std::isfinite( valueX ) && std::isfinite( valueY ) && std::isfinite( weight ) ) {
100 Gaudi::Utils::Histos::fill( histo, valueX, valueY, weight );
101 } else if ( std::isnan( valueX ) || std::isnan( valueY ) || std::isnan( weight ) ) {
102 this->Warning( "fill():: 'NaN' value is skipped from the histogram '" +
103 Gaudi::Utils::Histos::htitle( histo, title ) + "'" )
104 .ignore();
105 } else {
106 this->Warning( "fill():: 'Infinite' value is skipped from the histogram '" +
107 Gaudi::Utils::Histos::htitle( histo, title ) + "'" )
108 .ignore();
109 }
110 // return
111 return histo;
112 }
113 // ============================================================================
114 // fill the 1D profile histogram (book on demand)
115 // ============================================================================
116 template <class PBASE>
117 AIDA::IProfile1D* GaudiHistos<PBASE>::profile1D( const double valueX, const double valueY, const std::string& title,
118 const double lowX, const double highX, const unsigned long binsX,
119 const std::string& opt, const double lowY, const double highY,
120 const double weight ) const
121 {
122 AIDA::IProfile1D* h = nullptr;
123 if ( produceHistos() ) {
124 // retrieve or book the histogram
125 h = profile1D( title );
126 if ( !h ) {
127 h = bookProfile1D( title, lowX, highX, binsX, opt, lowY, highY );
128 }
129 // fill the histogram
130 h = fill( h, valueX, valueY, weight, title );
131 }
132 return h;
133 }
134 // ============================================================================
135 // fill the 1D profile histogram with forced ID assignment (book on demand)
136 // ============================================================================
137 template <class PBASE>
138 AIDA::IProfile1D* GaudiHistos<PBASE>::profile1D( const double valueX, const double valueY, const HistoID& ID,
139 const std::string& title, const double lowX, const double highX,
140 const unsigned long binsX, const std::string& opt, const double lowY,
141 const double highY, const double weight ) const
142 {
143 AIDA::IProfile1D* h = nullptr;
144 if ( produceHistos() ) {
145 // retrieve or book the histogram
146 h = profile1D( ID );
147 if ( !h ) {
148 h = bookProfile1D( ID, title, lowX, highX, binsX, opt, lowY, highY );
149 }
150 // fill the histogram
151 h = fill( h, valueX, valueY, weight, title );
152 }
153 return h;
154 }
155 // ============================================================================
156 // The END
157 // ============================================================================
Gaudi::Utils::Histos::htitle
GAUDI_API std::string htitle(const AIDA::IBaseHistogram *histo, const std::string &title="")
get the title
Definition: Fill.cpp:126
std::string::empty
T empty(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:117
GaudiAlg::ID::numericID
NumericID numericID() const noexcept
Returns the numerical ID.
Definition: GaudiHistoID.h:74
MSG::DEBUG
Definition: IMessageSvc.h:16
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::literal
bool literal() const noexcept
Is this ID numeric.
Definition: GaudiHistoID.h:68
std::isfinite
T isfinite(T...args)
GaudiAlg::ID::literalID
const LiteralID & literalID() const noexcept
Returns the ID as a LiteralID.
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::numeric
bool numeric() const noexcept
Is this ID numeric.
Definition: GaudiHistoID.h:66
std::isnan
T isnan(T...args)
Gaudi::Utils::Histos::toBase
GAUDI_API AIDA::IBaseHistogram * toBase(AIDA::IHistogram1D *histo)
Definition: Fill.cpp:180
GaudiAlg::ID::undefined
bool undefined() const noexcept
Is this ID undefined.
Definition: GaudiHistoID.h:70
GaudiAlg::ID
ID class for Histogram and Ntuples.
Definition: GaudiHistoID.h:44
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
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
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:89