Can't make multiple subsets from a single RooDataSet[SOLVED]

I have a single RooDataSet with which I wish to create multiple subsets. Each subset uses the same two variables, but consists of different RooCategories which have previously defined.

The RooDataSet consists of two RooRealVars, vtxmass0 and vtxmass1. There are multiple RooCategories, but for the code below, only two are being used for the cuts: regionbin and tsvtbin. Of those two, only tsvtbin is being varied.

  //get one RooDataSet
  dName  = "vtmDataSet_md"+itos(myMD);
  exDataROOTFile->GetObject(dName.c_str(), vtmDataSet_md.at(myMD));

  if (debugLevel>=1)
    vtmDataSet_md.at(myMD)->Print("V");
  int myRB = Control;
  RooDataSet *subset00, *subset01;

  subName  = std::string(vtmDataSet_md.at(myMD)->GetName())+sTwoSVTTypes.at(ZeroZero);
  subTitle = "Subset00";
  cuts.str("");
  cuts << "regionbin==regionbin::" << sRegions.at(myRB) << " && tsvtbin==tsvtbin::" << sTwoSVTTypes.at(ZeroZero) ;
  if (debugLevel>=1)
    cout << "DEBUG: cut selection :" << cuts.str() << endl;

  subset00 = (RooDataSet*)vtmDataSet_md.at(myMD)->reduce(Name(subName.c_str()), Title(subTitle.c_str()), SelectVars(RooArgSet(vtxmass0, vtxmass1)), Cut(cuts.str().c_str()));

  if (debugLevel>=1)
    subset00->Print("V");  

  subName  = std::string(vtmDataSet_md.at(myMD)->GetName())+sTwoSVTTypes.at(ZeroOne);
  subTitle = "Subset01";
  cuts.str("");
  cuts << "regionbin==regionbin::" << sRegions.at(myRB) << " && tsvtbin==tsvtbin::" << sTwoSVTTypes.at(ZeroOne) ;
  if (debugLevel>=1)
    cout << "DEBUG: cut selection :" << cuts.str() << endl;

  subset01 = (RooDataSet*)vtmDataSet_md.at(myMD)->reduce(Name(subName.c_str()), Title(subTitle.c_str()), SelectVars(RooArgSet(vtxmass0, vtxmass1)), Cut(cuts.str().c_str()));
^^^^^ Above is Line 959 ^^^^^

  if (debugLevel>=1)
    subset01->Print("V");  

Here is the output with the debugging statements.

RooDataSet::vtmDataSet_md3: "Vertex Mass Dataset max d0 0.30"
  Contains 1532206 entries
  Defines RooArgSet::Dataset Variables: (Owning contents)
    1) RooRealVar::vtxmass0: "Vertex Mass"
    2) RooRealVar::vtxmass1: "Vertex Mass"
    3) RooCategory::regionbin: "Region Bin"
    4) RooCategory::tetbin: "Two Et Bin"
    5) RooCategory::tsvtbin: "Two SVT Bin"
  Caches RooArgSet:::
DEBUG: cut selection :regionbin==regionbin::Control && tsvtbin==tsvtbin::2SVT00
RooDataSet::vtmDataSet_md32SVT00: "Subset00"
  Contains 4855 entries
  Defines RooArgSet::Dataset Variables: (Owning contents)
    1) RooRealVar::vtxmass0: "Vertex Mass"
    2) RooRealVar::vtxmass1: "Vertex Mass"
  Caches RooArgSet::Cached Variables:
DEBUG: cut selection :regionbin==regionbin::Control && tsvtbin==tsvtbin::2SVT01

 *** Break *** segmentation violation

The program produces a segmentation fault, which I have supplied the backtrace from the core file. Line 959 is indicated above.

