ROOT logo
// @(#)root/roostats:$Id: HypoTestCalculator.h 26964 2008-12-16 16:30:01Z moneta $
// 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_HypoTestCalculator
#define ROOSTATS_HypoTestCalculator

//#include "TNamed.h"

//_________________________________________________
/*
BEGIN_HTML
<p>
HypoTestCalculator is an interface class for a tools which produce RooStats HypoTestResults.  
The interface currently assumes that any hypothesis test calculator can be configured by specifying:
<ul>
 <li>a model for the null,</li>
 <li>a model for the alternate,</li>
 <li>a data set, </li>
 <li>a set of parameters of which specify the null (including values and const/non-const status), and </li>
 <li>a set of parameters of which specify the alternate (including values and const/non-const status).</li>
</ul>
The interface allows one to pass the model, data, and parameters via a workspace and then specify them with names.
The interface will be extended so that one does not need to use a workspace.
</p>
<p>
After configuring the calculator, one only needs to ask GetHypoTest, which will return a HypoTestResult pointer.
</p>
<p>
The concrete implementations of this interface should deal with the details of how the nuisance parameters are
dealt with (eg. integration vs. profiling) and which test-statistic is used (perhaps this should be added to the interface).
</p>
<p>
The motivation for this interface is that we hope to be able to specify the problem in a common way for several concrete calculators.
</p>
END_HTML
*/
//

class RooAbsPdf;
class RooArgSet; 
class RooWorkspace; 

namespace RooStats {

   class HypoTestResult;

   class HypoTestCalculator {

   public:

      // Concrete implementations should have a constructor like: 
      // HypoTestCalculator(RooWorkspace*, RooAbsData*,RooAbsPdf*, RooAbsPdf*, RooArgSet*, RooArgSet*) 
      // Concrete implementations should have a constructor like: 
      // HypoTestCalculator(RooAbsData*,RooAbsPdf*, RooAbsPdf*, RooArgSet*, RooArgSet*) 

      virtual ~HypoTestCalculator() {}

      // main interface to get a HypoTestResult, pure virtual
      virtual HypoTestResult* GetHypoTest() const = 0;

      // Initialize the calculator from a given data set, a null pdf and an  alternate pdf. 
      // The null parameters and alternate parameters can be optionally passed otherwise by default 
      // the parameters of the pdf's will be used. 
      // In addition, one can give optionally a nuisance pdf with nuisance parameters to be marginalized 
      virtual void Initialize(RooAbsData & data, RooAbsPdf & nullPdf, RooAbsPdf & alternatePdf, 
                              RooArgSet * nullParameters = 0, RooArgSet * alternateParameters = 0, 
                              RooArgSet * nuisanceParameters = 0, RooAbsPdf * nuisancePdf = 0  ) { 
         SetData(data); 
         SetNullPdf(nullPdf); 
         SetAlternatePdf(alternatePdf); 
         if (nullParameters) SetNullParameters(*nullParameters);
         if (alternateParameters) SetAlternateParameters(*alternateParameters); 
         if (nuisanceParameters) SetNuisanceParameters(*nuisanceParameters);  
         if (nuisancePdf) SetNuisancePdf(*nuisancePdf); 
      } 

      // Initialize the calculator from a given data set and a common  pdf for null and alternate hypothesis. 
      // In this case the null parameters and alternate parameters must be given.
      // In addition, one can give optionally a nuisance pdf with nuisance parameters to be marginalized 
      virtual void Initialize(RooAbsData & data, RooAbsPdf & commonPdf,  
                              RooArgSet & nullParameters, RooArgSet & alternateParameters, 
                              RooArgSet * nuisanceParameters = 0, RooAbsPdf * nuisancePdf = 0  ) { 
         Initialize(data, commonPdf, commonPdf, &nullParameters, &alternateParameters, nuisanceParameters, nuisancePdf);
      } 

      // Initialize the calculator from a workspace and names for the  data set, 
      // the null pdf and the alternate pdf. 
      // The null parameters and alternate parameters can be optionally passed otherwise by default 
      // the parameters of the pdf's will be used. 
      // In addition, one can give optionally a nuisance pdf with nuisance parameters to be marginalized 
      virtual void Initialize(RooWorkspace & ws, const char * data, const char * nullPdf, const char *  alternatePdf, 
                              RooArgSet * nullParameters = 0, RooArgSet * alternateParameters = 0, 
                              RooArgSet * nuisanceParameters = 0, const char * nuisancePdf = 0  ) { 
         SetWorkspace(ws);
         SetData(data); 
         SetNullPdf(nullPdf); 
         SetAlternatePdf(alternatePdf); 
         if (nullParameters) SetNullParameters(*nullParameters);
         if (alternateParameters) SetAlternateParameters(*alternateParameters); 
         if (nuisanceParameters) SetNuisanceParameters(*nuisanceParameters);  
         if (nuisancePdf) SetNuisancePdf(nuisancePdf); 
      } 

