/usr/include/root/RooStats/NumEventsTestStat.h is in libroot-roofit-dev 5.34.19+dfsg-1.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | // @(#)root/roostats:$Id$
// Author: Kyle Cranmer, Lorenzo Moneta, Gregory Schott, Wouter Verkerke
/*************************************************************************
* Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#ifndef ROOSTATS_NumEventsTestStat
#define ROOSTATS_NumEventsTestStat
//_________________________________________________
/*
BEGIN_HTML
<p>
NumEventsTestStat is a simple implementation of the TestStatistic interface used for simple number counting.
It should probably support simple cuts as well.
</p>
END_HTML
*/
//
#ifndef ROOT_Rtypes
#include "Rtypes.h"
#endif
#ifndef ROO_REAL_VAR
#include "RooRealVar.h"
#endif
#ifndef ROO_ABS_DATA
#include "RooAbsData.h"
#endif
#ifndef ROO_ABS_PDF
#include "RooAbsPdf.h"
#endif
#ifndef ROOSTATS_TestStatistic
#include "RooStats/TestStatistic.h"
#endif
//#include "RooStats/DistributionCreator.h"
namespace RooStats {
class NumEventsTestStat : public TestStatistic{
public:
NumEventsTestStat() : fPdf(0) { }
NumEventsTestStat(RooAbsPdf& pdf) {
fPdf = &pdf;
}
virtual ~NumEventsTestStat() {
// delete fRand;
// delete fTestStatistic;
}
// Main interface to evaluate the test statistic on a dataset
virtual Double_t Evaluate(RooAbsData& data, RooArgSet& /*paramsOfInterest*/) {
if(!&data) {
std::cout << "Data set reference is NULL" << std::endl;
return 0;
}
if(data.isWeighted()) {
return data.sumEntries();
}
// if no pdf is given in the constructor, we assume by default it can be extended
if (!fPdf || fPdf->canBeExtended()) {
return data.numEntries();
}
// data is not weighted as pdf cannot be extended
if(data.numEntries() == 1) {
const RooArgSet *obsSet = data.get(0);
RooLinkedListIter iter = obsSet->iterator();
RooRealVar *obs = NULL; Double_t numEvents = 0.0;
while((obs = (RooRealVar *)iter.Next()) != NULL) {
numEvents += obs->getValV();
}
return numEvents;
}
std::cout << "Data set is invalid" << std::endl;
return 0;
}
// Get the TestStatistic
virtual const RooAbsArg* GetTestStatistic() const {return fPdf;}
virtual const TString GetVarName() const {return "Number of events";}
private:
RooAbsPdf* fPdf;
protected:
ClassDef(NumEventsTestStat,1)
};
}
#endif
|