| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

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

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GaudiHistos_2DFixedBinning.icpp
Go to the documentation of this file.
1 // ============================================================================
2 // ==================================== 2D ====================================
3 // ============================================================================
4 // book the 2D histogram (book on demand)
5 // ============================================================================
6 template <class PBASE>
7 AIDA::IHistogram2D* GaudiHistos<PBASE>::book2D
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 ) const
15 {
16 //
17 if ( !produceHistos() ) { return 0 ; } // RETURN
18 //
19 // exist?
20 AIDA::IHistogram2D* hist = histo2D ( title ) ;
21 // histogram is already booked
22 if( NULL != hist ) { return hist ; } // 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 -> book2D ( ID, title, lowX, highX, binsX, lowY, highY, binsY );
30 }
31 // ============================================================================
32 // book the 2D histogram with forced ID (book on demand)
33 // ============================================================================
34 template <class PBASE>
35 AIDA::IHistogram2D* GaudiHistos<PBASE>::book2D
36 ( const HistoID& ID ,
37 const std::string& title ,
38 const double lowX ,
39 const double highX ,
40 const unsigned long binsX ,
41 const double lowY ,
42 const double highY ,
43 const unsigned long binsY ) const
44 {
45 //
46 if ( !produceHistos() ) { return 0 ; } // RETURN
47 //
48 // Check ID
49 if (ID.undefined())
50 {
51 this->Error("Undefined Histogram ID : Title='"+title+"'");
52 return NULL;
53 }
54
55 // exist?
56 AIDA::IHistogram2D* hist = histo2D( ID ) ;
57 // histogram is already booked
58 if( NULL != hist ) { return hist ; } // RETURN !!
59
60 // Histogram title
61 const std::string & htitle =
62 ( title.empty() ? "Unnamed 2D Histogram ID="+ID.idAsString() : title ) ;
63
64 // book the histogram
65 if ( ID.numeric() )
66 {
67 hist = this->histoSvc() -> book ( histoPath() ,
68 ID.numericID() ,
69 htitle ,
70 binsX ,
71 lowX ,
72 highX ,
73 binsY ,
74 lowY ,
75 highY ) ;
76 }
77 else if ( ID.literal() )
78 {
79 hist = this->histoSvc() -> book ( histoPath()+"/"+
80 ID.literalID() ,
81 htitle ,
82 binsX ,
83 lowX ,
84 highX ,
85 binsY ,
86 lowY ,
87 highY ) ;
88 }
89
90 // Check OK
91 if( NULL == hist )
92 { this->Error( "IHistogram2D* points to NULL! ID='" + ID.idAsString() +
93 "' title='"+htitle+"'" ) ; return NULL; } // RETURN !!
94
95 // add histogram into histogram storages
96 m_histo2DMapID [ ID ] = hist ;
97 m_histo2DMapTitle [ title ] = hist ;
98
99 // Declare to monitoring service
100 monitorHisto( Gaudi::Utils::Histos::toBase ( hist) , ID );
101
102 // Printout and return
103 if ( this->msgLevel(MSG::DEBUG) )
104 { this->debug() << "Booked 2D Histogram : ID='"
105 << ID << "' Path=" << histoPath()
106 << " Title='"
107 << Gaudi::Utils::Histos::htitle ( hist )
108 << "'" << endmsg; }
109 // return
110 return hist ;
111 }
112 // ============================================================================
113 // fill the 2D histogram with the values and weight
114 // ============================================================================
115 template <class PBASE>
116 AIDA::IHistogram2D* GaudiHistos<PBASE>::fill
117 ( AIDA::IHistogram2D* histo ,
118 const double valueX ,
119 const double valueY ,
120 const double weight ,
121 const std::string& title ) const
122 {
123 //
124 if ( NULL == histo ) { return 0 ; } // RETURN
125 //
126 if ( !checkForNaN() )
127 { Gaudi::Utils::Histos::fill ( histo , valueX , valueY , weight ) ; }
128 else if ( lfin ( valueX ) && lfin ( valueY ) && lfin ( weight ) )
129 { Gaudi::Utils::Histos::fill ( histo , valueX , valueY , weight ) ; }
130 else if ( lnan ( valueX ) || lnan ( valueY ) || lnan ( weight ) )
131 {
132 this -> Warning
133 ("fill():: 'NaN' value is skipped from the histogram '"
134 + Gaudi::Utils::Histos::htitle ( histo , title ) + "'" ) ;
135 }
136 else
137 {
138 this -> Warning
139 ("fill():: 'Infinite' value is skipped from the histogram '"
140 + Gaudi::Utils::Histos::htitle ( histo , title ) + "'" ) ;
141 }
142 // return
143 return histo ;
144 }
145 // ============================================================================
146 // fill the 2D histogram (book on demand)
147 // ============================================================================
148 template <class PBASE>
149 AIDA::IHistogram2D* GaudiHistos<PBASE>::plot2D
150 ( const double valueX ,
151 const double valueY ,
152 const std::string& title ,
153 const double lowX ,
154 const double highX ,
155 const double lowY ,
156 const double highY ,
157 const unsigned long binsX ,
158 const unsigned long binsY ,
159 const double weight ) const
160 {
161 AIDA::IHistogram2D * h(NULL);
162 if ( produceHistos() )
163 {
164 // retrieve or book the histogram
165 h = histo2D ( title ) ;
166 if ( NULL == h )
167 { h = book2D ( title , lowX , highX , binsX , lowY , highY , binsY ) ; }
168 // fill the histogram
169 h = fill ( h , valueX , valueY , weight , title ) ;
170 }
171 return h;
172 }
173 // ============================================================================
174 // fill the 2D histogram with forced ID assignment (book on demand)
175 // ============================================================================
176 template <class PBASE>
177 AIDA::IHistogram2D* GaudiHistos<PBASE>::plot2D
178 ( const double valueX ,
179 const double valueY ,
180 const HistoID& ID ,
181 const std::string& title ,
182 const double lowX ,
183 const double highX ,
184 const double lowY ,
185 const double highY ,
186 const unsigned long binsX ,
187 const unsigned long binsY ,
188 const double weight ) const
189 {
190 AIDA::IHistogram2D * h(NULL);
191 // produce histograms ?
192 if ( produceHistos() )
193 {
194 // retrieve or book the histogram
195 h = histo2D ( ID ) ;
196 if ( NULL == h ) { h = book2D ( ID , title ,
197 lowX , highX , binsX ,
198 lowY , highY , binsY ) ; }
199 // fill the histogram
200 h = fill ( h , valueX , valueY , weight , title ) ;
201 }
202 return h;
203 }
204 // ============================================================================
205 // The END
206 // ============================================================================
207