Logo ROOT   6.10/09
Reference Guide
HybridCalculatorOriginal.h
Go to the documentation of this file.
1 // @(#)root/roostats:$Id$
2 
3 /*************************************************************************
4  * Project: RooStats *
5  * Package: RooFit/RooStats *
6  * Authors: *
7  * Danilo Piparo, Gregory Schott *
8  *************************************************************************
9  * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. *
10  * All rights reserved. *
11  * *
12  * For the licensing terms see $ROOTSYS/LICENSE. *
13  * For the list of contributors see $ROOTSYS/README/CREDITS. *
14  *************************************************************************/
15 
16 #ifndef ROOSTATS_HybridCalculatorOriginal
17 #define ROOSTATS_HybridCalculatorOriginal
18 
20 
21 #include <vector>
22 
23 
24 #include "RooStats/HybridResult.h"
25 
26 #include "RooStats/ModelConfig.h"
27 
28 class TH1;
29 
30 namespace RooStats {
31 
32  class HybridResult;
33 
35 
36  public:
37 
38 
39  /// Dummy Constructor with only name
40  explicit HybridCalculatorOriginal(const char *name = 0);
41 
42  /// Constructor for HybridCalculator from pdf instances but without a data-set
44  RooAbsPdf& b_model,
45  RooArgList& observables,
46  const RooArgSet* nuisance_parameters = 0,
47  RooAbsPdf* prior_pdf = 0,
48  bool GenerateBinned = false, int testStatistics = 1, int ntoys = 1000 );
49 
50  /// Constructor for HybridCalculator using a data set and pdf instances
52  RooAbsPdf& sb_model,
53  RooAbsPdf& b_model,
54  const RooArgSet* nuisance_parameters = 0,
55  RooAbsPdf* prior_pdf = 0,
56  bool GenerateBinned = false, int testStatistics = 1, int ntoys = 1000 );
57 
58 
59  /// Constructor passing a ModelConfig for the SBmodel and a ModelConfig for the B Model
61  const ModelConfig& sb_model,
62  const ModelConfig& b_model,
63  bool GenerateBinned = false, int testStatistics = 1, int ntoys = 1000 );
64 
65 
66  public:
67 
68  /// Destructor of HybridCalculator
69  virtual ~HybridCalculatorOriginal();
70 
71  /// inherited methods from HypoTestCalculator interface
72  virtual HybridResult* GetHypoTest() const;
73 
74  // inherited setter methods from HypoTestCalculator
75 
76 
77  // set the model for the null hypothesis (only B)
78  virtual void SetNullModel(const ModelConfig & );
79  // set the model for the alternate hypothesis (S+B)
80  virtual void SetAlternateModel(const ModelConfig & );
81 
82 
83  // Set a common PDF for both the null and alternate
84  virtual void SetCommonPdf(RooAbsPdf & pdf) { fSbModel = &pdf; }
85  // Set the PDF for the null (only B)
86  virtual void SetNullPdf(RooAbsPdf& pdf) { fBModel = &pdf; }
87  // Set the PDF for the alternate hypothesis ( i.e. S+B)
88  virtual void SetAlternatePdf(RooAbsPdf& pdf) { fSbModel = &pdf; }
89 
90  // Set the DataSet
91  virtual void SetData(RooAbsData& data) { fData = &data; }
92 
93  // set parameter values for the null if using a common PDF
94  virtual void SetNullParameters(const RooArgSet& ) { } // not needed
95  // set parameter values for the alternate if using a common PDF
96  virtual void SetAlternateParameters(const RooArgSet&) {} // not needed
97 
98  // additional methods specific for HybridCalculator
99  // set a prior pdf for the nuisance parameters
100  void SetNuisancePdf(RooAbsPdf & prior_pdf) {
101  fPriorPdf = &prior_pdf;
102  fUsePriorPdf = true; // if set by default turn it on
103  }
104 
105  // set the nuisance parameters to be marginalized
106  void SetNuisanceParameters(const RooArgSet & params) { fNuisanceParameters = &params; }
107 
108  // set number of toy MC (Default is 1000)
109  void SetNumberOfToys(unsigned int ntoys) { fNToys = ntoys; }
110 
111  // return number of toys used
112  unsigned int GetNumberOfToys() const { return fNToys; }
113 
114  // control use of the pdf for the nuisance parameter and marginalize them
115  void UseNuisance(bool on = true) { fUsePriorPdf = on; }
116 
117  // control to use bin data generation
118  void SetGenerateBinned(bool on = true) { fGenerateBinned = on; }
119 
120  /// set the desired test statistics:
121  /// index=1 : 2 * log( L_sb / L_b ) (DEFAULT)
122  /// index=2 : number of generated events
123  /// index=3 : profiled likelihood ratio
124  /// if the index is different to any of those values, the default is used
125  void SetTestStatistic(int index);
126 
127  HybridResult* Calculate(TH1& data, unsigned int nToys, bool usePriors) const;
128  HybridResult* Calculate(RooAbsData& data, unsigned int nToys, bool usePriors) const;
129  HybridResult* Calculate(unsigned int nToys, bool usePriors) const;
130  void PrintMore(const char* options) const;
131 
132  void PatchSetExtended(bool on = true) { fTmpDoExtended = on; std::cout << "extended patch set to " << on << std::endl; } // patch to test with RooPoisson (or other non-extended models)
133 
134  private:
135 
136  void RunToys(std::vector<double>& bVals, std::vector<double>& sbVals, unsigned int nToys, bool usePriors) const;
137 
138  // check input parameters before performing the calculation
139  bool DoCheckInputs() const;
140 
141  unsigned int fTestStatisticsIdx; // Index of the test statistics to use
142  unsigned int fNToys; // number of Toys MC
143  RooAbsPdf* fSbModel; // The pdf of the signal+background model
144  RooAbsPdf* fBModel; // The pdf of the background model
145  mutable RooArgList* fObservables; // Collection of the observables of the model
146  const RooArgSet* fNuisanceParameters; // Collection of the nuisance parameters in the model
147  RooAbsPdf* fPriorPdf; // Prior PDF of the nuisance parameters
148  RooAbsData * fData; // pointer to the data sets
149  bool fGenerateBinned; //Flag to control binned generation
150  bool fUsePriorPdf; // use a prior for nuisance parameters
152 
153 // TString fSbModelName; // name of pdf of the signal+background model
154 // TString fBModelName; // name of pdf of the background model
155 // TString fPriorPdfName; // name of pdf of the background model
156 // TString fDataName; // name of the dataset in the workspace
157 
158  protected:
159  ClassDef(HybridCalculatorOriginal,1) // Hypothesis test calculator using a Bayesian-frequentist hybrid method
160  };
161 
162 }
163 
164 #endif
ModelConfig is a simple class that holds configuration information specifying how a model should be u...
Definition: ModelConfig.h:30
virtual void SetCommonPdf(RooAbsPdf &pdf)
HybridCalculatorOriginal class.
virtual void SetNullPdf(RooAbsPdf &pdf)
HybridResult * Calculate(TH1 &data, unsigned int nToys, bool usePriors) const
first compute the test statistics for data and then prepare and run the toy-MC experiments ...
#define ClassDef(name, id)
Definition: Rtypes.h:297
virtual void SetNullParameters(const RooArgSet &)
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
virtual HybridResult * GetHypoTest() const
inherited methods from HypoTestCalculator interface
virtual void SetAlternateModel(const ModelConfig &)
Set the model describing the alternate hypothesis.
virtual void SetNullModel(const ModelConfig &)
Set the model describing the null hypothesis.
void RunToys(std::vector< double > &bVals, std::vector< double > &sbVals, unsigned int nToys, bool usePriors) const
do the actual run-MC processing
HypoTestCalculator is an interface class for a tools which produce RooStats HypoTestResults.
HybridCalculatorOriginal(const char *name=0)
Dummy Constructor with only name.
virtual void SetData(RooAbsData &data)
RooAbsData is the common abstract base class for binned and unbinned datasets.
Definition: RooAbsData.h:37
void SetNuisanceParameters(const RooArgSet &params)
Namespace for the RooStats classes.
Definition: Asimov.h:20
The TH1 histogram class.
Definition: TH1.h:56
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
Definition: RooAbsPdf.h:41
virtual void SetAlternateParameters(const RooArgSet &)
Class encapsulating the result of the HybridCalculatorOriginal.
Definition: HybridResult.h:25
void PrintMore(const char *options) const
Print out some information about the input models.
virtual void SetAlternatePdf(RooAbsPdf &pdf)
void SetTestStatistic(int index)
set the desired test statistics: index=1 : 2 * log( L_sb / L_b ) (DEFAULT) index=2 : number of genera...
virtual ~HybridCalculatorOriginal()
Destructor of HybridCalculator.