Hi everybody,
this is my first request to the community, so please excuse me in advance for mistakes.
I have two kind of TTree s: the first one the DATA and the second one the MC entries.
I want to extract the shape of one TBranch of the MC and fit to the same TBranch of the DATA.
I tried with the “RooHistPdf()” class but it doesn’t worked.
I’m working with ROOT 6.17/01 version.
Thank’s in advice!
TChain chain("h1");
chain.Add("/home/emanuele/Scrivania/MC_double_corps_decay/SelppMC_0_9.root");
chain.Add("/home/emanuele/Scrivania/MC_double_corps_decay/SelppMC_10_29.root");
chain.Add("/home/emanuele/Scrivania/MC_double_corps_decay/SelppMC_30_50.root");
TChain chain1("h1");
chain1.Add("/home/emanuele/Scrivania/D_double_corps_decay/SelppD_0_9.root");
chain1.Add("/home/emanuele/Scrivania/D_double_corps_decay/SelppD_10_29.root");
chain1.Add("/home/emanuele/Scrivania/D_double_corps_decay/SelppD_30_50.root");
TH1D *hma1 = new TH1D("hma1","1", 200, 475., 510.);
//Here I create 2 chains and the 1D Histograms (I decide to use only one)
RooRealVar x("x","x",475,510);
chain.Draw("Variable>>hma1","Cuts that I want to add");
//Here I draw on the first Histogram the Variable that I want (with the cuts)
RooDataHist data("data","data",x,hma1);
RooHistPdf histpdf1("histpdf1","histpdf1",x,data,0);
chain1.Draw("Variable>>hma1","The same cuts");
RooDataHist data1("data1","data1",x,hma1);
histpdf1.fitTo(data1);
RooPlot* frame1 = x.frame(Title("..." ),Bins(200));
data1.plotOn(frame1);
histpdf1.plotOn(frame1);
frame1->Draw();
//I do the same for the DATA Values and with "RooDataHistpdf"
//I take the shape of the MC Histogram.
//At the end the program overlap the MC histogram to the DATA's one
This program is only able to Overlap the first shape to the second one. It seems that the line “histpdf1.fitTo(data1)” doesn’t work, cause it doesn’t call MINOS in order to do the fit of the second histogram.
How can I do it?
First of all when you post the code, please add using pre-formatted text, (as done below) to make it more readable.
The problem is due to the fact that your pdf has no parameters. You can add for example a normalisation parameter doing this, but you will fit only the number of events:
I corrected the error. Thanks @moneta for letting me know.
So I wanted to ask you if it was possible with RooFit to make a fit to an indirect variable (i.e. given by a function of other TBranches).
In the example you wrote I imagine that “nevts” is a TBranch of the TTree that I declare.
I need to fit a variable which is a function of many TBranches (including arrays).
One idea would be to declare “RooRealVals” with the names of the TBranches I need and then write the function.
Another one, which is the one I used, is to declare a “RooDataHist” and fill it with the variable I need to fit.
What I’m asking is: can it work?
If it doesn’t work, should I use the first method?
If not, do you know any other strategies?
HI,
I am not sure I understand your request.
From the Three you can retrieve a vector of data points. This branch normally can then be used:
as an observable variable of your model, but not as a a parameter that you fit. For example you have a vector of x values, you model for these values a Gaussian(x, mu, sigma) and you can fit using these values for the mu and sigma parameters.
estimate a distribution (e.g. an histogram) that can then be used then as input for the fit, together with some additional model parameters (e.g. histogram normalisation, bin by bin variation, etc…)
Hi @moneta,
What I want is to derive the invariant mass through the TBranches of the TTree.
Specifically, I have the TBranch of the momentum of the decaying particle and the TBranch of the momentum of the particles produced.
That’s why I used the “Draw ()”. I put:
chain.Draw("Function of P_father and P_sons( i.e. Invariant mass )>>hma1", "Cuts that I want");
in order to then work on the “hma1” histogram which should take into account the entries of the “invariant mass”.
What I’m wondering is if by doing so I can then work on the “invariant mass” via RooFit.
What you can do it is creating a subtree with the variable you want to input to RooFit as RooDataSet.
To create a subtree, you can use the power of RDataFrame to make a snapshot, see for example the tutorial :