| # Gaudi Framework, version v21r9 |

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