Fit to function of tree branches

I want to fit the difference of two branches in my TTree. Is there a simple way to do this in RooFit? Using the name 'x-y' does not work:

ws.factory('RooRealVar::x-y(2235, 2335, "MeV")')

which results in an empty dataset.
Nor does creating a RooFormulaVar like:

ws.factory('RooFormulaVar::Dm("@0-@1", {x[2400, 2500], y[2235, 2335]})'

which, when I try to initialize the RooDataSet, gives:

[#0] ERROR:InputArguments -- RooAbsDataStore::initialize(data): Data set cannot contain non-fundamental types, ignoring Dm

I would prefer not to have to create a new TTree containing a branch named Dm. Any suggestions are appreciated.


You can create in RooFiit a new function z= x -y using for example RooFormulaVar (your second case), but the mapping to the Three will be always to x and y. z cannot be a RooRealVar and your RooFiit DataSet will contain x and y. Otherwise it is easy to loop on the tree and create a new RooDataSet containing z.
I can send you an example for this if you want


Ah okay. Yes, an example might speed along my scripting, thanks.

I should say I also tried importing a RooDataSet with x and y from the TTree, using the RooFormulaVar Dm for my model, but ran into problem in C++; program state has been reset when I tried to fit it.


attaches is an simple example for creating a RooDataSet from a Tree, using the hsimple.root file created with the tutorial hsimple.C


example_import.C (357 Bytes)

Thank you. Additionally, I found $ROOTSYS/tutorials/roofit/, which contains a similar example.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.