50 fScannedVariable(&scannedVariable),
57 SetName(
"HypoTestInverterOriginal");
62 Fatal(
"HypoTestInverterOriginal",
"Using non HybridCalculatorOriginal class IS NOT SUPPORTED");
80 results_name +=
"_results";
98 std::cout <<
"Error: problem with the specified range\n";
101 if ( target<=0 || target>=1 ) {
102 std::cout <<
"Error: problem with target value\n";
105 if ( epsilon>0.5-
fabs(0.5-target) ) {
106 std::cout <<
"Error: problem with error value\n";
109 if ( numAlgorithm!=0 && numAlgorithm!=1 ) {
110 std::cout <<
"Error: invalid interpolation algorithm\n";
117 if (
fabs(1-target/(1-
Size()/2))<DBL_EPSILON ) {
119 std::cout <<
"Target matches lower limit: de-activate interpolation in HypoTestInverterResult\n";
122 if (
fabs(1-target/((
Size()/2)))<DBL_EPSILON ) {
124 std::cout <<
"Target matches upper limit: de-activate interpolation in HypoTestInverterResult\n";
128 const double nSigma = 1;
139 double rightX = xMax;
144 if ( rightCL>target && leftCL>target ) {
145 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";
148 if ( rightCL<target && leftCL<target ) {
149 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";
153 unsigned int nIteration = 2;
154 bool quitThisLoop =
false;
157 double centerCLError = 0;
166 if (leftCL==rightCL) {
167 std::cout <<
"This cannot (and should not) happen... quit\n";
169 }
else if (leftX==rightX) {
170 std::cout <<
"This cannot (and should not) happen... quit\n";
175 if (numAlgorithm==0) {
179 if (!leftCL) leftCL = DBL_EPSILON;
180 if (!rightCL) rightCL = DBL_EPSILON;
182 double a = (
log(leftCL) -
log(rightCL)) / (leftX - rightX);
183 double b = leftCL /
exp(a * leftX);
184 x = (
log(target) -
log(b)) / a;
188 std::cout <<
"Extrapolated value out of range or nan: exits\n";
191 }
else if (numAlgorithm==1) {
194 double a = (leftCL-rightCL)/(leftX-rightX);
195 double b = leftCL-a*leftX;
199 std::cout <<
"Extrapolated value out of range or nan: exits\n";
205 if ( x==leftX || x==rightX ) {
206 std::cout <<
"Error: exit because interpolated value equals to a previous iteration\n";
211 bool success =
false;
224 if ( (leftCL > target) == (rightCL < target) ) {
225 if ( (centerCL > target) == (leftCL > target) ) {
228 leftCLError = centerCLError;
232 rightCLError = centerCLError;
236 }
else if ( (
fabs(leftCL - target) / leftCLError) >
237 (
fabs(rightCL - target) / rightCLError) ) {
240 leftCLError = centerCLError;
244 rightCLError = centerCLError;
249 if (
fabs(centerCL-target) < nSigma*centerCLError && centerCLError >
epsilon ) {
253 int nToysTarget = (int)
TMath::Max(nToys*1.5, 1.2*nToys*
pow(centerCLError/epsilon,2));
255 std::cout <<
"Increasing the number of toys to: " << nToysTarget << std::endl;
267 }
while (
fabs(centerCL-target) < nSigma*centerCLError && centerCLError > epsilon && quitThisLoop==
false );
270 if (leftCL==rightCL) {
271 std::cout <<
"Algorithm failed: left and right CL are equal (no intrapolation possible or more toy-MC statistics needed)\n";
276 }
while ( (
fabs(centerCL-target) > nSigma*centerCLError || centerCLError > epsilon ) && quitThisLoop==
false );
281 if ( quitThisLoop==
true ) {
283 std::cout <<
"Aborted the search because something happened\n";
301 std::cout <<
"Please provide nBins>0\n";
304 if ( nBins==1 && xMin!=xMax ) {
305 std::cout <<
"nBins==1 -> I will run for xMin (" << xMin <<
")\n";
307 if ( xMin==xMax && nBins>1 ) {
308 std::cout <<
"xMin==xMax -> I will enforce nBins==1\n";
312 std::cout <<
"Please provide xMin (" << xMin <<
") smaller that xMax (" << xMax <<
")\n";
316 for (
int i=0; i<nBins; i++) {
317 double thisX = xMin+i*(xMax-xMin)/(nBins-1);
321 if ( status==
false ) {
322 std::cout <<
"Loop interrupted because of failed status\n";
338 if ( thisX<fScannedVariable->getMin() ) {
339 std::cout <<
"Out of range: using the lower bound on the scanned variable rather than " << thisX<<
"\n";
343 std::cout <<
"Out of range: using the upper bound on the scanned variable rather than " << thisX<<
"\n";
357 else lastXtested = -999;
359 if ( lastXtested==thisX ) {
361 std::cout <<
"Merge with previous result\n";
364 delete myHybridResult;
HypoTestCalculator * fCalculator0
bool RunAutoScan(double xMin, double xMax, double target, double epsilon=0.005, unsigned int numAlgorithm=0)
int ArraySize() const
number of entries in the results array
void Add(HybridResult *other)
virtual void SetName(const char *name)
Change (i.e.
virtual ~HypoTestInverterOriginal()
HypoTestResult is a base class for results from hypothesis tests.
virtual Double_t getMin(const char *name=0) const
HybridCalculatorOriginal class.
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...
ClassImp(TIterator) Bool_t TIterator return false
Compare two iterator objects.
ClassImp(RooStats::HypoTestInverterOriginal) using namespace RooStats
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
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
Double_t getVal(const RooArgSet *set=0) const
bool fInterpolateLowerLimit
two sided scan (look for lower/upper limit)
HypoTestCalculator is an interface class for a tools which produce RooStats HypoTestResults.
HypoTestResult * GetResult(int index) const
return a pointer to the i^th result 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)
virtual const char * GetName() const
Returns name of object.
bool RunOnePoint(double thisX)
virtual Double_t ConfidenceLevel() const
Get the Confidence level for the test.
virtual HypoTestResult * GetHypoTest() const =0
double GetXValue(int index) const
function to return the value of the parameter of interest for the i^th entry in the results ...
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 Double_t getMax(const char *name=0) const
virtual void Add(TObject *obj)
Short_t Max(Short_t a, Short_t b)
bool RunFixedScan(int nBins, double xMin, double xMax)
virtual void SetTitle(const char *title="")
Change (i.e. set) the title of the TNamed.
bool fInterpolateUpperLimit
std::vector< double > fXValues
max sigma value used to scan asymptotic expected p values