| The Gaudi Framework v29r0 (ff2e7097)

- 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 + "'" );
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 + "'" );
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 } else {
105 this->Warning( "fill():: 'Infinite' value is skipped from the histogram '" +
106 Gaudi::Utils::Histos::htitle( histo, title ) + "'" );
107 }
108 // return
109 return histo;
110 }
111 // ============================================================================
112 // fill the 1D profile histogram (book on demand)
113 // ============================================================================
114 template <class PBASE>
115 AIDA::IProfile1D* GaudiHistos<PBASE>::profile1D( const double valueX, const double valueY, const std::string& title,
116 const double lowX, const double highX, const unsigned long binsX,
117 const std::string& opt, const double lowY, const double highY,
118 const double weight ) const
119 {
120 AIDA::IProfile1D* h = nullptr;
121 if ( produceHistos() ) {
122 // retrieve or book the histogram
123 h = profile1D( title );
124 if ( !h ) {
125 h = bookProfile1D( title, lowX, highX, binsX, opt, lowY, highY );
126 }
127 // fill the histogram
128 h = fill( h, valueX, valueY, weight, title );
129 }
130 return h;
131 }
132 // ============================================================================
133 // fill the 1D profile histogram with forced ID assignment (book on demand)
134 // ============================================================================
135 template <class PBASE>
136 AIDA::IProfile1D* GaudiHistos<PBASE>::profile1D( const double valueX, const double valueY, const HistoID& ID,
137 const std::string& title, const double lowX, const double highX,
138 const unsigned long binsX, const std::string& opt, const double lowY,
139 const double highY, const double weight ) const
140 {
141 AIDA::IProfile1D* h = nullptr;
142 if ( produceHistos() ) {
143 // retrieve or book the histogram
144 h = profile1D( ID );
145 if ( !h ) {
146 h = bookProfile1D( ID, title, lowX, highX, binsX, opt, lowY, highY );
147 }
148 // fill the histogram
149 h = fill( h, valueX, valueY, weight, title );
150 }
151 return h;
152 }
153 // ============================================================================
154 // The END
155 // ============================================================================
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:115
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.
HiveAlgSequencer.h
h
Definition: HiveAlgSequencer.py:24
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