| The Gaudi Framework v28r2-patches (bc4ad17a)

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

- File List
- File Members

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 nullptr ; } // RETURN
16 //
17 // exist?
18 auto hist = profile1D ( title ) ;
19 // histogram is already booked
20 if( 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 nullptr ; } // RETURN
45 //
46 // Check ID
47 if (ID.undefined())
48 {
49 this->Error("Undefined Histogram ID : Title='"+title+"'");
50 return nullptr;
51 }
52
53 // exist?
54 auto hist = profile1D ( ID ) ;
55 // histogram is already booked
56 if( 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( !hist )
91 { this->Error( "IProfile1D* points to NULL! ID='" + ID.idAsString() +
92 "' title='"+htitle+"'" ) ; return nullptr; } // 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 ( !histo ) { return nullptr ; } // RETURN
123 //
124 if ( !checkForNaN() )
125 { Gaudi::Utils::Histos::fill ( histo , valueX , valueY , weight ); }
126 else if ( std::isfinite ( valueX ) && std::isfinite ( valueY ) && std::isfinite ( weight ) )
127 { Gaudi::Utils::Histos::fill ( histo , valueX , valueY , weight ); }
128 else if ( std::isnan ( valueX ) || std::isnan ( valueY ) || std::isnan ( 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 = nullptr;
160 if ( produceHistos() )
161 {
162 // retrieve or book the histogram
163 h = profile1D ( title ) ;
164 if ( !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 = nullptr;
189 if ( produceHistos() )
190 {
191 // retrieve or book the histogram
192 h = profile1D ( ID ) ;
193 if ( !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 // ============================================================================
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::profile1D
AIDA::IProfile1D * profile1D(const double valueX, const double valueY, const std::string &title, const double lowX, const double highX, const unsigned long binsX=100, const std::string &opt="", const double lowY=-std::numeric_limits< double >::max(), const double highY=std::numeric_limits< double >::max(), const double weight=1.0) const
fill the 1D profile histogram (book on demand)
Definition: GaudiHistos_1DProfFixedBinning.icpp:148
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
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::bookProfile1D
AIDA::IProfile1D * bookProfile1D(const std::string &title, const double low=0, const double high=100, const unsigned long bins=100, const std::string &opt="", const double lowY=-std::numeric_limits< double >::max(), const double highY=std::numeric_limits< double >::max()) const
book the 1D profile histogram
Definition: GaudiHistos_1DProfFixedBinning.icpp:6
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