Hi,
I have a mac with OSX 10.10.4 and ROOT 6.05/01. I am trying to extract the tree representation of a RooDataSet. In the code below:
[code] RooRealVar x(“x”,"",0,10);
RooRealVar p(“p”,"",0,10);
RooGenericPdf pdf("pdf","","TMath::Exp(-p*x)",RooArgList(x,p) );
RooDataSet *data = pdf.generate(x, 5000);
TTree *tree_data = (TTree*)data->tree();
RooAbsDataStore *ds = (RooAbsDataStore*)data->store();
TTree *tree = (TTree*)ds->tree();
[/code]
you can see that I try to call RooDataSet::tree() but I get a null pointer. Here RooDataSet::tree() in RooFit version 3.00 it says that I should be able to get a RooAbsDataStore object with RooDataSet::store() and then from it I should call RooAbsDataStore::tree(), which I did above, but the pointer is still null. Am I making a mistake in the code above? Any of these tree() functions are supposed to work?
Also, if anyone else needs this and its not available I wrote this function:
[code]TTree* GetDataTree(TString name, RooDataSet *data)
{
TTree *tree = new TTree(name,"");
std::map<TString, float> m_map;
for (int i_entry = 0; ; i_entry++)
{
RooArgSet *mset = (RooArgSet*)data->get(i_entry);
if(!mset)
break;
TIterator *iter = mset->createIterator();
while(TObject *obj = iter->Next())
{
RooRealVar *var = dynamic_cast<RooRealVar*>(obj);
TString name( var->GetName() );
m_map[name] = var->getValV();
if(i_entry != 0)
continue;
tree->Branch(name.Data(), &m_map[name]);
}
tree->Fill();
}
return tree;
}[/code]
It only makes branches with floats as types, however I have never needed anything else.
Thanks.