190 fDataHist->get(bin1);
192 fDataHist->get(bin2);
202 Double_t n1 = fSparseHist->GetBinContent(bin1);
203 Double_t n2 = fSparseHist->GetBinContent(bin2);
211 fChain(chain), fParam(param) {}
213 Double_t xi = fChain->Get(i)->getRealValue(fParam->GetName());
214 Double_t xj = fChain->Get(j)->getRealValue(fParam->GetName());
252 x[i] =
fAxes[i]->getVal();
282 <<
"Interval type not set. Returning false." << endl;
323 "number of variables in axes (" <<
size <<
324 ") doesn't match number of parameters ("
341 <<
"parameters have not been set." << endl;
347 "MCMCInterval::CreateKeysPdf: creation of Keys PDF failed: " <<
348 "Number of burn-in steps (num steps to ignore) >= number of steps " <<
349 "in Markov chain." << endl;
381 coutE(
Eval) <<
"* Error in MCMCInterval::CreateHist(): " <<
382 "Crucial data member was NULL." << endl;
383 coutE(
Eval) <<
"Make sure to fully construct/initialize." << endl;
393 "MCMCInterval::CreateHist: creation of histogram failed: " <<
394 "Number of burn-in steps (num steps to ignore) >= number of steps " <<
395 "in Markov chain." << endl;
400 fHist =
new TH1F(
"posterior",
"MCMC Posterior Histogram",
404 fHist =
new TH2F(
"posterior",
"MCMC Posterior Histogram",
409 fHist =
new TH3F(
"posterior",
"MCMC Posterior Histogram",
415 coutE(
Eval) <<
"* Error in MCMCInterval::CreateHist() : " <<
416 "TH1* couldn't handle dimension: " <<
fDimension << endl;
453 <<
"Crucial data member was NULL." << endl;
483 "MCMCInterval::CreateSparseHist: creation of histogram failed: " <<
484 "Number of burn-in steps (num steps to ignore) >= number of steps " <<
485 "in Markov chain." << endl;
506 coutE(
Eval) <<
"* Error in MCMCInterval::CreateDataHist(): " <<
507 "Crucial data member was NULL or empty." << endl;
508 coutE(
Eval) <<
"Make sure to fully construct/initialize." << endl;
514 "MCMCInterval::CreateDataHist: creation of histogram failed: " <<
515 "Number of burn-in steps (num steps to ignore) >= number of steps " <<
516 "in Markov chain." << endl;
534 "Crucial data member (Markov chain) was NULL." << endl;
542 "MCMCInterval::CreateVector: creation of vector failed: " <<
543 "Number of burn-in steps (num steps to ignore) >= number of steps " <<
544 "in Markov chain." << endl;
552 for (i = 0; i <
size; i++) {
575 while ((obj = it->
Next()) != NULL) {
579 coutE(
Eval) <<
"* Error in MCMCInterval::SetParameters: " <<
580 obj->
GetName() <<
" not a RooRealVar*" << std::endl;
599 "Error: Interval type not set" << endl;
618 if (fLeftSideTF < 0 || fLeftSideTF > 1) {
620 <<
"Fraction must be in the range [0, 1]. "
627 <<
"Error: Can only find a tail-fraction interval for 1-D intervals"
634 <<
"Crucial data member was NULL." << endl;
686 if (
TMath::Abs(leftTailSum + w - leftTailCutoff) <
701 if (
TMath::Abs(rightTailSum + w - rightTailCutoff) <
742 coutW(
Eval) <<
"Warning: Integral of Keys PDF came out to " << full
743 <<
" instead of expected value 1. Will continue using this "
744 <<
"factor to normalize further integrals of this PDF." << endl;
780 bottomCutoff = topCutoff / 2.0;
801 topCutoff = bottomCutoff * 2.0;
805 coutI(
Eval) <<
"range set: [" << bottomCutoff <<
", " << topCutoff <<
"]"
808 cutoff = (topCutoff + bottomCutoff) / 2.0;
820 bottomCutoff = cutoff;
823 cutoff = (topCutoff + bottomCutoff) / 2.0;
824 coutI(
Eval) <<
"cutoff range: [" << bottomCutoff <<
", "
825 << topCutoff <<
"]" << endl;
860 std::vector<Long_t> bins(numBins);
861 for (
Int_t ibin = 0; ibin < numBins; ibin++)
862 bins[ibin] = (
Long_t)ibin;
870 for (i = numBins - 1; i >= 0; i--) {
888 for ( ; i >= 0; i--) {
897 for ( ; i < numBins; i++) {
904 if (i == numBins - 1)
930 std::vector<Int_t> bins(numBins);
931 for (
Int_t ibin = 0; ibin < numBins; ibin++)
939 for (i = numBins - 1; i >= 0; i--) {
958 for ( ; i >= 0; i--) {
968 for ( ; i < numBins; i++) {
976 if (i == numBins - 1)
999 <<
"not implemented for this type of interval. Returning 0." << endl;
1015 "Error: Interval type not set" << endl;
1031 "Error: Interval type not set" << endl;
1108 <<
"Sorry, will not compute lower limit unless dimension == 1" << endl;
1116 coutE(
Eval) <<
"In MCMCInterval::LowerLimitBySparseHist: "
1117 <<
"couldn't determine cutoff. Check that num burn in steps < num "
1118 <<
"steps in the Markov chain. Returning param.getMin()." << endl;
1128 for (
Long_t i = 0; i < numBins; i++) {
1131 if (val < lowerLimit)
1152 coutE(
Eval) <<
"In MCMCInterval::LowerLimitByDataHist: "
1153 <<
"couldn't determine cutoff. Check that num burn in steps < num "
1154 <<
"steps in the Markov chain. Returning param.getMin()." << endl;
1163 for (
Int_t i = 0; i < numBins; i++) {
1167 if (val < lowerLimit)
1185 <<
"Sorry, will not compute upper limit unless dimension == 1" << endl;
1193 coutE(
Eval) <<
"In MCMCInterval::UpperLimitBySparseHist: "
1194 <<
"couldn't determine cutoff. Check that num burn in steps < num "
1195 <<
"steps in the Markov chain. Returning param.getMax()." << endl;
1205 for (
Long_t i = 0; i < numBins; i++) {
1208 if (val > upperLimit)
1229 coutE(
Eval) <<
"In MCMCInterval::UpperLimitByDataHist: "
1230 <<
"couldn't determine cutoff. Check that num burn in steps < num "
1231 <<
"steps in the Markov chain. Returning param.getMax()." << endl;
1240 for (
Int_t i = 0; i < numBins; i++) {
1244 if (val > upperLimit)
1268 coutE(
Eval) <<
"in MCMCInterval::LowerLimitByKeys(): "
1269 <<
"couldn't find lower limit, check that the number of burn in "
1270 <<
"steps < number of total steps in the Markov chain. Returning "
1271 <<
"param.getMin()" << endl;
1280 for (
Int_t i = 0; i < numBins; i++) {
1284 if (val < lowerLimit)
1308 coutE(
Eval) <<
"in MCMCInterval::UpperLimitByKeys(): "
1309 <<
"couldn't find upper limit, check that the number of burn in "
1310 <<
"steps < number of total steps in the Markov chain. Returning "
1311 <<
"param.getMax()" << endl;
1320 for (
Int_t i = 0; i < numBins; i++) {
1324 if (val > upperLimit)
1347 coutE(
Eval) <<
"in MCMCInterval::KeysMax(): "
1348 <<
"couldn't find Keys max value, check that the number of burn in "
1349 <<
"steps < number of total steps in the Markov chain. Returning 0"
1357 for (
Int_t i = 0; i < numBins; i++) {
1400 coutI(
Eval) <<
"cutoff = " << cutoff <<
", conf = " << confLevel << endl;
1412 <<
"confidence level not set " << endl;
1429 <<
"confidence level not set " << endl;
1446 <<
"confidence level not set " << endl;
1511 Bool_t tempChangeBinning =
true;
1513 if (!
fAxes[i]->getBinning(NULL,
false,
false).isUniform()) {
1514 tempChangeBinning =
false;
1523 tempChangeBinning =
false;
1525 if (tempChangeBinning) {
1537 "Keys PDF & Heaviside Product Data Hist",
fParameters);
1540 if (tempChangeBinning) {
1545 fAxes[i]->setBins(savedBins[i], NULL);
1559 coutE(
Eval) <<
"MCMCInterval: size is wrong, parameters don't match" << std::endl;
1563 coutE(
Eval) <<
"MCMCInterval: size is ok, but parameters don't match" << std::endl;
static const Double_t DEFAULT_DELTA
static const Double_t DEFAULT_EPSILON
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
THnSparseT< TArrayF > THnSparseF
TRObject operator()(const T1 &t1) const
virtual TObject * Clone(const char *newname=0) const
Make a clone of an object using the Streamer facility.
Int_t numBins() const
Return number of bins.
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
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.
Bool_t equals(const RooAbsCollection &otherColl) const
Check if this and other collection have identically-named contents.
TIterator * createIterator(Bool_t dir=kIterForward) const
TIterator-style iteration over contained elements.
virtual Double_t getMax(const char *name=0) const
Get maximum of currently defined range.
virtual Int_t numBins(const char *rangeName=0) const
virtual Double_t getMin(const char *name=0) const
Get miniminum of currently defined range.
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
RooAbsReal * createIntegral(const RooArgSet &iset, const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none()) const
Create an object that represents the integral of the function over one or more observables listed in ...
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
RooDataHist * fillDataHist(RooDataHist *hist, const RooArgSet *nset, Double_t scaleFactor, Bool_t correctForBinVolume=kFALSE, Bool_t showProgress=kFALSE) const
Fill a RooDataHist with values sampled from this function at the bin centers.
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
The RooDataHist is a container class to hold N-dimensional binned data.
Int_t getIndex(const RooAbsCollection &coord, Bool_t fast=false) const
Calculate bin number of the given coordinates.
double weight(std::size_t i) const
Return weight of i-th bin.
Int_t numEntries() const override
Return the number of bins.
const RooArgSet * get() const override
Get bin centre of current bin.
Double_t sum(bool correctForBinSize, bool inverseCorr=false) const
Return the sum of the weights of all bins in the histogram.
RooDataSet is a container class to hold unbinned data.
Generic N-dimensional implementation of a kernel estimation p.d.f.
static Double_t infinity()
Return internal infinity representation.
A RooProduct represents the product of a given set of RooAbsReal objects.
RooRealVar represents a variable that can be changed from the outside.
void setBins(Int_t nBins, const char *name=0)
Create a uniform binning under name 'name' for this variable.
const RooAbsBinning & getBinning(const char *name=0, Bool_t verbose=kTRUE, Bool_t createOnTheFly=kFALSE) const
Return binning definition with name.
virtual void setVal(Double_t value)
Set value of variable to 'value'.
ConfInterval is an interface class for a generic interval in the RooStats framework.
Represents the Heaviside function.
MCMCInterval is a concrete implementation of the RooStats::ConfInterval interface.
virtual void CreateDataHist()
virtual Double_t LowerLimitBySparseHist(RooRealVar ¶m)
determine lower limit using histogram
virtual void DetermineByDataHist()
virtual Double_t UpperLimitByKeys(RooRealVar ¶m)
determine upper limit in the shortest interval by using keys pdf
virtual void DetermineShortestInterval()
virtual void CreateVector(RooRealVar *param)
virtual Double_t UpperLimit(RooRealVar ¶m)
get the highest value of param that is within the confidence interval
virtual Bool_t IsInInterval(const RooArgSet &point) const
determine whether this point is in the confidence interval
Bool_t CheckParameters(const RooArgSet &point) const
check if parameters are correct. (dummy implementation to start)
virtual Double_t UpperLimitShortest(RooRealVar ¶m)
get the upper limit of param in the confidence interval Note that this works better for some distribu...
enum IntervalType fIntervalType
virtual Double_t UpperLimitBySparseHist(RooRealVar ¶m)
determine upper limit using histogram
virtual void SetAxes(RooArgList &axes)
Set which parameters go on which axis.
virtual void DetermineByKeys()
virtual void DetermineBySparseHist()
virtual TH1 * GetPosteriorHist()
set the number of bins to use (same for all axes, for now) virtual void SetNumBins(Int_t numBins);
virtual Double_t LowerLimitByKeys(RooRealVar ¶m)
determine lower limit in the shortest interval by using keys pdf
virtual Double_t GetHistCutoff()
get the cutoff bin height for being considered in the confidence interval
virtual Double_t UpperLimitTailFraction(RooRealVar ¶m)
determine upper limit of the lower confidence interval
MCMCInterval(const char *name=0)
default constructor
virtual void DetermineTailFractionInterval()
virtual void CreateSparseHist()
Double_t fConfidenceLevel
virtual void DetermineInterval()
Bool_t AcceptableConfLevel(Double_t confLevel)
virtual Double_t GetActualConfidenceLevel()
virtual Double_t GetKeysPdfCutoff() { return fKeysCutoff; }
virtual void SetConfidenceLevel(Double_t cl)
set the desired confidence level (see GetActualConfidenceLevel()) Note: calling this function trigger...
virtual Double_t LowerLimitShortest(RooRealVar ¶m)
get the lower limit of param in the shortest confidence interval Note that this works better for some...
virtual Double_t LowerLimit(RooRealVar ¶m)
get the lowest value of param that is within the confidence interval
virtual Double_t GetKeysPdfCutoff()
get the cutoff RooNDKeysPdf value for being considered in the confidence interval
std::vector< Int_t > fVector
virtual Double_t LowerLimitTailFraction(RooRealVar ¶m)
determine lower limit of the lower confidence interval
virtual RooProduct * GetPosteriorKeysProduct()
Get a clone of the (keyspdf * heaviside) product of the posterior.
virtual Double_t UpperLimitByHist(RooRealVar ¶m)
determine upper limit using histogram
virtual Double_t UpperLimitByDataHist(RooRealVar ¶m)
determine upper limit using histogram
virtual Double_t LowerLimitByHist(RooRealVar ¶m)
determine lower limit using histogram
virtual RooNDKeysPdf * GetPosteriorKeysPdf()
Get a clone of the keys pdf of the posterior.
virtual void CreateKeysPdf()
virtual Double_t LowerLimitByDataHist(RooRealVar ¶m)
determine lower limit using histogram
virtual void CreateHist()
RooDataHist * fKeysDataHist
virtual Double_t CalcConfLevel(Double_t cutoff, Double_t full)
virtual void DetermineByHist()
virtual void SetParameters(const RooArgSet ¶meters)
Set the parameters of interest for this interval and change other internal data members accordingly.
virtual void CreateKeysDataHist()
Double_t GetKeysMax()
Determine the approximate maximum value of the Keys PDF.
Bool_t WithinDeltaFraction(Double_t a, Double_t b)
virtual RooArgSet * GetParameters() const
return a set containing the parameters of this interval the caller owns the returned RooArgSet*
Stores the steps in a Markov Chain of points.
virtual Double_t Weight() const
get the weight of the current (last indexed) entry
virtual RooDataHist * GetAsDataHist(RooArgSet *whichVars=NULL) const
get this MarkovChain as a RooDataHist whose entries contain the values of whichVars.
virtual const RooArgSet * Get(Int_t i) const
get the entry at position i
virtual RooDataSet * GetAsDataSet(RooArgSet *whichVars=NULL) const
get this MarkovChain as a RooDataSet whose entries contain the values of whichVars.
virtual Int_t Size() const
get the number of steps in the chain
virtual Double_t GetBinCenter(Int_t bin) const
Return center of bin.
1-D histogram with a float per channel (see TH1 documentation)}
TH1 is the base class of all histogram classes in ROOT.
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
TObject * Clone(const char *newname=0) const
Make a complete copy of the underlying object.
2-D histogram with a float per channel (see TH1 documentation)}
3-D histogram with a float per channel (see TH1 documentation)}
Long64_t Fill(const Double_t *x, Double_t w=1.)
TAxis * GetAxis(Int_t dim) const
Efficient multidimensional histogram.
Long64_t GetBin(const Int_t *idx) const
Double_t GetBinContent(const Int_t *idx) const
Forwards to THnBase::GetBinContent() overload.
void Sumw2()
Enable calculation of errors.
Long64_t GetNbins() const
Iterator abstract base class.
virtual TObject * Next()=0
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
virtual const char * GetName() const
Returns name of object.
Mother of all ROOT objects.
virtual const char * GetName() const
Returns name of object.
RooCmdArg SelectVars(const RooArgSet &vars)
RooCmdArg EventRange(Int_t nStart, Int_t nStop)
RooCmdArg NormSet(Args_t &&... argsOrArgSet)
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Namespace for the RooStats classes.
void SetParameters(const RooArgSet *desiredVals, RooArgSet *paramsToChange)
CompareDataHistBins(RooDataHist *hist)
CompareSparseHistBins(THnSparse *hist)
CompareVectorIndices(MarkovChain *chain, RooRealVar *param)
static uint64_t sum(uint64_t i)