93 _paramSet(
"paramSet",
"Set of parameters",this),
97 _rangeName(cfg.rangeName),
98 _addCoefRangeName(cfg.addCoefRangeName),
99 _splitRange(cfg.splitCutRange),
100 _verbose(cfg.verbose),
102 _gofOpMode{(cfg.nCPU>1 || cfg.nCPU==-1) ? MPMaster : (dynamic_cast<
RooSimultaneous*>(_func) ? SimMaster : Slave)},
103 _nEvents{
data.numEntries()},
104 _nCPU(cfg.nCPU != -1 ? cfg.nCPU : 1),
105 _mpinterl(cfg.interleave),
106 _takeGlobalObservablesFromData{cfg.takeGlobalObservablesFromData}
119 _paramSet(
"paramSet",
"Set of parameters",this),
122 _projDeps((
RooArgSet*)other._projDeps->Clone()),
123 _rangeName(other._rangeName),
124 _addCoefRangeName(other._addCoefRangeName),
125 _splitRange(other._splitRange),
126 _verbose(other._verbose),
128 _gofOpMode{(other._nCPU>1 || other._nCPU==-1) ? MPMaster : (dynamic_cast<
RooSimultaneous*>(_func) ? SimMaster : Slave)},
129 _nEvents{_data->numEntries()},
130 _nCPU(other._nCPU != -1 ? other._nCPU : 1),
131 _mpinterl(other._mpinterl),
132 _doOffset(other._doOffset),
133 _takeGlobalObservablesFromData{other._takeGlobalObservablesFromData},
134 _offset(other._offset),
135 _evalCarry(other._evalCarry)
179 double sum = 0., carry = 0.;
183 double y = gof->getValV();
184 carry += gof->getCarry();
186 const double t =
sum +
y;
187 carry = (t -
sum) -
y;
211 double sum(0), carry = 0.;
216 const double t =
sum +
y;
217 carry = (t -
sum) -
y;
255 throw std::logic_error(
"this should never happen");
282 if (
_init)
return false;
303 gof->recursiveRedirectServers(newServerList,mustReplaceAll,nameChange);
327 os <<
indent <<
"RooAbsTestStatistic begin GOF contents" << endl ;
328 for (std::size_t i = 0; i <
_gofArray.size(); ++i) {
330 indent2 +=
"[" + std::to_string(i) +
"] ";
331 _gofArray[i]->printCompactTreeHook(os,indent2);
333 os <<
indent <<
"RooAbsTestStatistic end GOF contents" << endl;
355 gof->constOptimizeTestStatistic(opcode,doAlsoTrackingOpt);
380 gof->setMPSet(inSetNum,inNumSets);
418 ccoutD(Eval) <<
"RooAbsTestStatistic::initMPMode: starting remote server process #" << i << endl;
427 coutI(Eval) <<
"RooAbsTestStatistic::initMPMode: started " <<
_nCPU <<
" remote server process." << endl;
442 std::string
const& rangeName, std::string
const& addCoefRangeName)
450 for (
const auto& catState : simCat) {
451 const std::string& catName = catState.first;
456 if(!rangeName.empty()) {
459 auto simCatAsRooCategory =
dynamic_cast<RooCategory*
>(&simCat);
460 if(simCatAsRooCategory && !simCatAsRooCategory->isStateInRange(rangeName.c_str(), catIndex)) {
470 ccoutI(Fitting) <<
"RooAbsTestStatistic::initSimMode: creating slave calculator #" <<
_gofArray.size() <<
" for state " << catName
471 <<
" (" << dset->
numEntries() <<
" dataset entries)" << endl;
477 RooAbsReal &actualPdf = binnedInfo.binnedPdf ? *binnedInfo.binnedPdf : *pdf;
486 cfg.
binnedL = binnedInfo.isBinnedL;
496 _gofArray.emplace_back(
create(catName.c_str(),catName.c_str(),actualPdf,*dset,*projDeps,cfg));
511 _gofArray.back()->recursiveRedirectServers(selTargetParams);
517 coutI(Fitting) <<
"RooAbsTestStatistic::initSimMode: created " <<
_gofArray.size() <<
" slave calculators." << endl;
545 gof->setDataSlave(*compData, cloneData);
550 gof->setDataSlave(indata, cloneData);
555 coutE(Fitting) <<
"RooAbsTestStatistic::initSimMode(" <<
GetName() <<
") ERROR: index category of simultaneous pdf is missing in dataset, aborting" << endl;
556 throw std::runtime_error(
"RooAbsTestStatistic::initSimMode() ERROR, index category of simultaneous pdf is missing in dataset, aborting");
560 if (
auto compData =
static_cast<RooAbsData*
>(dlist->FindObject(gof->GetName()))) {
561 gof->setDataSlave(*compData,
false,
true);
563 coutE(DataHandling) <<
"RooAbsTestStatistic::setData(" <<
GetName() <<
") ERROR: Cannot find component data for state " << gof->GetName() << endl;
570 coutF(DataHandling) <<
"RooAbsTestStatistic::setData(" <<
GetName() <<
") FATAL: setData() is not supported in multi-processor mode" << endl;
571 throw std::runtime_error(
"RooAbsTestStatistic::setData is not supported in MPMaster mode");
599 gof->enableOffsetting(flag);
static void indent(ostringstream &buf, int indent_level)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
The Kahan summation is a compensated summation algorithm, which significantly reduces numerical error...
bool recursiveRedirectServers(const RooAbsCollection &newServerList, bool mustReplaceAll=false, bool nameChange=false, bool recurseInNewSet=true)
Recursively replace all servers with the new servers in newSet.
RooFit::OwningPtr< RooArgSet > getParameters(const RooAbsData *data, bool stripDisconnected=true) const
Create a list of leaf nodes in the arg tree starting with ourself as top node that don't match any of...
void SetName(const char *name) override
Set the name of the TNamed.
bool addOwnedComponents(const RooAbsCollection &comps)
Take ownership of the contents of 'comps'.
void setValueDirty()
Mark the element dirty. This forces a re-evaluation when a value is requested.
Abstract base class for objects that represent a discrete value that can be set from the outside,...
Abstract container object that can hold multiple RooAbsArg objects.
bool selectCommon(const RooAbsCollection &refColl, RooAbsCollection &outColl) const
Create a subset of the current collection, consisting only of those elements that are contained as we...
Abstract base class for binned and unbinned datasets.
virtual double sumEntries() const =0
Return effective number of entries in dataset, i.e., sum all weights.
virtual const RooArgSet * get() const
virtual RooFit::OwningPtr< TList > split(const RooAbsCategory &splitCat, bool createEmptyDataSets=false) const
Split the dataset into subsets based on states of a categorical variable in this dataset.
bool canSplitFast() const
RooAbsData * getSimData(const char *idxstate)
virtual Int_t numEntries() const
Return number of entries in dataset, i.e., count unweighted entries.
RooAbsOptTestStatistic is the abstract base class for test statistics objects that evaluate a functio...
Abstract interface for all probability density functions.
Abstract base class for objects that represent a real value and implements functionality common to al...
bool redirectServersHook(const RooAbsCollection &newServerList, bool mustReplaceAll, bool nameChange, bool isRecursiveStep) override
Function that is called at the end of redirectServers().
Abstract base class for all test statistics.
Int_t _setNum
Partition number of this instance in parallel calculation mode.
virtual RooAbsTestStatistic * create(const char *name, const char *title, RooAbsReal &real, RooAbsData &data, const RooArgSet &projDeps, Configuration const &cfg)=0
virtual bool processEmptyDataSets() const
double _evalCarry
! carry of Kahan sum in evaluatePartition
std::string _addCoefRangeName
Name of reference to be used for RooAddPdf components.
Int_t _nEvents
Total number of events in test statistic calculation.
GOFOpMode operMode() const
Int_t _nCPU
Number of processors to use in parallel calculation mode.
RooSetProxy _paramSet
Parameters of the test statistic (=parameters of the input function)
virtual double globalNormalization() const
RooAbsReal * _func
Pointer to original input function.
bool setData(RooAbsData &data, bool cloneData=true) override
Change dataset that is used to given one.
void printCompactTreeHook(std::ostream &os, const char *indent="") override
Add extra information on component test statistics when printing itself as part of a tree structure.
Int_t _numSets
Total number of partitions in parallel calculation mode.
RooFit::MPSplit _mpinterl
Use interleaving strategy rather than N-wise split for partitioning of dataset for multiprocessor-spl...
bool isOffsetting() const override
double evaluate() const override
Calculate and return value of test statistic.
GOFOpMode _gofOpMode
Operation mode of test statistic instance.
virtual bool setDataSlave(RooAbsData &, bool=true, bool=false)
void initMPMode(RooAbsReal *real, RooAbsData *data, const RooArgSet *projDeps, std::string const &rangeName, std::string const &addCoefRangeName)
Initialize multi-processor calculation mode.
std::string _rangeName
Name of range in which to calculate test statistic.
RooAbsTestStatistic(const char *name, const char *title, RooAbsReal &real, RooAbsData &data, const RooArgSet &projDeps, Configuration const &cfg)
Create a test statistic from the given function and the data.
void constOptimizeTestStatistic(ConstOpCode opcode, bool doAlsoTrackingOpt=true) override
Forward constant term optimization management calls to component test statistics.
bool _init
! Is object initialized
ROOT::Math::KahanSum< double > _offset
! Offset as KahanSum to avoid loss of precision
virtual void runRecalculateCache(std::size_t, std::size_t, std::size_t) const
Int_t _extSet
! Number of designated set to calculated extended term
std::vector< std::unique_ptr< RooAbsTestStatistic > > _gofArray
! Array of sub-contexts representing part of the combined test statistic
bool initialize()
One-time initialization of the test statistic.
const RooArgSet * _projDeps
Pointer to set with projected observables.
void initSimMode(RooSimultaneous *pdf, RooAbsData *data, const RooArgSet *projDeps, std::string const &rangeName, std::string const &addCoefRangeName)
Initialize simultaneous p.d.f processing mode.
~RooAbsTestStatistic() override
Destructor.
virtual double getCarry() const
bool _verbose
Verbose messaging if true.
void enableOffsetting(bool flag) override
virtual double evaluatePartition(std::size_t firstEvent, std::size_t lastEvent, std::size_t stepSize) const =0
bool _splitRange
Split rangeName in RooSimultaneous index labels if true.
virtual double combinedValue(RooAbsReal **gofArray, Int_t nVal) const =0
pRooRealMPFE * _mpfeArray
! Array of parallel execution frond ends
bool _doOffset
Apply interval value offset to control numeric precision?
RooAbsData * _data
Pointer to original input dataset.
const bool _takeGlobalObservablesFromData
If the global observable values are taken from data.
void setMPSet(Int_t setNum, Int_t numSets)
Set MultiProcessor set number identification of this instance.
bool redirectServersHook(const RooAbsCollection &newServerList, bool mustReplaceAll, bool nameChange, bool isRecursive) override
Forward server redirect calls to component test statistics.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Object to represent discrete states.
bool add(const RooAbsArg &var, bool valueServer, bool shapeServer, bool silent)
Overloaded RooCollection_t::add() method insert object into set and registers object as server to own...
Multi-processor front-end for parallel calculation of RooAbsReal objects.
void initialize()
Initialize the remote process and message passing pipes between current process and remote process.
void constOptimizeTestStatistic(ConstOpCode opcode, bool doAlsoTracking=true) override
Intercept call to optimize constant term in test statistics and forward it to object on server side.
virtual double getCarry() const
void enableOffsetting(bool flag) override
Control verbose messaging related to inter process communication on both client and server side.
void followAsSlave(RooRealMPFE &master)
double getValV(const RooArgSet *nset=nullptr) const override
If value needs recalculation and calculation has not been started with a call to calculate() start it...
Facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
RooAbsPdf * getPdf(RooStringView catName) const
Return the p.d.f associated with the given index category name.
const RooAbsCategoryLValue & indexCat() const
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
std::string getRangeNameForSimComponent(std::string const &rangeName, bool splitRange, std::string const &catName)
BinnedLOutput getBinnedL(RooAbsPdf const &pdf)
std::string rangeName
Stores the configuration parameters for RooAbsTestStatistic.
std::string addCoefRangeName
bool takeGlobalObservablesFromData
double integrateOverBinsPrecision
RooFit::MPSplit interleave
static uint64_t sum(uint64_t i)