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