118using std::endl, std::string, std::map, std::list, std::ifstream, std::ofstream, std::ostream;
133struct FinalizeVarsOutput {
135 std::unique_ptr<RooRealVar> weight;
136 std::string weightVarName;
140FinalizeVarsOutput finalizeVars(
RooArgSet const &vars,
142 const char* wgtVarName,
147 FinalizeVarsOutput out;
148 out.finalVars.
add(vars);
152 std::vector<RooAbsData*> weightedImpDatasets;
153 if(impData && impData->
isWeighted()) weightedImpDatasets.push_back(impData);
155 if(data->isWeighted()) {
156 weightedImpDatasets.push_back(data);
160 bool needsWeightErrors =
false;
163 for(
RooAbsData * data : weightedImpDatasets) {
165 needsWeightErrors =
true;
170 out.finalVars.
add(*indexCat,
true);
173 out.weightVarName = wgtVarName ? wgtVarName :
"";
175 if(out.weightVarName.empty()) {
178 for(
RooAbsData * data : weightedImpDatasets) {
179 if(
auto ds =
dynamic_cast<RooDataSet const*
>(data)) {
181 out.weightVarName = ds->weightVar()->GetName();
194 RooAbsArg * wgtVar = out.finalVars.
find(out.weightVarName.c_str());
195 if (!out.weightVarName.empty() && !wgtVar) {
196 const char*
name = out.weightVarName.c_str();
197 out.weight = std::make_unique<RooRealVar>(
name,
name, 1.0);
198 wgtVar = out.weight.get();
199 out.finalVars.
add(*out.weight);
202 if(needsWeightErrors) {
203 out.errorSet.
add(*wgtVar);
207 if(errorSet) out.errorSet.
add(*errorSet,
true);
213std::unique_ptr<RooDataSet> makeDataSetFromDataHist(
RooDataHist const &hist)
218 const char* wgtName = wgtVarCmdArg.
getString(0);
281 RooCmdConfig pc(
"RooDataSet::ctor(" + std::string(GetName()) +
")");
282 pc.defineInt(
"ownLinked",
"OwnLinked",0) ;
283 pc.defineObject(
"impTree",
"ImportTree",0) ;
284 pc.defineObject(
"impData",
"ImportData",0) ;
285 pc.defineObject(
"indexCat",
"IndexCat",0) ;
286 pc.defineObject(
"impSliceData",
"ImportDataSlice",0,
nullptr,
true) ;
287 pc.defineString(
"impSliceState",
"ImportDataSlice",0,
"",
true) ;
288 pc.defineObject(
"lnkSliceData",
"LinkDataSlice",0,
nullptr,
true) ;
289 pc.defineString(
"lnkSliceState",
"LinkDataSlice",0,
"",
true) ;
290 pc.defineString(
"cutSpec",
"CutSpec",0,
"") ;
291 pc.defineObject(
"cutVar",
"CutVar",0) ;
292 pc.defineString(
"cutRange",
"CutRange",0,
"") ;
293 pc.defineString(
"wgtVarName",
"WeightVarName",0,
"") ;
294 pc.defineInt(
"newWeight1",
"WeightVarName",0,0) ;
295 pc.defineString(
"fname",
"ImportFromFile",0,
"") ;
296 pc.defineString(
"tname",
"ImportFromFile",1,
"") ;
297 pc.defineObject(
"wgtVar",
"WeightVar",0) ;
298 pc.defineInt(
"newWeight2",
"WeightVar",0,0) ;
299 pc.defineObject(
"dummy1",
"ImportDataSliceMany",0) ;
300 pc.defineObject(
"dummy2",
"LinkDataSliceMany",0) ;
301 pc.defineSet(
"errorSet",
"StoreError",0) ;
302 pc.defineSet(
"asymErrSet",
"StoreAsymError",0) ;
303 pc.defineSet(
"glObs",
"GlobalObservables",0,
nullptr) ;
304 pc.defineMutex(
"ImportTree",
"ImportData",
"ImportDataSlice",
"LinkDataSlice",
"ImportFromFile") ;
305 pc.defineMutex(
"CutSpec",
"CutVar") ;
306 pc.defineMutex(
"WeightVarName",
"WeightVar") ;
307 pc.defineDependency(
"ImportDataSlice",
"IndexCat") ;
308 pc.defineDependency(
"LinkDataSlice",
"IndexCat") ;
309 pc.defineDependency(
"OwnLinked",
"LinkDataSlice") ;
321 const std::string errMsg =
"Error in RooDataSet constructor: command argument list could not be processed";
323 throw std::invalid_argument(errMsg);
326 if(pc.getSet(
"glObs")) setGlobalObservables(*pc.getSet(
"glObs"));
329 TTree* impTree =
static_cast<TTree*
>(pc.getObject(
"impTree")) ;
330 auto impData =
static_cast<RooAbsData*
>(pc.getObject(
"impData")) ;
332 const char* cutSpec = pc.getString(
"cutSpec",
"",
true) ;
333 const char* cutRange = pc.getString(
"cutRange",
"",
true) ;
334 const char* wgtVarName = pc.getString(
"wgtVarName",
"",
true) ;
336 const char* impSliceNames = pc.getString(
"impSliceState",
"",
true) ;
337 const RooLinkedList& impSliceData = pc.getObjectList(
"impSliceData") ;
338 const char* lnkSliceNames = pc.getString(
"lnkSliceState",
"",
true) ;
339 const RooLinkedList& lnkSliceData = pc.getObjectList(
"lnkSliceData") ;
341 RooArgSet* asymErrorSet = pc.getSet(
"asymErrSet") ;
342 const char* fname = pc.getString(
"fname") ;
343 const char* tname = pc.getString(
"tname") ;
344 Int_t ownLinked = pc.getInt(
"ownLinked") ;
345 Int_t newWeight = pc.getInt(
"newWeight1") + pc.getInt(
"newWeight2") ;
349 wgtVarName = wgtVar->
GetName();
352 auto finalVarsInfo = finalizeVars(vars,indexCat,wgtVarName,impData,impSliceData, pc.getSet(
"errorSet"));
353 initializeVars(finalVarsInfo.finalVars);
354 if(!finalVarsInfo.weightVarName.empty()) {
355 wgtVarName = finalVarsInfo.weightVarName.c_str();
358 RooArgSet* errorSet = finalVarsInfo.errorSet.
empty() ? nullptr : &finalVarsInfo.errorSet;
364 map<string,RooAbsData*> hmap ;
367 strlcpy(tmp, lnkSliceNames, 64000);
368 char *token = strtok(tmp,
",");
369 auto hiter = lnkSliceData.
begin();
371 hmap[token] =
static_cast<RooAbsData *
>(*hiter);
372 token = strtok(
nullptr,
",");
380 map<string,RooAbsDataStore*> storeMap ;
383 throw std::string(
"RooDataSet::RooDataSet() ERROR in constructor, cannot find index category") ;
387 if (indexCat && !indexCat->
hasLabel(hiter->first)) {
389 coutI(
InputArguments) <<
"RooDataSet::ctor(" << GetName() <<
") defining state \"" << hiter->first <<
"\" in index category " << indexCat->
GetName() << std::endl ;
391 if (icat && !icat->
hasLabel(hiter->first)) {
394 icat->
setLabel(hiter->first.c_str()) ;
399 addOwnedComponent(hiter->first.c_str(),*hiter->second) ;
404 _dstore = std::make_unique<RooCompositeDataStore>(
name,title,_vars,*icat,storeMap) ;
411 if (defaultStorageType==Tree) {
412 _dstore = std::make_unique<RooTreeDataStore>(
name,title,_vars,wgtVarName) ;
414 }
else if (defaultStorageType==Vector) {
415 if (wgtVarName && newWeight) {
416 RooAbsArg* wgttmp = _vars.find(wgtVarName) ;
421 _dstore = std::make_unique<RooVectorDataStore>(
name,title,_vars,wgtVarName) ;
426 std::map<string,RooAbsData*> hmap ;
428 auto hiter = impSliceData.
begin() ;
429 for (
const auto& token :
ROOT::Split(impSliceNames,
",")) {
432 std::stringstream errorMsgStream;
433 errorMsgStream <<
"RooDataSet::RooDataSet(\"" << GetName() <<
"\") "
434 <<
"you are providing import data for the category state \"" << token
435 <<
"\", but the index category \"" << indexCat->
GetName() <<
"\" has no such state!";
436 const std::string errorMsg = errorMsgStream.str();
438 throw std::invalid_argument(errorMsg);
441 hmap[token] =
static_cast<RooDataSet*
>(*hiter);
448 std::unique_ptr<RooArgSet> intErrorSet{_vars.selectCommon(*errorSet)};
449 intErrorSet->setAttribAll(
"StoreError") ;
451 arg->attachToStore(*_dstore) ;
455 std::unique_ptr<RooArgSet> intAsymErrorSet{_vars.selectCommon(*asymErrorSet)};
456 intAsymErrorSet->setAttribAll(
"StoreAsymError") ;
458 arg->attachToStore(*_dstore) ;
466 std::unique_ptr<RooFormulaVar> cutVarTmp;
470 loadValuesFromSlices(*indexCat, hmap, cutRange, cutVar, cutSpec);
471 }
else if (impData) {
473 std::unique_ptr<RooDataSet> impDataSet;
477 impDataSet = makeDataSetFromDataHist(
static_cast<RooDataHist const &
>(*impData));
478 impData = impDataSet.get();
481 cutVarTmp = std::make_unique<RooFormulaVar>(cutSpec, cutSpec, *impData->
get(),
false);
482 cutVar = cutVarTmp.get();
484 _dstore->loadValues(impData->
store(), cutVar, cutRange);
486 }
else if (impTree || (fname && strlen(fname))) {
488 std::unique_ptr<TFile> file;
490 if (impTree ==
nullptr) {
493 std::stringstream ss;
494 ss <<
"RooDataSet::ctor(" << GetName() <<
") ERROR file '" << fname
495 <<
"' cannot be opened or does not exist";
496 const std::string errMsg = ss.str();
498 throw std::invalid_argument(errMsg);
501 file->GetObject(tname, impTree);
503 std::stringstream ss;
504 ss <<
"RooDataSet::ctor(" << GetName() <<
") ERROR file '" << fname
505 <<
"' does not contain a TTree named '" << tname <<
"'";
506 const std::string errMsg = ss.str();
508 throw std::invalid_argument(errMsg);
513 cutVarTmp = std::make_unique<RooFormulaVar>(cutSpec, cutSpec, _vars,
false);
514 cutVar = cutVarTmp.get();
518 tstore->
loadValues(impTree, cutVar, cutRange);
521 tmpstore.loadValues(impTree, cutVar, cutRange);
522 _dstore->append(tmpstore);
543 bool useOldWeight =
_wgtVar && (wgtVarName ==
nullptr || strcmp(wgtVarName,
_wgtVar->GetName()) == 0);
545 if(newName ==
nullptr) newName =
GetName();
546 if(newTitle ==
nullptr) newTitle =
GetTitle();
547 if(useOldWeight) wgtVarName =
_wgtVar->GetName();
550 if(vars ==
nullptr) {
557 auto varInData =
_vars.find(*var);
558 vars2.
add(varInData ? *varInData : *var);
569 if(var->getAttribute(
"StoreError")) errorSet.
add(*var);
570 if(var->getAttribute(
"StoreAsymError")) asymErrorSet.
add(*var);
593 << wgtVarName <<
" not found in set of variables, no weighting will be assigned" << std::endl ;
594 throw std::invalid_argument(
"RooDataSet::initialize() weight variable could not be initialised.");
597 << wgtVarName <<
" is not of type RooRealVar, no weighting will be assigned" << std::endl ;
598 throw std::invalid_argument(
"RooDataSet::initialize() weight variable could not be initialised.");
612 const char *cutRange, std::size_t nStart, std::size_t nStop)
const
622 std::unique_ptr<RooAbsData> out{createEmptyClone()};
624 if (!cutRange || strchr(cutRange,
',') ==
nullptr) {
626 ds._dstore =
_dstore->reduce(ds.GetName(), ds.GetTitle(), ds._vars, cutVar, cutRange, nStart, nStop);
627 ds._cachedVars.add(
_dstore->cachedVars());
632 std::stringstream errMsg;
633 errMsg <<
"Error in RooAbsData::reduce! The ranges " << cutRange <<
" are overlapping!";
634 throw std::runtime_error(errMsg.str());
636 for (
const auto &token : tokens) {
637 std::unique_ptr<RooAbsData> appendedData{createEmptyClone()};
638 auto &ds =
static_cast<RooDataSet &
>(*appendedData);
639 ds._dstore =
_dstore->reduce(ds.GetName(), ds.GetTitle(), ds._vars, cutVar, token.c_str(), nStart, nStop);
640 ds._cachedVars.add(
_dstore->cachedVars());
675 title = std::string(
GetTitle()) +
"_binned" ;
704 return e > 0.0 ?
e *
e : w * w;
714 if(first + len > nEntries) {
715 throw std::runtime_error(
"RooDataSet::getWeightBatch(): requested range not valid for dataset.");
719 if(allWeights.empty())
return {};
721 if(!sumW2)
return {&*(std::cbegin(allWeights) + first), len};
731 for (std::size_t i = 0; i < nEntries; ++i) {
737 return std::span<const double>(&*(
_sumW2Buffer->begin() + first), len);
784 std::unique_ptr<RooFormula> select = nullptr ;
785 if (cutSpec && strlen(cutSpec) > 0) {
786 select = std::make_unique<RooFormula>(
"select",cutSpec,*
get()) ;
798 if (select && select->eval()==0.) continue ;
799 if (cutRange && !
_vars.allInRange(cutRange)) continue ;
876 ccoutE(
DataHandling) <<
"An event weight/error was passed but no weight variable was defined"
877 <<
" in the dataset '" <<
GetName() <<
"'. The weight will be ignored." << std::endl;
883 && std::abs(wgt*wgt - wgtError)/wgtError > 1.E-15
886 <<
"', but the weight variable '" <<
_wgtVar->GetName()
887 <<
"' does not store errors. Check `StoreError` in the RooDataSet constructor." << std::endl;
923 _wgtVar->setAsymError(weightErrorLo,weightErrorHi) ;
925 ccoutE(
DataHandling) <<
"An event weight was given but no weight variable was defined"
926 <<
" in the dataset '" <<
GetName() <<
"'. The weight will be ignored." << std::endl;
933 <<
"', but the weight variable '" <<
_wgtVar->GetName()
934 <<
"' does not store errors. Check `StoreAsymError` in the RooDataSet constructor." << std::endl;
977 ccoutE(
DataHandling) <<
"An event weight was given but no weight variable was defined"
978 <<
" in the dataset '" <<
GetName() <<
"'. The weight will be ignored." << std::endl;
985 && wgtError != 0. && wgtError != wgt*wgt
988 <<
"', but the weight variable '" <<
_wgtVar->GetName()
989 <<
"' does not store errors. Check `StoreError` in the RooDataSet constructor." << std::endl;
1010 list<RooDataSet*> dsetList ;
1011 if (data1) dsetList.push_back(data1) ;
1012 if (data2) dsetList.push_back(data2) ;
1013 if (data3) dsetList.push_back(data3) ;
1014 if (data4) dsetList.push_back(data4) ;
1015 if (data5) dsetList.push_back(data5) ;
1016 if (data6) dsetList.push_back(data6) ;
1017 return merge(dsetList) ;
1033 for (list<RooDataSet*>::iterator iter = dsetList.begin() ; iter != dsetList.end() ; ++iter) {
1041 list<RooAbsDataStore*> dstoreList ;
1042 for (list<RooDataSet*>::iterator iter = dsetList.begin() ; iter != dsetList.end() ; ++iter) {
1043 _vars.addClone((*iter)->_vars,
true) ;
1044 dstoreList.push_back((*iter)->store()) ;
1068 _dstore->append(*data._dstore) ;
1083 std::unique_ptr<RooAbsArg>
ret{
_dstore->addColumn(var,adjustRange)};
1132 pc.
defineInt(
"lineColor",
"LineColor",0,-999) ;
1133 pc.
defineInt(
"lineStyle",
"LineStyle",0,-999) ;
1134 pc.
defineInt(
"lineWidth",
"LineWidth",0,-999) ;
1135 pc.
defineInt(
"markerColor",
"MarkerColor",0,-999) ;
1136 pc.
defineInt(
"markerStyle",
"MarkerStyle",0,8) ;
1138 pc.
defineInt(
"fillColor",
"FillColor",0,-999) ;
1139 pc.
defineInt(
"fillStyle",
"FillStyle",0,-999) ;
1140 pc.
defineInt(
"histInvisible",
"Invisible",0,0) ;
1153 const char* drawOptions = pc.
getString(
"drawOption") ;
1154 Int_t histInvisible = pc.
getInt(
"histInvisible") ;
1155 const char* histName = pc.
getString(
"histName",
nullptr,
true) ;
1156 double scaleFactor = pc.
getDouble(
"scaleFactor") ;
1165 coutE(
InputArguments) <<
"RooDataSet::plotOnXY(" <<
GetName() <<
") ERROR: no YVar() argument specified and dataset is not weighted" << std::endl ;
1170 if (yvar && !dataY) {
1171 coutE(
InputArguments) <<
"RooDataSet::plotOnXY(" <<
GetName() <<
") ERROR on YVar() argument, dataset does not contain a variable named " << yvar->
GetName() << std::endl ;
1223 frame->
addPlotable(graph,drawOptions,histInvisible) ;
1280 const char *verbOpt,
const char* commonPath,
1281 const char* indexCatName) {
1286 bool ownIsBlind(
true) ;
1287 RooAbsArg* blindState = variables.find(
"blindState") ;
1289 blindState =
new RooCategory(
"blindState",
"Blinding State") ;
1290 variables.add(*blindState) ;
1292 ownIsBlind = false ;
1294 oocoutE(
nullptr,
DataHandling) <<
"RooDataSet::read: ERROR: variable list already contains"
1295 <<
"a non-RooCategory blindState member" << std::endl ;
1299 <<
"blindState category in variable list" << std::endl ;
1314 auto data = std::make_unique<RooDataSet>(
"dataset", fileList, variables);
1315 if (ownIsBlind) { variables.remove(*blindState) ;
delete blindState ; }
1323 blindCat =
static_cast<RooCategory*
>(data->_vars.find(
"blindState")) ;
1330 tmp = data->_vars.find(indexCatName) ;
1333 << indexCatName <<
" in supplied variable list" << std::endl ;
1338 <<
" is not a RooCategory" << std::endl ;
1348 Int_t outOfRange(0) ;
1351 Int_t fileSeqNum(0);
1352 for (
const auto& filename :
ROOT::Split(std::string(fileList),
", ")) {
1357 const char *catname = strchr(filename.c_str(),
':');
1373 char newLabel[128] ;
1374 snprintf(newLabel,128,
"file%03d",fileSeqNum) ;
1375 if (indexCat->
defineType(newLabel,fileSeqNum)) {
1376 oocoutE(data.get(),
DataHandling) <<
"RooDataSet::read: Error, cannot register automatic type name " << newLabel
1377 <<
" in index category " << indexCat->
GetName() << std::endl ;
1385 oocoutI(data.get(),
DataHandling) <<
"RooDataSet::read: reading file " << filename << std::endl ;
1388 TString fullName(commonPath) ;
1389 fullName.
Append(filename) ;
1390 ifstream file(fullName) ;
1394 << filename <<
"'. Returning nullptr now." << std::endl;
1400 bool haveBlindString(
false) ;
1402 while(file.good() && !file.eof()) {
1407 if (file.peek() ==
'#') {
1411 bool readError = variables.readFromStream(file,
true,verbose) ;
1412 data->_vars.assign(variables) ;
1423 blindCat->
setIndex(haveBlindString) ;
1429 while (isspace(file.peek())) {
1431 file >> std::noskipws >> dummy >> std::skipws;
1443 assert(
dynamic_cast<RooCategory*
>(variables.find(indexCatName)));
1444 const auto origIndexCat =
static_cast<RooCategory*
>(variables.find(indexCatName));
1445 for (
const auto& nameIdx : *indexCat) {
1446 origIndexCat->defineType(nameIdx.first, nameIdx.second);
1450 <<
" events (ignored " << outOfRange <<
" out of range events)" << std::endl;
1452 return data.release();
1467 ofstream ofs(filename) ;
1492 coutW(
DataHandling) <<
"RooDataSet::write(" <<
GetName() <<
"): WARNING error(s) have occurred in writing" << std::endl ;
1510 os <<
indent <<
" Dataset variable \"" <<
_wgtVar->GetName() <<
"\" is interpreted as the event weight" << std::endl ;
1541 os << arg->GetName() ;
1544 os <<
",weight:" <<
_wgtVar->GetName() ;
1556 if (
_dir)
_dir->GetList()->Remove(
this);
1559 if (
_dir)
_dir->GetList()->Add(
this);
1604 TTree *X_tree(
nullptr);
1614 _dstore = std::make_unique<RooTreeDataStore>(X_tree,
_vars);
1649 const char * cstr =
"cstr";
1660 const char *rangeName,
RooFormulaVar const *cutVar,
const char *cutSpec)
1663 if (cutVar && cutSpec) {
1664 throw std::invalid_argument(
"Only one of cutVar or cutSpec should be not a nullptr!");
1669 for (
auto const &item : slices) {
1670 std::unique_ptr<RooDataSet> sliceDataSet;
1675 sliceDataSet = makeDataSetFromDataHist(
static_cast<RooDataHist const &
>(*sliceData));
1676 sliceData = sliceDataSet.get();
1680 if (!indexCat.
hasLabel(item.first)) {
1683 <<
"\" in index category " << indexCat.
GetName() << std::endl;
1685 if (!indexCatInData.hasLabel(item.first)) {
1686 indexCatInData.defineType(item.first);
1688 indexCatInData.setLabel(item.first.c_str());
1689 std::unique_ptr<RooFormulaVar> cutVarTmp;
1691 cutVarTmp = std::make_unique<RooFormulaVar>(cutSpec, cutSpec, *sliceData->
get(),
false);
1692 cutVar = cutVarTmp.get();
1694 _dstore->loadValues(sliceData->
store(), cutVar, rangeName);
1710 os <<
"Contents of RooDataSet \"" <<
GetName() <<
"\"" << std::endl;
1713 os <<
"(dataset is empty)" << std::endl;
1717 if (
get() ==
nullptr ||
get()->empty()) {
1718 os <<
"(dataset has no observables)" << std::endl;
1724 os <<
" Entry " << i <<
": ";
1727 for (
const auto* var : *row) {
1728 if (!first) os <<
", ";
1731 os << var->GetName() <<
"=";
1732 if (
auto realVar =
dynamic_cast<const RooRealVar*
>(var)) {
1733 os << realVar->getVal();
1734 }
else if (
auto catVar =
dynamic_cast<const RooCategory*
>(var)) {
1735 os << catVar->getLabel();
1737 os <<
"(unsupported type)";
1741 os <<
", weight=" <<
weight();
1745 if (lo != 0.0 ||
hi != 0.0) {
1746 os <<
" ±[" << lo <<
"," <<
hi <<
"]";
ROOT::RRangeCast< T, false, Range_t > static_range_cast(Range_t &&coll)
int Int_t
Signed integer 4 bytes (int).
float Size_t
Attribute size (float).
short Version_t
Class version identifier (short).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
static void indent(ostringstream &buf, int indent_level)
The Kahan summation is a compensated summation algorithm, which significantly reduces numerical error...
Common abstract base class for objects that represent a value and a "shape" in RooFit.
TClass * IsA() const override
void setAttribute(const Text_t *name, bool value=true)
Set (default) or clear a named boolean attribute of this object.
bool hasLabel(const std::string &label) const
Check if a state with name label exists.
virtual const char * getCurrentLabel() const
Return label string of current state.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
RooAbsArg * find(const char *name) const
Find object with given name in list.
Abstract base class for a data collection.
virtual bool isWeighted() const =0
virtual double sumEntries() const
virtual double weightError(RooAbsData::ErrorType etype=RooAbsData::Poisson) const =0
virtual double weight() const =0
Abstract base class for binned and unbinned datasets.
virtual const RooArgSet * get() const
void printMultiline(std::ostream &os, Int_t contents, bool verbose=false, TString indent="") const override
Interface for detailed printing of object.
RooAbsData()
Default constructor.
void SetName(const char *name) override
Set the name of the TNamed.
RooAbsDataStore * store()
std::unique_ptr< RooAbsDataStore > _dstore
Data storage implementation.
RooArgSet _vars
Dimensions of this data set.
virtual Int_t numEntries() const
Return number of entries in dataset, i.e., count unweighted entries.
virtual bool isWeighted() const
void Streamer(TBuffer &) override
Stream an object of class RooAbsData.
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
void Streamer(TBuffer &) override
Stream an object of class TObject.
virtual void writeToStream(std::ostream &os, bool compact, const char *section=nullptr) const
Write the contents of the argset in ASCII form to given stream.
Object to represent discrete states.
bool setIndex(Int_t index, bool printError=true) override
Set value by specifying the index code of the desired state.
bool defineType(const std::string &label)
Define a state with given name.
bool setLabel(const char *label, bool printError=true) override
Set value by specifying the name of the desired state.
Named container for two doubles, two integers two object points and three string pointers that can be...
const char * getString(Int_t idx) const
Return string stored in slot idx.
Configurable parser for RooCmdArg named arguments.
bool process(const RooCmdArg &arg)
Process given RooCmdArg.
double getDouble(const char *name, double defaultValue=0.0) const
Return double property registered with name 'name'.
bool defineDouble(const char *name, const char *argName, int doubleNum, double defValue=0.0)
Define double property name 'name' mapped to double in slot 'doubleNum' in RooCmdArg with name argNam...
bool ok(bool verbose) const
Return true of parsing was successful.
bool defineObject(const char *name, const char *argName, int setNum, const TObject *obj=nullptr, bool isArray=false)
Define TObject property name 'name' mapped to object in slot 'setNum' in RooCmdArg with name argName ...
const char * getString(const char *name, const char *defaultValue="", bool convEmptyToNull=false) const
Return string property registered with name 'name'.
bool defineString(const char *name, const char *argName, int stringNum, const char *defValue="", bool appendMode=false)
Define double property name 'name' mapped to double in slot 'stringNum' in RooCmdArg with name argNam...
bool defineInt(const char *name, const char *argName, int intNum, int defValue=0)
Define integer property name 'name' mapped to integer in slot 'intNum' in RooCmdArg with name argName...
int getInt(const char *name, int defaultValue=0) const
Return integer property registered with name 'name'.
TObject * getObject(const char *name, TObject *obj=nullptr) const
Return TObject property registered with name 'name'.
Container class to hold N-dimensional binned data.
double weight(std::size_t i) const
Return weight of i-th bin.
double weightSquared(std::size_t i) const
Return squared weight sum of i-th bin.
const RooArgSet * get() const override
Get bin centre of current bin.
Container class to hold unbinned data.
RooFit::OwningPtr< RooAbsData > emptyClone(const char *newName=nullptr, const char *newTitle=nullptr, const RooArgSet *vars=nullptr, const char *wgtVarName=nullptr) const override
Return an empty clone of this dataset.
RooRealVar * _wgtVar
Pointer to weight variable (if set).
bool _doWeightErrorCheck
! When adding events with weights, check that weights can actually be stored.
RooArgSet _varsNoWgt
Vars without weight variable.
void loadValuesFromSlices(RooCategory &indexCat, std::map< std::string, RooAbsData * > const &slices, const char *rangeName, RooFormulaVar const *cutVar, const char *cutSpec)
RooFit::OwningPtr< RooDataHist > binnedClone(const char *newName=nullptr, const char *newTitle=nullptr) const
Return binned clone of this dataset.
void weightError(double &lo, double &hi, ErrorType etype=SumW2) const override
Return the asymmetric errors on the current weight.
const RooArgSet * get() const override
Return a RooArgSet with the coordinates of the current event.
void printContents(std::ostream &os=std::cout) const override
Print the contents of the dataset to the specified output stream.
virtual RooPlot * plotOnXY(RooPlot *frame, const RooCmdArg &arg1={}, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={}, const RooCmdArg &arg7={}, const RooCmdArg &arg8={}) const
Special plot method for 'X-Y' datasets used in fitting.
void initialize(const char *wgtVarName)
Initialize the dataset.
void printArgs(std::ostream &os) const override
Print argument of dataset, i.e. the observable names.
void SetName(const char *name) override
Change the name of this dataset into the given name.
virtual void addFast(const RooArgSet &row, double weight=1.0, double weightError=0.0)
Add a data point, with its coordinates specified in the 'data' argset, to the data set.
bool merge(RooDataSet *data1, RooDataSet *data2=nullptr, RooDataSet *data3=nullptr, RooDataSet *data4=nullptr, RooDataSet *data5=nullptr, RooDataSet *data6=nullptr)
TClass * IsA() const override
virtual RooAbsArg * addColumn(RooAbsArg &var, bool adjustRange=true)
Add a column with the values of the given (function) argument to this dataset.
bool write(const char *filename) const
Write the contents of this dataset to an ASCII file with the specified name.
double sumEntries() const override
Return effective number of entries in dataset, i.e., sum all weights.
std::span< const double > getWeightBatch(std::size_t first, std::size_t len, bool sumW2) const override
~RooDataSet() override
Destructor.
bool isNonPoissonWeighted() const override
Returns true if histogram contains bins with entries with a non-integer weight.
void SetNameTitle(const char *name, const char *title) override
Change the title of this dataset into the given name.
void printValue(std::ostream &os) const override
Print value of the dataset, i.e. the sum of weights contained in the dataset.
void append(RooDataSet &data)
Add all data points of given data set to this data set.
RooDataSet()
Default constructor for persistence.
std::unique_ptr< std::vector< double > > _sumW2Buffer
! Buffer for sumW2 in case a batch of values is requested.
void Streamer(TBuffer &) override
Stream an object of class RooDataSet.
void add(const RooArgSet &row, double weight, double weightError)
Add one ore more rows of data.
unsigned short _errorMsgCount
! Counter to silence error messages when filling dataset.
std::unique_ptr< RooAbsData > reduceEng(const RooArgSet &varSubset, const RooFormulaVar *cutVar, const char *cutRange=nullptr, std::size_t nStart=0, std::size_t nStop=std::numeric_limits< std::size_t >::max()) const override
Implementation of RooAbsData virtual method that drives the RooAbsData::reduce() methods.
void convertToTreeStore() override
Convert vector-based storage to tree-based storage.
void printMultiline(std::ostream &os, Int_t contents, bool verbose=false, TString indent="") const override
Print info about this dataset to the specified output stream.
double weightSquared() const override
Return squared event weight of the current event.
double weight() const override
Return event weight of current event.
static RooDataSet * read(const char *filename, const RooArgList &variables, const char *opts="", const char *commonPath="", const char *indexCatName=nullptr)
Read data from a text file and create a dataset from it.
bool isWeighted() const override
Return true if dataset contains weighted events.
virtual void Streamer(TBuffer &)
void removeFromDir(TObject *obj)
Remove object from directory it was added to.
TDirectory * _dir
! Associated directory
Graphical representation of binned data based on the TGraphAsymmErrors class.
void addBinWithXYError(Axis_t binCenter, double n, double exlow, double exhigh, double eylow, double eyhigh, double scaleFactor=1.0)
Add a bin to this histogram with the specified bin contents and error.
Collection class for internal use, storing a collection of RooAbsArg pointers in a doubly linked list...
virtual void Add(TObject *arg)
RooLinkedListIterImpl begin() const
Plot frame and a container for graphics objects within that frame.
RooAbsRealLValue * getPlotVar() const
void addPlotable(RooPlotable *plotable, Option_t *drawOptions="", bool invisible=false, bool refreshNorm=false)
Add the specified plotable object to our plot.
Variable that can be changed from the outside.
double getErrorLo() const
double getErrorHi() const
The RooStringView is a wrapper around a C-style string that can also be constructed from a std::strin...
TTree-backed data storage.
void loadValues(const TTree *t, const RooFormulaVar *select=nullptr, const char *rangeName=nullptr, Int_t nStart=0, Int_t nStop=2000000000)
Load values from tree 't' into this data collection, optionally selecting events using the RooFormula...
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
Buffer base class used for serializing objects.
virtual Version_t ReadVersion(UInt_t *start=nullptr, UInt_t *bcnt=nullptr, const TClass *cl=nullptr)=0
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=nullptr)=0
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
void SetName(const char *name="") override
Set the name of the TNamed.
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 void SetName(const char *name)
Set the name of the TNamed.
Mother of all ROOT objects.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
TObject()
TObject constructor.
void ToLower()
Change string to lower-case.
virtual void Streamer(TBuffer &)
Stream a string object.
TString & Append(const char *cs)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
A TTree represents a columnar dataset.
RooCmdArg StoreAsymError(const RooArgSet &aset)
RooCmdArg StoreError(const RooArgSet &aset)
RooCmdArg WeightVar(const char *name="weight", bool reinterpretAsWeight=false)
std::vector< std::string > Split(std::string_view str, std::string_view delims, bool skipEmpty=false)
Splits a string at each character in delims.
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
T * OwningPtr
An alias for raw pointers for indicating that the return type of a RooFit function is an owning point...
OwningPtr< T > makeOwningPtr(std::unique_ptr< T > &&ptr)
Internal helper to turn a std::unique_ptr<T> into an OwningPtr.
bool checkIfRangesOverlap(RooArgSet const &observables, std::vector< std::string > const &rangeNames)