Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:29:46

0001 // @(#)root/roostats:$Id$
0002 
0003 /*************************************************************************
0004  * Project: RooStats                                                     *
0005  * Package: RooFit/RooStats                                              *
0006  * Authors:                                                              *
0007  *   Kyle Cranmer, Lorenzo Moneta, Gregory Schott, Wouter Verkerke       *
0008  *************************************************************************
0009  * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers.               *
0010  * All rights reserved.                                                  *
0011  *                                                                       *
0012  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0013  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0014  *************************************************************************/
0015 
0016 #ifndef ROOSTATS_SamplingDistribution
0017 #define ROOSTATS_SamplingDistribution
0018 
0019 #include "TNamed.h"
0020 
0021 #include "Rtypes.h"
0022 #include "RooDataSet.h"
0023 
0024 #include <vector>
0025 
0026 namespace RooStats {
0027 
0028  class SamplingDistribution : public TNamed {
0029 
0030    public:
0031 
0032     /// Constructor for SamplingDistribution
0033     SamplingDistribution(const char *name,const char *title, std::vector<double>& samplingDist, const char * varName = nullptr);
0034     SamplingDistribution(const char *name,const char *title,
0035           std::vector<double>& samplingDist, std::vector<double>& sampleWeights, const char * varName = nullptr);
0036 
0037 
0038     SamplingDistribution(const char *name,const char *title, const char * varName = nullptr);
0039 
0040     SamplingDistribution(const char *name,const char *title, RooDataSet& dataSet, const char * columnName = nullptr, const char * varName = nullptr);
0041 
0042     /// Default constructor for SamplingDistribution
0043     SamplingDistribution();
0044 
0045     /// Destructor of SamplingDistribution
0046     ~SamplingDistribution() override;
0047 
0048     /// get the inverse of the Cumulative distribution function
0049     double InverseCDF(double pvalue);
0050 
0051     /// get the inverse of the Cumulative distribution function
0052     double InverseCDFInterpolate(double pvalue);
0053 
0054     /// get the inverse of the Cumulative distribution function
0055     /// together with the inverse based on sampling variation
0056     double InverseCDF(double pvalue, double sigmaVariaton, double& inverseVariation);
0057 
0058     /// merge two sampling distributions
0059     void Add(const SamplingDistribution* other);
0060 
0061     /// size of samples
0062     Int_t GetSize() const{return fSamplingDist.size();}
0063 
0064     /// Get test statistics values
0065     const std::vector<double> & GetSamplingDistribution() const {return fSamplingDist;}
0066     /// Get the sampling weights
0067     const std::vector<double> & GetSampleWeights() const {return fSampleWeights;}
0068 
0069     const TString GetVarName() const {return fVarName;}
0070 
0071     /// numerical integral in these limits
0072     double Integral(double low, double high, bool normalize = true, bool lowClosed = true, bool highClosed = false) const;
0073 
0074     /// numerical integral in these limits including error estimation
0075     double IntegralAndError(double & error, double low, double high, bool normalize = true,
0076                               bool lowClosed = true, bool highClosed = false) const;
0077 
0078     /// calculate CDF as a special case of Integral(...) with lower limit equal to -inf
0079     double CDF(double x) const;
0080 
0081   private:
0082 
0083     mutable std::vector<double> fSamplingDist;  ///< vector of points for the sampling distribution
0084     mutable std::vector<double> fSampleWeights; ///< vector of weights for the samples
0085 
0086     TString fVarName;
0087 
0088     mutable std::vector<double> fSumW;   ///<! Cached vector with sum of the weight used to compute integral
0089     mutable std::vector<double> fSumW2;  ///<! Cached vector with sum of the weight used to compute integral error
0090 
0091   protected:
0092 
0093     /// internal function to sort values
0094     void SortValues() const;
0095 
0096     ClassDefOverride(SamplingDistribution,2)  /// Class containing the results of the HybridCalculator
0097   };
0098 }
0099 
0100 #endif