| # Gaudi Framework, version v21r10p1 |

Home |  | Generated: 29 Jul 2010

# GaudiHistos_1DVariableBinning.icpp

Go to the documentation of this file.

    00001 // ==================================== 1D ====================================
    00002 // ============================= Variable Binning =============================
    00003 // ============================================================================
    00004 // book the 1D histogram (book on demand)
    00005 // ============================================================================
    00006 template <class PBASE>
    00007 AIDA::IHistogram1D*  GaudiHistos<PBASE>::book1D
    00008 ( const std::string&   title        ,
    00009   const HistoBinEdges& edges        ) const
    00010 {
    00011   // exist?
    00012   AIDA::IHistogram1D* hist = histo1D ( title ) ;
    00013   // histogram is already booked
    00014   if( NULL != hist      )                      { return hist ; } // RETURN !!
    00015
    00016   // propose the histogram ID
    00017   HistoID ID;
    00018   newHistoID( title, ID );
    00019
    00020   // Create a new histogram and return
    00021   return this -> book1D ( ID, title, edges );
    00022 }
    00023 // ============================================================================
    00024 // book the 1D histogram with forced ID (book on demand)
    00025 // ============================================================================
    00026 template <class PBASE>
    00027 AIDA::IHistogram1D*  GaudiHistos<PBASE>::book1D
    00028 ( const HistoID&       ID           ,
    00029   const std::string&   title        ,
    00030   const HistoBinEdges& edges        ) const
    00031 {
    00032   // Check ID
    00033   if (ID.undefined())
    00034   {
    00035     this->Error("Undefined Histogram ID : Title='"+title+"'");
    00036     return NULL;
    00037   }
    00038
    00039   // exist?
    00040   AIDA::IHistogram1D* hist = histo1D ( ID ) ;
    00041   // histogram is already booked
    00042   if ( NULL != hist       )                    { return hist ; } // RETURN !!
    00043
    00044   // Histogram title
    00045   const std::string & htitle =
    00046     ( title.empty() ? "Unnamed 1D Histogram ID="+ID.idAsString() : title ) ;
    00047
    00048   // book the histogram
    00049   if ( ID.numeric() )
    00050   {
    00051     hist = this->histoSvc() -> book ( histoPath()  ,
    00052                                       ID.numericID() ,
    00053                                       htitle       ,
    00054                                       edges     ) ;
    00055   }
    00056   else if ( ID.literal() )
    00057   {
    00058     hist = this->histoSvc() -> book ( histoPath()+"/"+
    00059                                       ID.literalID() ,
    00060                                       htitle         ,
    00061                                       edges        ) ;
    00062   }
    00063
    00064   // check OK
    00065   if( NULL == hist )
    00066   { this->Error( "IHistogram1D* points to NULL! ID='" + ID.idAsString() +
    00067                  "' title='"+htitle+"'" ) ; return NULL; } // RETURN !!
    00068
    00069   // add histogram into histogram storages
    00070   m_histo1DMapID    [ ID    ] = hist ;
    00071   m_histo1DMapTitle [ title ] = hist ;
    00072
    00073   // Declare to monitoring service
    00074   monitorHisto( Gaudi::Utils::Histos::toBase ( hist ) , ID );
    00075
    00076   // Printout and return
    00077   if ( this->msgLevel(MSG::DEBUG) )
    00078   { this->debug() << "Booked 1D Histogram : ID='" << ID
    00079                   << "' Path=" << histoPath()
    00080                   << " Title='"
    00081                   << Gaudi::Utils::Histos::htitle ( hist )
    00082                   << "'" << endmsg; }
    00083   return hist ;
    00084 }
    00085 // ============================================================================
    00086 // fill the 1D histogram (book on demand)
    00087 // ============================================================================
    00088 template <class PBASE>
    00089 AIDA::IHistogram1D*
    00090 GaudiHistos<PBASE>::plot1D
    00091 ( const double         value  ,
    00092   const std::string&   title  ,
    00093   const HistoBinEdges& edges  ,
    00094   const double         weight ) const
    00095 {
    00096   AIDA::IHistogram1D * h(NULL);
    00097   if ( produceHistos() )
    00098   {
    00099     // retrieve or book the histogram
    00100     h = histo1D ( title ) ;
    00101     if ( NULL == h ) { h = book1D ( title , edges ) ; }
    00102     // fill the histogram
    00103     h = fill ( h , value , weight , title );
    00104   }
    00105   return h;
    00106 }
    00107 // ============================================================================
    00108 // fill the 1D variable histogram with forced ID assignment (book on demand)
    00109 // ============================================================================
    00110 template <class PBASE>
    00111 AIDA::IHistogram1D*
    00112 GaudiHistos<PBASE>::plot1D
    00113 ( const double        value  ,
    00114   const HistoID&      ID     ,
    00115   const std::string&  title  ,
    00116   const HistoBinEdges&        edges  ,
    00117   const double        weight ) const
    00118 {
    00119   AIDA::IHistogram1D* h(NULL);
    00120   if ( produceHistos() )
    00121   {
    00122     // retrieve or book the histogram
    00123     h = histo1D ( ID ) ;
    00124     if ( NULL == h ) {  h = book1D ( ID , title , edges ) ; }
    00125     // fill
    00126     h = fill ( h , value , weight , title ) ;
    00127   }
    00128   return h;
    00129 }