Gaudi Framework, version v22r0

Home   Generated: 9 Feb 2011

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

Generated at Wed Feb 9 16:24:47 2011 for Gaudi Framework, version v22r0 by Doxygen version 1.6.2 written by Dimitri van Heesch, © 1997-2004