Logo ROOT   6.14/05
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 #include "Rtypes.h"
17 
18 
19 #include "RooRealVar.h"
20 
21 #include "RooAbsData.h"
22 
23 #include "RooAbsPdf.h"
24 
25 #include "RooStats/TestStatistic.h"
26 
27 
28 //#include "RooStats/DistributionCreator.h"
29 
30 
31 namespace RooStats {
32 
33  /**
34 
35  NumEventsTestStat is a simple implementation of the TestStatistic interface used for simple number counting.
36  It should probably support simple cuts as well.
37 
38  \ingroup RooStats
39  */
40 
42 
43  public:
46  fPdf = &pdf;
47  }
48  virtual ~NumEventsTestStat() {
49  // delete fRand;
50  // delete fTestStatistic;
51  }
52 
53  // Main interface to evaluate the test statistic on a dataset
54  virtual Double_t Evaluate(RooAbsData& data, RooArgSet& /*paramsOfInterest*/) {
55 
56  if(data.isWeighted()) {
57  return data.sumEntries();
58  }
59 
60  // if no pdf is given in the constructor, we assume by default it can be extended
61  if (!fPdf || fPdf->canBeExtended()) {
62  return data.numEntries();
63  }
64 
65  // data is not weighted as pdf cannot be extended
66  if(data.numEntries() == 1) {
67 
68  const RooArgSet *obsSet = data.get(0);
69  RooLinkedListIter iter = obsSet->iterator();
70 
71  RooRealVar *obs = NULL; Double_t numEvents = 0.0;
72  while((obs = (RooRealVar *)iter.Next()) != NULL) {
73  numEvents += obs->getValV();
74  }
75  return numEvents;
76  }
77 
78  std::cout << "Data set is invalid" << std::endl;
79  return 0;
80  }
81 
82  // Get the TestStatistic
83  virtual const RooAbsArg* GetTestStatistic() const {return fPdf;}
84 
85  virtual const TString GetVarName() const {return "Number of events";}
86 
87 
88  private:
90 
91  protected:
93  };
94 
95 }
96 
97 
98 #endif
virtual Double_t sumEntries() const =0
virtual const RooArgSet * get() const
Definition: RooAbsData.h:79
Basic string class.
Definition: TString.h:131
virtual Double_t getValV(const RooArgSet *nset=0) const
Return value of variable.
Definition: RooRealVar.cxx:193
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:320
virtual const RooAbsArg * GetTestStatistic() const
virtual TObject * Next()
RooRealVar represents a fundamental (non-derived) real valued object.
Definition: RooRealVar.h:36
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:94
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
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:31
RooLinkedListIter is the TIterator implementation for RooLinkedList.
virtual Int_t numEntries() const
Definition: RooAbsData.cxx:285
NumEventsTestStat is a simple implementation of the TestStatistic interface used for simple number co...