Hello,
I really would appreciate to help me understanding what is wrong with my projections. I have a TH3 histogram that results from a weighted sum of 5 TH3 histograms. I do not get consistent results, namely the number of entries is very different, when projecting the Z axis in X or Y slices. The code i use to project is:
for(Int_t j = 0; j < nCentBins; j++){
int a=0, b=0;
for(Int_t i = 0; i < nEtJetBins/rebin; i++){
a=b+1;
b=a+rebin-1;
sprintf(HistName,“h15Projection_%i%i”,i,j);
a4ItrPervsEtT[i] = a4ItrPervsEtTEta_MT[j]->ProjectionZ(HistName,a,b,28,70);
a4HIItrJer[j][i]=a4ItrPervsEtT[i]->GetRMS();
erra4HIItrJer[j][i]=a4ItrPervsEtT[i]->GetRMSError();
a4HIItrJes[j][i]=a4ItrPervsEtT[i]->GetMean();
erra4HIItrJes[j][i]=a4ItrPervsEtT[i]->GetMeanError();
cout<<"ET “<<a4ItrPervsEtT[i]->GetEntries()<<” i,j “<<i<<” "<<j<<endl;
}
}
for(Int_t j = 0; j < nCentBins; j++){
int a=0, b=0;
for(Int_t i = 0; i < nEtaJetBins/rebin; i++){
a=b+1;
b=a+rebin-1;
sprintf(HistName,“h16Projection_%i%i”,i,j);
a4ItrPervsEtaT[i] = a4ItrPervsEtTEta_MT[j]->ProjectionZ(HistName,5,nEtJetBins,a,b);
a4HIItrJereta[j][i]=a4ItrPervsEtaT[i]->GetRMS();
erra4HIItrJereta[j][i]=a4ItrPervsEtaT[i]->GetRMSError();
a4HIItrJeseta[j][i]=a4ItrPervsEtaT[i]->GetMean();
erra4HIItrJeseta[j][i]=a4ItrPervsEtaT[i]->GetMeanError();
cout<<"eta “<<a4ItrPervsEtaT[i]->GetEntries()<<” i,j “<<i<<” "<<j<<endl;
if (a4ItrPervsEtaT[i]->GetEntries()==0){
a4HIItrJereta[j][i]=1000;
a4HIItrJeseta[j][i]=1000;
}
}
}
a4ItrPervsEtT[i]->GetEntries(), either in X or Y slices, are only consistent if all weights are set to 1. So, the problem seems to be in TH3 and sumw2:
a4ItrPervsEtTEta_MT_J1[j]->Sumw2();
a4ItrPervsEtTEta_MT_J2[j]->Sumw2();
a4ItrPervsEtTEta_MT_J3[j]->Sumw2();
a4ItrPervsEtTEta_MT_J4[j]->Sumw2();
a4ItrPervsEtTEta_MT_J5[j]->Sumw2();
a4ItrPervsEtTEta_MT[j]->Add(a4ItrPervsEtTEta_MT_J1[j],a4ItrPervsEtTEta_MT_J2[j],J1XS,J2XS );
a4ItrPervsEtTEta_MT[j]->Add(a4ItrPervsEtTEta_MT[j],a4ItrPervsEtTEta_MT_J3[j],1,J3XS );
a4ItrPervsEtTEta_MT[j]->Add(a4ItrPervsEtTEta_MT[j],a4ItrPervsEtTEta_MT_J4[j],1,J4XS );
a4ItrPervsEtTEta_MT[j]->Add(a4ItrPervsEtTEta_MT[j],a4ItrPervsEtTEta_MT_J5[j],1,J5XS );
a4ItrPervsEtTEta_MT[j]->Scale(1/(J1XS+J2XS+J3XS+J4XS+J5XS));
The results of the projections become also wrong, of course. Do you know where the problem might be? Do I need to first project and only then make the weighted sum?
Thank you so much in advance.
Best regards,
Helena