Back to home page

EIC code displayed by LXR

 
 

    


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