19 #ifndef ROO_MSG_SERVICE 40 SamplingDistribution::SamplingDistribution(
const char *
name,
const char *title,
41 std::vector<Double_t>& samplingDist,
const char * varName) :
58 std::vector<Double_t>& samplingDist, std::vector<Double_t>& sampleWeights,
const char * varName) :
83 const char * _columnName,
103 TString columnName( _columnName );
105 if( !columnName.Length() ) {
106 columnName.Form(
"%s_TS0", name );
107 if( !dataSet.
get()->
find(columnName) ) {
130 TNamed(
"SamplingDistribution_DefaultName",
"SamplingDistribution")
164 for(
unsigned int i=0; i<newSamplingDist.size(); ++i){
200 std::vector<unsigned int> index(n);
204 fSumW = std::vector<double>(
n );
205 fSumW2 = std::vector<double>(
n );
207 std::vector<double> sortedDist( n);
208 std::vector<double> sortedWeights( n);
210 for(
unsigned int i=0; i <
n; i++) {
211 unsigned int j = index[i];
213 fSumW[i] += fSumW[i-1];
214 fSumW2[i] += fSumW2[i-1];
220 sortedWeights[i] = fSampleWeights[ j] ;
240 error = numeric_limits<Double_t>::infinity();
244 if (
int(
fSumW.size()) != n)
270 assert(indexLow < n && indexHigh < n);
275 if (indexHigh >= 0) {
276 sum =
fSumW[indexHigh];
280 sum -=
fSumW[indexLow];
288 double norm2 =
fSumW2.back();
294 error =
std::sqrt( sum2 * (1. - 2. * sum) + norm2 * sum * sum ) /
norm;
334 Warning(
"InverseCDF",
"Estimation of Quantiles (InverseCDF) for weighted events is not yet supported");
359 else if(pvalue < 0.5){
360 int delta = (int)(sigmaVariation*
sqrt(1.0*nominal));
361 int variation = nominal+delta;
365 else if(variation<=0)
372 else if(pvalue >= 0.5){
374 int variation = nominal+delta;
380 else if(variation<=0)
395 std::cout <<
"problem in SamplingDistribution::InverseCDF" << std::endl;
412 Warning(
"InverseCDFInterpolate",
"Estimation of Quantiles (InverseCDF) for weighted events is not yet supported.");
430 return (upperX-lowerX)/(upperY-lowerY)*(pvalue-lowerY)+lowerX;
virtual const char * GetName() const
Returns name of object.
static long int sum(long int i)
std::vector< Double_t > fSumW
std::vector< Double_t > fSumW2
Chached vector with sum of the weight used to compute integral.
TString fVarName
vector of weights for the samples
virtual void SetName(const char *name)
Set the name of the TNamed.
Double_t InverseCDF(Double_t pvalue)
get the inverse of the Cumulative distribution function
std::vector< Double_t > fSampleWeights
vector of points for the sampling distribution
The TNamed class is the base class for all named ROOT classes.
virtual Double_t weight() const
Return event weight of current event.
Double_t InverseCDFInterpolate(Double_t pvalue)
get the inverse of the Cumulative distribution function
Bool_t AreEqualRel(Double_t af, Double_t bf, Double_t relPrec)
Double_t Integral(Double_t low, Double_t high, Bool_t normalize=kTRUE, Bool_t lowClosed=kTRUE, Bool_t highClosed=kFALSE) const
numerical integral in these limits
void SortValues() const
Chached vector with sum of the weight used to compute integral error.
std::vector< Double_t > fSamplingDist
RooAbsArg * first() const
Double_t CDF(Double_t x) const
calculate CDF as a special case of Integral(...) with lower limit equal to -inf
virtual ~SamplingDistribution()
Destructor of SamplingDistribution.
static Double_t infinity()
Return internal infinity representation.
void Add(const SamplingDistribution *other)
merge two sampling distributions
RooDataSet is a container class to hold unbinned data.
This class simply holds a sampling distribution of some test statistic.
virtual const RooArgSet * get(Int_t index) const
Return RooArgSet with coordinates of event 'index'.
Namespace for the RooStats classes.
RooAbsArg * find(const char *name) const
Find object with given name in list.
static RooMathCoreReg dummy
Double_t IntegralAndError(Double_t &error, Double_t low, Double_t high, Bool_t normalize=kTRUE, Bool_t lowClosed=kTRUE, Bool_t highClosed=kFALSE) const
numerical integral in these limits including error estimation
const TString GetVarName() const
SamplingDistribution()
Default constructor for SamplingDistribution.
Double_t getRealValue(const char *name, Double_t defVal=0, Bool_t verbose=kFALSE) const
Get value of a RooAbsReal stored in set with given name.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
double norm(double *x, double *p)
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual Int_t numEntries() const
virtual const char * GetTitle() const
Returns title of object.
void SortItr(Iterator first, Iterator last, IndexIterator index, Bool_t down=kTRUE)