57using std::endl, std::ostream;
93 _paramSet(
"paramSet",
"Set of parameters",this),
104 _nCPU(cfg.nCPU != -1 ? cfg.nCPU : 1),
119 _paramSet(
"paramSet",
"Set of parameters",this),
184 double y = gof->getValV();
185 carry += gof->getCarry();
187 const double t =
sum +
y;
188 carry = (t -
sum) -
y;
217 const double t =
sum +
y;
218 carry = (t -
sum) -
y;
258 throw std::logic_error(
"this should never happen");
285 if (
_init)
return false;
306 gof->recursiveRedirectServers(newServerList,mustReplaceAll,nameChange);
330 os <<
indent <<
"RooAbsTestStatistic begin GOF contents" << endl ;
331 for (std::size_t i = 0; i <
_gofArray.size(); ++i) {
333 indent2 +=
"[" + std::to_string(i) +
"] ";
334 _gofArray[i]->printCompactTreeHook(os,indent2);
336 os <<
indent <<
"RooAbsTestStatistic end GOF contents" << endl;
358 gof->constOptimizeTestStatistic(opcode,doAlsoTrackingOpt);
383 gof->setMPSet(inSetNum,inNumSets);
421 ccoutD(Eval) <<
"RooAbsTestStatistic::initMPMode: starting remote server process #" << i << endl;
430 coutI(Eval) <<
"RooAbsTestStatistic::initMPMode: started " <<
_nCPU <<
" remote server process." << endl;
445 std::string
const& rangeName, std::string
const& addCoefRangeName)
453 for (
const auto& catState : simCat) {
454 const std::string& catName = catState.first;
459 if(!rangeName.empty()) {
462 auto simCatAsRooCategory =
dynamic_cast<RooCategory*
>(&simCat);
463 if(simCatAsRooCategory && !simCatAsRooCategory->isStateInRange(rangeName.c_str(), catIndex)) {
473 ccoutI(Fitting) <<
"RooAbsTestStatistic::initSimMode: creating slave calculator #" <<
_gofArray.size() <<
" for state " << catName
474 <<
" (" << dset->
numEntries() <<
" dataset entries)" << endl;
480 RooAbsReal &actualPdf = binnedInfo.binnedPdf ? *binnedInfo.binnedPdf : *pdf;
489 cfg.
binnedL = binnedInfo.isBinnedL;
499 _gofArray.emplace_back(
create(catName.c_str(),catName.c_str(),actualPdf,*dset,*projDeps,cfg));
514 _gofArray.back()->recursiveRedirectServers(selTargetParams);
520 coutI(Fitting) <<
"RooAbsTestStatistic::initSimMode: created " <<
_gofArray.
size() <<
" slave calculators." << endl;
548 gof->setDataSlave(*compData, cloneData);
553 gof->setDataSlave(indata, cloneData);
558 coutE(Fitting) <<
"RooAbsTestStatistic::initSimMode(" <<
GetName() <<
") ERROR: index category of simultaneous pdf is missing in dataset, aborting" << endl;
559 throw std::runtime_error(
"RooAbsTestStatistic::initSimMode() ERROR, index category of simultaneous pdf is missing in dataset, aborting");
563 if (
auto compData =
static_cast<RooAbsData*
>(dlist->FindObject(gof->GetName()))) {
564 gof->setDataSlave(*compData,
false,
true);
566 coutE(DataHandling) <<
"RooAbsTestStatistic::setData(" <<
GetName() <<
") ERROR: Cannot find component data for state " << gof->GetName() << endl;
573 coutF(DataHandling) <<
"RooAbsTestStatistic::setData(" <<
GetName() <<
") FATAL: setData() is not supported in multi-processor mode" << endl;
574 throw std::runtime_error(
"RooAbsTestStatistic::setData is not supported in MPMaster mode");
602 gof->enableOffsetting(flag);
RooArgSet * _projDeps
Set of projected observable.
const bool _takeGlobalObservablesFromData
If the global observable values are taken from data.
bool _splitRange
Split rangeName in RooSimultaneous index labels if true.
bool _doOffset
Apply interval value offset to control numeric precision?
bool _verbose
Verbose messaging if true.
RooFit::MPSplit _mpinterl
Use interleaving strategy rather than N-wise split for partitioning of dataset for multiprocessor-spl...
Int_t _nCPU
Number of processors to use in parallel calculation mode.
std::string _addCoefRangeName
Name of reference to be used for RooAddPdf components.
RooAbsData * _data
Pointer to original input dataset.
ROOT::Math::KahanSum< double > _offset
! Offset as KahanSum to avoid loss of precision
RooSetProxy _paramSet
Parameters of the test statistic (=parameters of the input function)
RooAbsReal * _func
Pointer to original input function.
std::string _rangeName
Name of range in which to calculate test statistic.
Int_t _nEvents
Total number of events in test statistic calculation.
double _evalCarry
! carry of Kahan sum in evaluatePartition
GOFOpMode _gofOpMode
Operation mode of test statistic instance.
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.
Storage_t::size_type size() const
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.
Abstract base class for test statistics objects that evaluate a function or PDF at each point of a gi...
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.
RooArgSet * selectCommon(const RooAbsCollection &refColl) const
Use RooAbsCollection::selecCommon(), but return as RooArgSet.
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.
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)