| The Gaudi Framework v28r2p1 (f1a77ff4)

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

- File List
- File Members

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