diff --git a/roofit/roofitcore/src/RooDataSet.cxx b/roofit/roofitcore/src/RooDataSet.cxx index 97d816715ea5180abc6ab18b918f2820954cace8..91755f5eb968e3d101b5f28da0956d22245526b3 100644 --- a/roofit/roofitcore/src/RooDataSet.cxx +++ b/roofit/roofitcore/src/RooDataSet.cxx @@ -652,19 +652,32 @@ RooDataSet::RooDataSet(RooStringView name, RooStringView title, const RooArgSet& /// intermediate formula objects, use the equivalent constructor /// accepting RooFormulaVar reference as cut specification. /// -/// This constructor will internally store the data in a TTree. -/// /// For most uses the RooAbsData::reduce() wrapper function, which /// uses this constructor, is the most convenient way to create a /// subset of an existing data -/// RooDataSet::RooDataSet(RooStringView name, RooStringView title, RooDataSet *dset, const RooArgSet& vars, const char *cuts, const char* wgtVarName) : RooAbsData(name,title,vars) { // Initialize datastore - _dstore = new RooTreeDataStore(name,title,_vars,*dset->_dstore,cuts,wgtVarName) ; + if(defaultStorageType == Tree) { + _dstore = new RooTreeDataStore(name,title,_vars,*dset->_dstore,cuts,wgtVarName); + } else { + std::unique_ptr<RooFormulaVar> cutVar; + if (cuts && strlen(cuts) != 0) { + // Create a RooFormulaVar cut from given cut expression + cutVar = std::make_unique<RooFormulaVar>(cuts, cuts, _vars, /*checkVariables=*/false); + } + _dstore = new RooVectorDataStore(name,title, + /*tds=*/*dset->_dstore, + /*vars=*/_vars, + /*cutVar=*/cutVar.get(), + /*cutRange=*/nullptr, + /*nStart=*/0, + /*nStop=*/dset->numEntries(), + /*wgtVarName=*/wgtVarName); + } appendToDir(this,true) ; @@ -694,8 +707,6 @@ RooDataSet::RooDataSet(RooStringView name, RooStringView title, RooDataSet *dset /// equivalent constructor with a string based cut expression is /// recommended. /// -/// This constructor will internally store the data in a TTree. -/// /// For most uses the RooAbsData::reduce() wrapper function, which /// uses this constructor, is the most convenient way to create a /// subset of an existing data @@ -707,7 +718,7 @@ RooDataSet::RooDataSet(RooStringView name, RooStringView title, RooDataSet *dset //////////////////////////////////////////////////////////////////////////////// -/// Constructor of a data set from (part of) an ROOT TTRee. The dimensions +/// Constructor of a data set from (part of) an ROOT TTree. The dimensions /// of the data set are defined by the 'vars' RooArgSet. For each dimension /// specified, the TTree must have a branch with the same name. For category /// branches, this branch should contain the numeric index value. Real dimensions diff --git a/test/stressRooFit_tests.h b/test/stressRooFit_tests.h index 6da7f1b165a26ed58864a34566133182b3ab3969..5f48ad022ad672283843f7fe0447c2424b36c891 100644 --- a/test/stressRooFit_tests.h +++ b/test/stressRooFit_tests.h @@ -3004,7 +3004,6 @@ public: // Instruct dataset d in interpret w as event weight rather than as observable RooDataSet dataw(data->GetName(),data->GetTitle(),data.get(),*data->get(),nullptr,w->GetName()) ; - dataw.convertToVectorStore(); //data->setWeightVar(*w) ;