// 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"
ClassImp(RooDataWeightedAverage)
;
RooDataWeightedAverage::RooDataWeightedAverage(const char *name, const char *title, RooAbsReal& pdf, RooAbsData& data,
Int_t nCPU, Bool_t interleave, Bool_t showProgress, Bool_t verbose) :
RooAbsOptTestStatistic(name,title,pdf,data,RooArgSet(),0,0,nCPU,interleave,verbose,kFALSE),
_showProgress(showProgress)
{
if (_showProgress) {
coutI(Plotting) << "RooDataWeightedAverage::ctor(" << GetName() << ") constructing data weighted average of function " << pdf.GetName()
<< " over " << data.numEntries() << " data points of " << *(data.get()) << " with a total weight of " << data.numEntries(kTRUE) << endl ;
}
_sumWeight = data.numEntries(kTRUE) ;
}
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) ;
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 ;
}
Last change: Wed Jun 25 08:32:34 2008
Last generated: 2008-06-25 08:32
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.