# Fit construction using RooSimultaneous

Hello

I have the dataset with three variables.
I would like to obtain the fraction of three states with the three variables as well.
I know total 9 pdfs for each variable of each state.

``````                                       state A          state B          state C

Yield                                   Y_A              Y_B              Y_C
pdf for 1st variable      pdf_A1         pdf_B1         pdf_C1
pdf for 2nd variable     pdf_A2         pdf_B2         pdf_C2
pdf for 3rd variable      pdf_A3         pdf_B3         pdf_C3``````

The composite pdf for each variable is as follows.

pdf_1 = Y_Apdf_A1 + Y_Bpdf_B1 + Y_Cpdf_C1
pdf_2 = Y_A
pdf_A2 + Y_Bpdf_B2 + Y_Cpdf_C2
pdf_3 = Y_Apdf_A3 + Y_Bpdf_B3 + Y_C*pdf_C3

How can I construct the fit using RooSimultaneous?

Hi,

You can use RooAddPdf to construct the pdfs pdf_1, pdf_2 and pdf_3
in your mail. (Note that with the formalism you used you have constructed
these p.d.f.s to be extended pdfs so be sure to include the extended likelihood
term in the fit using the “e” option. Otherwise omit and explicit coefficient for
the last term, which is then taken to be 1-sum(otherCoefs))

Then you should make sure that your dataset contains a fourth discrete variable
that labels to which state each event belongs:i.e. add a RooCategory observable
named ‘state’ and define three labels to it, e.g. ‘A’ and ‘B’ and ‘C’ .

Once that is done you can construct the simulateneous fit as follows

RooSimultaneous simPdf(“simPdf”,“simPdf”,state) ; // ‘state’ is index observable
simPdf.addPdf(pdf_1,“A”) ; // Associate pdf_1 with state “A” (which must be previously definted in 'state’