Warning, /include/GaudiAlg/GaudiHistos_1DProfVariableBinning.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 HistoBinEdges& edges ) const {
0016 //
0017 if ( !produceHistos() ) { return nullptr; } // RETURN
0018 //
0019 // exist?
0020 auto hist = profile1D( title );
0021 // histogram is already booked
0022 if ( hist ) { return hist; } // RETURN !!
0023
0024 // propose the histogram ID
0025 HistoID ID;
0026 newHistoID( title, ID );
0027
0028 // Book the histo and return
0029 return this->bookProfile1D( ID, title, edges );
0030 }
0031 // ============================================================================
0032 // book the 1D profile histogram with forced ID (book on demand)
0033 // ============================================================================
0034 template <class PBASE>
0035 AIDA::IProfile1D* GaudiHistos<PBASE>::bookProfile1D( const HistoID& ID, const std::string& title,
0036 const HistoBinEdges& edges ) const {
0037 //
0038 if ( !produceHistos() ) { return nullptr; } // RETURN
0039 //
0040 // Check ID
0041 if ( ID.undefined() ) {
0042 this->Error( "Undefined Histogram ID : Title='" + title + "'" ).ignore();
0043 return nullptr;
0044 }
0045
0046 // exist?
0047 auto hist = profile1D( ID );
0048 // histogram is already booked
0049 if ( hist ) { return hist; } // RETURN !!
0050
0051 // Histogram title
0052 const std::string& htitle = ( title.empty() ? "Unnamed 1D Profile Histogram ID=" + ID.idAsString() : title );
0053
0054 // book the histogram
0055 if ( ID.numeric() ) {
0056 hist = this->histoSvc()->bookProf( histoPath(), ID.numericID(), htitle, edges );
0057 } else if ( ID.literal() ) {
0058 hist = this->histoSvc()->bookProf( histoPath() + "/" + ID.literalID(), htitle, edges );
0059 }
0060
0061 // test ok
0062 if ( !hist ) {
0063 this->Error( "IProfile1D* points to NULL! ID='" + ID.idAsString() + "' title='" + htitle + "'" ).ignore();
0064 return nullptr;
0065 } // RETURN !!
0066
0067 // add histogram into histogram storages
0068 m_profile1DMapID[ID] = hist;
0069 m_profile1DMapTitle[title] = hist;
0070
0071 // Declare to monitoring service
0072 monitorHisto( Gaudi::Utils::Histos::toBase( hist ), ID );
0073
0074 // printout and return
0075 if ( this->msgLevel( MSG::DEBUG ) ) {
0076 this->debug() << "Booked 1D Profile Histogram : ID='" << ID << "' Path=" << histoPath() << " Title='"
0077 << Gaudi::Utils::Histos::htitle( hist ) << "'" << endmsg;
0078 }
0079 return hist;
0080 }
0081 // ============================================================================
0082 // fill the 1D profile histogram (book on demand)
0083 // ============================================================================
0084 template <class PBASE>
0085 AIDA::IProfile1D* GaudiHistos<PBASE>::profile1D( const double valueX, const double valueY, const std::string& title,
0086 const HistoBinEdges& edges, const double weight ) const {
0087 AIDA::IProfile1D* h( nullptr );
0088 if ( produceHistos() ) {
0089 // retrieve or book the histogram
0090 h = profile1D( title );
0091 if ( !h ) { h = bookProfile1D( title, edges ); }
0092 // fill the histogram
0093 h = fill( h, valueX, valueY, weight, title );
0094 }
0095 return h;
0096 }
0097 // ============================================================================
0098 // fill the 1D profile histogram with forced ID assignment (book on demand)
0099 // ============================================================================
0100 template <class PBASE>
0101 AIDA::IProfile1D* GaudiHistos<PBASE>::profile1D( const double valueX, const double valueY, const HistoID& ID,
0102 const std::string& title, const HistoBinEdges& edges,
0103 const double weight ) const {
0104 AIDA::IProfile1D* h( nullptr );
0105 if ( produceHistos() ) {
0106 // retrieve or book the histogram
0107 h = profile1D( ID );
0108 if ( !h ) { h = bookProfile1D( ID, title, edges ); }
0109 // fill the histogram
0110 h = fill( h, valueX, valueY, weight, title );
0111 }
0112 return h;
0113 }
0114 // ============================================================================
0115 // The END
0116 // ============================================================================