11 #ifndef GAUDIALG_GAUDIHISTOS_ICPP
12 #define GAUDIALG_GAUDIHISTOS_ICPP 1
59 constexpr
struct ordered_t {
66 template <
typename Map>
67 typename Map::mapped_type lookup_(
const Map&
map,
const typename Map::key_type& ID ) {
68 auto found =
map.find( ID );
69 return found !=
std::end(
map ) ? found->second :
nullptr;
84 template <
class PBASE>
97 if ( !produceHistos() ) {
98 this->debug() <<
"Histogram production is switched OFF" <<
endmsg;
103 if ( !this->histoSvc() ) {
return this->Error(
"initialize():: IHistogramSvc* is invalid" ); }
106 if ( useNumericAutoIDs() ) {
108 "Using numerical automatic IDs. These are not guaranteed to be totally deterministic. Use with care...",
121 template <
class PBASE>
130 if ( produceHistos() ) {
133 if ( ( !noHistos() ) && histoCountersPrint() ) {
134 const unsigned int n1D = histo1DMapID().size();
135 const unsigned int n2D = histo2DMapID().size();
136 const unsigned int n3D = histo3DMapID().size();
137 const unsigned int n1DP = profile1DMapID().size();
138 const unsigned int n2DP = profile2DMapID().size();
139 const unsigned int total = n1D + n2D + n3D + n1DP + n2DP;
141 this->always() <<
"Booked " << total <<
" Histogram(s) : ";
142 if ( n1D > 0 ) this->always() <<
"1D=" << n1D <<
" ";
143 if ( n2D > 0 ) this->always() <<
"2D=" << n2D <<
" ";
144 if ( n3D > 0 ) this->always() <<
"3D=" << n3D <<
" ";
145 if ( n1DP > 0 ) this->always() <<
"1DProf=" << n1DP <<
" ";
146 if ( n2DP > 0 ) this->always() <<
"2DProf=" << n2DP <<
" ";
152 if ( histosPrint() ) { printHistos(); }
156 m_histo1DMapTitle.clear();
157 m_histo2DMapTitle.clear();
158 m_histo3DMapTitle.clear();
159 m_histo1DMapID.clear();
160 m_histo2DMapID.clear();
161 m_histo3DMapID.clear();
162 m_profile1DMapTitle.clear();
163 m_profile2DMapTitle.clear();
164 m_profile1DMapID.clear();
165 m_profile2DMapID.clear();
168 return PBASE::finalize();
173 template <
class PBASE>
178 if ( this->msgLevel(
MSG::DEBUG ) ) { this->msgStream(
level ) <<
"No histograms are booked" <<
endmsg; }
186 if ( !histo1DMapID().empty() ) {
187 msg <<
"1D histograms in directory "
188 <<
"\"" << histoPath() <<
"\" : " << histo1DMapID().size();
193 for (
const auto& entry : ordered( histo1DMapID() ) ) {
194 const auto* aida = entry.second;
196 this->error() <<
"IHistogram1D points to NULL" <<
endmsg;
205 if ( !histo2DMapID().empty() ) {
206 msg <<
"2D histograms in directory "
207 <<
"\"" << histoPath() <<
"\" : " << histo2DMapID().size();
209 for (
const auto& entry : ordered( histo2DMapID() ) ) {
210 const auto* aida = entry.second;
212 this->error() <<
"IHistogram2D points to NULL" <<
endmsg;
220 if ( !histo3DMapID().empty() ) {
221 msg <<
"3D histograms in directory "
222 <<
"\"" << histoPath() <<
"\" : " << histo3DMapID().size();
223 for (
const auto& entry : ordered( histo3DMapID() ) ) {
224 const auto* aida = entry.second;
226 this->error() <<
"IHistogram3D points to NULL" <<
endmsg;
234 if ( !profile1DMapID().empty() ) {
235 msg <<
"1D profile histograms in directory "
236 <<
"\"" << histoPath() <<
"\" : " << profile1DMapID().size();
241 for (
const auto& entry : ordered( profile1DMapID() ) ) {
242 const auto* aida = entry.second;
244 this->error() <<
"IProfile1D points to NULL" <<
endmsg;
252 if ( !profile2DMapID().empty() ) {
253 msg <<
"2D profile histograms in directory "
254 <<
"\"" << histoPath() <<
"\" : " << profile2DMapID().size();
255 for (
const auto& entry : ordered( profile2DMapID() ) ) {
256 const auto* aida = entry.second;
258 this->error() <<
"IProfile2D points to NULL" <<
endmsg;
266 return this->totalNumberOfHistos();
271 template <
class PBASE>
273 return ( histo1DMapTitle().empty() && histo2DMapTitle().empty() && histo3DMapTitle().empty() &&
274 profile1DMapTitle().empty() && profile2DMapTitle().empty() && histo1DMapID().empty() &&
275 histo2DMapID().empty() && histo3DMapID().empty() && profile1DMapID().empty() && profile2DMapID().empty() );
280 template <
class PBASE>
282 if ( hist && m_declareMoniHists ) {
284 this->debug() <<
"Monitoring histogram '" << ID.
idAsString() <<
"' desc = '"
293 template <
class PBASE>
295 return lookup_( histo1DMapID(), ID );
300 template <
class PBASE>
302 return lookup_( histo2DMapID(), ID );
307 template <
class PBASE>
309 return lookup_( histo3DMapID(), ID );
314 template <
class PBASE>
316 return lookup_( profile1DMapID(), ID );
321 template <
class PBASE>
323 return lookup_( profile2DMapID(), ID );
328 template <
class PBASE>
330 return histo1DMapID().size() + histo2DMapID().size() + histo3DMapID().size() + profile1DMapID().size() +
331 profile2DMapID().size();
336 template <
class PBASE>
338 if ( useNumericAutoIDs() || title.
empty() ) {
339 if ( !useNumericAutoIDs() ) {
341 "Cannot generate automatic literal ID from an empty title ! Using numeric ID instead for histogram ID",
346 ID =
HistoID( totalNumberOfHistos() + 1 + histoOffSet() );
351 ID =
HistoID( this->convertTitleToID( title ) );
359 template <
class PBASE>
362 for (
const auto& i : m_idReplaceInfo ) { stringSearchReplace( title, i.first, i.second ); }
367 template <
class PBASE>
370 return splitHistoDir() ? dirHbookName(
path ) :
path;
391 #endif // GAUDIALG_GAUDIHISTOS_ICPP