PSHist/include/Axis.h

Go to the documentation of this file.
00001 #ifndef PSHIST_AXIS_H
00002 #define PSHIST_AXIS_H
00003 
00004 //--------------------------------------------------------------------------
00005 // File and Version Information:
00006 //      $Id: Axis.h 2050 2011-06-29 21:30:05Z salnikov@SLAC.STANFORD.EDU $
00007 //
00008 // Description:
00009 //      Class Axis.
00010 //
00011 //------------------------------------------------------------------------
00012 
00013 //-----------------
00014 // C/C++ Headers --
00015 //-----------------
00016 #include <vector>
00017 #include <iosfwd>
00018 
00019 //              ---------------------
00020 //              -- Class Interface --
00021 //              ---------------------
00022 
00023 namespace PSHist {
00024 
00025 /**
00026  *  @ingroup PSHist
00027  * 
00028  *  @brief Axis class defines the binning parameters for H1 and H2 histogram axes.
00029  *  
00030  *  This class can be used to define both same-width and variable-width
00031  *  binnings for histograms. Type of the binning is defined by the constructor
00032  *  used to instantiate Axis object.
00033  *
00034  *  This software was developed for the LCLS project.  If you use all or 
00035  *  part of it, please give an appropriate acknowledgment.
00036  *
00037  *  @see HManager
00038  *
00039  *  @version $Id: Axis.h 2050 2011-06-29 21:30:05Z salnikov@SLAC.STANFORD.EDU $
00040  *
00041  *  @author Mikhail S. Dubrovin
00042  */
00043 
00044 class Axis {
00045 public:
00046 
00047   // Constructors
00048 
00049   /**
00050    *  @brief Create axis with fixed bin sizes
00051    *  
00052    *  @param[in] nbins  Number of bins.
00053    *  @param[in] amin   Low edge of the first bin.
00054    *  @param[in] amax   High edge of the last bin.
00055    *  
00056    *  @throw ExceptionBins thrown when number of bins is 0
00057    *  @throw ExceptionAxisRange thrown when amin is equal or higher that amax
00058    */ 
00059   Axis (unsigned nbins, double amin, double amax);
00060 
00061   /**
00062    *  @brief Create axis with variable bin sizes
00063    *
00064    *  @param[in] nbins  Number of bins.
00065    *  @param[in] edges  Array of the histogram edges, size of the array 
00066    *                    is @c nbins+1, it should contain ordered values for
00067    *                    low edges of all bins plus high edge of last bin. 
00068    *  
00069    *  @throw ExceptionBins thrown when number of bins is 0
00070    *  @throw ExceptionAxisEdgeOrder thrown when edges are not ordered
00071    */ 
00072   Axis (unsigned nbins, const double *edges);
00073 
00074   /// Get low edge of range, makes sense to call only for fixed-width bins.
00075   double amin() const { return m_amin; }
00076   
00077   /// Get high edge of range, makes sense to call only for fixed-width bins.
00078   double amax() const { return m_amax; }
00079   
00080   /// Get number of bins.
00081   unsigned nbins() const { return m_nbins; }
00082   
00083   /// Get array of edges, will return zero pointer for fixed-width bins.
00084   const double* edges() const;
00085 
00086   // print data members
00087   void print(std::ostream& out) const;
00088   
00089 private:
00090 
00091   // Data members
00092   double        m_amin;
00093   double        m_amax;
00094   unsigned      m_nbins;
00095   std::vector<double> m_edges;
00096   
00097 };
00098 
00099 } // namespace PSHist
00100 
00101 #endif // PSHIST_AXIS_H

Generated on 19 Dec 2016 for PSANAclasses by  doxygen 1.4.7