Gaudi Framework, version v21r4

Home   Generated: 7 Sep 2009

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   if      ( ID.numeric() )
00071   { m_histo1DMapNumID [ ID.numericID() ] = hist ; }
00072   else if ( ID.literal() )
00073   { m_histo1DMapLitID [ ID.literalID() ] = hist ; }
00074   m_histo1DMapTitle [ title ] = hist ;
00075 
00076   // Declare to monitoring service
00077   monitorHisto( Gaudi::Utils::Histos::toBase ( hist ) , ID );
00078 
00079   // Printout and return
00080   if ( this->msgLevel(MSG::DEBUG) )
00081   { this->debug() << "Booked 1D Histogram : ID='" << ID
00082                   << "' Path=" << histoPath()
00083                   << " Title='"
00084                   << Gaudi::Utils::Histos::htitle ( hist )
00085                   << "'" << endmsg; }
00086   return hist ;
00087 }
00088 // ============================================================================
00089 // fill the 1D histogram (book on demand)
00090 // ============================================================================
00091 template <class PBASE>
00092 AIDA::IHistogram1D*
00093 GaudiHistos<PBASE>::plot1D
00094 ( const double         value  ,
00095   const std::string&   title  ,
00096   const HistoBinEdges& edges  ,
00097   const double         weight ) const
00098 {
00099   AIDA::IHistogram1D * h(NULL);
00100   if ( produceHistos() )
00101   {
00102     // retrieve or book the histogram
00103     h = histo1D ( title ) ;
00104     if ( NULL == h ) { h = book1D ( title , edges ) ; }
00105     // fill the histogram
00106     h = fill ( h , value , weight , title );
00107   }
00108   return h;
00109 }
00110 // ============================================================================
00111 // fill the 1D variable histogram with forced ID assignment (book on demand)
00112 // ============================================================================
00113 template <class PBASE>
00114 AIDA::IHistogram1D*
00115 GaudiHistos<PBASE>::plot1D
00116 ( const double        value  ,
00117   const HistoID&      ID     ,
00118   const std::string&  title  ,
00119   const HistoBinEdges&        edges  ,
00120   const double        weight ) const
00121 {
00122   AIDA::IHistogram1D* h(NULL);
00123   if ( produceHistos() )
00124   {
00125     // retrieve or book the histogram
00126     h = histo1D ( ID ) ;
00127     if ( NULL == h ) {  h = book1D ( ID , title , edges ) ; }
00128     // fill
00129     h = fill ( h , value , weight , title ) ;
00130   }
00131   return h;
00132 }

Generated at Mon Sep 7 18:05:34 2009 for Gaudi Framework, version v21r4 by Doxygen version 1.5.6 written by Dimitri van Heesch, © 1997-2004