| # Gaudi Framework, version v23r0 |

Home |  | Generated: Mon Jan 30 2012

# GaudiHistos_3DVariableBinning.icpp

Go to the documentation of this file.

    00001 // ==================================== 3D ====================================
    00002 // ============================= Variable Binning =============================
    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 HistoBinEdges&        edgesX       ,
    00010   const HistoBinEdges&        edgesY       ,
    00011   const HistoBinEdges&        edgesZ       ) const
    00012 {
    00013   //
    00014   if  ( !produceHistos() )                   { return 0    ; } // RETURN
    00015   //
    00016   // exist?
    00017   AIDA::IHistogram3D * hist = histo3D ( 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 -> book3D ( ID, title, edgesX, edgesY, edgesZ );
    00027 }
    00028 // ============================================================================
    00029 // book the 2D histogram with forced ID (book on demand)
    00030 // ============================================================================
    00031 template <class PBASE>
    00032 AIDA::IHistogram3D*  GaudiHistos<PBASE>::book3D
    00033 ( const HistoID&      ID           ,
    00034   const std::string&  title        ,
    00035   const HistoBinEdges&        edgesX       ,
    00036   const HistoBinEdges&        edgesY       ,
    00037   const HistoBinEdges&        edgesZ       ) const
    00038 {
    00039   //
    00040   if  ( !produceHistos() )                   { return 0    ; } // RETURN
    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::IHistogram3D * hist = histo3D ( 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 3D 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                                       edgesX       ,
    00065                                       edgesY       ,
    00066                                       edgesZ       ) ;
    00067   }
    00068   else if ( ID.literal() )
    00069   {
    00070     hist = this->histoSvc() -> book ( histoPath()+"/"+
    00071                                       ID.literalID() ,
    00072                                       htitle         ,
    00073                                       edgesX         ,
    00074                                       edgesY         ,
    00075                                       edgesZ         ) ;
    00076   }
    00077
    00078   // check OK
    00079   if( NULL == hist )
    00080   { this->Error( "IHistogram3D* points to NULL! ID='" + ID.idAsString() +
    00081                  "' title='"+htitle+"'" ) ; return NULL; } // RETURN !!
    00082
    00083   // add histogram into histogram storages
    00084   m_histo3DMapID    [ ID    ] = hist ;
    00085   m_histo3DMapTitle [ title ] = hist ;
    00086
    00087   // Declare to monitoring service
    00088   monitorHisto( Gaudi::Utils::Histos::toBase ( hist ) , ID );
    00089
    00090   // Printout and return
    00091   if ( this->msgLevel(MSG::DEBUG) )
    00092   { this->debug() << "Booked 3D Histogram : ID='" << ID
    00093                   << "' Path=" << histoPath()
    00094                   << " Title='"
    00095                   << Gaudi::Utils::Histos::htitle ( hist )
    00096                   << "'" << endmsg; }
    00097   return hist ;
    00098 }
    00099 // ============================================================================
    00100 // fill the 3D histogram (book on demand)
    00101 // ============================================================================
    00102 template <class PBASE>
    00103 AIDA::IHistogram3D*
    00104 GaudiHistos<PBASE>::plot3D
    00105 ( const double        valueX ,
    00106   const double        valueY ,
    00107   const double        valueZ ,
    00108   const std::string&  title  ,
    00109   const HistoBinEdges&        edgesX ,
    00110   const HistoBinEdges&        edgesY ,
    00111   const HistoBinEdges&        edgesZ ,
    00112   const double        weight ) const
    00113 {
    00114   AIDA::IHistogram3D * h(NULL);
    00115   if ( produceHistos() )
    00116   {
    00117     // retrieve or book the histogram
    00118     h = histo3D ( title ) ;
    00119     if ( NULL == h ) { h = book3D ( title , edgesX , edgesY , edgesZ ) ; }
    00120     // fill the histogram
    00121     h = fill ( h , valueX , valueY , valueZ , weight , title );
    00122   }
    00123   return h;
    00124 }
    00125 // ============================================================================
    00126 // fill the 3D variable histogram with forced ID assignment (book on demand)
    00127 // ============================================================================
    00128 template <class PBASE>
    00129 AIDA::IHistogram3D*
    00130 GaudiHistos<PBASE>::plot3D
    00131 ( const double        valueX ,
    00132   const double        valueY ,
    00133   const double        valueZ ,
    00134   const HistoID&      ID     ,
    00135   const std::string&  title  ,
    00136   const HistoBinEdges&        edgesX ,
    00137   const HistoBinEdges&        edgesY ,
    00138   const HistoBinEdges&        edgesZ ,
    00139   const double        weight ) const
    00140 {
    00141   AIDA::IHistogram3D * h(NULL);
    00142   if ( produceHistos() )
    00143   {
    00144     // retrieve or book the histogram
    00145     h = histo3D ( ID ) ;
    00146     if ( NULL == h ) {  h = book3D ( ID , title , edgesX , edgesY , edgesZ ) ; }
    00147     // fill
    00148     h = fill ( h , valueX , valueY , valueZ , weight , title ) ;
    00149   }
    00150   return h;
    00151 }
    00152 // ============================================================================
    00153 // The END
    00154 // ============================================================================
    00155

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