• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

BCH2D.h

Go to the documentation of this file.
00001 #ifndef __BCH2D__H
00002 #define __BCH2D__H
00003 
00004 /*!
00005  * \class BCH2D
00006  * \brief  A class for handling 2D distributions.
00007  * \author Daniel Kollar
00008  * \author Kevin Kröninger
00009  * \version 1.0
00010  * \date 08.2008
00011  * \detail This class contains a TH2D histogram and some additional
00012  * functions. It is used for marginalized distributions.
00013  */
00014 
00015 /*
00016  * Copyright (C) 2008-2010, Daniel Kollar and Kevin Kroeninger.
00017  * All rights reserved.
00018  *
00019  * For the licensing terms see doc/COPYING.
00020  */
00021 
00022 // ---------------------------------------------------------
00023 
00024 #include <vector>
00025 
00026 // ROOT classes
00027 class TH1D;
00028 class TH2D;
00029 class TGraph;
00030 
00031 // ---------------------------------------------------------
00032 
00033 class BCH2D
00034 {
00035 
00036    public:
00037 
00038       /** \name Constructors and destructors */
00039       /* @{ */
00040 
00041       /**
00042        * The default constructor. */
00043       BCH2D();
00044 
00045       /**
00046        * The complete constructor. */
00047       BCH2D(TH2D * h);
00048 
00049       /**
00050        * The default destructor. */
00051       ~BCH2D();
00052 
00053       /* @} */
00054       /** \name Member functions (get)  */
00055       /* @{ */
00056 
00057       /**
00058        * @return The 2D histogram. */
00059       TH2D * GetHistogram()
00060          { return fHistogram; };
00061 
00062       /**
00063        * @return The mean of the distribution. */
00064 //    void GetMean(double& mean);
00065 
00066       /**
00067        * @return The mode of the distribution */
00068       void GetMode(double& mode);
00069 
00070       /* @} */
00071       /** \name Member functions (set)  */
00072       /* @{ */
00073 
00074       /**
00075        * Set the 2D histogram. */
00076       void SetHistogram(TH2D * hist)
00077          { fHistogram = hist; };
00078 
00079       /**
00080        * Set global mode.
00081        * @param The global mode. */
00082       void SetGlobalMode(double mode[2])
00083          { fMode[0] = mode[0]; fMode[1] = mode[1]; fModeFlag =1; };
00084 
00085       /* @} */
00086       /** \name Member functions (miscellaneous methods) */
00087       /* @{ */
00088 
00089       /**
00090        * Print 2-d histogram to file
00091        * @param filename The filename
00092        * @param ww canvas size in pixels along X
00093        * @param ww canvas size in pixels along Y
00094        * If ww and wh are set to 0, default ROOT canvas size is used.
00095        * For explanation of the parameter options see the Draw() method. */
00096       void Print(const char * filename, int options=0, int ww=0, int wh=0);
00097 
00098       /**
00099        * Draw 2-d distribution into the active canvas
00100        * @param options explanation to come
00101        * @param drawmode specify whether a marker should be drawn at the location of the mode */
00102       void Draw(int options=0, bool drawmode=true);
00103 
00104       /*
00105        * Calculates the integral of the distribution as a function of the
00106        * height. */
00107       void CalculateIntegratedHistogram();
00108 
00109       /*
00110        * Calculates the height below which the integrated probability has
00111        * a certain value.
00112        * @param p The integrated probability in the region below the height to be estimated. */
00113       double GetLevel(double p);
00114 
00115       /**
00116        * Returns the number of intervals as a function of x
00117        * @param h The histogram.
00118        * @param nfoundmax The maximum number of intervals.
00119        * @return A vector containing the number of intervals for all bins in x. */
00120       std::vector <int> GetNIntervalsY(TH2D * h, int &nfoundmax);
00121 
00122       /**
00123        *   */
00124       TGraph * GetLowestBandGraph(TH2D * h, std::vector<int> nint);
00125       TGraph * GetLowestBandGraph(TH2D * h);
00126 
00127 
00128       std::vector <double> GetLevelBoundary(double level);
00129       std::vector <double> GetLevelBoundary(TH2D * h, double level);
00130       TGraph * GetBandGraph(double level1, double level2);
00131       TGraph * GetBandGraph(TH2D * h , double level1, double level2);
00132 
00133 //    TGraph ** GetBandGraphs(TH2D * h);
00134       TGraph ** GetBandGraphs(TH2D * h, int &n);
00135 
00136       /* @} */
00137 
00138    private:
00139 
00140       /**
00141        * The 2D histogram */
00142       TH2D * fHistogram;
00143 
00144       /**
00145        * The integrated 2D histogram */
00146       TH1D * fIntegratedHistogram;
00147 
00148       /**
00149        * Global mode */
00150       double fMode[2];
00151 
00152       /**
00153        * "Is there a global mode?" flag */
00154       int fModeFlag;
00155 
00156 };
00157 
00158 // ---------------------------------------------------------
00159 
00160 #endif

Generated on Mon Aug 30 2010 22:14:54 for Bayesian Analysis Toolkit by  doxygen 1.7.1