| # Gaudi Framework, version v21r11 |

Home |  | Generated: 30 Sep 2010

# GaudiHistos_1DProfFixedBinning.icpp

Go to the documentation of this file.

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