| # Gaudi Framework, version v22r0 |

Home |  | Generated: 9 Feb 2011

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

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines