TProfile From a TH2D Histogram

Hi,
I have a 2D-Histogram and a TProfile that I have declared:

 Double_t x[ ] = {1., 2., 3., 5., 7., 9., 13., 19., 27., 37., 52., 74., 105., 155.};
//define histogram and profile
TProfile *prof = new TProfile("prof", "prof", (sizeof(x) / sizeof(Double_t) - 1), x);
TH2F *h1 = new TH2F("h1","hist",100,0.,10.,100,0.,11.);

After some retrieving of data, I fill the histogram and TProfile.

for(Int_t i =0; i<NumEntries; ++i){
  k->GetEntry(i);
  Double_t total = c+d+e+ff+g;

//checking results using console output
  
 cout << a << "\t" << "0" << "\t" << g << "\t" <<c << "\t" << d << "\t" << e << "\t"  << ff <<  "\t" << "total: " << total <<  endl;
   h1->Fill(a,total);
   prof->Fill(a*a,total);
}

However I don’t think I have done this correctly. Shouldn’t the TProfile depend on my histogram? Whereas the way I have created it they exist independently. The effect this has is that I do not have any error bars on my TPofile y-axis when it is drawn?

Could someone point me in the right direction?

Thanks.

Hi

The Profile is independent of the histogram, ably you are using dependent data.

I don’t know why you don’t have error bars, maybe too few entries?
When the bin entry is 1 no error is displayed

Lorenzo

Hi,
may be you mix up the 2 cases:

  1. Construct and fill a TProfile as you did (independent of a TH2)

  2. Construct and fill a TH2
    then apply TProfile *prof = TH2::ProfileX(… ) to get a profile
    of your TH2 i.e. the means of Y vs X including errors
    Cheers
    Otto