| The Gaudi Framework v29r0 (ff2e7097)

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

- File List
- File Members

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