// Class RooDataWeightedAverage calculate a weighted
// average of a function or p.d.f given a dataset with observable
// values, i.e. DWA(f(x),D(x)) = sum_i f(x_i) where x_i is draw from
// D(i). This class is an implementation of RooAbsOptTestStatistics
// can make use of the optimization and parallization infrastructure
// of that base class. The main use of RooDataWeightedAverage is
// to calculate curves in RooPlots that are added with ProjWData()
// plot option.
//
// END_HTML
#include "RooFit.h"
#include "Riostream.h"
#include "RooDataWeightedAverage.h"
#include "RooAbsData.h"
#include "RooAbsPdf.h"
#include "RooCmdConfig.h"
#include "RooMsgService.h"
#include "RooAbsDataStore.h"
using namespace std;
ClassImp(RooDataWeightedAverage)
;
RooDataWeightedAverage::RooDataWeightedAverage(const char *name, const char *title, RooAbsReal& pdf, RooAbsData& indata,
const RooArgSet& projdeps, Int_t nCPU, RooFit::MPSplit interleave, Bool_t showProgress, Bool_t verbose) :
RooAbsOptTestStatistic(name,title,pdf,indata,projdeps,0,0,nCPU,interleave,verbose,kFALSE),
_showProgress(showProgress)
{
if (_showProgress) {
coutI(Plotting) << "RooDataWeightedAverage::ctor(" << GetName() << ") constructing data weighted average of function " << pdf.GetName()
<< " over " << indata.numEntries() << " data points of " << *(indata.get()) << " with a total weight of " << indata.sumEntries() << endl ;
}
_sumWeight = indata.sumEntries() ;
}
RooDataWeightedAverage::RooDataWeightedAverage(const RooDataWeightedAverage& other, const char* name) :
RooAbsOptTestStatistic(other,name),
_sumWeight(other._sumWeight),
_showProgress(other._showProgress)
{
}
RooDataWeightedAverage::~RooDataWeightedAverage()
{
}
Double_t RooDataWeightedAverage::globalNormalization() const
{
return _sumWeight ;
}
Double_t RooDataWeightedAverage::evaluatePartition(Int_t firstEvent, Int_t lastEvent, Int_t stepSize) const
{
Int_t i ;
Double_t result(0) ;
_dataClone->store()->recalculateCache( _projDeps, firstEvent, lastEvent, stepSize ) ;
if (setNum()==0 && _showProgress) {
ccoutP(Plotting) << "." ;
cout.flush() ;
}
for (i=firstEvent ; i<lastEvent ; i+=stepSize) {
_dataClone->get(i);
if (_dataClone->weight()==0) continue ;
Double_t term = _dataClone->weight() * _funcClone->getVal(_normSet);
result += term;
}
return result ;
}
RooDataWeightedAverage.cxx:1 RooDataWeightedAverage.cxx:2 RooDataWeightedAverage.cxx:3 RooDataWeightedAverage.cxx:4 RooDataWeightedAverage.cxx:5 RooDataWeightedAverage.cxx:6 RooDataWeightedAverage.cxx:7 RooDataWeightedAverage.cxx:8 RooDataWeightedAverage.cxx:9 RooDataWeightedAverage.cxx:10 RooDataWeightedAverage.cxx:11 RooDataWeightedAverage.cxx:12 RooDataWeightedAverage.cxx:13 RooDataWeightedAverage.cxx:14 RooDataWeightedAverage.cxx:15 RooDataWeightedAverage.cxx:16 RooDataWeightedAverage.cxx:17 RooDataWeightedAverage.cxx:18 RooDataWeightedAverage.cxx:19 RooDataWeightedAverage.cxx:20 RooDataWeightedAverage.cxx:21 RooDataWeightedAverage.cxx:22 RooDataWeightedAverage.cxx:23 RooDataWeightedAverage.cxx:24 RooDataWeightedAverage.cxx:25 RooDataWeightedAverage.cxx:26 RooDataWeightedAverage.cxx:27 RooDataWeightedAverage.cxx:28 RooDataWeightedAverage.cxx:29 RooDataWeightedAverage.cxx:30 RooDataWeightedAverage.cxx:31 RooDataWeightedAverage.cxx:32 RooDataWeightedAverage.cxx:33 RooDataWeightedAverage.cxx:34 RooDataWeightedAverage.cxx:35 RooDataWeightedAverage.cxx:36 RooDataWeightedAverage.cxx:37 RooDataWeightedAverage.cxx:38 RooDataWeightedAverage.cxx:39 RooDataWeightedAverage.cxx:40 RooDataWeightedAverage.cxx:41 RooDataWeightedAverage.cxx:42 RooDataWeightedAverage.cxx:43 RooDataWeightedAverage.cxx:44 RooDataWeightedAverage.cxx:45 RooDataWeightedAverage.cxx:46 RooDataWeightedAverage.cxx:47 RooDataWeightedAverage.cxx:48 RooDataWeightedAverage.cxx:49 RooDataWeightedAverage.cxx:50 RooDataWeightedAverage.cxx:51 RooDataWeightedAverage.cxx:52 RooDataWeightedAverage.cxx:53 RooDataWeightedAverage.cxx:54 RooDataWeightedAverage.cxx:55 RooDataWeightedAverage.cxx:56 RooDataWeightedAverage.cxx:57 RooDataWeightedAverage.cxx:58 RooDataWeightedAverage.cxx:59 RooDataWeightedAverage.cxx:60 RooDataWeightedAverage.cxx:61 RooDataWeightedAverage.cxx:62 RooDataWeightedAverage.cxx:63 RooDataWeightedAverage.cxx:64 RooDataWeightedAverage.cxx:65 RooDataWeightedAverage.cxx:66 RooDataWeightedAverage.cxx:67 RooDataWeightedAverage.cxx:68 RooDataWeightedAverage.cxx:69 RooDataWeightedAverage.cxx:70 RooDataWeightedAverage.cxx:71 RooDataWeightedAverage.cxx:72 RooDataWeightedAverage.cxx:73 RooDataWeightedAverage.cxx:74 RooDataWeightedAverage.cxx:75 RooDataWeightedAverage.cxx:76 RooDataWeightedAverage.cxx:77 RooDataWeightedAverage.cxx:78 RooDataWeightedAverage.cxx:79 RooDataWeightedAverage.cxx:80 RooDataWeightedAverage.cxx:81 RooDataWeightedAverage.cxx:82 RooDataWeightedAverage.cxx:83 RooDataWeightedAverage.cxx:84 RooDataWeightedAverage.cxx:85 RooDataWeightedAverage.cxx:86 RooDataWeightedAverage.cxx:87 RooDataWeightedAverage.cxx:88 RooDataWeightedAverage.cxx:89 RooDataWeightedAverage.cxx:90 RooDataWeightedAverage.cxx:91 RooDataWeightedAverage.cxx:92 RooDataWeightedAverage.cxx:93 RooDataWeightedAverage.cxx:94 RooDataWeightedAverage.cxx:95 RooDataWeightedAverage.cxx:96 RooDataWeightedAverage.cxx:97 RooDataWeightedAverage.cxx:98 RooDataWeightedAverage.cxx:99 RooDataWeightedAverage.cxx:100 RooDataWeightedAverage.cxx:101 RooDataWeightedAverage.cxx:102 RooDataWeightedAverage.cxx:103 RooDataWeightedAverage.cxx:104 RooDataWeightedAverage.cxx:105 RooDataWeightedAverage.cxx:106 RooDataWeightedAverage.cxx:107 RooDataWeightedAverage.cxx:108 RooDataWeightedAverage.cxx:109 RooDataWeightedAverage.cxx:110 RooDataWeightedAverage.cxx:111 RooDataWeightedAverage.cxx:112 RooDataWeightedAverage.cxx:113 RooDataWeightedAverage.cxx:114 RooDataWeightedAverage.cxx:115 RooDataWeightedAverage.cxx:116 RooDataWeightedAverage.cxx:117 RooDataWeightedAverage.cxx:118 RooDataWeightedAverage.cxx:119 RooDataWeightedAverage.cxx:120 RooDataWeightedAverage.cxx:121 RooDataWeightedAverage.cxx:122 RooDataWeightedAverage.cxx:123 RooDataWeightedAverage.cxx:124 RooDataWeightedAverage.cxx:125 RooDataWeightedAverage.cxx:126 RooDataWeightedAverage.cxx:127 RooDataWeightedAverage.cxx:128 RooDataWeightedAverage.cxx:129