Thanks for reply,

This is my code

```
using namespace RooFit ;
//Adopt this style
gROOT->Reset();
// ==> Observables
RooRealVar m("m","",0,10) ;
RooRealVar pT("pT","",0,10);
RooRealVar y("y","",-5,5) ;
void blabla()
{
// load all data
RooDataSet* dataPtYM = RooDataSet::read("data/dimuVecPPbMarek_UPCpPbDiTrkTree.txt",RooArgList(m,pT,y)) ;
// submit study for each different sample
doAllCases(dataPtYM);
}
void doAllCases(RooDataSet *dataPtYM)
{
int nbins=100;
float x1=0;
float x2=5;
float r1=0.1;
float r2=0.7;
float r3=5.0;
TH1F *hpT = new TH1F("histo","",nbins,x1,x2);
for (Int_t i=0; i< dataPtYM->numEntries(); i++){
hpT->Fill( dataPtYM->get(i)->getRealValue("pT") * dataPtYM->get(i)->getRealValue("pT") );
}
// expo functions used for initial parameters for total function
Double_t par[6];
TF1 *expo1 = new TF1("expo1","expo",0.0,r1);
TF1 *expo2 = new TF1("expo2","expo",r1,r2);
TF1 *expo3 = new TF1("expo3","expo",r2,r3);
TF1 *total = new TF1("total","expo(0)+expo(2)+expo(4)",0,5);
total->SetLineColor(2);
hpT->Fit(expo1,"R");
hpT->Fit(expo2,"R");
hpT->Fit(expo3,"R");
expo1->GetParameters(&par[0]);
expo2->GetParameters(&par[2]);
expo3->GetParameters(&par[4]);
total->SetParameters(par);
hpT->Fit(total,"R");
////////////// for signal extraction //////////////////
TFitResultPtr r = hpT->Fit(total,"R S");
TMatrixDSym covTot = r->GetCovarianceMatrix();
// make sub matrix for the second expo function
TMatrixDSym covEX(2,3, covTot.GetMatrixArray() );
TF1 *expoEX = new TF1("expoEX","expo",0.0,5);
// exporange->SetLineStyle(5);
expoEX->SetParameter(0,total->GetParameter(2));
expoEX->SetParameter(1,total->GetParameter(3));
expoEX->SetParError(0,total->GetParError(2));
expoEX->SetParError(1,total->GetParError(3));
// hpT->Fit(expoNEX,"RB+");
float Nex=expoEX->Integral(0,5)/((x2-x1)/nbins);
double errNex=expoEX->IntegralError(0,5, expoEX->GetParameters(), covEX.GetMatrixArray());
/////////////// canvas for plots /////////////////
TCanvas *c1 = new TCanvas("c1","c1",600,600);
c1->SetLogy();
hpT->Draw("E");
// c1->Update();
/////////// TERMINAL OUTPUT /////////////
cout << endl << "integral and error : " << Nex << "+/-" << errNex <<endl;
}
```

I have 3 different slopes in 3 regions, and want to get the integral under the second one, but on whole rande (0,5) and the error. The integral is ok, the error is “nan”. Sometimes it has some value, generally one or two orders of mag to small (depending on txt file I use). What is wrong with my code? The problem seems quite simple.

Marek