| # Gaudi Framework, version v21r10p1 |

Home |  | Generated: 29 Jul 2010

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