Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
47 // Main interface to evaluate the test statistic on a dataset
48 double Evaluate(RooAbsData& data, RooArgSet& /*paramsOfInterest*/) override {
49
50 if(data.isWeighted()) {
51 return data.sumEntries();
52 }
53
54 // if no pdf is given in the constructor, we assume by default it can be extended
55 if (!fPdf || fPdf->canBeExtended()) {
56 return data.numEntries();
57 }
58
59 // data is not weighted as pdf cannot be extended
60 if(data.numEntries() == 1) {
61 double numEvents = 0.0;
62 for (auto const *obs : static_range_cast<RooRealVar *>(*data.get(0))) {
63 numEvents += obs->getValV();
64 }
65 return numEvents;
66 }
67
68 std::cout << "Data set is invalid" << std::endl;
69 return 0;
70 }
71
72 // Get the TestStatistic
73 virtual const RooAbsArg* GetTestStatistic() const {return fPdf;}
74
75 const TString GetVarName() const override {return "Number of events";}
76
77
78 private:
80
81 protected:
83 };
84
85}
86
87
88#endif
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Definition RooAbsArg.h:77
Abstract base class for binned and unbinned datasets.
Definition RooAbsData.h:57
Abstract interface for all probability density functions.
Definition RooAbsPdf.h:40
bool canBeExtended() const
If true, PDF can provide extended likelihood term.
Definition RooAbsPdf.h:219
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:55
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...
Basic string class.
Definition TString.h:139
Namespace for the RooStats classes.
Definition Asimov.h:19