73 SetName(
"HypoTestInverterOriginal");
78 Fatal(
"HypoTestInverterOriginal",
"Using non HybridCalculatorOriginal class IS NOT SUPPORTED");
98 TString results_name = this->
GetName();
99 results_name +=
"_results";
118 std::cout <<
"Error: problem with the specified range\n";
121 if ( target<=0 || target>=1 ) {
122 std::cout <<
"Error: problem with target value\n";
125 if ( epsilon>0.5-
fabs(0.5-target) ) {
126 std::cout <<
"Error: problem with error value\n";
129 if ( numAlgorithm!=0 && numAlgorithm!=1 ) {
130 std::cout <<
"Error: invalid interpolation algorithm\n";
137 if (
fabs(1-target/(1-
Size()/2))<DBL_EPSILON ) {
139 std::cout <<
"Target matches lower limit: de-activate interpolation in HypoTestInverterResult\n";
142 if (
fabs(1-target/((
Size()/2)))<DBL_EPSILON ) {
144 std::cout <<
"Target matches upper limit: de-activate interpolation in HypoTestInverterResult\n";
148 const double nSigma = 1;
159 double rightX = xMax;
164 if ( rightCL>target && leftCL>target ) {
165 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";
168 if ( rightCL<target && leftCL<target ) {
169 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";
173 unsigned int nIteration = 2;
174 bool quitThisLoop =
false;
177 double centerCLError = 0;
186 if (leftCL==rightCL) {
187 std::cout <<
"This cannot (and should not) happen... quit\n";
189 }
else if (leftX==rightX) {
190 std::cout <<
"This cannot (and should not) happen... quit\n";
195 if (numAlgorithm==0) {
199 if (!leftCL) leftCL = DBL_EPSILON;
200 if (!rightCL) rightCL = DBL_EPSILON;
202 double a = (
log(leftCL) -
log(rightCL)) / (leftX - rightX);
203 double b = leftCL /
exp(a * leftX);
204 x = (
log(target) -
log(b)) / a;
208 std::cout <<
"Extrapolated value out of range or nan: exits\n";
211 }
else if (numAlgorithm==1) {
214 double a = (leftCL-rightCL)/(leftX-rightX);
215 double b = leftCL-a*leftX;
219 std::cout <<
"Extrapolated value out of range or nan: exits\n";
225 if ( x==leftX || x==rightX ) {
226 std::cout <<
"Error: exit because interpolated value equals to a previous iteration\n";
231 bool success =
false;
244 if ( (leftCL > target) == (rightCL < target) ) {
245 if ( (centerCL > target) == (leftCL > target) ) {
248 leftCLError = centerCLError;
252 rightCLError = centerCLError;
256 }
else if ( (
fabs(leftCL - target) / leftCLError) >
257 (
fabs(rightCL - target) / rightCLError) ) {
260 leftCLError = centerCLError;
264 rightCLError = centerCLError;
269 if (
fabs(centerCL-target) < nSigma*centerCLError && centerCLError >
epsilon ) {
273 int nToysTarget = (int)
TMath::Max(nToys*1.5, 1.2*nToys*
pow(centerCLError/epsilon,2));
275 std::cout <<
"Increasing the number of toys to: " << nToysTarget << std::endl;
287 }
while (
fabs(centerCL-target) < nSigma*centerCLError && centerCLError > epsilon && quitThisLoop==
false );
290 if (leftCL==rightCL) {
291 std::cout <<
"Algorithm failed: left and right CL are equal (no interpolation possible or more toy-MC statistics needed)\n";
296 }
while ( (
fabs(centerCL-target) > nSigma*centerCLError || centerCLError > epsilon ) && quitThisLoop==
false );
301 if ( quitThisLoop==
true ) {
303 std::cout <<
"Aborted the search because something happened\n";
322 std::cout <<
"Please provide nBins>0\n";
325 if ( nBins==1 && xMin!=xMax ) {
326 std::cout <<
"nBins==1 -> I will run for xMin (" << xMin <<
")\n";
328 if ( xMin==xMax && nBins>1 ) {
329 std::cout <<
"xMin==xMax -> I will enforce nBins==1\n";
333 std::cout <<
"Please provide xMin (" << xMin <<
") smaller that xMax (" << xMax <<
")\n";
337 for (
int i=0; i<nBins; i++) {
338 double thisX = xMin+i*(xMax-xMin)/(nBins-1);
342 if ( status==
false ) {
343 std::cout <<
"Loop interrupted because of failed status\n";
360 if ( thisX<fScannedVariable->getMin() ) {
361 std::cout <<
"Out of range: using the lower bound on the scanned variable rather than " << thisX<<
"\n";
365 std::cout <<
"Out of range: using the upper bound on the scanned variable rather than " << thisX<<
"\n";
379 else lastXtested = -999;
381 if ( lastXtested==thisX ) {
383 std::cout <<
"Merge with previous result\n";
386 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)
run only one point
virtual HypoTestResult * GetHypoTest() const =0
Namespace for the RooStats classes.
This class is now deprecated and to be replaced by the HypoTestInverter.
RooRealVar * fScannedVariable
HypoTestInverterResult class holds the array of hypothesis test results and compute a confidence inte...
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
Class encapsulating the result of the HybridCalculatorOriginal.
bool fInterpolateUpperLimit
std::vector< double > fXValues
number of points used to build expected p-values