93 _paramSet(
"paramSet",
"Set of parameters",this),
97 _rangeName(cfg.rangeName),
98 _addCoefRangeName(cfg.addCoefRangeName),
99 _splitRange(cfg.splitCutRange),
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}
111 if (cfg.
rangeName.find(
',') != std::string::npos) {
112 auto errorMsg = std::string(
"Ranges ") + cfg.
rangeName
113 +
" were passed to the RooAbsTestStatistic with name \"" +
name +
"\", "
114 +
"but it doesn't support multiple comma-separated fit ranges!\n" +
115 +
"Instead, one should combine multiple RooAbsTestStatistic objects "
116 +
"(see RooAbsPdf::createNLL for an example with RooNLLVar).";
118 throw std::invalid_argument(errorMsg);
129 _paramSet(
"paramSet",
"Set of parameters",this),
132 _projDeps((
RooArgSet*)other._projDeps->Clone()),
133 _rangeName(other._rangeName),
134 _addCoefRangeName(other._addCoefRangeName),
135 _splitRange(other._splitRange),
136 _verbose(other._verbose),
138 _gofOpMode{(other._nCPU>1 || other._nCPU==-1) ? MPMaster : (dynamic_cast<
RooSimultaneous*>(_func) ? SimMaster : Slave)},
139 _nEvents{_data->numEntries()},
140 _gofSplitMode(other._gofSplitMode),
141 _nCPU(other._nCPU != -1 ? other._nCPU : 1),
142 _mpinterl(other._mpinterl),
143 _doOffset(other._doOffset),
144 _takeGlobalObservablesFromData{other._takeGlobalObservablesFromData},
145 _offset(other._offset),
146 _evalCarry(other._evalCarry)
196 double sum = 0., carry = 0.;
202 const double t =
sum +
y;
203 carry = (t -
sum) -
y;
226 double sum(0), carry = 0.;
231 const double t =
sum +
y;
232 carry = (t -
sum) -
y;
270 throw std::logic_error(
"this should never happen");
296 if (
_init)
return false;
343 os <<
indent <<
"RooAbsTestStatistic begin GOF contents" << endl ;
347 indent2 +=
Form(
"[%d] ",i);
351 os <<
indent <<
"RooAbsTestStatistic end GOF contents" << endl;
434 ccoutD(
Eval) <<
"RooAbsTestStatistic::initMPMode: starting remote server process #" << i << endl;
443 coutI(
Eval) <<
"RooAbsTestStatistic::initMPMode: started " <<
_nCPU <<
" remote server process." << endl;
458 std::string
const& rangeName, std::string
const& addCoefRangeName)
466 coutE(
Fitting) <<
"RooAbsTestStatistic::initSimMode(" <<
GetName() <<
") ERROR: index category of simultaneous pdf is missing in dataset, aborting" << endl;
467 throw std::runtime_error(
"RooAbsTestStatistic::initSimMode() ERROR, index category of simultaneous pdf is missing in dataset, aborting");
474 for (
const auto& catState : simCat) {
489 for (
const auto& catState : simCat) {
490 const std::string& catName = catState.first;
496 ccoutI(
Fitting) <<
"RooAbsTestStatistic::initSimMode: creating slave calculator #" <<
n <<
" for state " << catName
497 <<
" (" << dset->
numEntries() <<
" dataset entries)" << endl;
503 bool binnedL = false ;
512 while ((component = iter.
next())) {
540 cfg.
rangeName = rangeName +
"_" + catName;
546 _gofArray[
n] =
create(catName.c_str(),catName.c_str(),(binnedPdf?*binnedPdf:*pdf),*dset,*projDeps,cfg);
570 delete selTargetParams;
578 ccoutD(
Fitting) <<
"RooAbsTestStatistic::initSimMode: state " << catName
579 <<
" has no data entries, no slave calculator created" << endl;
584 coutI(
Fitting) <<
"RooAbsTestStatistic::initSimMode: created " <<
n <<
" slave calculators." << endl;
611 for (
int i = 0; i <
_nGof; ++i) {
617 for (
int i = 0; i <
_nGof; ++i) {
622 std::unique_ptr<TList> dlist{indata.
split(indexCat,
true)};
625 <<
"', but splitting failed. Input data:" << std::endl;
627 throw std::runtime_error(
"Error when setting up test statistic: dataset couldn't be split into categories.");
630 for (
int i = 0; i <
_nGof; ++i) {
641 coutF(
DataHandling) <<
"RooAbsTestStatistic::setData(" <<
GetName() <<
") FATAL: setData() is not supported in multi-processor mode" << endl;
642 throw std::runtime_error(
"RooAbsTestStatistic::setData is not supported in MPMaster mode");
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.
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
bool recursiveRedirectServers(const RooAbsCollection &newServerList, bool mustReplaceAll=false, bool nameChange=false, bool recurseInNewSet=true)
Recursively replace all servers with the new servers in newSet.
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.
bool getAttribute(const Text_t *name) const
Check if a named attribute is set. By default, all attributes are unset.
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...
RooAbsCategoryLValue is the common abstract base class for objects that represent a discrete value th...
RooAbsCollection is an 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...
RooAbsData is the common 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.
bool canSplitFast() const
RooAbsData * getSimData(const char *idxstate)
void Print(Option_t *options=0) const override
Print TNamed name and title.
virtual Int_t numEntries() const
Return number of entries in dataset, i.e., count unweighted entries.
virtual TList * split(const RooAbsCategory &splitCat, bool createEmptyDataSets=false) const
Split dataset into subsets based on states of given splitCat in this dataset.
RooAbsOptTestStatistic is the abstract base class for test statistics objects that evaluate a functio...
TClass * IsA() const override
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
virtual double getValV(const RooArgSet *normalisationSet=nullptr) const
Return value of object.
RooAbsTestStatistic is the 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
Int_t _nGof
Number of sub-contexts.
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 partioning of dataset for multiprocessor-split...
pRooAbsTestStatistic * _gofArray
! Array of sub-contexts representing part of the combined test statistic
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.
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
void setSimCount(Int_t simCount)
Int_t _extSet
! Number of designated set to calculated extended term
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?
std::vector< RooFit::MPSplit > _gofSplitMode
! GOF MP Split mode specified by component (when Auto is active)
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.
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...
A one-time forward iterator working on RooLinkedList or RooAbsCollection.
RooAbsArg * next()
Return next element or nullptr if at end.
RooProdPdf is an efficient implementation of a product of PDFs of the form.
RooRealMPFE is the 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.
double getValV(const RooArgSet *nset=0) const override
If value needs recalculation and calculation has not beed started with a call to calculate() start it...
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)
RooSimultaneous facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
const RooAbsCategoryLValue & indexCat() const
RooAbsPdf * getPdf(const char *catName) const
Return the p.d.f associated with the given index category name.
Bool_t InheritsFrom(const char *cl) const override
Return kTRUE if this class inherits from a class with name "classname".
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
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.
TClass * IsA() const override
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)