Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
HybridCalculator.h
Go to the documentation of this file.
1 // @(#)root/roostats:$Id$
2 // Author: Sven Kreiss, Kyle Cranmer Nov 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 #ifndef ROOSTATS_HybridCalculator
12 #define ROOSTATS_HybridCalculator
13 
15 
16 #include "RooStats/ToyMCSampler.h"
17 
18 
19 
20 namespace RooStats {
21 
22  class HybridCalculator : public HypoTestCalculatorGeneric {
23 
24  public:
25  HybridCalculator(
26  const RooAbsData &data,
27  const ModelConfig &altModel,
28  const ModelConfig &nullModel,
29  TestStatSampler* sampler=0
30  ) :
31  HypoTestCalculatorGeneric(data, altModel, nullModel, sampler),
32  fPriorNuisanceNull(MakeNuisancePdf(nullModel, "PriorNuisanceNull")),
33  fPriorNuisanceAlt(MakeNuisancePdf(altModel, "PriorNuisanceAlt")),
34  fPriorNuisanceNullExternal(false),
35  fPriorNuisanceAltExternal(false),
36  fNToysNull(-1),
37  fNToysAlt(-1),
38  fNToysNullTail(0),
39  fNToysAltTail(0)
40  {
41  }
42 
43  ~HybridCalculator() {
44  if(fPriorNuisanceNullExternal == false) delete fPriorNuisanceNull;
45  if(fPriorNuisanceAltExternal == false) delete fPriorNuisanceAlt;
46  }
47 
48 
49  /// Override the distribution used for marginalizing nuisance parameters that is inferred from ModelConfig
50  virtual void ForcePriorNuisanceNull(RooAbsPdf& priorNuisance) {
51  if(fPriorNuisanceNullExternal == false) delete fPriorNuisanceNull;
52  fPriorNuisanceNull = &priorNuisance; fPriorNuisanceNullExternal = true;
53  }
54  virtual void ForcePriorNuisanceAlt(RooAbsPdf& priorNuisance) {
55  if(fPriorNuisanceAltExternal == false) delete fPriorNuisanceAlt;
56  fPriorNuisanceAlt = &priorNuisance; fPriorNuisanceAltExternal = true;
57  }
58 
59  virtual void SetNullModel(const ModelConfig &nullModel) {
60  fNullModel = &nullModel;
61  if(fPriorNuisanceNullExternal == false) {
62  delete fPriorNuisanceNull;
63  fPriorNuisanceNull = MakeNuisancePdf(nullModel, "PriorNuisanceNull");
64  }
65  }
66 
67  virtual void SetAlternateModel(const ModelConfig &altModel) {
68  fAltModel = &altModel;
69  if(fPriorNuisanceAltExternal == false) {
70  delete fPriorNuisanceAlt;
71  fPriorNuisanceAlt = MakeNuisancePdf(altModel, "PriorNuisanceAlt");
72  }
73  }
74 
75  /// set number of toys
76  void SetToys(int toysNull, int toysAlt) { fNToysNull = toysNull; fNToysAlt = toysAlt; }
77 
78  /// set least number of toys in tails
79  void SetNToysInTails(int toysNull, int toysAlt) { fNToysNullTail = toysNull; fNToysAltTail = toysAlt; }
80 
81  protected:
82  /// check whether all input is consistent
83  int CheckHook(void) const;
84 
85  /// configure TestStatSampler for the Null run
86  int PreNullHook(RooArgSet* /*parameterPoint*/, double obsTestStat) const;
87 
88  /// configure TestStatSampler for the Alt run
89  int PreAltHook(RooArgSet* /*parameterPoint*/, double obsTestStat) const;
90 
91  protected:
92  RooAbsPdf *fPriorNuisanceNull;
93  RooAbsPdf *fPriorNuisanceAlt;
94 
95  // these flags tell us if the nuisance pdfs came from an external resource (via ForcePriorNuisance)
96  // or were created internally and should be deleted
97  Bool_t fPriorNuisanceNullExternal;
98  Bool_t fPriorNuisanceAltExternal;
99 
100  // different number of toys for null and alt
101  int fNToysNull;
102  int fNToysAlt;
103 
104  // adaptive sampling
105  int fNToysNullTail;
106  int fNToysAltTail;
107 
108  protected:
109  ClassDef(HybridCalculator,2)
110  };
111 }
112 
113 #endif