1 #ifndef GAUDIALG_GAUDIHISTOS_ICPP 2 #define GAUDIALG_GAUDIHISTOS_ICPP 1 51 constexpr
struct ordered_t {
59 template <
typename Map>
60 typename Map::mapped_type lookup_(
const Map&
map,
const typename Map::key_type& ID )
62 auto found = map.find( ID );
63 return found !=
std::end( map ) ? found->second :
nullptr;
79 template <
class PBASE>
87 template <
class PBASE>
101 if ( !produceHistos() ) {
102 this->debug() <<
"Histogram production is switched OFF" <<
endmsg;
107 if ( !this->histoSvc() ) {
108 return this->Error(
"initialize():: IHistogramSvc* is invalid" );
112 if ( useNumericAutoIDs() ) {
114 "Using numerical automatic IDs. These are not guaranteed to be totally deterministic. Use with care...",
129 template <
class PBASE>
139 if ( produceHistos() ) {
142 if ( ( !noHistos() ) && histoCountersPrint() ) {
143 const unsigned int n1D = histo1DMapID().size();
144 const unsigned int n2D = histo2DMapID().size();
145 const unsigned int n3D = histo3DMapID().size();
146 const unsigned int n1DP = profile1DMapID().size();
147 const unsigned int n2DP = profile2DMapID().size();
148 const unsigned int total = n1D + n2D + n3D + n1DP + n2DP;
150 this->always() <<
"Booked " << total <<
" Histogram(s) : ";
151 if ( n1D > 0 ) this->always() <<
"1D=" << n1D <<
" ";
152 if ( n2D > 0 ) this->always() <<
"2D=" << n2D <<
" ";
153 if ( n3D > 0 ) this->always() <<
"3D=" << n3D <<
" ";
154 if ( n1DP > 0 ) this->always() <<
"1DProf=" << n1DP <<
" ";
155 if ( n2DP > 0 ) this->always() <<
"2DProf=" << n2DP <<
" ";
161 if ( histosPrint() ) {
167 m_histo1DMapTitle.clear();
168 m_histo2DMapTitle.clear();
169 m_histo3DMapTitle.clear();
170 m_histo1DMapID.clear();
171 m_histo2DMapID.clear();
172 m_histo3DMapID.clear();
173 m_profile1DMapTitle.clear();
174 m_profile2DMapTitle.clear();
175 m_profile1DMapID.clear();
176 m_profile2DMapID.clear();
179 return PBASE::finalize();
184 template <
class PBASE>
191 this->msgStream( level ) <<
"No histograms are booked" <<
endmsg;
202 if ( !histo1DMapID().empty() ) {
203 msg <<
"List of booked 1D histograms in directory " 204 <<
"\"" << histoPath() <<
"\" :-";
209 for (
const auto& entry : ordered( histo1DMapID() ) ) {
210 const auto* aida = entry.second;
212 this->error() <<
"IHistogram1D points to NULL" <<
endmsg;
221 if ( !histo2DMapID().empty() ) {
222 msg <<
"List of booked 2D histograms in directory " 223 <<
"\"" << histoPath() <<
"\" :-";
225 for (
const auto& entry : ordered( histo2DMapID() ) ) {
226 const auto* aida = entry.second;
228 this->error() <<
"IHistogram2D points to NULL" <<
endmsg;
236 if ( !histo3DMapID().empty() ) {
237 msg <<
"List of booked 3D histograms in directory " 238 <<
"\"" << histoPath() <<
"\" :-";
239 for (
const auto& entry : ordered( histo3DMapID() ) ) {
240 const auto* aida = entry.second;
242 this->error() <<
"IHistogram3D points to NULL" <<
endmsg;
250 if ( !profile1DMapID().empty() ) {
251 msg <<
"List of booked 1D profile histograms in directory " 252 <<
"\"" << histoPath() <<
"\" :-";
253 for (
const auto& entry : ordered( profile1DMapID() ) ) {
254 const auto* aida = entry.second;
256 this->error() <<
"IProfile1D points to NULL" <<
endmsg;
264 if ( !profile2DMapID().empty() ) {
265 msg <<
"List of booked 2D profile histograms in directory " 266 <<
"\"" << histoPath() <<
"\" :-";
267 for (
const auto& entry : ordered( profile2DMapID() ) ) {
268 const auto* aida = entry.second;
270 this->error() <<
"IProfile2D points to NULL" <<
endmsg;
278 return this->totalNumberOfHistos();
283 template <
class PBASE>
286 return ( histo1DMapTitle().empty() && histo2DMapTitle().empty() && histo3DMapTitle().empty() &&
287 profile1DMapTitle().empty() && profile2DMapTitle().empty() && histo1DMapID().empty() &&
288 histo2DMapID().empty() && histo3DMapID().empty() && profile1DMapID().empty() && profile2DMapID().empty() );
293 template <
class PBASE>
296 if ( hist && m_declareMoniHists ) {
298 this->debug() <<
"Monitoring histogram '" << ID.
idAsString() <<
"' desc = '" 307 template <
class PBASE>
310 return lookup_( histo1DMapID(), ID );
315 template <
class PBASE>
318 return lookup_( histo2DMapID(), ID );
323 template <
class PBASE>
326 return lookup_( histo3DMapID(), ID );
331 template <
class PBASE>
334 return lookup_( profile1DMapID(), ID );
339 template <
class PBASE>
342 return lookup_( profile2DMapID(), ID );
347 template <
class PBASE>
350 return histo1DMapID().size() + histo2DMapID().size() + histo3DMapID().size() + profile1DMapID().size() +
351 profile2DMapID().size();
356 template <
class PBASE>
359 if ( useNumericAutoIDs() || title.
empty() ) {
360 if ( !useNumericAutoIDs() ) {
362 "Cannot generate automatic literal ID from an empty title ! Using numeric ID instead for histogram ID",
367 ID =
HistoID( totalNumberOfHistos() + 1 + histoOffSet() );
369 while ( histoExists( ID ) ) {
374 ID =
HistoID( this->convertTitleToID( title ) );
376 while ( histoExists( ID ) ) {
384 template <
class PBASE>
388 for (
const auto& i : m_idReplaceInfo ) {
389 stringSearchReplace( title, i.first, i.second );
396 template <
class PBASE>
403 if ( this->histosPrint() ) {
410 template <
class PBASE>
414 return splitHistoDir() ? dirHbookName( path ) :
path;
435 #endif // GAUDIALG_GAUDIHISTOS_ICPP
Definition of the MsgStream class used to transmit messages.
GAUDI_API std::string htitle(const AIDA::IBaseHistogram *histo, const std::string &title="")
get the title
AIDA::IHistogram2D * histo2D(const std::string &title) const
access the EXISTING 2D histogram by title return the pointer to existing 2D histogram or NULL ...
int printHistos(const MSG::Level level=MSG::ALWAYS) const
perform the actual printout of histograms
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)
bool noHistos() const
Check if all histogram maps are empty.
GaudiAlg::ID HistoID
The actual type for histogram identifier.
void newHistoID(const std::string &title, HistoID &ID) const
Create a new histogram ID using the given title.
GAUDI_API std::string format(const AIDA::IHistogram1D *histo, const std::string &fmt)
Make the string representation of the historgam according to the specified format.
Collection of useful utilities for manipulations with AIDA hisgograms.
few useful function to construct names of Hbook histograms and directories functions are imported fro...
const std::string & header() const
the table header
void monitorHisto(const AIDA::IBaseHistogram *hist, const HistoID &ID) const
Declare a histogram to the monitor service.
AIDA::IHistogram1D * histo1D(const std::string &title) const
access the EXISTING 1D histogram by title return the pointer to existing 1D histogram or NULL ...
struct GAUDI_API map
Parametrisation class for map-like implementation.
This class is used for returning status codes from appropriate routines.
void printHistoHandler(Gaudi::Details::PropertyBase &)
the handler for "HistoPrint" property
T find_first_of(T...args)
unsigned int totalNumberOfHistos() const
Returns the total number of histograms (of all types) currently booked.
Simple class for the customizeble printout of the histogram tables.
collection of useful utilities to print certain objects (currently used for implementation in class G...
static std::string toString(const AIDA::IHistogram3D *aida, const GaudiAlg::HistoID &ID)
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
constexpr static const auto SUCCESS
std::string histoPath() const
get the constructed histogram path
virtual Out operator()(const vector_of_const_< In > &inputs) const =0
GAUDI_API LiteralID idAsString() const
Return ID as string, for both numeric and literal IDs.
bool numeric() const noexcept
Is this ID numeric.
static std::string toString(const AIDA::IHistogram2D *aida, const GaudiAlg::HistoID &ID)
Templated base class providing common histogramming methods for GaudiAlgorithm and GaudiTool like cla...
static std::string toString(const AIDA::IProfile1D *aida, const GaudiAlg::HistoID &ID)
std::string convertTitleToID(std::string title) const
Create an ID string from a title string.
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)
KeyedObjectManager< map > Map
Forward declaration of specialized std::map-like object manager.
static std::string toString(const AIDA::IProfile2D *aida, const GaudiAlg::HistoID &ID)
ID class for Histogram and Ntuples.
AIDA::IHistogram3D * histo3D(const std::string &title) const
access the EXISTING 3D histogram by title return the pointer to existing 3D histogram or NULL ...
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
std::string toString(const AIDA::IHistogram1D *histo) const
make the string representation according to the default format
void initGaudiHistosConstructor()
Constructor initialisation and job options.