Logo ROOT  
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
26
27
28//#include "RooStats/DistributionCreator.h"
29
30
31namespace 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 }
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
double Double_t
Definition: RtypesCore.h:55
#define ClassDef(name, id)
Definition: Rtypes.h:326
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:71
RooLinkedListIter iterator(Bool_t dir=kIterForward) const R__SUGGEST_ALTERNATIVE("begin()
TIterator-style iteration over contained elements.
RooAbsData is the common abstract base class for binned and unbinned datasets.
Definition: RooAbsData.h:39
virtual const RooArgSet * get() const
Definition: RooAbsData.h:82
virtual Double_t sumEntries() const =0
virtual Bool_t isWeighted() const
Definition: RooAbsData.h:99
virtual Int_t numEntries() const
Definition: RooAbsData.cxx:307
Bool_t canBeExtended() const
Definition: RooAbsPdf.h:237
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:28
A wrapper around TIterator derivatives.
TObject * Next() override
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:35
virtual Double_t getValV(const RooArgSet *nset=0) const
Return value of variable.
Definition: RooRealVar.cxx:248
NumEventsTestStat is a simple implementation of the TestStatistic interface used for simple number co...
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...
virtual const RooAbsArg * GetTestStatistic() const
TestStatistic is an interface class to provide a facility for construction test statistics distributi...
Definition: TestStatistic.h:31
Basic string class.
Definition: TString.h:131
Namespace for the RooStats classes.
Definition: Asimov.h:20