Warning, /include/GaudiAlg/GaudiHistos_1DProfFixedBinning.icpp is written in an unsupported language. File is not indexed.
0001 /***********************************************************************************\
0002 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
0003 * *
0004 * This software is distributed under the terms of the Apache version 2 licence, *
0005 * copied verbatim in the file "LICENSE". *
0006 * *
0007 * In applying this licence, CERN does not waive the privileges and immunities *
0008 * granted to it by virtue of its status as an Intergovernmental Organization *
0009 * or submit itself to any jurisdiction. *
0010 \***********************************************************************************/
0011 // ============================================================================
0012 // book the 1D profile histogram (book on demand)
0013 // ============================================================================
0014 template <class PBASE>
0015 AIDA::IProfile1D* GaudiHistos<PBASE>::bookProfile1D( const std::string& title, const double low, const double high,
0016 const unsigned long bins, const std::string& opt,
0017 const double lowY, const double highY ) const {
0018 //
0019 if ( !produceHistos() ) { return nullptr; } // RETURN
0020 //
0021 // exist?
0022 auto hist = profile1D( title );
0023 // histogram is already booked
0024 if ( hist ) { return hist; } // RETURN !!
0025
0026 // propose the histogram ID
0027 HistoID ID;
0028 newHistoID( title, ID );
0029
0030 // Book the histo and return
0031 return this->bookProfile1D( ID, title, low, high, bins, opt, lowY, highY );
0032 }
0033 // ============================================================================
0034 // book the 1D profile histogram with forced ID (book on demand)
0035 // ============================================================================
0036 template <class PBASE>
0037 AIDA::IProfile1D* GaudiHistos<PBASE>::bookProfile1D( const HistoID& ID, const std::string& title, const double low,
0038 const double high, const unsigned long bins,
0039 const std::string& opt, const double lowY,
0040 const double highY ) const {
0041 //
0042 if ( !produceHistos() ) { return nullptr; } // RETURN
0043 //
0044 // Check ID
0045 if ( ID.undefined() ) {
0046 this->Error( "Undefined Histogram ID : Title='" + title + "'" ).ignore();
0047 return nullptr;
0048 }
0049
0050 // exist?
0051 auto hist = profile1D( ID );
0052 // histogram is already booked
0053 if ( hist ) { return hist; } // RETURN !!
0054
0055 // Histogram title
0056 const std::string& htitle = ( title.empty() ? "Unnamed 1D Profile Histogram ID=" + ID.idAsString() : title );
0057
0058 // book the histogram
0059 if ( ID.numeric() ) {
0060 hist = this->histoSvc()->bookProf( histoPath(), ID.numericID(), htitle, bins, low, high, lowY, highY, opt );
0061 } else if ( ID.literal() ) {
0062 hist = this->histoSvc()->bookProf( histoPath() + "/" + ID.literalID(), htitle, bins, low, high, lowY, highY, opt );
0063 }
0064
0065 // test ok
0066 if ( !hist ) {
0067 this->Error( "IProfile1D* points to NULL! ID='" + ID.idAsString() + "' title='" + htitle + "'" ).ignore();
0068 return nullptr;
0069 } // RETURN !!
0070
0071 // add histogram into histogram storages
0072 m_profile1DMapID[ID] = hist;
0073 m_profile1DMapTitle[title] = hist;
0074
0075 // Declare to monitoring service
0076 monitorHisto( Gaudi::Utils::Histos::toBase( hist ), ID );
0077
0078 // printout and return
0079 if ( this->msgLevel( MSG::DEBUG ) ) {
0080 this->debug() << "Booked 1D Profile Histogram : ID='" << ID << "' Path=" << histoPath() << " Title='"
0081 << Gaudi::Utils::Histos::htitle( hist ) << "'" << endmsg;
0082 }
0083 return hist;
0084 }
0085 // ============================================================================
0086 // fill the 1D profile histogram with the value and weight
0087 // ============================================================================
0088 template <class PBASE>
0089 AIDA::IProfile1D* GaudiHistos<PBASE>::fill( AIDA::IProfile1D* histo, const double valueX, const double valueY,
0090 const double weight, const std::string& title ) const {
0091 //
0092 if ( !histo ) { return nullptr; } // RETURN
0093 //
0094 if ( !checkForNaN() ) {
0095 Gaudi::Utils::Histos::fill( histo, valueX, valueY, weight );
0096 } else if ( std::isfinite( valueX ) && std::isfinite( valueY ) && std::isfinite( weight ) ) {
0097 Gaudi::Utils::Histos::fill( histo, valueX, valueY, weight );
0098 } else if ( std::isnan( valueX ) || std::isnan( valueY ) || std::isnan( weight ) ) {
0099 this->Warning( "fill():: 'NaN' value is skipped from the histogram '" +
0100 Gaudi::Utils::Histos::htitle( histo, title ) + "'" )
0101 .ignore();
0102 } else {
0103 this->Warning( "fill():: 'Infinite' value is skipped from the histogram '" +
0104 Gaudi::Utils::Histos::htitle( histo, title ) + "'" )
0105 .ignore();
0106 }
0107 // return
0108 return histo;
0109 }
0110 // ============================================================================
0111 // fill the 1D profile histogram (book on demand)
0112 // ============================================================================
0113 template <class PBASE>
0114 AIDA::IProfile1D* GaudiHistos<PBASE>::profile1D( const double valueX, const double valueY, const std::string& title,
0115 const double lowX, const double highX, const unsigned long binsX,
0116 const std::string& opt, const double lowY, const double highY,
0117 const double weight ) const {
0118 AIDA::IProfile1D* h = nullptr;
0119 if ( produceHistos() ) {
0120 // retrieve or book the histogram
0121 h = profile1D( title );
0122 if ( !h ) { h = bookProfile1D( title, lowX, highX, binsX, opt, lowY, highY ); }
0123 // fill the histogram
0124 h = fill( h, valueX, valueY, weight, title );
0125 }
0126 return h;
0127 }
0128 // ============================================================================
0129 // fill the 1D profile histogram with forced ID assignment (book on demand)
0130 // ============================================================================
0131 template <class PBASE>
0132 AIDA::IProfile1D* GaudiHistos<PBASE>::profile1D( const double valueX, const double valueY, const HistoID& ID,
0133 const std::string& title, const double lowX, const double highX,
0134 const unsigned long binsX, const std::string& opt, const double lowY,
0135 const double highY, const double weight ) const {
0136 AIDA::IProfile1D* h = nullptr;
0137 if ( produceHistos() ) {
0138 // retrieve or book the histogram
0139 h = profile1D( ID );
0140 if ( !h ) { h = bookProfile1D( ID, title, lowX, highX, binsX, opt, lowY, highY ); }
0141 // fill the histogram
0142 h = fill( h, valueX, valueY, weight, title );
0143 }
0144 return h;
0145 }
0146 // ============================================================================
0147 // The END
0148 // ============================================================================