Gaudi Framework, version v21r4

Home   Generated: 7 Sep 2009

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   if      ( ID.numeric() )
00079   { m_histo1DMapNumID [ ID.numericID() ] = hist ; }
00080   else if ( ID.literal() )
00081   { m_histo1DMapLitID [ ID.literalID() ] = hist ; }
00082   m_histo1DMapTitle [ title ] = hist ;
00083 
00084   // Declare to monitoring service
00085   monitorHisto( Gaudi::Utils::Histos::toBase ( hist ) , ID );
00086 
00087   // Printout and return
00088   if ( this->msgLevel(MSG::DEBUG) )
00089   { this->debug() << "Booked 1D Histogram : ID='" << ID
00090                   << "' Path=" << histoPath()
00091                   << " Title='"
00092                   << Gaudi::Utils::Histos::htitle ( hist )
00093                   << "'" << endmsg; }
00094   return hist ;
00095 }
00096 // ============================================================================
00097 // fill the 1D histogram with the value and weight
00098 // ============================================================================
00099 template <class PBASE>
00100 AIDA::IHistogram1D* GaudiHistos<PBASE>::fill
00101 ( AIDA::IHistogram1D*  histo  ,
00102   const double         value  ,
00103   const double         weight ,
00104   const std::string&   title  ) const
00105 {
00106   if ( NULL != histo && produceHistos() )
00107   {
00108     if ( !checkForNaN() )
00109     { Gaudi::Utils::Histos::fill ( histo , value , weight ) ; }
00110     else if  ( lfin ( value ) && lfin ( weight ) )
00111     { Gaudi::Utils::Histos::fill ( histo , value , weight ) ; }
00112     else if  ( lnan ( value ) || lnan ( weight ) )
00113     {
00114       this -> Warning
00115         ("fill():: 'NaN'      value is skipped from the histogram '"
00116          + Gaudi::Utils::Histos::htitle ( histo , title ) + "'" ) ;
00117     }
00118     else
00119     {
00120       this -> Warning
00121         ("fill():: 'Infinite' value is skipped from the histogram '"
00122          + Gaudi::Utils::Histos::htitle ( histo , title ) + "'" ) ;
00123     }
00124   }
00125   // return
00126   return histo ;
00127 }
00128 // ============================================================================
00129 // fill the 1D histogram (book on demand)
00130 // ============================================================================
00131 template <class PBASE>
00132 AIDA::IHistogram1D*
00133 GaudiHistos<PBASE>::plot1D
00134 ( const double        value  ,
00135   const std::string&  title  ,
00136   const double        low    ,
00137   const double        high   ,
00138   const unsigned long bins   ,
00139   const double        weight ) const
00140 {
00141   AIDA::IHistogram1D * h(NULL);
00142   if ( produceHistos() )
00143   {
00144     // retrieve or book the histogram
00145     h = histo1D ( title ) ;
00146     if ( NULL == h ) { h = book1D  ( title , low , high , bins ) ; }
00147     // fill the histogram
00148     h = fill ( h , value , weight , title );
00149   }
00150   return h;
00151 }
00152 // ============================================================================
00153 // fill the 1D histogram with forced ID assignment (book on demand)
00154 // ============================================================================
00155 template <class PBASE>
00156 AIDA::IHistogram1D*
00157 GaudiHistos<PBASE>::plot1D
00158 ( const double        value  ,
00159   const HistoID&      ID     ,
00160   const std::string&  title  ,
00161   const double        low    ,
00162   const double        high   ,
00163   const unsigned long bins   ,
00164   const double        weight ) const
00165 {
00166   AIDA::IHistogram1D* h(NULL);
00167   if ( produceHistos() )
00168   {
00169     // retrieve or book the histogram
00170     h = histo1D ( ID ) ;
00171     if ( NULL == h ) {  h = book1D ( ID , title , low , high , bins ) ; }
00172     // fill
00173     h = fill ( h , value , weight , title ) ;
00174   }
00175   return h;
00176 }
00177 // ============================================================================
00178 // book the 1D histogram
00179 // ============================================================================
00180 template <class PBASE>
00181 AIDA::IHistogram1D*
00182 GaudiHistos<PBASE>::book
00183 ( const Gaudi::Histo1DDef& hdef ) const
00184 {
00185   return book1D ( hdef.title    () ,
00186                   hdef.lowEdge  () ,
00187                   hdef.highEdge () ,
00188                   hdef.bins     () ) ;
00189 }
00190 // ============================================================================
00191 // book the 1D histogram with forced ID
00192 // ============================================================================
00193 template <class PBASE>
00194 AIDA::IHistogram1D*
00195 GaudiHistos<PBASE>::book
00196 ( const HistoID&           ID   ,
00197   const Gaudi::Histo1DDef& hdef ) const
00198 {
00199   return book1D ( ID               ,
00200                   hdef.title    () ,
00201                   hdef.lowEdge  () ,
00202                   hdef.highEdge () ,
00203                   hdef.bins     () ) ;
00204 }
00205 // ============================================================================
00206 // fill the 1D histogram (book on demand)
00207 // ============================================================================
00208 template <class PBASE>
00209 AIDA::IHistogram1D*
00210 GaudiHistos<PBASE>::plot1D
00211 ( const double             value  ,
00212   const Gaudi::Histo1DDef& hdef   ,
00213   const double             weight ) const
00214 {
00215   return plot1D
00216     ( value  ,
00217       hdef.title() , hdef.lowEdge() , hdef.highEdge() , hdef.bins() ,
00218       weight ) ;
00219 }
00220 // ============================================================================
00221 // fill the 1D histogram with forced ID assignment (book on demand)
00222 // ============================================================================
00223 template <class PBASE>
00224 AIDA::IHistogram1D*
00225 GaudiHistos<PBASE>::plot1D
00226 ( const double             value  ,
00227   const HistoID&           ID     ,
00228   const Gaudi::Histo1DDef& hdef   ,
00229   const double             weight ) const
00230 {
00231   return plot1D
00232     ( value  , ID ,
00233       hdef.title() , hdef.lowEdge() , hdef.highEdge() , hdef.bins() ,
00234       weight ) ;
00235 }
00236 

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