| The Gaudi Framework v28r2p1 (f1a77ff4)

- 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
8 ( const std::string& title ,
9 const double lowX ,
10 const double highX ,
11 const unsigned long binsX ,
12 const double lowY ,
13 const double highY ,
14 const unsigned long binsY ,
15 const double lowZ ,
16 const double highZ ,
17 const unsigned long binsZ ) const
18 {
19 //
20 if ( !produceHistos() ) { return nullptr ; } // RETURN
21 //
22 // exist?
23 auto hist = histo3D ( title ) ;
24 // histogram is already booked
25 if( hist ) { return hist ; } // RETURN !!
26
27 // propose the histogram ID
28 HistoID ID;
29 newHistoID( title, ID );
30
31 // Create a new histogram and return
32 return this -> book3D ( ID, title,
33 lowX, highX, binsX,
34 lowY, highY, binsY,
35 lowZ, highZ, binsZ );
36 }
37 // ============================================================================
38 // book the 3D histogram with forced ID (book on demand)
39 // ============================================================================
40 template <class PBASE>
41 AIDA::IHistogram3D* GaudiHistos<PBASE>::book3D
42 ( const HistoID& ID ,
43 const std::string& title ,
44 const double lowX ,
45 const double highX ,
46 const unsigned long binsX ,
47 const double lowY ,
48 const double highY ,
49 const unsigned long binsY ,
50 const double lowZ ,
51 const double highZ ,
52 const unsigned long binsZ ) const
53 {
54 //
55 if ( !produceHistos() ) { return nullptr; } // RETURN
56 //
57 // Check ID
58 if (ID.undefined())
59 {
60 this->Error("Undefined Histogram ID : Title='"+title+"'");
61 return nullptr;
62 }
63
64 // exist?
65 auto hist = histo3D( ID ) ;
66 // histogram is already booked
67 if( hist ) { return hist ; } // RETURN !!
68
69 // Histogram title
70 const std::string & htitle =
71 ( title.empty() ? "Unnamed 3D Histogram ID="+ID.idAsString() : title ) ;
72
73 // book the histogram
74 if ( ID.numeric() )
75 {
76 hist = this->histoSvc() -> book ( histoPath() ,
77 ID.numericID() ,
78 htitle ,
79 binsX ,
80 lowX ,
81 highX ,
82 binsY ,
83 lowY ,
84 highY ,
85 binsZ ,
86 lowZ ,
87 highZ ) ;
88 }
89 else if ( ID.literal() )
90 {
91 hist = this->histoSvc() -> book ( histoPath()+"/"+
92 ID.literalID() ,
93 htitle ,
94 binsX ,
95 lowX ,
96 highX ,
97 binsY ,
98 lowY ,
99 highY ,
100 binsZ ,
101 lowZ ,
102 highZ ) ;
103 }
104
105 // Check OK
106 if( !hist )
107 { this->Error( "IHistogram3D* points to NULL! ID='" + ID.idAsString() +
108 "' title='"+htitle+"'" ) ; return nullptr; } // RETURN !!
109
110 // add histogram into histogram storages
111 m_histo3DMapID [ ID ] = hist ;
112 m_histo3DMapTitle [ title ] = hist ;
113
114 // Declare to monitoring service
115 monitorHisto( Gaudi::Utils::Histos::toBase ( hist ) , ID );
116
117 // Printout and return
118 if ( this->msgLevel(MSG::DEBUG) )
119 { this->debug() << "Booked 3D Histogram : ID='"
120 << ID << "' Path=" << histoPath()
121 << " Title='"
122 << Gaudi::Utils::Histos::htitle ( hist )
123 << "'" << endmsg; }
124 return hist ;
125 }
126 // ============================================================================
127 // fill the 3D histogram with the values and weight
128 // ============================================================================
129 template <class PBASE>
130 AIDA::IHistogram3D* GaudiHistos<PBASE>::fill
131 ( AIDA::IHistogram3D* histo ,
132 const double valueX ,
133 const double valueY ,
134 const double valueZ ,
135 const double weight ,
136 const std::string& title ) const
137 {
138 if ( !histo ) { return nullptr ; } // RETURN
139 //
140 if ( !checkForNaN() )
141 { Gaudi::Utils::Histos::fill ( histo , valueX , valueY , valueZ , weight ) ; }
142 else if ( std::isfinite ( valueX ) && std::isfinite ( valueY ) &&
143 std::isfinite ( valueZ ) && std::isfinite ( weight ) )
144 { Gaudi::Utils::Histos::fill ( histo , valueX , valueY , valueZ , weight ) ; }
145 else if ( std::isnan ( valueX ) || std::isnan ( valueY ) ||
146 std::isnan ( valueZ ) || std::isnan ( weight ) )
147 {
148 this -> Warning
149 ("fill():: 'NaN' value is skipped from the histogram '"
150 + Gaudi::Utils::Histos::htitle ( histo , title ) + "'" ) ;
151 }
152 else
153 {
154 this -> Warning
155 ("fill():: 'Infinite' value is skipped from the histogram '"
156 + Gaudi::Utils::Histos::htitle ( histo , title ) + "'" ) ;
157 }
158 // return
159 return histo ;
160 }
161 // ============================================================================
162 // fill the 3D histogram (book on demand)
163 // ============================================================================
164 template <class PBASE>
165 AIDA::IHistogram3D* GaudiHistos<PBASE>::plot3D
166 ( const double valueX ,
167 const double valueY ,
168 const double valueZ ,
169 const std::string& title ,
170 const double lowX ,
171 const double highX ,
172 const double lowY ,
173 const double highY ,
174 const double lowZ ,
175 const double highZ ,
176 const unsigned long binsX ,
177 const unsigned long binsY ,
178 const unsigned long binsZ ,
179 const double weight ) const
180 {
181 AIDA::IHistogram3D * h(nullptr);
182 if ( produceHistos() )
183 {
184 // retrieve or book the histogram
185 h = histo3D ( title ) ;
186 if ( !h ) { h = book3D ( title ,
187 lowX , highX , binsX ,
188 lowY , highY , binsY ,
189 lowZ , highZ , binsZ ) ; }
190 // fill the histogram
191 h = fill ( h , valueX , valueY , valueZ , weight , title ) ;
192 }
193 return h;
194 }
195 // ============================================================================
196 // fill the 3D histogram with forced ID assignment (book on demand)
197 // ============================================================================
198 template <class PBASE>
199 AIDA::IHistogram3D* GaudiHistos<PBASE>::plot3D
200 ( const double valueX ,
201 const double valueY ,
202 const double valueZ ,
203 const HistoID& ID ,
204 const std::string& title ,
205 const double lowX ,
206 const double highX ,
207 const double lowY ,
208 const double highY ,
209 const double lowZ ,
210 const double highZ ,
211 const unsigned long binsX ,
212 const unsigned long binsY ,
213 const unsigned long binsZ ,
214 const double weight ) const
215 {
216 AIDA::IHistogram3D * h(nullptr);
217 if ( produceHistos() )
218 {
219 // retrieve or book the histogram
220 h = histo3D ( ID ) ;
221 if ( !h ) { h = book3D ( ID , title ,
222 lowX , highX , binsX ,
223 lowY , highY , binsY ,
224 lowZ , highZ , binsZ ) ; }
225 // fill the histogram
226 h = fill ( h , valueX , valueY , valueZ , weight , title ) ;
227 }
228 return h;
229 }
230 // ============================================================================
231 // The END
232 // ============================================================================
Gaudi::Utils::Histos::htitle
GAUDI_API std::string htitle(const AIDA::IBaseHistogram *histo, const std::string &title="")
get the title
Definition: Fill.cpp:138
std::string::empty
T empty(T...args)
Gaudi::Histos::book
GAUDI_API AIDA::IHistogram1D * book(IHistogramSvc *svc, const std::string &path, const Gaudi::Histo1DDef &hist)
helper function to book 1D-histogram
Definition: HistoDef.cpp:124
GaudiAlg::ID::numericID
NumericID numericID() const noexcept
Returns the numerical ID.
Definition: GaudiHistoID.h:82
MSG::DEBUG
Definition: IMessageSvc.h:18
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:36
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:76
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:166
GaudiAlg::ID::literalID
const LiteralID & literalID() const noexcept
Returns the ID as a LiteralID.
Definition: GaudiHistoID.h:80
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:74
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:8
Gaudi::Utils::Histos::toBase
GAUDI_API AIDA::IBaseHistogram * toBase(AIDA::IHistogram1D *histo)
Definition: Fill.cpp:193
GaudiAlg::ID::undefined
bool undefined() const noexcept
Is this ID undefined.
Definition: GaudiHistoID.h:78
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:244
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:105