Gaudi Framework, version v21r4

Home   Generated: 7 Sep 2009

GaudiHistos_2DFixedBinning.icpp

Go to the documentation of this file.
00001 // ============================================================================
00002 // ==================================== 2D ====================================
00003 // ============================================================================
00004 // book the 2D histogram (book on demand)
00005 // ============================================================================
00006 template <class PBASE>
00007 AIDA::IHistogram2D*  GaudiHistos<PBASE>::book2D
00008 ( const std::string&  title   ,
00009   const double        lowX    ,
00010   const double        highX   ,
00011   const unsigned long binsX   ,
00012   const double        lowY    ,
00013   const double        highY   ,
00014   const unsigned long binsY   ) const
00015 {
00016   // exist?
00017   AIDA::IHistogram2D* hist = histo2D ( 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 -> book2D ( ID, title, lowX, highX, binsX, lowY, highY, binsY );
00027 }
00028 // ============================================================================
00029 // book the 2D histogram with forced ID (book on demand)
00030 // ============================================================================
00031 template <class PBASE>
00032 AIDA::IHistogram2D*  GaudiHistos<PBASE>::book2D
00033 ( const HistoID&      ID           ,
00034   const std::string&  title   ,
00035   const double        lowX    ,
00036   const double        highX   ,
00037   const unsigned long binsX   ,
00038   const double        lowY    ,
00039   const double        highY   ,
00040   const unsigned long binsY   ) const
00041 {
00042   // Check ID
00043   if (ID.undefined())
00044   {
00045     this->Error("Undefined Histogram ID : Title='"+title+"'");
00046     return NULL;
00047   }
00048 
00049   // exist?
00050   AIDA::IHistogram2D* hist = histo2D( ID ) ;
00051   // histogram is already booked
00052   if( NULL != hist       )                  { return hist ; } // RETURN !!
00053 
00054   // Histogram title
00055   const std::string & htitle =
00056     ( title.empty() ? "Unnamed 2D Histogram ID="+ID.idAsString() : title ) ;
00057 
00058   // book the histogram
00059   if ( ID.numeric() )
00060   {
00061     hist = this->histoSvc() -> book ( histoPath()  ,
00062                                       ID.numericID() ,
00063                                       htitle       ,
00064                                       binsX        ,
00065                                       lowX         ,
00066                                       highX        ,
00067                                       binsY        ,
00068                                       lowY         ,
00069                                       highY        ) ;
00070   }
00071   else if ( ID.literal() )
00072   {
00073     hist = this->histoSvc() -> book ( histoPath()+"/"+
00074                                       ID.literalID() ,
00075                                       htitle       ,
00076                                       binsX        ,
00077                                       lowX         ,
00078                                       highX        ,
00079                                       binsY        ,
00080                                       lowY         ,
00081                                       highY        ) ;
00082   }
00083 
00084   // Check OK
00085   if( NULL == hist )
00086   { this->Error( "IHistogram2D* points to NULL! ID='" + ID.idAsString() +
00087                  "' title='"+htitle+"'" ) ; return NULL; } // RETURN !!
00088 
00089   // add histogram into histogram storages
00090   if      ( ID.numeric() )
00091   { m_histo2DMapNumID [ ID.numericID() ] = hist ; }
00092   else if ( ID.literal() )
00093   { m_histo2DMapLitID [ ID.literalID() ] = hist ; }
00094   m_histo2DMapTitle [ title ] = hist ;
00095 
00096   // Declare to monitoring service
00097   monitorHisto( Gaudi::Utils::Histos::toBase ( hist) , ID );
00098 
00099   // Printout and return
00100   if ( this->msgLevel(MSG::DEBUG) )
00101   { this->debug() << "Booked 2D Histogram : ID='"
00102                   << ID << "' Path=" << histoPath()
00103                   << " Title='"
00104                   << Gaudi::Utils::Histos::htitle ( hist )
00105                   << "'" << endmsg; }
00106   // return
00107   return hist ;
00108 }
00109 // ============================================================================
00110 // fill the 2D histogram with the values and weight
00111 // ============================================================================
00112 template <class PBASE>
00113 AIDA::IHistogram2D* GaudiHistos<PBASE>::fill
00114 ( AIDA::IHistogram2D* histo  ,
00115   const double        valueX ,
00116   const double        valueY ,
00117   const double        weight ,
00118   const std::string&  title  ) const
00119 {
00120   if ( NULL != histo && produceHistos() )
00121   {
00122     if ( !checkForNaN() )
00123     { Gaudi::Utils::Histos::fill ( histo , valueX , valueY , weight ) ; }
00124     else if  ( lfin ( valueX ) && lfin ( valueY ) && lfin ( weight ) )
00125     { Gaudi::Utils::Histos::fill ( histo , valueX , valueY , weight ) ; }
00126     else if  ( lnan ( valueX ) || lnan ( valueY ) || lnan ( weight ) )
00127     {
00128       this -> Warning
00129         ("fill():: 'NaN'      value is skipped from the histogram '"
00130          + Gaudi::Utils::Histos::htitle ( histo , title ) + "'" ) ;
00131     }
00132     else
00133     {
00134       this -> Warning
00135         ("fill():: 'Infinite' value is skipped from the histogram '"
00136          + Gaudi::Utils::Histos::htitle ( histo , title ) + "'" ) ;
00137     }
00138   }
00139   // return
00140   return histo ;
00141 }
00142 // ============================================================================
00143 // fill the 2D histogram (book on demand)
00144 // ============================================================================
00145 template <class PBASE>
00146 AIDA::IHistogram2D* GaudiHistos<PBASE>::plot2D
00147 ( const double        valueX       ,
00148   const double        valueY       ,
00149   const std::string&  title        ,
00150   const double        lowX         ,
00151   const double        highX        ,
00152   const double        lowY         ,
00153   const double        highY        ,
00154   const unsigned long binsX        ,
00155   const unsigned long binsY        ,
00156   const double        weight       ) const
00157 {
00158   AIDA::IHistogram2D * h(NULL);
00159   if ( produceHistos() )
00160   {
00161     // retrieve or book the histogram
00162     h = histo2D ( title ) ;
00163     if ( NULL == h )
00164     { h = book2D ( title , lowX , highX , binsX , lowY , highY , binsY ) ; }
00165     // fill the histogram
00166     h = fill ( h , valueX , valueY , weight , title ) ;
00167   }
00168   return h;
00169 }
00170 // ============================================================================
00171 // fill the 2D histogram with forced ID assignment (book on demand)
00172 // ============================================================================
00173 template <class PBASE>
00174 AIDA::IHistogram2D*  GaudiHistos<PBASE>::plot2D
00175 ( const double        valueX       ,
00176   const double        valueY       ,
00177   const HistoID&      ID           ,
00178   const std::string&  title        ,
00179   const double        lowX         ,
00180   const double        highX        ,
00181   const double        lowY         ,
00182   const double        highY        ,
00183   const unsigned long binsX        ,
00184   const unsigned long binsY        ,
00185   const double        weight       ) const
00186 {
00187   AIDA::IHistogram2D * h(NULL);
00188   // produce histograms ?
00189   if ( produceHistos() )
00190   {
00191     // retrieve or book the histogram
00192     h = histo2D ( ID ) ;
00193     if ( NULL == h ) { h = book2D ( ID   , title ,
00194                                  lowX , highX , binsX ,
00195                                  lowY , highY , binsY ) ; }
00196     // fill the histogram
00197     h = fill ( h , valueX , valueY , weight , title ) ;
00198   }
00199   return h;
00200 }

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