56 SetName(
"HypoTestInverterOriginal");
61 Fatal(
"HypoTestInverterOriginal",
"Using non HybridCalculatorOriginal class IS NOT SUPPORTED");
78 TString results_name = this->
GetName();
79 results_name +=
"_results";
97 std::cout <<
"Error: problem with the specified range\n";
100 if ( target<=0 || target>=1 ) {
101 std::cout <<
"Error: problem with target value\n";
104 if ( epsilon>0.5-
fabs(0.5-target) ) {
105 std::cout <<
"Error: problem with error value\n";
108 if ( numAlgorithm!=0 && numAlgorithm!=1 ) {
109 std::cout <<
"Error: invalid interpolation algorithm\n";
116 if (
fabs(1-target/(1-
Size()/2))<DBL_EPSILON ) {
118 std::cout <<
"Target matches lower limit: de-activate interpolation in HypoTestInverterResult\n";
121 if (
fabs(1-target/((
Size()/2)))<DBL_EPSILON ) {
123 std::cout <<
"Target matches upper limit: de-activate interpolation in HypoTestInverterResult\n";
127 const double nSigma = 1;
138 double rightX = xMax;
143 if ( rightCL>target && leftCL>target ) {
144 std::cout <<
"The confidence level at both boundaries are both too large ( " << leftCL <<
" and " << rightCL << std::endl <<
"Run again with other boundaries or larger toy-MC statistics\n";
147 if ( rightCL<target && leftCL<target ) {
148 std::cout <<
"The confidence level at both boundaries are both too small ( " << leftCL <<
" and " << rightCL << std::endl <<
"Run again with other boundaries or larger toy-MC statistics\n";
152 unsigned int nIteration = 2;
153 bool quitThisLoop =
false;
156 double centerCLError = 0;
165 if (leftCL==rightCL) {
166 std::cout <<
"This cannot (and should not) happen... quit\n";
168 }
else if (leftX==rightX) {
169 std::cout <<
"This cannot (and should not) happen... quit\n";
174 if (numAlgorithm==0) {
178 if (!leftCL) leftCL = DBL_EPSILON;
179 if (!rightCL) rightCL = DBL_EPSILON;
181 double a = (
log(leftCL) -
log(rightCL)) / (leftX - rightX);
182 double b = leftCL /
exp(a * leftX);
183 x = (
log(target) -
log(b)) / a;
187 std::cout <<
"Extrapolated value out of range or nan: exits\n";
190 }
else if (numAlgorithm==1) {
193 double a = (leftCL-rightCL)/(leftX-rightX);
194 double b = leftCL-a*leftX;
198 std::cout <<
"Extrapolated value out of range or nan: exits\n";
204 if ( x==leftX || x==rightX ) {
205 std::cout <<
"Error: exit because interpolated value equals to a previous iteration\n";
210 bool success =
false;
223 if ( (leftCL > target) == (rightCL < target) ) {
224 if ( (centerCL > target) == (leftCL > target) ) {
227 leftCLError = centerCLError;
231 rightCLError = centerCLError;
235 }
else if ( (
fabs(leftCL - target) / leftCLError) >
236 (
fabs(rightCL - target) / rightCLError) ) {
239 leftCLError = centerCLError;
243 rightCLError = centerCLError;
248 if (
fabs(centerCL-target) < nSigma*centerCLError && centerCLError >
epsilon ) {
252 int nToysTarget = (int)
TMath::Max(nToys*1.5, 1.2*nToys*
pow(centerCLError/epsilon,2));
254 std::cout <<
"Increasing the number of toys to: " << nToysTarget << std::endl;
266 }
while (
fabs(centerCL-target) < nSigma*centerCLError && centerCLError > epsilon && quitThisLoop==
false );
269 if (leftCL==rightCL) {
270 std::cout <<
"Algorithm failed: left and right CL are equal (no intrapolation possible or more toy-MC statistics needed)\n";
275 }
while ( (
fabs(centerCL-target) > nSigma*centerCLError || centerCLError > epsilon ) && quitThisLoop==
false );
280 if ( quitThisLoop==
true ) {
282 std::cout <<
"Aborted the search because something happened\n";
300 std::cout <<
"Please provide nBins>0\n";
303 if ( nBins==1 && xMin!=xMax ) {
304 std::cout <<
"nBins==1 -> I will run for xMin (" << xMin <<
")\n";
306 if ( xMin==xMax && nBins>1 ) {
307 std::cout <<
"xMin==xMax -> I will enforce nBins==1\n";
311 std::cout <<
"Please provide xMin (" << xMin <<
") smaller that xMax (" << xMax <<
")\n";
315 for (
int i=0; i<nBins; i++) {
316 double thisX = xMin+i*(xMax-xMin)/(nBins-1);
320 if ( status==
false ) {
321 std::cout <<
"Loop interrupted because of failed status\n";
337 if ( thisX<fScannedVariable->getMin() ) {
338 std::cout <<
"Out of range: using the lower bound on the scanned variable rather than " << thisX<<
"\n";
342 std::cout <<
"Out of range: using the upper bound on the scanned variable rather than " << thisX<<
"\n";
356 else lastXtested = -999;
358 if ( lastXtested==thisX ) {
360 std::cout <<
"Merge with previous result\n";
363 delete myHybridResult;
virtual Double_t getMin(const char *name=0) const
virtual const char * GetName() const
Returns name of object.
virtual Double_t getMax(const char *name=0) const
HypoTestCalculator * fCalculator0
bool RunAutoScan(double xMin, double xMax, double target, double epsilon=0.005, unsigned int numAlgorithm=0)
void Add(HybridResult *other)
add additional toy-MC experiments to the current results use the data test statistics of the added ob...
Double_t getVal(const RooArgSet *set=0) const
virtual void SetName(const char *name)
Set the name of the TNamed.
virtual ~HypoTestInverterOriginal()
double GetXValue(int index) const
function to return the value of the parameter of interest for the i^th entry in the results ...
HypoTestResult is a base class for results from hypothesis tests.
HypoTestResult * GetResult(int index) const
return a pointer to the i^th result object
HybridCalculatorOriginal class.
virtual Double_t ConfidenceLevel() const
Get the Confidence level for the test.
double GetYError(int index) const
function to return the estimated error on the value of the confidence level for the i^th entry in the...
The TNamed class is the base class for all named ROOT classes.
double pow(double, double)
HypoTestInverterResult * fResults
void UseCLs(bool on=true)
flag to switch between using CLsb (default) or CLs as confidence level
bool fInterpolateLowerLimit
two sided scan (look for lower/upper limit)
HypoTestCalculator is an interface class for a tools which produce RooStats HypoTestResults.
RooRealVar represents a fundamental (non-derived) real valued object.
virtual void setVal(Double_t value)
Set value of variable to 'value'.
virtual Double_t Size() const
Get the size of the test (eg. rate of Type I error)
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
HypoTestInverterOriginal()
bool RunOnePoint(double thisX)
virtual HypoTestResult * GetHypoTest() const =0
Namespace for the RooStats classes.
This class is now depratcated and to be replaced by the HypoTestInverter.
RooRealVar * fScannedVariable
HypoTestInverterResult class: holds the array of hypothesis test results and compute a confidence int...
double GetYValue(int index) const
function to return the value of the confidence level for the i^th entry in the results ...
virtual void Add(TObject *obj)
Short_t Max(Short_t a, Short_t b)
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 void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
bool RunFixedScan(int nBins, double xMin, double xMax)
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
int ArraySize() const
number of entries in the results array
bool fInterpolateUpperLimit
std::vector< double > fXValues
number of points used to build expected p-values