How to tie a single fitting variable to multiple histograms?

So I have 4 histograms and 4 functions. What I do currently is fit each of the functions to a histogram
an example of the code is

TH1D* h1 = new TH1D("h1","", 1e2,0,1e4);
TH1D* h2 = new TH1D("h2","", 1e2,0,1e4);
TH1D* h3 = new TH1D("h3","", 1e2,0,1e4);
TH1D* h4 = new TH1D("h4","", 1e2,0,1e4);

// fill functions for the histograms

TF1 *f1 = new TF1("f1","[0]*TMath::Poisson(x/[1],0)",0,10);
TF1 *f2 = new TF1("f2","[0]*TMath::Poisson(x/[1],1)",0,10);
TF1 *f3 = new TF1("f3","[0]*TMath::Poisson(x/[1],2)",0,10);
TF1 *f4 = new TF1("f4","[0]*TMath::Poisson(x/[1],3)",0,10);

f1->SetParameters(S1,mean);
f2->SetParameters(S2,mean);
f3->SetParameters(S3,mean);
f4->SetParameters(S4,mean);

h1->Fit(f1);
h2->Fit(f2);
h3->Fit(f3);
h4->Fit(f4);

The S1,S2,S3,S4 values are independent of one another but I want a singular value for “mean” or [1] that would work best for all four fitting results. As of right now, four different mean values are spat out and I have to average them together to get a hopefully ideal value, but I was wondering if there was a way to bind the variable for all the fittings.


Please read tips for efficient and successful posting and posting code

ROOT Version: 6.24
Platform: Ubuntu
Compiler: Not Provided


I think @moneta can help you.

${ROOTSYS}/tutorials/fit/combinedFit.C
${ROOTSYS}/tutorials/fit/combinedFit.py