11 #ifndef ROOSTATS_HypoTestInverter
12 #define ROOSTATS_HypoTestInverter
29 class HybridCalculator;
30 class FrequentistCalculator;
31 class AsymptoticCalculator;
32 class HypoTestCalculatorGeneric;
36 class HypoTestInverter :
public IntervalCalculator {
40 enum ECalculatorType { kUndefined = 0, kHybrid = 1, kFrequentist = 2, kAsymptotic = 3};
46 HypoTestInverter( HypoTestCalculatorGeneric & hc,
47 RooRealVar* scannedVariable =0,
52 HypoTestInverter( HybridCalculator & hc,
53 RooRealVar* scannedVariable = 0,
57 HypoTestInverter( FrequentistCalculator & hc,
58 RooRealVar* scannedVariable,
62 HypoTestInverter( AsymptoticCalculator & hc,
63 RooRealVar* scannedVariable,
68 HypoTestInverter( RooAbsData& data, ModelConfig &sb, ModelConfig &b,
69 RooRealVar * scannedVariable = 0, ECalculatorType type = kFrequentist,
73 virtual HypoTestInverterResult* GetInterval()
const;
82 void SetFixedScan(
int nBins,
double xMin = 1,
double xMax = -1,
bool scanLog =
false ) {
84 fXmin = xMin; fXmax = xMax;
89 void SetAutoScan() { SetFixedScan(0); }
96 bool RunFixedScan(
int nBins,
double xMin,
double xMax,
bool scanLog =
false )
const;
98 bool RunOnePoint(
double thisX,
bool adaptive =
false,
double clTarget = -1 )
const;
102 bool RunLimit(
double &limit,
double &limitErr,
double absTol = 0,
double relTol = 0,
const double *hint=0)
const;
104 void UseCLs(
bool on =
true) { fUseCLs = on;
if (fResults) fResults->UseCLs(on); }
106 virtual void SetData(RooAbsData &);
108 virtual void SetModel(
const ModelConfig &) { }
111 virtual void SetTestSize(Double_t size) {fSize = size;
if (fResults) fResults->SetTestSize(size); }
113 virtual void SetConfidenceLevel(Double_t cl) {fSize = 1.-cl;
if (fResults) fResults->SetConfidenceLevel(cl); }
115 virtual Double_t Size()
const {
return fSize;}
117 virtual Double_t ConfidenceLevel()
const {
return 1.-fSize;}
120 virtual ~HypoTestInverter() ;
124 HypoTestCalculatorGeneric * GetHypoTestCalculator()
const {
return fCalculator0; }
127 SamplingDistribution * GetLowerLimitDistribution(
bool rebuild=
false,
int nToys = 100);
128 SamplingDistribution * GetUpperLimitDistribution(
bool rebuild=
false,
int nToys = 100);
131 SamplingDistribution * RebuildDistributions(
bool isUpper=
true,
int nToys = 100,
132 TList * clsDist = 0, TList *clsbDist= 0, TList * clbDist = 0,
const char * outputfile =
"HypoTestInverterRebuiltDist.root");
135 TestStatistic * GetTestStatistic()
const;
138 bool SetTestStatistic(TestStatistic& stat);
141 void SetVerbose(
int level=1) { fVerbose = level; }
144 void SetMaximumToys(
int ntoys) { fMaxToys = ntoys;}
147 void SetNumErr(
double err) { fNumErr = err; }
150 static void SetCloseProof(Bool_t flag);
156 HypoTestInverter(
const HypoTestInverter & rhs);
159 HypoTestInverter & operator=(
const HypoTestInverter & rhs);
161 void CreateResults()
const;
164 HypoTestResult * Eval( HypoTestCalculatorGeneric &hc,
bool adaptive ,
double clsTarget)
const;
167 static RooRealVar * GetVariableToScan(
const HypoTestCalculatorGeneric &hc);
168 static void CheckInputModels(
const HypoTestCalculatorGeneric &hc,
const RooRealVar & scanVar);
173 static unsigned int fgNToys;
174 static double fgCLAccuracy;
175 static double fgAbsAccuracy;
176 static double fgRelAccuracy;
177 static bool fgCloseProof;
178 static std::string fgAlgo;
181 mutable std::unique_ptr<TGraphErrors> fLimitPlot;
185 mutable int fTotalToysRun;
188 HypoTestCalculatorGeneric* fCalculator0;
189 std::unique_ptr<HypoTestCalculatorGeneric> fHC;
190 RooRealVar* fScannedVariable;
191 mutable HypoTestInverterResult* fResults;
197 ECalculatorType fCalcType;
205 ClassDef(HypoTestInverter,4)