Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/GaudiAlg/GaudiHistos_3DVariableBinning.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 // ==================================== 3D ====================================
0012 // ============================= Variable Binning =============================
0013 // ============================================================================
0014 // book the 3D histogram (book on demand)
0015 // ============================================================================
0016 template <class PBASE>
0017 AIDA::IHistogram3D* GaudiHistos<PBASE>::book3D( const std::string& title, const HistoBinEdges& edgesX,
0018                                                 const HistoBinEdges& edgesY, const HistoBinEdges& edgesZ ) const {
0019   //
0020   if ( !produceHistos() ) { return nullptr; } // RETURN
0021   //
0022   // exist?
0023   auto hist = histo3D( title );
0024   // histogram is already booked
0025   if ( hist ) { return hist; } // RETURN !!
0026 
0027   // propose the histogram ID
0028   HistoID ID;
0029   newHistoID( title, ID );
0030 
0031   // Create a new histogram and return
0032   return this->book3D( ID, title, edgesX, edgesY, edgesZ );
0033 }
0034 // ============================================================================
0035 // book the 2D histogram with forced ID (book on demand)
0036 // ============================================================================
0037 template <class PBASE>
0038 AIDA::IHistogram3D* GaudiHistos<PBASE>::book3D( const HistoID& ID, const std::string& title,
0039                                                 const HistoBinEdges& edgesX, const HistoBinEdges& edgesY,
0040                                                 const HistoBinEdges& edgesZ ) 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 = histo3D( ID );
0052   // histogram is already booked
0053   if ( hist ) { return hist; } // RETURN !!
0054 
0055   // Histogram title
0056   const std::string& htitle = ( title.empty() ? "Unnamed 3D Histogram ID=" + ID.idAsString() : title );
0057 
0058   // book the histogram
0059   if ( ID.numeric() ) {
0060     hist = this->histoSvc()->book( histoPath(), ID.numericID(), htitle, edgesX, edgesY, edgesZ );
0061   } else if ( ID.literal() ) {
0062     hist = this->histoSvc()->book( histoPath() + "/" + ID.literalID(), htitle, edgesX, edgesY, edgesZ );
0063   }
0064 
0065   // check OK
0066   if ( !hist ) {
0067     this->Error( "IHistogram3D* points to NULL! ID='" + ID.idAsString() + "' title='" + htitle + "'" ).ignore();
0068     return nullptr;
0069   } // RETURN !!
0070 
0071   // add histogram into histogram storages
0072   m_histo3DMapID[ID]       = hist;
0073   m_histo3DMapTitle[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 3D Histogram : ID='" << ID << "' Path=" << histoPath() << " Title='"
0081                   << Gaudi::Utils::Histos::htitle( hist ) << "'" << endmsg;
0082   }
0083   return hist;
0084 }
0085 // ============================================================================
0086 // fill the 3D histogram (book on demand)
0087 // ============================================================================
0088 template <class PBASE>
0089 AIDA::IHistogram3D* GaudiHistos<PBASE>::plot3D( const double valueX, const double valueY, const double valueZ,
0090                                                 const std::string& title, const HistoBinEdges& edgesX,
0091                                                 const HistoBinEdges& edgesY, const HistoBinEdges& edgesZ,
0092                                                 const double weight ) const {
0093   AIDA::IHistogram3D* h( nullptr );
0094   if ( produceHistos() ) {
0095     // retrieve or book the histogram
0096     h = histo3D( title );
0097     if ( !h ) { h = book3D( title, edgesX, edgesY, edgesZ ); }
0098     // fill the histogram
0099     h = fill( h, valueX, valueY, valueZ, weight, title );
0100   }
0101   return h;
0102 }
0103 // ============================================================================
0104 // fill the 3D variable histogram with forced ID assignment (book on demand)
0105 // ============================================================================
0106 template <class PBASE>
0107 AIDA::IHistogram3D* GaudiHistos<PBASE>::plot3D( const double valueX, const double valueY, const double valueZ,
0108                                                 const HistoID& ID, const std::string& title,
0109                                                 const HistoBinEdges& edgesX, const HistoBinEdges& edgesY,
0110                                                 const HistoBinEdges& edgesZ, const double weight ) const {
0111   AIDA::IHistogram3D* h( nullptr );
0112   if ( produceHistos() ) {
0113     // retrieve or book the histogram
0114     h = histo3D( ID );
0115     if ( !h ) { h = book3D( ID, title, edgesX, edgesY, edgesZ ); }
0116     // fill
0117     h = fill( h, valueX, valueY, valueZ, weight, title );
0118   }
0119   return h;
0120 }
0121 // ============================================================================
0122 // The END
0123 // ============================================================================