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:
44 NumEventsTestStat() : fPdf(nullptr) { }
46 fPdf = &pdf;
47 }
48 ~NumEventsTestStat() override {
49 // delete fRand;
50 // delete fTestStatistic;
51 }
52
53 // Main interface to evaluate the test statistic on a dataset
54 double Evaluate(RooAbsData& data, RooArgSet& /*paramsOfInterest*/) override {
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 double numEvents = 0.0;
68 for (auto const *obs : static_range_cast<RooRealVar *>(*data.get(0))) {
69 numEvents += obs->getValV();
70 }
71 return numEvents;
72 }
73
74 std::cout << "Data set is invalid" << std::endl;
75 return 0;
76 }
77
78 // Get the TestStatistic
79 virtual const RooAbsArg* GetTestStatistic() const {return fPdf;}
80
81 const TString GetVarName() const override {return "Number of events";}
82
83
84 private:
86
87 protected:
89 };
90
91}
92
93
94#endif
#define ClassDefOverride(name, id)
Definition: Rtypes.h:339
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition: RooAbsArg.h:71
RooAbsData is the common abstract base class for binned and unbinned datasets.
Definition: RooAbsData.h:62
bool canBeExtended() const
If true, PDF can provide extended likelihood term.
Definition: RooAbsPdf.h:264
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:56
NumEventsTestStat is a simple implementation of the TestStatistic interface used for simple number co...
double Evaluate(RooAbsData &data, RooArgSet &) override
Main interface to evaluate the test statistic on a dataset given the values for the Null Parameters O...
const TString GetVarName() const override
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:136
Namespace for the RooStats classes.
Definition: Asimov.h:19