Warning, /include/GaudiAlg/GaudiHistos_2DProfFixedBinning.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 2D profile histogram (book on demand)
0013 // ============================================================================
0014 template <class PBASE>
0015 AIDA::IProfile2D* GaudiHistos<PBASE>::bookProfile2D( const std::string& title, const double lowX, const double highX,
0016 const unsigned long binsX, const double lowY, const double highY,
0017 const unsigned long binsY ) const {
0018 //
0019 if ( !produceHistos() ) { return 0; } // RETURN
0020 //
0021 // exist?
0022 auto hist = profile2D( title );
0023 // histogram is already booked
0024 if ( 0 != hist ) { return hist; } // RETURN !!
0025
0026 // propose the histogram ID
0027 HistoID ID;
0028 newHistoID( title, ID );
0029
0030 // book histogram and return
0031 return this->bookProfile2D( ID, title, lowX, highX, binsX, lowY, highY, binsY );
0032 }
0033 // ============================================================================
0034 // book the 2D profile histogram with forced ID (book on demand)
0035 // ============================================================================
0036 template <class PBASE>
0037 AIDA::IProfile2D* GaudiHistos<PBASE>::bookProfile2D( const HistoID& ID, const std::string& title, const double lowX,
0038 const double highX, const unsigned long binsX, const double lowY,
0039 const double highY, const unsigned long binsY ) const {
0040 //
0041 if ( !produceHistos() ) { return 0; } // RETURN
0042 //
0043 // Check ID
0044 if ( ID.undefined() ) {
0045 this->Error( "Undefined Histogram ID : Title='" + title + "'" ).ignore();
0046 return nullptr;
0047 }
0048 // exist?
0049 auto hist = profile2D( ID );
0050 // histogram is already booked
0051 if ( 0 != hist ) { return hist; } // RETURN !!
0052
0053 // Histogram title
0054 const std::string& htitle = ( title.empty() ? "Unnamed 2D Profile Histogram ID=" + ID.idAsString() : title );
0055
0056 // book the histogram
0057 if ( ID.numeric() ) {
0058 hist = this->histoSvc()->bookProf( histoPath(), ID.numericID(), htitle, binsX, lowX, highX, binsY, lowY, highY );
0059 } else if ( ID.literal() ) {
0060 hist = this->histoSvc()->bookProf( histoPath() + "/" + ID.literalID(), htitle, binsX, lowX, highX, binsY, lowY,
0061 highY );
0062 }
0063
0064 // test OK
0065 if ( 0 == hist ) {
0066 this->Error( "IProfile2D* points to NULL! ID='" + ID.idAsString() + "' title='" + htitle + "'" ).ignore();
0067 return 0;
0068 } // RETURN !!
0069
0070 // add histogram into histogram storages
0071 m_profile2DMapID[ID] = hist;
0072 m_profile2DMapTitle[title] = hist;
0073
0074 // Declare to monitoring service
0075 monitorHisto( Gaudi::Utils::Histos::toBase( hist ), ID );
0076
0077 // printout and return
0078 if ( this->msgLevel( MSG::DEBUG ) ) {
0079 this->debug() << "Booked 2D Profile Histogram : ID='" << ID << "' Path=" << histoPath() << " Title='"
0080 << Gaudi::Utils::Histos::htitle( hist ) << "'" << endmsg;
0081 }
0082 return hist;
0083 }
0084 // ============================================================================
0085 // fill the 2D profile histogram with the value and weight
0086 // ============================================================================
0087 template <class PBASE>
0088 AIDA::IProfile2D* GaudiHistos<PBASE>::fill( AIDA::IProfile2D* histo, const double valueX, const double valueY,
0089 const double valueZ, const double weight, const std::string& title ) const {
0090 if ( 0 == histo ) { return 0; } // RETURN
0091 //
0092 if ( !checkForNaN() ) {
0093 Gaudi::Utils::Histos::fill( histo, valueX, valueY, valueZ, weight );
0094 } else if ( std::isfinite( valueX ) && std::isfinite( valueY ) && std::isfinite( valueZ ) &&
0095 std::isfinite( weight ) ) {
0096 Gaudi::Utils::Histos::fill( histo, valueX, valueY, valueZ, weight );
0097 } else if ( std::isnan( valueX ) || std::isnan( valueY ) || std::isnan( valueZ ) || std::isnan( weight ) ) {
0098 this->Warning( "fill():: 'NaN' value is skipped from the histogram '" +
0099 Gaudi::Utils::Histos::htitle( histo, title ) + "'" )
0100 .ignore();
0101 } else {
0102 this->Warning( "fill():: 'Infinite' value is skipped from the histogram '" +
0103 Gaudi::Utils::Histos::htitle( histo, title ) + "'" )
0104 .ignore();
0105 }
0106 // return
0107 return histo;
0108 }
0109 // ============================================================================
0110 // fill the 2D profile histogram (book on demand)
0111 // ============================================================================
0112 template <class PBASE>
0113 AIDA::IProfile2D* GaudiHistos<PBASE>::profile2D( const double valueX, const double valueY, const double valueZ,
0114 const std::string& title, const double lowX, const double highX,
0115 const double lowY, const double highY, const unsigned long binsX,
0116 const unsigned long binsY, const double weight ) const {
0117 AIDA::IProfile2D* h = nullptr;
0118 if ( produceHistos() ) {
0119 // retrieve or book the histogram
0120 h = profile2D( title );
0121 if ( 0 == h ) { h = bookProfile2D( title, lowX, highX, binsX, lowY, highY, binsY ); }
0122 // fill the histogram
0123 h = fill( h, valueX, valueY, valueZ, weight, title );
0124 }
0125 return h;
0126 }
0127 // ============================================================================
0128 // fill the 2D profile histogram with forced ID assignment (book on demand)
0129 // ============================================================================
0130 template <class PBASE>
0131 AIDA::IProfile2D* GaudiHistos<PBASE>::profile2D( const double valueX, const double valueY, const double valueZ,
0132 const HistoID& ID, const std::string& title, const double lowX,
0133 const double highX, const double lowY, const double highY,
0134 const unsigned long binsX, const unsigned long binsY,
0135 const double weight ) const {
0136 AIDA::IProfile2D* h = nullptr;
0137 if ( produceHistos() ) {
0138 // retrieve or book the histogram
0139 h = profile2D( ID );
0140 if ( 0 == h ) { h = bookProfile2D( ID, title, lowX, highX, binsX, lowY, highY, binsY ); }
0141 // fill the histogram
0142 h = fill( h, valueX, valueY, valueZ, weight, title );
0143 }
0144 return h;
0145 }
0146 // ============================================================================
0147 // The END
0148 // ============================================================================