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 fPdf = &pdf;
47 }
48
49 // Main interface to evaluate the test statistic on a dataset
50 double Evaluate(RooAbsData& data, RooArgSet& /*paramsOfInterest*/) override {
51
52 if(data.isWeighted()) {
53 return data.sumEntries();
54 }
55
56 // if no pdf is given in the constructor, we assume by default it can be extended
57 if (!fPdf || fPdf->canBeExtended()) {
58 return data.numEntries();
59 }
60
61 // data is not weighted as pdf cannot be extended
62 if(data.numEntries() == 1) {
63 double numEvents = 0.0;
64 for (auto const *obs : static_range_cast<RooRealVar *>(*data.get(0))) {
65 numEvents += obs->getValV();
66 }
67 return numEvents;
68 }
69
70 std::cout << "Data set is invalid" << std::endl;
71 return 0;
72 }
73
74 // Get the TestStatistic
75 virtual const RooAbsArg* GetTestStatistic() const {return fPdf;}
76
77 const TString GetVarName() const override {return "Number of events";}
78
79
80 private:
82
83 protected:
85 };
86
87}
88
89
90#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:79
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:218
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