100 MCMCInterval::MCMCInterval(
const char*
name)
190 struct CompareDataHistBins {
202 struct CompareSparseHistBins {
212 struct CompareVectorIndices {
214 fChain(chain), fParam(param) {}
255 x[i] =
fAxes[i]->getVal();
285 <<
"Interval type not set. Returning false." << endl;
326 "number of variables in axes (" << size <<
327 ") doesn't match number of parameters (" 331 for (
Int_t i = 0; i < size; i++)
344 <<
"parameters have not been set." << endl;
350 "MCMCInterval::CreateKeysPdf: creation of Keys PDF failed: " <<
351 "Number of burn-in steps (num steps to ignore) >= number of steps " <<
352 "in Markov chain." << endl;
384 coutE(
Eval) <<
"* Error in MCMCInterval::CreateHist(): " <<
385 "Crucial data member was NULL." << endl;
386 coutE(
Eval) <<
"Make sure to fully construct/initialize." << endl;
394 "MCMCInterval::CreateHist: creation of histogram failed: " <<
395 "Number of burn-in steps (num steps to ignore) >= number of steps " <<
396 "in Markov chain." << endl;
402 fHist =
new TH1F(
"posterior",
"MCMC Posterior Histogram",
406 fHist =
new TH2F(
"posterior",
"MCMC Posterior Histogram",
411 fHist =
new TH3F(
"posterior",
"MCMC Posterior Histogram",
417 coutE(
Eval) <<
"* Error in MCMCInterval::CreateHist() : " <<
418 "TH1* couldn't handle dimension: " <<
fDimension << endl;
455 <<
"Crucial data member was NULL." << endl;
472 fDimension, bins, min, max);
485 "MCMCInterval::CreateSparseHist: creation of histogram failed: " <<
486 "Number of burn-in steps (num steps to ignore) >= number of steps " <<
487 "in Markov chain." << endl;
508 coutE(
Eval) <<
"* Error in MCMCInterval::CreateDataHist(): " <<
509 "Crucial data member was NULL or empty." << endl;
510 coutE(
Eval) <<
"Make sure to fully construct/initialize." << endl;
516 "MCMCInterval::CreateDataHist: creation of histogram failed: " <<
517 "Number of burn-in steps (num steps to ignore) >= number of steps " <<
518 "in Markov chain." << endl;
536 "Crucial data member (Markov chain) was NULL." << endl;
544 "MCMCInterval::CreateVector: creation of vector failed: " <<
545 "Number of burn-in steps (num steps to ignore) >= number of steps " <<
546 "in Markov chain." << endl;
554 for (i = 0; i < size; i++) {
561 CompareVectorIndices(
fChain, param));
577 while ((obj = it->
Next()) != NULL) {
578 if (dynamic_cast<RooRealVar*>(obj) != NULL)
581 coutE(
Eval) <<
"* Error in MCMCInterval::SetParameters: " <<
582 obj->
GetName() <<
" not a RooRealVar*" << std::endl;
601 "Error: Interval type not set" << endl;
620 if (fLeftSideTF < 0 || fLeftSideTF > 1) {
622 <<
"Fraction must be in the range [0, 1]. " 629 <<
"Error: Can only find a tail-fraction interval for 1-D intervals" 636 <<
"Crucial data member was NULL." << endl;
688 if (
TMath::Abs(leftTailSum + w - leftTailCutoff) <
703 if (
TMath::Abs(rightTailSum + w - rightTailCutoff) <
744 coutW(
Eval) <<
"Warning: Integral of Keys PDF came out to " << full
745 <<
" instead of expected value 1. Will continue using this " 746 <<
"factor to normalize further integrals of this PDF." << endl;
782 bottomCutoff = topCutoff / 2.0;
803 topCutoff = bottomCutoff * 2.0;
807 coutI(
Eval) <<
"range set: [" << bottomCutoff <<
", " << topCutoff <<
"]" 810 cutoff = (topCutoff + bottomCutoff) / 2.0;
822 bottomCutoff = cutoff;
825 cutoff = (topCutoff + bottomCutoff) / 2.0;
826 coutI(
Eval) <<
"cutoff range: [" << bottomCutoff <<
", " 827 << topCutoff <<
"]" << endl;
862 std::vector<Long_t> bins(numBins);
863 for (
Int_t ibin = 0; ibin < numBins; ibin++)
864 bins[ibin] = (
Long_t)ibin;
865 std::stable_sort(bins.begin(), bins.end(), CompareSparseHistBins(
fSparseHist));
872 for (i = numBins - 1; i >= 0; i--) {
890 for ( ; i >= 0; i--) {
899 for ( ; i < numBins; i++) {
906 if (i == numBins - 1)
932 std::vector<Int_t> bins(numBins);
933 for (
Int_t ibin = 0; ibin < numBins; ibin++)
935 std::stable_sort(bins.begin(), bins.end(), CompareDataHistBins(
fDataHist));
941 for (i = numBins - 1; i >= 0; i--) {
960 for ( ; i >= 0; i--) {
970 for ( ; i < numBins; i++) {
978 if (i == numBins - 1)
1001 <<
"not implemented for this type of interval. Returning 0." << endl;
1017 "Error: Interval type not set" << endl;
1033 "Error: Interval type not set" << endl;
1110 <<
"Sorry, will not compute lower limit unless dimension == 1" << endl;
1118 coutE(
Eval) <<
"In MCMCInterval::LowerLimitBySparseHist: " 1119 <<
"couldn't determine cutoff. Check that num burn in steps < num " 1120 <<
"steps in the Markov chain. Returning param.getMin()." << endl;
1130 for (
Long_t i = 0; i < numBins; i++) {
1133 if (val < lowerLimit)
1154 coutE(
Eval) <<
"In MCMCInterval::LowerLimitByDataHist: " 1155 <<
"couldn't determine cutoff. Check that num burn in steps < num " 1156 <<
"steps in the Markov chain. Returning param.getMin()." << endl;
1165 for (
Int_t i = 0; i < numBins; i++) {
1169 if (val < lowerLimit)
1187 <<
"Sorry, will not compute upper limit unless dimension == 1" << endl;
1195 coutE(
Eval) <<
"In MCMCInterval::UpperLimitBySparseHist: " 1196 <<
"couldn't determine cutoff. Check that num burn in steps < num " 1197 <<
"steps in the Markov chain. Returning param.getMax()." << endl;
1207 for (
Long_t i = 0; i < numBins; i++) {
1210 if (val > upperLimit)
1231 coutE(
Eval) <<
"In MCMCInterval::UpperLimitByDataHist: " 1232 <<
"couldn't determine cutoff. Check that num burn in steps < num " 1233 <<
"steps in the Markov chain. Returning param.getMax()." << endl;
1242 for (
Int_t i = 0; i < numBins; i++) {
1246 if (val > upperLimit)
1270 coutE(
Eval) <<
"in MCMCInterval::LowerLimitByKeys(): " 1271 <<
"couldn't find lower limit, check that the number of burn in " 1272 <<
"steps < number of total steps in the Markov chain. Returning " 1273 <<
"param.getMin()" << endl;
1282 for (
Int_t i = 0; i < numBins; i++) {
1286 if (val < lowerLimit)
1310 coutE(
Eval) <<
"in MCMCInterval::UpperLimitByKeys(): " 1311 <<
"couldn't find upper limit, check that the number of burn in " 1312 <<
"steps < number of total steps in the Markov chain. Returning " 1313 <<
"param.getMax()" << endl;
1322 for (
Int_t i = 0; i < numBins; i++) {
1326 if (val > upperLimit)
1349 coutE(
Eval) <<
"in MCMCInterval::KeysMax(): " 1350 <<
"couldn't find Keys max value, check that the number of burn in " 1351 <<
"steps < number of total steps in the Markov chain. Returning 0" 1359 for (
Int_t i = 0; i < numBins; i++) {
1402 coutI(
Eval) <<
"cutoff = " << cutoff <<
", conf = " << confLevel << endl;
1414 <<
"confidence level not set " << endl;
1431 <<
"confidence level not set " << endl;
1448 <<
"confidence level not set " << endl;
1513 Bool_t tempChangeBinning =
true;
1515 if (!
fAxes[i]->getBinning(NULL,
false,
false).isUniform()) {
1516 tempChangeBinning =
false;
1524 if (fDimension >= 2)
1525 tempChangeBinning =
false;
1527 if (tempChangeBinning) {
1539 "Keys PDF & Heaviside Product Data Hist",
fParameters);
1542 if (tempChangeBinning) {
1547 fAxes[i]->setBins(savedBins[i], NULL);
1561 coutE(
Eval) <<
"MCMCInterval: size is wrong, parameters don't match" << std::endl;
1565 coutE(
Eval) <<
"MCMCInterval: size is ok, but parameters don't match" << std::endl;
virtual Double_t getMin(const char *name=0) const
virtual Bool_t IsInInterval(const RooArgSet &point) const
determine whether this point is in the confidence interval
virtual const char * GetName() const
Returns name of object.
TIterator * createIterator(Bool_t dir=kIterForward) const
static long int sum(long int i)
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
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 UpperLimitBySparseHist(RooRealVar ¶m)
determine upper limit using histogram
virtual Double_t LowerLimitTailFraction(RooRealVar ¶m)
determine lower limit of the lower confidence interval
virtual Double_t getMax(const char *name=0) const
virtual Bool_t add(const RooAbsCollection &col, Bool_t silent=kFALSE)
Add a collection of arguments to this collection by calling add() for each element in the source coll...
virtual const RooArgSet * get() const
virtual TH1 * GetPosteriorHist()
set the number of bins to use (same for all axes, for now) virtual void SetNumBins(Int_t numBins); ...
virtual RooArgSet * GetParameters() const
return a set containing the parameters of this interval the caller owns the returned RooArgSet* ...
virtual RooProduct * GetPosteriorKeysProduct()
Get a clone of the (keyspdf * heaviside) product of the posterior.
virtual void CreateKeysPdf()
3-D histogram with a float per channel (see TH1 documentation)}
Long64_t Fill(const Double_t *x, Double_t w=1.)
virtual void DetermineByKeys()
virtual void CreateVector(RooRealVar *param)
virtual Int_t numBins(const char *rangeName=0) const
virtual Double_t GetHistCutoff()
get the cutoff bin height for being considered in the confidence interval
Double_t getVal(const RooArgSet *set=0) const
std::vector< Int_t > fVector
Long64_t GetBin(const Int_t *idx) const
THist< 1, float, THistStatContent, THistStatUncertainty > TH1F
RooCmdArg NormSet(const RooArgSet &nset)
const RooAbsBinning & getBinning(const char *name=0, Bool_t verbose=kTRUE, Bool_t createOnTheFly=kFALSE) const
Return binning definition with name.
Int_t getIndex(const RooArgSet &coord, Bool_t fast=kFALSE)
void SetParameters(const RooArgSet *desiredVals, RooArgSet *paramsToChange)
virtual Double_t UpperLimitByKeys(RooRealVar ¶m)
determine upper limit in the shortest interval by using keys pdf
virtual void SetAxes(RooArgList &axes)
Set which parameters go on which axis.
virtual Int_t Size() const
get the number of steps in the chain
virtual void DetermineInterval()
1-D histogram with a float per channel (see TH1 documentation)}
Bool_t equals(const RooAbsCollection &otherColl) const
Check if this and other collection have identically named contents.
virtual TObject * Clone(const char *newname=0) const
Make a clone of an object using the Streamer facility.
virtual void CreateKeysDataHist()
Long64_t GetNbins() const
TRObject operator()(const T1 &t1) const
Iterator abstract base class.
virtual void DetermineShortestInterval()
virtual RooDataHist * GetAsDataHist(RooArgSet *whichVars=NULL) const
get this MarkovChain as a RooDataHist whose entries contain the values of whichVars.
virtual void CreateHist()
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.
virtual Double_t LowerLimitByHist(RooRealVar ¶m)
determine lower limit using histogram
RooDataSet is a container class to hold N-dimensional binned data.
Bool_t WithinDeltaFraction(Double_t a, Double_t b)
virtual const RooArgSet * Get(Int_t i) const
get the entry at position i
Efficient multidimensional histogram.
Double_t fConfidenceLevel
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
virtual Double_t UpperLimitByHist(RooRealVar ¶m)
determine upper limit using histogram
virtual Double_t GetBinCenter(Int_t bin) const
Return center of bin.
virtual Double_t weight() const
void setBins(Int_t nBins, const char *name=0)
THnSparseT< TArrayF > THnSparseF
RooRealVar represents a fundamental (non-derived) real valued object.
RooDataHist * fKeysDataHist
Double_t GetBinContent(const Int_t *idx) const
virtual void setVal(Double_t value)
Set value of variable to 'value'.
virtual void DetermineByDataHist()
MCMCInterval(const char *name=0)
default constructor
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 ...
enum IntervalType fIntervalType
TAxis * GetAxis(Int_t dim) const
RooCmdArg SelectVars(const RooArgSet &vars)
virtual Double_t GetKeysPdfCutoff()
get the cutoff RooNDKeysPdf value for being considered in the confidence interval ...
virtual RooNDKeysPdf * GetPosteriorKeysPdf()
Get a clone of the keys pdf of the posterior.
virtual Double_t LowerLimitBySparseHist(RooRealVar ¶m)
determine lower limit using histogram
RooAbsArg * at(Int_t idx) const
2-D histogram with a float per channel (see TH1 documentation)}
void Sumw2()
Enable calculation of errors.
virtual void DetermineByHist()
static Double_t infinity()
Return internal infinity representation.
static const Double_t DEFAULT_EPSILON
virtual Double_t UpperLimit(RooRealVar ¶m)
get the highest value of param that is within the confidence interval
virtual void SetConfidenceLevel(Double_t cl)
set the desired confidence level (see GetActualConfidenceLevel()) Note: calling this function trigger...
RooDataSet is a container class to hold unbinned data.
Represents the Heaviside function.
Generic N-dimensional implementation of a kernel estimation p.d.f.
RooProduct a RooAbsReal implementation that represent the product of a given set of other RooAbsReal ...
Double_t sum(Bool_t correctForBinSize, Bool_t inverseCorr=kFALSE) const
Return the sum of the weights of all hist bins.
virtual Double_t GetActualConfidenceLevel()
virtual Double_t GetKeysPdfCutoff() { return fKeysCutoff; }
static const Double_t DEFAULT_DELTA
ConfInterval is an interface class for a generic interval in the RooStats framework.
Stores the steps in a Markov Chain of points.
Namespace for the RooStats classes.
RooCmdArg EventRange(Int_t nStart, Int_t nStop)
virtual Int_t numEntries() const
Return the number of bins.
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
virtual void CreateDataHist()
virtual Double_t LowerLimit(RooRealVar ¶m)
get the lowest value of param that is within the confidence interval
virtual RooDataSet * GetAsDataSet(RooArgSet *whichVars=NULL) const
get this MarkovChain as a RooDataSet whose entries contain the values of whichVars.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
Bool_t AcceptableConfLevel(Double_t confLevel)
Double_t GetKeysMax()
Determine the approximate maximum value of the Keys PDF.
virtual void CreateSparseHist()
THist< 3, float, THistStatContent, THistStatUncertainty > TH3F
virtual Double_t Weight() const
get the weight of the current (last indexed) entry
Mother of all ROOT objects.
virtual void DetermineTailFractionInterval()
virtual Double_t UpperLimitByDataHist(RooRealVar ¶m)
determine upper limit using histogram
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 SetParameters(const RooArgSet ¶meters)
Set the parameters of interest for this interval and change other internal data members accordingly...
virtual TObject * Next()=0
TObject * Clone(const char *newname=0) const
Make a complete copy of the underlying object.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
virtual Double_t UpperLimitTailFraction(RooRealVar ¶m)
determine upper limit of the lower confidence interval
virtual Double_t LowerLimitByKeys(RooRealVar ¶m)
determine lower limit in the shortest interval by using keys pdf
MCMCInterval is a concrete implementation of the RooStats::ConfInterval interface.
virtual void DetermineBySparseHist()
virtual const char * GetName() const
Returns name of object.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
THist< 2, float, THistStatContent, THistStatUncertainty > TH2F
virtual Double_t UpperLimitShortest(RooRealVar ¶m)
get the upper limit of param in the confidence interval Note that this works better for some distribu...
virtual Double_t CalcConfLevel(Double_t cutoff, Double_t full)
Bool_t CheckParameters(const RooArgSet &point) const
check if parameters are correct. (dummy implementation to start)
virtual Double_t LowerLimitByDataHist(RooRealVar ¶m)
determine lower limit using histogram
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...