Hi

I’m using my own functions(tf1) to fit my data. I do this for a mass distribution divide in bins. My distribution array looks as follows: massDistBin[ptbin][etabin][cut][whichcut]… the dimensions are [8][5][2][2]…the filling of these distributions with my mass data works, but when I try to fit my functions to it via a loop going of the bins (pt and eta) and the cuts(cut of uncut, id or iso) I get some problems… I try to adjust the parameters of some specific bins via if statements, but when I adjust the parameters for some of these I also see adjustments to other bins combinations … can someone explain how this is possible? a part of my code can be found at the end (as example it try to adjust the parameters for the uncut distribution in the case of ID). I already divided the code into different parts for uncut and cut and id and iso in the hope that this would solve my problem but it doesn’t.

```
for(int ptbins=0; ptbins<NumberOfptbins;ptbins++){
for(int etabins=0;etabins<NumberOfetabins;etabins++){
function.SetParameters(1200,-100,0.02,200000000,91,1,88,5);
if(ptbins == 7 and etabins == 2){
function.SetParameters(120,-100,0.02,2000000000,91,3,90,7);
cout << PT[ptbins] << ETA[etabins] << "\n";
}else{
if( ptbins == 7 and etabins == 0){
function.SetParameters(1200,-100,-0.02,200000000,91,1,88,5);
cout << PT[ptbins] << ETA[etabins] << "\n";
}else{
if( ptbins == 6 and etabins == 2){
function.SetParameters(1200,-100,-0.02,200000000,91,1,88,5);
cout << PT[ptbins] << ETA[etabins] << "\n";
}else{
if( ptbins == 0 and etabins == 4){
function.SetParameters(60,-10,0.04,-1200000,116,-2,84,7);
cout << PT[ptbins] << ETA[etabins] << "\n";
}else{
if( ptbins == 2 and etabins == 4){
function.SetParameters(1200,-100,0.02,200000000,91,1,88,5);
cout << PT[ptbins] << ETA[etabins] << "\n";
}else{
if( ptbins == 7 and etabins == 4){
function.SetParameters(1200,-100,0.02,2000000000,91,1,88,5);
cout << PT[ptbins] << ETA[etabins] << "\n";
}else{
if( ptbins == 7 and etabins == 3){
function.SetParameters(1200,-100,0.02,2000000000,91,1,88,5);
cout << PT[ptbins] << ETA[etabins] << "\n";
}else{
function.SetParameters(1200,-100,0.02,200000000,91,1,88,5);
}
}
}
}
}
}
}
function.SetParNames("b", "c", "d", "a", "Mean","Gamma","Mean Gauss", "Sigma");
massDistBins[ptbins][etabins][Uncut][ID]->Fit(&function,"S");
massDistBins[ptbins][etabins][Uncut][ID]->Fit(&function,"S");
for(int par=0;par<nFitPar;par++){
massDistFit_Total[ptbins][etabins][Uncut][ID]->SetParameter(par, function.GetParameter(par));
if(par<3) massDistFit_Background[ptbins][etabins][Uncut][ID]->SetParameter(par,function.GetParameter(par));
else massDistFit_Signal[ptbins][etabins][Uncut][ID]->SetParameter(par-3,function.GetParameter(par));
}
}
}
```

Kind regards

Wouter