Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
HypoTestPlot.cxx
Go to the documentation of this file.
1 // @(#)root/roostats:$Id$
2 // Author: Sven Kreiss June 2010
3 /*************************************************************************
4  * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. *
5  * All rights reserved. *
6  * *
7  * For the licensing terms see $ROOTSYS/LICENSE. *
8  * For the list of contributors see $ROOTSYS/README/CREDITS. *
9  *************************************************************************/
10 
11 /** \class RooStats::HypoTestPlot
12  \ingroup Roostats
13 
14 This class provides the plots for the result of a study performed with any of the
15 HypoTestCalculatorGeneric (e.g. HybridCalculator or FrequentistCalculator) class.
16 
17  */
18 
19 #include "RooStats/HypoTestPlot.h"
22 
23 #include "TStyle.h"
24 
25 ClassImp(RooStats::HypoTestPlot);
26 
27 using namespace RooStats;
28 using namespace std;
29 
30 ////////////////////////////////////////////////////////////////////////////////
31 
32 HypoTestPlot::HypoTestPlot(HypoTestResult& result, Int_t bins, Option_t* opt) :
33  SamplingDistPlot(bins),
34  fHypoTestResult(&result)
35 {
36  ApplyResult(result, opt);
37 }
38 HypoTestPlot::HypoTestPlot(HypoTestResult& result, Int_t bins, Double_t min, Double_t max, Option_t* opt) :
39  SamplingDistPlot(bins,min,max),
40  fHypoTestResult(&result)
41 {
42  ApplyResult(result, opt);
43 }
44 
45 ////////////////////////////////////////////////////////////////////////////////
46 
47 void HypoTestPlot::ApplyResult(HypoTestResult& result, Option_t* opt) {
48  fLegend = new TLegend(0.55,0.95-0.3*0.66,0.95,0.95);
49 
50  const SamplingDistribution *alt = result.GetAltDistribution();
51  const SamplingDistribution *null = result.GetNullDistribution();
52  if(!result.HasTestStatisticData()) {
53  if(alt) AddSamplingDistribution(alt, opt);
54  if(null) AddSamplingDistribution(null, opt);
55  }else{
56  if(result.GetPValueIsRightTail()) {
57  if(alt) AddSamplingDistributionShaded(alt, result.GetTestStatisticData(), RooNumber::infinity(), opt);
58  if(null) AddSamplingDistributionShaded(null, result.GetTestStatisticData(), RooNumber::infinity() , opt);
59  }else{
60  if(alt) AddSamplingDistributionShaded(alt, -RooNumber::infinity(), result.GetTestStatisticData(), opt);
61  if(null) AddSamplingDistributionShaded(null, - RooNumber::infinity(), result.GetTestStatisticData() , opt);
62  }
63  }
64 
65  if(result.HasTestStatisticData()) {
66  Double_t theMin(0.), theMax(0.), theYMax(0.);
67  GetAbsoluteInterval(theMin, theMax, theYMax);
68 
69  AddLine(result.GetTestStatisticData(), 0, result.GetTestStatisticData(), theYMax*0.66, "test statistic data");
70  }
71 
72  ApplyDefaultStyle();
73 }
74 
75 ////////////////////////////////////////////////////////////////////////////////
76 
77 void HypoTestPlot::ApplyDefaultStyle(void) {
78  if(!fHypoTestResult) return;
79 
80  const SamplingDistribution *alt = fHypoTestResult->GetAltDistribution();
81  const SamplingDistribution *null = fHypoTestResult->GetNullDistribution();
82 
83  if(alt) {
84  SetLineWidth(2, alt);
85  SetLineColor(kBlue, alt);
86  }
87  if(null) {
88  SetLineWidth(2, null);
89  SetLineColor(kRed, null);
90  }
91 }