      // Initialize the calculator from a workspace and names for the  data set and a common pdf 
      // for both the null and the alternate hypothesis.  
      // In this case the null parameters and alternate parameters must be given.
      // In addition, one can give optionally a nuisance pdf with nuisance parameters to be marginalized 
      virtual void Initialize(RooWorkspace & ws, const char * data, const char * commonPdf, 
                              RooArgSet & nullParameters, RooArgSet & alternateParameters, 
                              RooArgSet * nuisanceParameters = 0, const char * nuisancePdf = 0  ) { 
         Initialize(ws, data, commonPdf, commonPdf, &nullParameters, &alternateParameters, nuisanceParameters, nuisancePdf);
      }

      // set a workspace that owns all the necessary components for the analysis
      virtual void SetWorkspace(RooWorkspace& ws) = 0;
      // set the PDF for the null hypothesis
      virtual void SetNullPdf(const char* name) = 0;
      // set the PDF for the alternate hypothesis
      virtual void SetAlternatePdf(const char* name) = 0;
      // set a common PDF for both the null and alternate hypotheses
      virtual void SetCommonPdf(const char* name) { 
         SetNullPdf(name); 
         SetAlternatePdf(name); 
      }
      // Set a common PDF for both the null and alternate, add to the the workspace if not already there
      virtual void SetCommonPdf(RooAbsPdf& pdf) { 
         SetNullPdf(pdf); 
         SetAlternatePdf(pdf); 
      }
      // Set the PDF for the null, add to the the workspace if not already there
      virtual void SetNullPdf(RooAbsPdf& pdf) = 0;
      // Set the PDF for the alternate hypothesis, add to the the workspace if not already there
      virtual void SetAlternatePdf(RooAbsPdf& pdf) = 0;

      // specify the name of the dataset in the workspace to be used
      virtual void SetData(const char* name) = 0;
      // Set the DataSet, add to the the workspace if not already there
      virtual void SetData(RooAbsData& data) = 0;

      // set parameter values for the null if using a common PDF
      virtual void SetNullParameters(RooArgSet&) = 0;
      // set parameter values for the alternate if using a common PDF
      virtual void SetAlternateParameters(RooArgSet&) = 0;

      // set the pdf name for an auxillary measurement of the nuisance which will be marginalized by the calculator
      // needs to be implemented by the derived class only if this feature is supported
      virtual void SetNuisancePdf(const char * ) {}

      // set the pdf for an auxillary measurement which will be marginalized by the calculator
      // needs to be implemented by the derived class only if this feature is supported
      virtual void SetNuisancePdf(RooAbsPdf &) {}

      // set the parameters for the constraned pdf which  will be marginalized by the calculator
      // needs to be implemented by the derived class if this feature is supported
      virtual void SetNuisanceParameters(RooArgSet &) {}

   protected:
      ClassDef(HypoTestCalculator,1)  // Interface for tools doing hypothesis tests
   };
}


