Gaudi Framework, version v21r9

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

Generated at Mon May 3 12:14:01 2010 for Gaudi Framework, version v21r9 by Doxygen version 1.5.6 written by Dimitri van Heesch, © 1997-2004