| # Gaudi Framework, version v21r7p1 |

Home |  | Generated: 15 Feb 2010

# 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   m_histo2DMapID    [ ID    ] = hist ;
    00091   m_histo2DMapTitle [ title ] = hist ;
    00092
    00093   // Declare to monitoring service
    00094   monitorHisto( Gaudi::Utils::Histos::toBase ( hist) , ID );
    00095
    00096   // Printout and return
    00097   if ( this->msgLevel(MSG::DEBUG) )
    00098   { this->debug() << "Booked 2D Histogram : ID='"
    00099                   << ID << "' Path=" << histoPath()
    00100                   << " Title='"
    00101                   << Gaudi::Utils::Histos::htitle ( hist )
    00102                   << "'" << endmsg; }
    00103   // return
    00104   return hist ;
    00105 }
    00106 // ============================================================================
    00107 // fill the 2D histogram with the values and weight
    00108 // ============================================================================
    00109 template <class PBASE>
    00110 AIDA::IHistogram2D* GaudiHistos<PBASE>::fill
    00111 ( AIDA::IHistogram2D* histo  ,
    00112   const double        valueX ,
    00113   const double        valueY ,
    00114   const double        weight ,
    00115   const std::string&  title  ) const
    00116 {
    00117   if ( NULL != histo && produceHistos() )
    00118   {
    00119     if ( !checkForNaN() )
    00120     { Gaudi::Utils::Histos::fill ( histo , valueX , valueY , weight ) ; }
    00121     else if  ( lfin ( valueX ) && lfin ( valueY ) && lfin ( weight ) )
    00122     { Gaudi::Utils::Histos::fill ( histo , valueX , valueY , weight ) ; }
    00123     else if  ( lnan ( valueX ) || lnan ( valueY ) || lnan ( weight ) )
    00124     {
    00125       this -> Warning
    00126         ("fill():: 'NaN'      value is skipped from the histogram '"
    00127          + Gaudi::Utils::Histos::htitle ( histo , title ) + "'" ) ;
    00128     }
    00129     else
    00130     {
    00131       this -> Warning
    00132         ("fill():: 'Infinite' value is skipped from the histogram '"
    00133          + Gaudi::Utils::Histos::htitle ( histo , title ) + "'" ) ;
    00134     }
    00135   }
    00136   // return
    00137   return histo ;
    00138 }
    00139 // ============================================================================
    00140 // fill the 2D histogram (book on demand)
    00141 // ============================================================================
    00142 template <class PBASE>
    00143 AIDA::IHistogram2D* GaudiHistos<PBASE>::plot2D
    00144 ( const double        valueX       ,
    00145   const double        valueY       ,
    00146   const std::string&  title        ,
    00147   const double        lowX         ,
    00148   const double        highX        ,
    00149   const double        lowY         ,
    00150   const double        highY        ,
    00151   const unsigned long binsX        ,
    00152   const unsigned long binsY        ,
    00153   const double        weight       ) const
    00154 {
    00155   AIDA::IHistogram2D * h(NULL);
    00156   if ( produceHistos() )
    00157   {
    00158     // retrieve or book the histogram
    00159     h = histo2D ( title ) ;
    00160     if ( NULL == h )
    00161     { h = book2D ( title , lowX , highX , binsX , lowY , highY , binsY ) ; }
    00162     // fill the histogram
    00163     h = fill ( h , valueX , valueY , weight , title ) ;
    00164   }
    00165   return h;
    00166 }
    00167 // ============================================================================
    00168 // fill the 2D histogram with forced ID assignment (book on demand)
    00169 // ============================================================================
    00170 template <class PBASE>
    00171 AIDA::IHistogram2D*  GaudiHistos<PBASE>::plot2D
    00172 ( const double        valueX       ,
    00173   const double        valueY       ,
    00174   const HistoID&      ID           ,
    00175   const std::string&  title        ,
    00176   const double        lowX         ,
    00177   const double        highX        ,
    00178   const double        lowY         ,
    00179   const double        highY        ,
    00180   const unsigned long binsX        ,
    00181   const unsigned long binsY        ,
    00182   const double        weight       ) const
    00183 {
    00184   AIDA::IHistogram2D * h(NULL);
    00185   // produce histograms ?
    00186   if ( produceHistos() )
    00187   {
    00188     // retrieve or book the histogram
    00189     h = histo2D ( ID ) ;
    00190     if ( NULL == h ) { h = book2D ( ID   , title ,
    00191                                  lowX , highX , binsX ,
    00192                                  lowY , highY , binsY ) ; }
    00193     // fill the histogram
    00194     h = fill ( h , valueX , valueY , weight , title ) ;
    00195   }
    00196   return h;
    00197 }