| # Gaudi Framework, version v22r2 |

Home |  | Generated: Tue May 10 2011

# GaudiHistos_2DVariableBinning.icpp

Go to the documentation of this file.

    00001 // ==================================== 2D ====================================
    00002 // ============================= Variable Binning =============================
    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 HistoBinEdges& edgesX       ,
    00010   const HistoBinEdges& edgesY       ) const
    00011 {
    00012   //
    00013   if  ( !produceHistos() )                   { return 0    ; } // RETURN
    00014   //
    00015   // exist?
    00016   AIDA::IHistogram2D * hist = histo2D ( title ) ;
    00017   // histogram is already booked
    00018   if ( NULL != hist      )                  { return hist ; } // RETURN !!
    00019
    00020   // propose the histogram ID
    00021   HistoID ID;
    00022   newHistoID( title, ID );
    00023
    00024   // Create a new histogram and return
    00025   return this -> book2D ( ID, title, edgesX, edgesY );
    00026 }
    00027 // ============================================================================
    00028 // book the 2D histogram with forced ID (book on demand)
    00029 // ============================================================================
    00030 template <class PBASE>
    00031 AIDA::IHistogram2D*  GaudiHistos<PBASE>::book2D
    00032 ( const HistoID&       ID           ,
    00033   const std::string&   title        ,
    00034   const HistoBinEdges& edgesX       ,
    00035   const HistoBinEdges& edgesY       ) const
    00036 {
    00037   //
    00038   if  ( !produceHistos() )                   { return 0    ; } // RETURN
    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::IHistogram2D * hist = histo2D ( 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() ? "Unnamed 2D Histogram ID="+ID.idAsString() : title ) ;
    00055
    00056   // book the histogram
    00057   if ( ID.numeric() )
    00058   {
    00059     hist = this->histoSvc() -> book ( histoPath()  ,
    00060                                       ID.numericID() ,
    00061                                       htitle       ,
    00062                                       edgesX       ,
    00063                                       edgesY       ) ;
    00064   }
    00065   else if ( ID.literal() )
    00066   {
    00067     hist = this->histoSvc() -> book ( histoPath()+"/"+
    00068                                       ID.literalID() ,
    00069                                       htitle         ,
    00070                                       edgesX         ,
    00071                                       edgesY         ) ;
    00072   }
    00073
    00074   // check OK
    00075   if( NULL == hist )
    00076   { this->Error( "IHistogram2D* points to NULL! ID='" + ID.idAsString() +
    00077                  "' title='"+htitle+"'" ) ; return NULL; } // RETURN !!
    00078
    00079   // add histogram into histogram storages
    00080   m_histo2DMapID    [ ID    ] = hist ;
    00081   m_histo2DMapTitle [ title ] = hist ;
    00082
    00083   // Declare to monitoring service
    00084   monitorHisto( Gaudi::Utils::Histos::toBase ( hist ) , ID );
    00085
    00086   // Printout and return
    00087   if ( this->msgLevel(MSG::DEBUG) )
    00088   { this->debug() << "Booked 2D Histogram : ID='" << ID
    00089                   << "' Path=" << histoPath()
    00090                   << " Title='"
    00091                   << Gaudi::Utils::Histos::htitle ( hist )
    00092                   << "'" << endmsg; }
    00093   return hist ;
    00094 }
    00095 // ============================================================================
    00096 // fill the 2D histogram (book on demand)
    00097 // ============================================================================
    00098 template <class PBASE>
    00099 AIDA::IHistogram2D*
    00100 GaudiHistos<PBASE>::plot2D
    00101 ( const double        valueX ,
    00102   const double        valueY ,
    00103   const std::string&  title  ,
    00104   const HistoBinEdges& edgesX ,
    00105   const HistoBinEdges& edgesY ,
    00106   const double        weight ) const
    00107 {
    00108   AIDA::IHistogram2D * h(NULL);
    00109   if ( produceHistos() )
    00110   {
    00111     // retrieve or book the histogram
    00112     h = histo2D ( title ) ;
    00113     if ( NULL == h ) { h = book2D ( title , edgesX , edgesY ) ; }
    00114     // fill the histogram
    00115     h = fill ( h , valueX , valueY , weight , title );
    00116   }
    00117   return h;
    00118 }
    00119 // ============================================================================
    00120 // fill the 2D variable histogram with forced ID assignment (book on demand)
    00121 // ============================================================================
    00122 template <class PBASE>
    00123 AIDA::IHistogram2D*
    00124 GaudiHistos<PBASE>::plot2D
    00125 ( const double        valueX ,
    00126   const double        valueY ,
    00127   const HistoID&      ID     ,
    00128   const std::string&  title  ,
    00129   const HistoBinEdges& edgesX ,
    00130   const HistoBinEdges& edgesY ,
    00131   const double        weight ) const
    00132 {
    00133   AIDA::IHistogram2D * h(NULL);
    00134   if ( produceHistos() )
    00135   {
    00136     // retrieve or book the histogram
    00137     h = histo2D ( ID ) ;
    00138     if ( NULL == h ) {  h = book2D ( ID , title , edgesX , edgesY ) ; }
    00139     // fill
    00140     h = fill ( h , valueX , valueY , weight , title ) ;
    00141   }
    00142   return h;
    00143 }
    00144 // ============================================================================
    00145 // The END
    00146 // ============================================================================
    00147

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