#endif
 HypoTestCalculator.h:1
 HypoTestCalculator.h:2
 HypoTestCalculator.h:3
 HypoTestCalculator.h:4
 HypoTestCalculator.h:5
 HypoTestCalculator.h:6
 HypoTestCalculator.h:7
 HypoTestCalculator.h:8
 HypoTestCalculator.h:9
 HypoTestCalculator.h:10
 HypoTestCalculator.h:11
 HypoTestCalculator.h:12
 HypoTestCalculator.h:13
 HypoTestCalculator.h:14
 HypoTestCalculator.h:15
 HypoTestCalculator.h:16
 HypoTestCalculator.h:17
 HypoTestCalculator.h:18
 HypoTestCalculator.h:19
 HypoTestCalculator.h:20
 HypoTestCalculator.h:21
 HypoTestCalculator.h:22
 HypoTestCalculator.h:23
 HypoTestCalculator.h:24
 HypoTestCalculator.h:25
 HypoTestCalculator.h:26
 HypoTestCalculator.h:27
 HypoTestCalculator.h:28
 HypoTestCalculator.h:29
 HypoTestCalculator.h:30
 HypoTestCalculator.h:31
 HypoTestCalculator.h:32
 HypoTestCalculator.h:33
 HypoTestCalculator.h:34
 HypoTestCalculator.h:35
 HypoTestCalculator.h:36
 HypoTestCalculator.h:37
 HypoTestCalculator.h:38
 HypoTestCalculator.h:39
 HypoTestCalculator.h:40
 HypoTestCalculator.h:41
 HypoTestCalculator.h:42
 HypoTestCalculator.h:43
 HypoTestCalculator.h:44
 HypoTestCalculator.h:45
 HypoTestCalculator.h:46
 HypoTestCalculator.h:47
 HypoTestCalculator.h:48
 HypoTestCalculator.h:49
 HypoTestCalculator.h:50
 HypoTestCalculator.h:51
 HypoTestCalculator.h:52
 HypoTestCalculator.h:53
 HypoTestCalculator.h:54
 HypoTestCalculator.h:55
 HypoTestCalculator.h:56
 HypoTestCalculator.h:57
 HypoTestCalculator.h:58
 HypoTestCalculator.h:59
 HypoTestCalculator.h:60
 HypoTestCalculator.h:61
 HypoTestCalculator.h:62
 HypoTestCalculator.h:63
 HypoTestCalculator.h:64
 HypoTestCalculator.h:65
 HypoTestCalculator.h:66
 HypoTestCalculator.h:67
 HypoTestCalculator.h:68
 HypoTestCalculator.h:69
 HypoTestCalculator.h:70
 HypoTestCalculator.h:71
 HypoTestCalculator.h:72
 HypoTestCalculator.h:73
 HypoTestCalculator.h:74
 HypoTestCalculator.h:75
 HypoTestCalculator.h:76
 HypoTestCalculator.h:77
 HypoTestCalculator.h:78
 HypoTestCalculator.h:79
 HypoTestCalculator.h:80
 HypoTestCalculator.h:81
 HypoTestCalculator.h:82
 HypoTestCalculator.h:83
 HypoTestCalculator.h:84
 HypoTestCalculator.h:85
 HypoTestCalculator.h:86
 HypoTestCalculator.h:87
 HypoTestCalculator.h:88
 HypoTestCalculator.h:89
 HypoTestCalculator.h:90
 HypoTestCalculator.h:91
 HypoTestCalculator.h:92
 HypoTestCalculator.h:93
 HypoTestCalculator.h:94
 HypoTestCalculator.h:95
 HypoTestCalculator.h:96
 HypoTestCalculator.h:97
 HypoTestCalculator.h:98
 HypoTestCalculator.h:99
 HypoTestCalculator.h:100
 HypoTestCalculator.h:101
 HypoTestCalculator.h:102
 HypoTestCalculator.h:103
 HypoTestCalculator.h:104
 HypoTestCalculator.h:105
 HypoTestCalculator.h:106
 HypoTestCalculator.h:107
 HypoTestCalculator.h:108
 HypoTestCalculator.h:109
 HypoTestCalculator.h:110
 HypoTestCalculator.h:111
 HypoTestCalculator.h:112
 HypoTestCalculator.h:113
 HypoTestCalculator.h:114
 HypoTestCalculator.h:115
 HypoTestCalculator.h:116
 HypoTestCalculator.h:117
 HypoTestCalculator.h:118
 HypoTestCalculator.h:119
 HypoTestCalculator.h:120
 HypoTestCalculator.h:121
 HypoTestCalculator.h:122
 HypoTestCalculator.h:123
 HypoTestCalculator.h:124
 HypoTestCalculator.h:125
 HypoTestCalculator.h:126
 HypoTestCalculator.h:127
 HypoTestCalculator.h:128
 HypoTestCalculator.h:129
 HypoTestCalculator.h:130
 HypoTestCalculator.h:131
 HypoTestCalculator.h:132
 HypoTestCalculator.h:133
 HypoTestCalculator.h:134
 HypoTestCalculator.h:135
 HypoTestCalculator.h:136
 HypoTestCalculator.h:137
 HypoTestCalculator.h:138
 HypoTestCalculator.h:139
 HypoTestCalculator.h:140
 HypoTestCalculator.h:141
 HypoTestCalculator.h:142
 HypoTestCalculator.h:143
 HypoTestCalculator.h:144
 HypoTestCalculator.h:145
 HypoTestCalculator.h:146
 HypoTestCalculator.h:147
 HypoTestCalculator.h:148
 HypoTestCalculator.h:149
 HypoTestCalculator.h:150
 HypoTestCalculator.h:151
 HypoTestCalculator.h:152
 HypoTestCalculator.h:153
 HypoTestCalculator.h:154
 HypoTestCalculator.h:155
 HypoTestCalculator.h:156
 HypoTestCalculator.h:157
 HypoTestCalculator.h:158
 HypoTestCalculator.h:159
 HypoTestCalculator.h:160
 HypoTestCalculator.h:161
 HypoTestCalculator.h:162
 HypoTestCalculator.h:163
 HypoTestCalculator.h:164
 HypoTestCalculator.h:165
 HypoTestCalculator.h:166
 HypoTestCalculator.h:167
 HypoTestCalculator.h:168
 HypoTestCalculator.h:169
 HypoTestCalculator.h:170