43 SamplingDistribution::SamplingDistribution(
const char *
name,
const char *title,
44 std::vector<Double_t>& samplingDist,
const char * varName) :
61 std::vector<Double_t>& samplingDist, std::vector<Double_t>& sampleWeights,
const char * varName) :
97 const char * _columnName,
108 TString columnName( _columnName );
110 if( !columnName.Length() ) {
111 columnName.Form(
"%s_TS0", name );
112 if( !dataSet.
get()->
find(columnName) ) {
135 TNamed(
"SamplingDistribution_DefaultName",
"SamplingDistribution")
168 for(
unsigned int i=0; i<newSamplingDist.size(); ++i){
203 std::vector<unsigned int> index(n);
207 fSumW = std::vector<double>(
n );
208 fSumW2 = std::vector<double>(
n );
210 std::vector<double> sortedDist( n);
211 std::vector<double> sortedWeights( n);
213 for(
unsigned int i=0; i <
n; i++) {
214 unsigned int j = index[i];
216 fSumW[i] += fSumW[i-1];
217 fSumW2[i] += fSumW2[i-1];
223 sortedWeights[i] = fSampleWeights[ j] ;
243 error = numeric_limits<Double_t>::infinity();
247 if (
int(
fSumW.size()) != n)
273 assert(indexLow < n && indexHigh < n);
278 if (indexHigh >= 0) {
279 sum =
fSumW[indexHigh];
283 sum -=
fSumW[indexLow];
291 double norm2 =
fSumW2.back();
297 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
Cached 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
Cached 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)