72using std::endl, std::string;
82 fTestStatSampler(nullptr),
83 fPointsToTest(nullptr),
86 fAdaptiveSampling(false),
87 fAdditionalNToysFactor(1.),
88 fSaveBeltToFile(false),
115 oocoutI(
f,
Contents) <<
"NeymanConstruction saving ConfidenceBelt to file SamplingDistributions.root" << std::endl;
116 f =
new TFile(
"SamplingDistributions.root",
"recreate");
127 "points in interval",
156 double upperEdgeOfAcceptance;
157 double upperEdgeMinusSigma;
158 double upperEdgePlusSigma;
159 double lowerEdgeOfAcceptance;
160 double lowerEdgeMinusSigma;
161 double lowerEdgePlusSigma;
162 Int_t additionalMC=0;
180 totalMC = (
Int_t) tmc;
190 additionalMC = 2*totalMC;
196 oocoutE(
nullptr,
Eval) <<
"Neyman Construction: error generating sampling distribution" << std::endl;
199 totalMC=samplingDist->
GetSize();
205 upperEdgeOfAcceptance =
207 sigma, upperEdgePlusSigma);
210 sigma, upperEdgeMinusSigma);
213 lowerEdgeOfAcceptance =
215 sigma, lowerEdgePlusSigma);
218 sigma, lowerEdgeMinusSigma);
221 <<
"total MC = " << totalMC
222 <<
" this test stat = " << thisTestStatistic << std::endl
223 <<
" upper edge -1sigma = " << upperEdgeMinusSigma
224 <<
", upperEdge = "<<upperEdgeOfAcceptance
225 <<
", upper edge +1sigma = " << upperEdgePlusSigma << std::endl
226 <<
" lower edge -1sigma = " << lowerEdgeMinusSigma
227 <<
", lowerEdge = "<<lowerEdgeOfAcceptance
228 <<
", lower edge +1sigma = " << lowerEdgePlusSigma << std::endl;
230 (thisTestStatistic <= upperEdgeOfAcceptance &&
231 thisTestStatistic > upperEdgeMinusSigma)
232 || (thisTestStatistic >= upperEdgeOfAcceptance &&
233 thisTestStatistic < upperEdgePlusSigma)
234 || (thisTestStatistic <= lowerEdgeOfAcceptance &&
235 thisTestStatistic > lowerEdgeMinusSigma)
236 || (thisTestStatistic >= lowerEdgeOfAcceptance &&
237 thisTestStatistic < lowerEdgePlusSigma)
238 ) && (totalMC < 100./
fSize)
245 oocoutE(
nullptr,
Eval) <<
"Neyman Construction: error generating sampling distribution" << std::endl;
249 lowerEdgeOfAcceptance =
251 upperEdgeOfAcceptance =
259 lowerEdgeOfAcceptance,
260 upperEdgeOfAcceptance);
265 <<
" total MC = " << samplingDist->
GetSize()
266 <<
" this test stat = " << thisTestStatistic << std::endl;
268 for (
auto const *myarg : static_range_cast<RooRealVar *> (*point)){
269 ooccoutP(samplingDist,
Eval) << myarg->GetName() <<
"=" << myarg->getVal() <<
" ";
271 ooccoutP(samplingDist,
Eval) <<
"[" << lowerEdgeOfAcceptance <<
", "
272 << upperEdgeOfAcceptance <<
"] " <<
" in interval = " <<
273 (thisTestStatistic >= lowerEdgeOfAcceptance && thisTestStatistic <= upperEdgeOfAcceptance)
274 << std::endl << std::endl;
277 if(thisTestStatistic >= lowerEdgeOfAcceptance && thisTestStatistic <= upperEdgeOfAcceptance) {
280 pointsInInterval->
add(*point);
286 samplingDist->
Write();
287 string tmpName =
"hist_";
288 tmpName+=samplingDist->
GetName();
289 TH1F h{tmpName.c_str(),
"",500,0.,5.};
290 for(
int ii=0; ii<samplingDist->
GetSize(); ++ii){
299 oocoutI(pointsInInterval,
Eval) << npass <<
" points in interval" << std::endl;
int Int_t
Signed integer 4 bytes (int)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
void assign(const RooAbsCollection &other) const
Sets the value, cache and constant attribute of any argument in our set that also appears in the othe...
Abstract base class for binned and unbinned datasets.
virtual const RooArgSet * get() const
virtual Int_t numEntries() const
Return number of entries in dataset, i.e., count unweighted entries.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Container class to hold unbinned data.
void add(const RooArgSet &row, double weight, double weightError)
Add one ore more rows of data.
void AddAcceptanceRegion(RooArgSet &, AcceptanceRegion region, double cl=-1., double leftside=-1.)
add after creating a region
< A class that holds configuration information for a model using a workspace as a store
const RooArgSet * GetParametersOfInterest() const
get RooArgSet containing the parameter of interest (return nullptr if not existing)
bool fAdaptiveSampling
controls use of adaptive sampling algorithm
RooAbsData * fPointsToTest
double fSize
size of the test (eg. specified rate of Type I error)
PointSetInterval * GetInterval() const override
Main interface to get a ConfInterval (will be a PointSetInterval)
ConfidenceBelt * fConfBelt
~NeymanConstruction() override
default constructor if(fOwnsWorkspace && fWS) delete fWS; if(fConfBelt) delete fConfBelt;
bool fSaveBeltToFile
controls use if ConfidenceBelt should be saved to a TFile
RooAbsData & fData
data set
NeymanConstruction(RooAbsData &data, ModelConfig &model)
default constructor
double fAdditionalNToysFactor
give user ability to ask for more toys
bool fCreateBelt
controls use if ConfidenceBelt should be saved to a TFile
TestStatSampler * fTestStatSampler
PointSetInterval is a concrete implementation of the ConfInterval interface.
This class simply holds a sampling distribution of some test statistic.
Int_t GetSize() const
size of samples
double InverseCDF(double pvalue)
get the inverse of the Cumulative distribution function
const std::vector< double > & GetSamplingDistribution() const
Get test statistics values.
virtual void SetParametersForTestStat(const RooArgSet &)=0
specify the values of parameters used when evaluating test statistic
virtual double EvaluateTestStatistic(RooAbsData &data, RooArgSet ¶msOfInterest)=0
Main interface to evaluate the test statistic on a dataset.
virtual SamplingDistribution * GetSamplingDistribution(RooArgSet ¶msOfInterest)=0
Main interface to get a ConfInterval, pure virtual.
ToyMCSampler is an implementation of the TestStatSampler interface.
virtual SamplingDistribution * AppendSamplingDistribution(RooArgSet &allParameters, SamplingDistribution *last, Int_t additionalMC)
Extended interface to append to sampling distribution more samples.
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
1-D histogram with a float per channel (see TH1 documentation)
const char * GetName() const override
Returns name of object.
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Namespace for the RooStats classes.