91 _paramSet(
"paramSet",
"Set of parameters",this),
95 _rangeName(cfg.rangeName),
96 _addCoefRangeName(cfg.addCoefRangeName),
97 _splitRange(cfg.splitCutRange),
98 _verbose(cfg.verbose),
100 _gofOpMode{(cfg.nCPU>1 || cfg.nCPU==-1) ? MPMaster : (dynamic_cast<
RooSimultaneous*>(_func) ? SimMaster : Slave)},
101 _nEvents{data.numEntries()},
102 _nCPU(cfg.nCPU != -1 ? cfg.nCPU : 1),
103 _mpinterl(cfg.interleave),
104 _takeGlobalObservablesFromData{cfg.takeGlobalObservablesFromData}
109 if (cfg.
rangeName.find(
',') != std::string::npos) {
110 auto errorMsg = std::string(
"Ranges ") + cfg.
rangeName
111 +
" were passed to the RooAbsTestStatistic with name \"" +
name +
"\", "
112 +
"but it doesn't support multiple comma-separated fit ranges!\n" +
113 +
"Instead, one should combine multiple RooAbsTestStatistic objects "
114 +
"(see RooAbsPdf::createNLL for an example with RooNLLVar).";
115 coutE(InputArguments) << errorMsg << std::endl;
116 throw std::invalid_argument(errorMsg);
127 _paramSet(
"paramSet",
"Set of parameters",this),
130 _projDeps((
RooArgSet*)other._projDeps->Clone()),
131 _rangeName(other._rangeName),
132 _addCoefRangeName(other._addCoefRangeName),
133 _splitRange(other._splitRange),
134 _verbose(other._verbose),
136 _gofOpMode{(other._nCPU>1 || other._nCPU==-1) ? MPMaster : (dynamic_cast<
RooSimultaneous*>(_func) ? SimMaster : Slave)},
137 _nEvents{_data->numEntries()},
138 _gofSplitMode(other._gofSplitMode),
139 _nCPU(other._nCPU != -1 ? other._nCPU : 1),
140 _mpinterl(other._mpinterl),
141 _doOffset(other._doOffset),
142 _takeGlobalObservablesFromData{other._takeGlobalObservablesFromData},
143 _offset(other._offset),
144 _evalCarry(other._evalCarry)
201 carry = (t -
sum) -
y;
230 carry = (t -
sum) -
y;
268 throw std::logic_error(
"this should never happen");
341 os <<
indent <<
"RooAbsTestStatistic begin GOF contents" << endl ;
345 indent2 +=
Form(
"[%d] ",i);
349 os <<
indent <<
"RooAbsTestStatistic end GOF contents" << endl;
432 ccoutD(Eval) <<
"RooAbsTestStatistic::initMPMode: starting remote server process #" << i << endl;
441 coutI(Eval) <<
"RooAbsTestStatistic::initMPMode: started " <<
_nCPU <<
" remote server process." << endl;
456 std::string
const& rangeName, std::string
const& addCoefRangeName)
464 coutE(Fitting) <<
"RooAbsTestStatistic::initSimMode(" <<
GetName() <<
") ERROR: index category of simultaneous pdf is missing in dataset, aborting" << endl;
465 throw std::runtime_error(
"RooAbsTestStatistic::initSimMode() ERROR, index category of simultaneous pdf is missing in dataset, aborting");
472 for (
const auto& catState : simCat) {
487 for (
const auto& catState : simCat) {
488 const std::string& catName = catState.first;
494 ccoutI(Fitting) <<
"RooAbsTestStatistic::initSimMode: creating slave calculator #" <<
n <<
" for state " << catName
495 <<
" (" << dset->
numEntries() <<
" dataset entries)" << endl;
506 }
else if (pdf->IsA()->
InheritsFrom(RooProdPdf::Class())) {
510 while ((component = iter.
next())) {
538 cfg.
rangeName = rangeName +
"_" + catName;
544 _gofArray[
n] =
create(catName.c_str(),catName.c_str(),(binnedPdf?*binnedPdf:*pdf),*dset,*projDeps,cfg);
568 delete selTargetParams;
576 ccoutD(Fitting) <<
"RooAbsTestStatistic::initSimMode: state " << catName
577 <<
" has no data entries, no slave calculator created" << endl;
582 coutI(Fitting) <<
"RooAbsTestStatistic::initSimMode: created " <<
n <<
" slave calculators." << endl;
609 for (
int i = 0; i <
_nGof; ++i) {
615 for (
int i = 0; i <
_nGof; ++i) {
620 std::unique_ptr<TList> dlist{indata.
split(indexCat,
true)};
622 coutF(DataHandling) <<
"Tried to split '" << indata.
GetName() <<
"' into categories of '" << indexCat.
GetName()
623 <<
"', but splitting failed. Input data:" << std::endl;
625 throw std::runtime_error(
"Error when setting up test statistic: dataset couldn't be split into categories.");
628 for (
int i = 0; i <
_nGof; ++i) {
632 coutE(DataHandling) <<
"RooAbsTestStatistic::setData(" <<
GetName() <<
") ERROR: Cannot find component data for state " <<
_gofArray[i]->
GetName() << endl;
639 coutF(DataHandling) <<
"RooAbsTestStatistic::setData(" <<
GetName() <<
") FATAL: setData() is not supported in multi-processor mode" << endl;
640 throw std::runtime_error(
"RooAbsTestStatistic::setData is not supported in MPMaster mode");
static void indent(ostringstream &buf, int indent_level)
char * Form(const char *fmt,...)
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
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_t 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...
Bool_t recursiveRedirectServers(const RooAbsCollection &newServerList, Bool_t mustReplaceAll=kFALSE, Bool_t nameChange=kFALSE, Bool_t recurseInNewSet=kTRUE)
Recursively replace all servers with the new servers in newSet.
void SetName(const char *name)
Set the name of the TNamed.
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 TList * split(const RooAbsCategory &splitCat, Bool_t createEmptyDataSets=kFALSE) const
Split dataset into subsets based on states of given splitCat in this dataset.
virtual Double_t sumEntries() const =0
Return effective number of entries in dataset, i.e., sum all weights.
virtual void Print(Option_t *options=0) const
Print TNamed name and title.
RooAbsData * getSimData(const char *idxstate)
virtual Int_t numEntries() const
Return number of entries in dataset, i.e., count unweighted entries.
Bool_t canSplitFast() const
RooAbsOptTestStatistic is the abstract base class for test statistics objects that evaluate a functio...
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
virtual Double_t getValV(const RooArgSet *normalisationSet=nullptr) const
Return value of object.
RooAbsTestStatistic is the abstract base class for all test statistics.
virtual Bool_t processEmptyDataSets() const
virtual RooAbsTestStatistic * create(const char *name, const char *title, RooAbsReal &real, RooAbsData &data, const RooArgSet &projDeps, Configuration const &cfg)=0
Int_t _nGof
Number of designated set to calculated extended term.
std::string _addCoefRangeName
GOFOpMode operMode() const
Int_t _nCPU
GOF MP Split mode specified by component (when Auto is active)
RooFit::MPSplit _mpinterl
Array of parallel execution frond ends.
virtual void constOptimizeTestStatistic(ConstOpCode opcode, Bool_t doAlsoTrackingOpt=kTRUE)
Forward constant term optimization management calls to component test statistics.
pRooAbsTestStatistic * _gofArray
virtual Double_t globalNormalization() const
Bool_t setData(RooAbsData &data, Bool_t cloneData=kTRUE)
Change dataset that is used to given one.
void enableOffsetting(Bool_t flag)
GOFOpMode _gofOpMode
Is object initialized
void initMPMode(RooAbsReal *real, RooAbsData *data, const RooArgSet *projDeps, std::string const &rangeName, std::string const &addCoefRangeName)
Initialize multi-processor calculation mode.
ROOT::Math::KahanSum< double > _offset
void setSimCount(Int_t simCount)
virtual Bool_t redirectServersHook(const RooAbsCollection &newServerList, Bool_t mustReplaceAll, Bool_t nameChange, Bool_t isRecursive)
Forward server redirect calls to component test statistics.
virtual Double_t getCarry() const
virtual Double_t evaluatePartition(std::size_t firstEvent, std::size_t lastEvent, std::size_t stepSize) const =0
virtual Bool_t setDataSlave(RooAbsData &, Bool_t=kTRUE, Bool_t=kFALSE)
virtual ~RooAbsTestStatistic()
Destructor.
const RooArgSet * _projDeps
void initSimMode(RooSimultaneous *pdf, RooAbsData *data, const RooArgSet *projDeps, std::string const &rangeName, std::string const &addCoefRangeName)
Initialize simultaneous p.d.f processing mode.
virtual Double_t combinedValue(RooAbsReal **gofArray, Int_t nVal) const =0
virtual Double_t evaluate() const
Calculate and return value of test statistic.
Bool_t isOffsetting() const
Double_t _evalCarry
Offset as KahanSum to avoid loss of precision.
pRooRealMPFE * _mpfeArray
std::vector< RooFit::MPSplit > _gofSplitMode
Array of sub-contexts representing part of the combined test statistic.
const bool _takeGlobalObservablesFromData
virtual void printCompactTreeHook(std::ostream &os, const char *indent="")
Add extra information on component test statistics when printing itself as part of a tree structure.
void setMPSet(Int_t setNum, Int_t numSets)
Set MultiProcessor set number identification of this instance.
Bool_t initialize()
One-time initialization of the test statistic.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
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.
virtual Double_t getCarry() const
void initialize()
Initialize the remote process and message passing pipes between current process and remote process.
void enableOffsetting(Bool_t flag)
Control verbose messaging related to inter process communication on both client and server side.
virtual Double_t getValV(const RooArgSet *nset=0) const
If value needs recalculation and calculation has not beed started with a call to calculate() start it...
virtual void constOptimizeTestStatistic(ConstOpCode opcode, Bool_t doAlsoTracking=kTRUE)
Intercept call to optimize constant term in test statistics and forward it to object on server side.
void followAsSlave(RooRealMPFE &master)
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE) override
Overloaded RooArgSet::add() method inserts 'var' into set and registers 'var' as server to owner with...
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.
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
virtual const char * GetTitle() const
Returns title of object.
virtual const char * GetName() const
Returns name of object.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
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)