Logo ROOT   6.08/07
Reference Guide
NumEventsTestStat.h
Go to the documentation of this file.
1 // @(#)root/roostats:$Id$
2 // Author: Kyle Cranmer, Lorenzo Moneta, Gregory Schott, Wouter Verkerke
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_NumEventsTestStat
12 #define ROOSTATS_NumEventsTestStat
13 
14 
15 
16 #ifndef ROOT_Rtypes
17 #include "Rtypes.h"
18 #endif
19 
20 
21 #ifndef ROO_REAL_VAR
22 #include "RooRealVar.h"
23 #endif
24 
25 #ifndef ROO_ABS_DATA
26 #include "RooAbsData.h"
27 #endif
28 
29 #ifndef ROO_ABS_PDF
30 #include "RooAbsPdf.h"
31 #endif
32 
33 #ifndef ROOSTATS_TestStatistic
34 #include "RooStats/TestStatistic.h"
35 #endif
36 
37 
38 //#include "RooStats/DistributionCreator.h"
39 
40 
41 namespace RooStats {
42 
43  /**
44 
45  NumEventsTestStat is a simple implementation of the TestStatistic interface used for simple number counting.
46  It should probably support simple cuts as well.
47 
48  \ingroup RooStats
49  */
50 
52 
53  public:
56  fPdf = &pdf;
57  }
58  virtual ~NumEventsTestStat() {
59  // delete fRand;
60  // delete fTestStatistic;
61  }
62 
63  // Main interface to evaluate the test statistic on a dataset
64  virtual Double_t Evaluate(RooAbsData& data, RooArgSet& /*paramsOfInterest*/) {
65 
66  if(data.isWeighted()) {
67  return data.sumEntries();
68  }
69 
70  // if no pdf is given in the constructor, we assume by default it can be extended
71  if (!fPdf || fPdf->canBeExtended()) {
72  return data.numEntries();
73  }
74 
75  // data is not weighted as pdf cannot be extended
76  if(data.numEntries() == 1) {
77 
78  const RooArgSet *obsSet = data.get(0);
79  RooLinkedListIter iter = obsSet->iterator();
80 
81  RooRealVar *obs = NULL; Double_t numEvents = 0.0;
82  while((obs = (RooRealVar *)iter.Next()) != NULL) {
83  numEvents += obs->getValV();
84  }
85  return numEvents;
86  }
87 
88  std::cout << "Data set is invalid" << std::endl;
89  return 0;
90  }
91 
92  // Get the TestStatistic
93  virtual const RooAbsArg* GetTestStatistic() const {return fPdf;}
94 
95  virtual const TString GetVarName() const {return "Number of events";}
96 
97 
98  private:
100 
101  protected:
103  };
104 
105 }
106 
107 
108 #endif
virtual Double_t sumEntries() const =0
virtual const RooArgSet * get() const
Definition: RooAbsData.h:77
Basic string class.
Definition: TString.h:137
virtual Double_t getValV(const RooArgSet *nset=0) const
Return value of variable.
Definition: RooRealVar.cxx:194
virtual const TString GetVarName() const
virtual Double_t Evaluate(RooAbsData &data, RooArgSet &)
Main interface to evaluate the test statistic on a dataset given the values for the Null Parameters O...
#define ClassDef(name, id)
Definition: Rtypes.h:254
virtual const RooAbsArg * GetTestStatistic() const
virtual TObject * Next()
RooRealVar represents a fundamental (non-derived) real valued object.
Definition: RooRealVar.h:37
RooAbsData is the common abstract base class for binned and unbinned datasets.
Definition: RooAbsData.h:37
Bool_t canBeExtended() const
Definition: RooAbsPdf.h:216
Namespace for the RooStats classes.
Definition: Asimov.h:20
double Double_t
Definition: RtypesCore.h:55
virtual Bool_t isWeighted() const
Definition: RooAbsData.h:92
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
Definition: RooAbsPdf.h:41
RooLinkedListIter iterator(Bool_t dir=kIterForward) const
#define NULL
Definition: Rtypes.h:82
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:66
TestStatistic is an interface class to provide a facility for construction test statistics distributi...
Definition: TestStatistic.h:33
RooLinkedListIter is the TIterator implementation for RooLinkedList.
virtual Int_t numEntries() const
Definition: RooAbsData.cxx:269
NumEventsTestStat is a simple implementation of the TestStatistic interface used for simple number co...