#0  0xb4762582 in RooSharedPropertiesList::~RooSharedPropertiesList() () from /cdf/code/cdfsoft/products/root/v5_14_00gGCC_3_4_3/Linux+2.4-2.3.2/lib/libRooFit.so
#1  0xb46abcc1 in __static_initialization_and_destruction_0(int, int) () from /cdf/code/cdfsoft/products/root/v5_14_00gGCC_3_4_3/Linux+2.4-2.3.2/lib/libRooFit.so
#2  0xb46abd24 in _GLOBAL__D__ZN11RooCategory15_sharedPropListE () from /cdf/code/cdfsoft/products/root/v5_14_00gGCC_3_4_3/Linux+2.4-2.3.2/lib/libRooFit.so
#3  0xb4647130 in __do_global_dtors_aux () from /cdf/code/cdfsoft/products/root/v5_14_00gGCC_3_4_3/Linux+2.4-2.3.2/lib/libRooFit.so
#4  0xb4a80c86 in _fini () from /cdf/code/cdfsoft/products/root/v5_14_00gGCC_3_4_3/Linux+2.4-2.3.2/lib/libRooFit.so
#5  0xb75f10dd in _dl_fini () from /lib/ld-linux.so.2
#6  0xb42ad8f3 in exit () from /lib/tls/libc.so.6
#7  0xb6f85760 in TUnixSystem::Exit(int, bool) () from /cdf/code/cdfsoft/products/root/v5_14_00gGCC_3_4_3/Linux+2.4-2.3.2/lib/libCore.so
#8  0xb6f8396a in TUnixSystem::DispatchSignals(ESignals) () from /cdf/code/cdfsoft/products/root/v5_14_00gGCC_3_4_3/Linux+2.4-2.3.2/lib/libCore.so
#9  0xb6f816f2 in SigHandler(ESignals) () from /cdf/code/cdfsoft/products/root/v5_14_00gGCC_3_4_3/Linux+2.4-2.3.2/lib/libCore.so
#10 0xb6f8845c in sighandler(int) () from /cdf/code/cdfsoft/products/root/v5_14_00gGCC_3_4_3/Linux+2.4-2.3.2/lib/libCore.so
#11 <signal handler called>
#12 0xb476275f in RooSharedPropertiesList::registerProperties(RooSharedProperties*) () from /cdf/code/cdfsoft/products/root/v5_14_00gGCC_3_4_3/Linux+2.4-2.3.2/lib/libRooFit.so
#13 0xb46ab01f in RooCategory::RooCategory(RooCategory const&, char const*) () from /cdf/code/cdfsoft/products/root/v5_14_00gGCC_3_4_3/Linux+2.4-2.3.2/lib/libRooFit.so
#14 0xb46abe9e in RooCategory::clone(char const*) const () from /cdf/code/cdfsoft/products/root/v5_14_00gGCC_3_4_3/Linux+2.4-2.3.2/lib/libRooFit.so
#15 0xb464bf2c in RooAbsArg::Clone(char const*) const () from /cdf/code/cdfsoft/products/root/v5_14_00gGCC_3_4_3/Linux+2.4-2.3.2/lib/libRooFit.so
#16 0xb465a7bd in RooAbsCollection::addServerClonesToList(RooAbsArg const&) () from /cdf/code/cdfsoft/products/root/v5_14_00gGCC_3_4_3/Linux+2.4-2.3.2/lib/libRooFit.so
#17 0xb465a660 in RooAbsCollection::snapshot(bool) const () from /cdf/code/cdfsoft/products/root/v5_14_00gGCC_3_4_3/Linux+2.4-2.3.2/lib/libRooFit.so
#18 0xb47719f2 in RooTreeData::RooTreeData(char const*, char const*, RooTreeData*, RooArgSet const&, RooFormulaVar const*, char const*, int, int, bool) ()
   from /cdf/code/cdfsoft/products/root/v5_14_00gGCC_3_4_3/Linux+2.4-2.3.2/lib/libRooFit.so
#19 0xb46ce3ba in RooDataSet::RooDataSet(char const*, char const*, RooDataSet*, RooArgSet const&, RooFormulaVar const*, char const*, int, int, bool) ()
   from /cdf/code/cdfsoft/products/root/v5_14_00gGCC_3_4_3/Linux+2.4-2.3.2/lib/libRooFit.so
#20 0xb46ce8f3 in RooDataSet::reduceEng(RooArgSet const&, RooFormulaVar const*, char const*, int, int, bool) ()
   from /cdf/code/cdfsoft/products/root/v5_14_00gGCC_3_4_3/Linux+2.4-2.3.2/lib/libRooFit.so
#21 0xb465f37a in RooAbsData::reduce(RooCmdArg, RooCmdArg, RooCmdArg, RooCmdArg, RooCmdArg, RooCmdArg, RooCmdArg, RooCmdArg) ()
   from /cdf/code/cdfsoft/products/root/v5_14_00gGCC_3_4_3/Linux+2.4-2.3.2/lib/libRooFit.so
#22 0x080776cc in main (argc=11, argv=0xbfff9884) at Calc_BGEFlavorComp06.C:959

If I only extract/reduce one subset from the RooDataSet, for any set of RooCategories, there are no problems. But I would like to extract multiple subsets in a for-loop for multiple fits. Is there a problem with how I am using reduce? Or is this not possible with RooDataSets?

Finally, this code is being compiled against Root v5.14/00 and RooFit v2.10.

I changed the problem line (numbered 959 above) from

subset01 = (RooDataSet*)vtmDataSet_md.at(myMD)->reduce(Name(subName.c_str()), Title(subTitle.c_str()), SelectVars(RooArgSet(vtxmass0, vtxmass1)), Cut(cuts.str().c_str()));

to

subset01 = (RooDataSet*)vtmDataSet_md.at(myMD)->reduce(Name(subName.c_str()), Title(subTitle.c_str()), Cut(cuts.str().c_str()));

Removing the SelectVars argument seems to solve my problem. I don’t understand why this is, but I’m going to mark the forum title as [SOLVED] anyway.