| # Gaudi Framework, version v21r7p1 |

Home |  | Generated: 15 Feb 2010

# GaudiHistos_3DFixedBinning.icpp

Go to the documentation of this file.

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