Gaudi Framework, version v21r11

Home   Generated: 30 Sep 2010

GaudiHistos_1DFixedBinning.icpp

Go to the documentation of this file.
00001 // ==================================== 1D ====================================
00002 // ================================ Fixed 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 double        low          ,
00010   const double        high         ,
00011   const unsigned long bins         ) const
00012 {
00013   //
00014   if  ( !produceHistos() )                   { return 0    ; } // RETURN
00015   //
00016   // exist?
00017   AIDA::IHistogram1D* hist = histo1D ( title ) ;
00018   // histogram is already booked
00019   if( NULL != hist      )                    { return hist ; } // RETURN !!
00020 
00021   // propose the histogram ID
00022   HistoID ID;
00023   newHistoID( title, ID );
00024 
00025   // Create a new histogram and return
00026   return this -> book1D ( ID, title, low, high, bins );
00027 }
00028 // ============================================================================
00029 // book the 1D histogram with forced ID (book on demand)
00030 // ============================================================================
00031 template <class PBASE>
00032 AIDA::IHistogram1D*  GaudiHistos<PBASE>::book1D
00033 ( const HistoID&                ID     ,
00034   const std::string&            title  ,
00035   const double                  low    ,
00036   const double                  high   ,
00037   const unsigned long           bins   ) const
00038 {
00039   //
00040   if  ( !produceHistos() ) { return 0 ; }  // RETURN
00041   //
00042 
00043   // Check ID
00044   if ( ID.undefined() )
00045   {
00046     this->Error("Undefined Histogram ID : Title='"+title+"'");
00047     return NULL;
00048   }
00049 
00050   // exist?
00051   AIDA::IHistogram1D* hist = histo1D ( ID ) ;
00052   // histogram is already booked
00053   if ( NULL != hist       )                  { return hist ; } // RETURN !!
00054 
00055   // Histogram title
00056   const std::string & htitle =
00057     ( title.empty() ? "Unnamed 1D Histogram ID="+ID.idAsString() : title ) ;
00058 
00059   // book the histogram
00060   if ( ID.numeric() )
00061   {
00062     hist = this->histoSvc() -> book ( histoPath()  ,
00063                                       ID.numericID() ,
00064                                       htitle       ,
00065                                       bins         ,
00066                                       low          ,
00067                                       high         ) ;
00068   }
00069   else if ( ID.literal() )
00070   {
00071     hist = this->histoSvc() -> book ( histoPath()+"/"+
00072                                       ID.literalID() ,
00073                                       htitle         ,
00074                                       bins           ,
00075                                       low            ,
00076                                       high         ) ;
00077   }
00078 
00079   // check OK
00080   if( NULL == hist )
00081   { this->Error( "IHistogram1D* points to NULL! ID='" + ID.idAsString() +
00082                  "' title='"+htitle+"'" ) ; return NULL; } // RETURN !!
00083 
00084   // add histogram into histogram storages
00085   m_histo1DMapID    [ ID    ] = hist ;
00086   m_histo1DMapTitle [ title ] = hist ;
00087 
00088   // Declare to monitoring service
00089   monitorHisto( Gaudi::Utils::Histos::toBase ( hist ) , ID );
00090 
00091   // Printout and return
00092   if ( this->msgLevel(MSG::DEBUG) )
00093   { this->debug() << "Booked 1D Histogram : ID='" << ID
00094                   << "' Path=" << histoPath()
00095                   << " Title='"
00096                   << Gaudi::Utils::Histos::htitle ( hist )
00097                   << "'" << endmsg; }
00098   return hist ;
00099 }
00100 // ============================================================================
00101 // fill the 1D histogram with the value and weight
00102 // ============================================================================
00103 template <class PBASE>
00104 AIDA::IHistogram1D* GaudiHistos<PBASE>::fill
00105 ( AIDA::IHistogram1D*  histo  ,
00106   const double         value  ,
00107   const double         weight ,
00108   const std::string&   title  ) const
00109 {
00110   if ( 0 == histo     ) { return 0 ; }                          // RETURN
00111   //
00112   if ( !checkForNaN() )
00113   { Gaudi::Utils::Histos::fill ( histo , value , weight ) ; }
00114   else if  ( lfin ( value ) && lfin ( weight ) )
00115   { Gaudi::Utils::Histos::fill ( histo , value , weight ) ; }
00116   else if  ( lnan ( value ) || lnan ( weight ) )
00117   {
00118     this -> Warning
00119       ("fill():: 'NaN'      value is skipped from the histogram '"
00120        + Gaudi::Utils::Histos::htitle ( histo , title ) + "'" ) ;
00121   }
00122   else
00123   {
00124     this -> Warning
00125       ("fill():: 'Infinite' value is skipped from the histogram '"
00126        + Gaudi::Utils::Histos::htitle ( histo , title ) + "'" ) ;
00127   }
00128   // return
00129   return histo ;
00130 }
00131 // ============================================================================
00132 // fill the 1D histogram (book on demand)
00133 // ============================================================================
00134 template <class PBASE>
00135 AIDA::IHistogram1D*
00136 GaudiHistos<PBASE>::plot1D
00137 ( const double        value  ,
00138   const std::string&  title  ,
00139   const double        low    ,
00140   const double        high   ,
00141   const unsigned long bins   ,
00142   const double        weight ) const
00143 {
00144   AIDA::IHistogram1D * h(NULL);
00145   if ( produceHistos() )
00146   {
00147     // retrieve or book the histogram
00148     h = histo1D ( title ) ;
00149     if ( NULL == h ) { h = book1D  ( title , low , high , bins ) ; }
00150     // fill the histogram
00151     h = fill ( h , value , weight , title );
00152   }
00153   return h;
00154 }
00155 // ============================================================================
00156 // fill the 1D histogram with forced ID assignment (book on demand)
00157 // ============================================================================
00158 template <class PBASE>
00159 AIDA::IHistogram1D*
00160 GaudiHistos<PBASE>::plot1D
00161 ( const double        value  ,
00162   const HistoID&      ID     ,
00163   const std::string&  title  ,
00164   const double        low    ,
00165   const double        high   ,
00166   const unsigned long bins   ,
00167   const double        weight ) const
00168 {
00169   AIDA::IHistogram1D* h(NULL);
00170   if ( produceHistos() )
00171   {
00172     // retrieve or book the histogram
00173     h = histo1D ( ID ) ;
00174     if ( NULL == h ) {  h = book1D ( ID , title , low , high , bins ) ; }
00175     // fill
00176     h = fill ( h , value , weight , title ) ;
00177   }
00178   return h;
00179 }
00180 // ============================================================================
00181 // book the 1D histogram
00182 // ============================================================================
00183 template <class PBASE>
00184 AIDA::IHistogram1D*
00185 GaudiHistos<PBASE>::book
00186 ( const Gaudi::Histo1DDef& hdef ) const
00187 {
00188   return book1D ( hdef.title    () ,
00189                   hdef.lowEdge  () ,
00190                   hdef.highEdge () ,
00191                   hdef.bins     () ) ;
00192 }
00193 // ============================================================================
00194 // book the 1D histogram with forced ID
00195 // ============================================================================
00196 template <class PBASE>
00197 AIDA::IHistogram1D*
00198 GaudiHistos<PBASE>::book
00199 ( const HistoID&           ID   ,
00200   const Gaudi::Histo1DDef& hdef ) const
00201 {
00202   return book1D ( ID               ,
00203                   hdef.title    () ,
00204                   hdef.lowEdge  () ,
00205                   hdef.highEdge () ,
00206                   hdef.bins     () ) ;
00207 }
00208 // ============================================================================
00209 // fill the 1D histogram (book on demand)
00210 // ============================================================================
00211 template <class PBASE>
00212 AIDA::IHistogram1D*
00213 GaudiHistos<PBASE>::plot1D
00214 ( const double             value  ,
00215   const Gaudi::Histo1DDef& hdef   ,
00216   const double             weight ) const
00217 {
00218   return plot1D
00219     ( value  ,
00220       hdef.title() , hdef.lowEdge() , hdef.highEdge() , hdef.bins() ,
00221       weight ) ;
00222 }
00223 // ============================================================================
00224 // fill the 1D histogram with forced ID assignment (book on demand)
00225 // ============================================================================
00226 template <class PBASE>
00227 AIDA::IHistogram1D*
00228 GaudiHistos<PBASE>::plot1D
00229 ( const double             value  ,
00230   const HistoID&           ID     ,
00231   const Gaudi::Histo1DDef& hdef   ,
00232   const double             weight ) const
00233 {
00234   return plot1D
00235     ( value  , ID ,
00236       hdef.title() , hdef.lowEdge() , hdef.highEdge() , hdef.bins() ,
00237       weight ) ;
00238 }
00239 // ============================================================================
00240 // The END
00241 // ============================================================================
00242 

Generated at Thu Sep 30 09:57:28 2010 for Gaudi Framework, version v21r11 by Doxygen version 1.5.6 written by Dimitri van Heesch, © 1997-2004