ROOT logo
// @(#)root/roostats:$Id: HypoTestInverterResult.h 36230 2010-10-09 20:21:02Z wouter $
// Author: Kyle Cranmer, Lorenzo Moneta, Gregory Schott, Wouter Verkerke
/*************************************************************************
 * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOSTATS_HypoTestInverterResult
#define ROOSTATS_HypoTestInverterResult



#ifndef ROOSTATS_SimpleInterval
#include "RooStats/SimpleInterval.h"
#endif

#include "RooStats/HypoTestResult.h"

class RooRealVar;

namespace RooStats {

  class HypoTestInverterResult : public SimpleInterval {

  public:

    // default constructor
    explicit HypoTestInverterResult(const char* name = 0);

    // constructor
    HypoTestInverterResult( const char* name, 
			    const RooRealVar& scannedVariable,
			    double cl ) ;

    // destructor
    virtual ~HypoTestInverterResult();

    // function to return the value of the parameter of interest for the i^th entry in the results
    double GetXValue( int index ) const ;

    // function to return the value of the confidence level for the i^th entry in the results
    double GetYValue( int index ) const ;

    // function to return the estimated error on the value of the confidence level for the i^th entry in the results
    double GetYError( int index ) const ;
    
    // return a pointer to the i^th result object
    HypoTestResult* GetResult( int index ) const ;   

    // number of entries in the results array
    int ArraySize() const { return fXValues.size(); };

    // set the size of the test (rate of Type I error) (eg. 0.05 for a 95% Confidence Interval)
    virtual void SetTestSize( Double_t size ) { fConfidenceLevel = 1.-size; }

    // set the confidence level for the interval (eg. 0.95 for a 95% Confidence Interval)
    virtual void SetConfidenceLevel( Double_t cl ) { fConfidenceLevel = cl; }

    // flag to switch between using CLsb (default) or CLs as confidence level
    void UseCLs( bool on = true ) { fUseCLs = on; }  

    // lower and upper bound of the confidence interval (to get upper/lower limits, multiply the size( = 1-confidence level ) by 2
    Double_t LowerLimit();
    Double_t UpperLimit();

    // rough estimation of the error on the computed bound of the confidence interval 
    // Estimate of lower limit error
    //function evaluates only a rought error on the lower limit. Be careful when using this estimation
    Double_t LowerLimitEstimatedError();

    // Estimate of lower limit error
    //function evaluates only a rought error on the lower limit. Be careful when using this estimation
    Double_t UpperLimitEstimatedError();

  private:

    // merge with the content of another HypoTestInverterResult object
    bool Add( const HypoTestInverterResult& otherResult );

    double CalculateEstimatedError(double target);
    int FindClosestPointIndex(double target);
    double FindInterpolatedLimit(double target);

  protected:

    bool fUseCLs; 
    bool fInterpolateLowerLimit;
    bool fInterpolateUpperLimit;

    std::vector<double> fXValues;

    TList fYObjects;

    friend class HypoTestInverter;

    ClassDef(HypoTestInverterResult,1)  // HypoTestInverterResult class      
  };
}

#endif
 HypoTestInverterResult.h:1
 HypoTestInverterResult.h:2
 HypoTestInverterResult.h:3
 HypoTestInverterResult.h:4
 HypoTestInverterResult.h:5
 HypoTestInverterResult.h:6
 HypoTestInverterResult.h:7
 HypoTestInverterResult.h:8
 HypoTestInverterResult.h:9
 HypoTestInverterResult.h:10
 HypoTestInverterResult.h:11
 HypoTestInverterResult.h:12
 HypoTestInverterResult.h:13
 HypoTestInverterResult.h:14
 HypoTestInverterResult.h:15
 HypoTestInverterResult.h:16
 HypoTestInverterResult.h:17
 HypoTestInverterResult.h:18
 HypoTestInverterResult.h:19
 HypoTestInverterResult.h:20
 HypoTestInverterResult.h:21
 HypoTestInverterResult.h:22
 HypoTestInverterResult.h:23
 HypoTestInverterResult.h:24
 HypoTestInverterResult.h:25
 HypoTestInverterResult.h:26
 HypoTestInverterResult.h:27
 HypoTestInverterResult.h:28
 HypoTestInverterResult.h:29
 HypoTestInverterResult.h:30
 HypoTestInverterResult.h:31
 HypoTestInverterResult.h:32
 HypoTestInverterResult.h:33
 HypoTestInverterResult.h:34
 HypoTestInverterResult.h:35
 HypoTestInverterResult.h:36
 HypoTestInverterResult.h:37
 HypoTestInverterResult.h:38
 HypoTestInverterResult.h:39
 HypoTestInverterResult.h:40
 HypoTestInverterResult.h:41
 HypoTestInverterResult.h:42
 HypoTestInverterResult.h:43
 HypoTestInverterResult.h:44
 HypoTestInverterResult.h:45
 HypoTestInverterResult.h:46
 HypoTestInverterResult.h:47
 HypoTestInverterResult.h:48
 HypoTestInverterResult.h:49
 HypoTestInverterResult.h:50
 HypoTestInverterResult.h:51
 HypoTestInverterResult.h:52
 HypoTestInverterResult.h:53
 HypoTestInverterResult.h:54
 HypoTestInverterResult.h:55
 HypoTestInverterResult.h:56
 HypoTestInverterResult.h:57
 HypoTestInverterResult.h:58
 HypoTestInverterResult.h:59
 HypoTestInverterResult.h:60
 HypoTestInverterResult.h:61
 HypoTestInverterResult.h:62
 HypoTestInverterResult.h:63
 HypoTestInverterResult.h:64
 HypoTestInverterResult.h:65
 HypoTestInverterResult.h:66
 HypoTestInverterResult.h:67
 HypoTestInverterResult.h:68
 HypoTestInverterResult.h:69
 HypoTestInverterResult.h:70
 HypoTestInverterResult.h:71
 HypoTestInverterResult.h:72
 HypoTestInverterResult.h:73
 HypoTestInverterResult.h:74
 HypoTestInverterResult.h:75
 HypoTestInverterResult.h:76
 HypoTestInverterResult.h:77
 HypoTestInverterResult.h:78
 HypoTestInverterResult.h:79
 HypoTestInverterResult.h:80
 HypoTestInverterResult.h:81
 HypoTestInverterResult.h:82
 HypoTestInverterResult.h:83
 HypoTestInverterResult.h:84
 HypoTestInverterResult.h:85
 HypoTestInverterResult.h:86
 HypoTestInverterResult.h:87
 HypoTestInverterResult.h:88
 HypoTestInverterResult.h:89
 HypoTestInverterResult.h:90
 HypoTestInverterResult.h:91
 HypoTestInverterResult.h:92
 HypoTestInverterResult.h:93
 HypoTestInverterResult.h:94
 HypoTestInverterResult.h:95
 HypoTestInverterResult.h:96
 HypoTestInverterResult.h:97
 HypoTestInverterResult.h:98
 HypoTestInverterResult.h:99
 HypoTestInverterResult.h:100
 HypoTestInverterResult.h:101
 HypoTestInverterResult.h:102
 HypoTestInverterResult.h:103