Hello,
I am trying to make a Gaussian distribution over bins of variable width. For that Gaussian distribution, I am extracting the bin content of bins that are occupied by the distribution and applying Poisson distribution to each bin and finally redrawing the new distribution. (I am only considering the odd numbered occupied bins).
Following is the code for the same.
But for the Gaussian distribution with the larger values of sigma, more bins are covered. So how can I apply ‘for’ loop over bins of variable width to get the bin content?
const Int_t Nx = 8;
Double_t edgesx[Nx + 1] = {0,3,3.2,6.2,6.4,9.4,9.6,12.6,12.8};
const Int_t Ny = 8;
Double_t edgesy[Ny + 1] = {0,3,3.2,6.2,6.4,9.4,9.6,12.6,12.8};
TH2F *h2 = new TH2F("h2","h",Nx,edgesx,Ny,edgesy);
TF2 *f2 = new TF2("f2","xygaus",0,20,0,20);
f2->SetParameters(1,6.3,1.028,6.3,1.028); //amplitude, meanx,sigmax,meany,sigmay
h2->FillRandom("f2",3000);
Double_t bin1 = (h2->GetBinContent(3,3))*0.34;
Double_t bin2 = (h2->GetBinContent(5,3))*0.34;
Double_t bin3 = (h2->GetBinContent(3,5))*0.34;
Double_t bin4 = (h2->GetBinContent(5,5))*0.34;
TF1 *f3 = new TF1("f3", "TMath::Poisson(x,[1])",0,10000);
f3->SetParameter(1,bin1);
TF1 *f4 = new TF1("f4", "TMath::Poisson(x,[2])",0,10000);
f4->SetParameter(2,bin2);
TF1 *f5 = new TF1("f5", "TMath::Poisson(x,[3])",0,10000);
f5->SetParameter(3,bin3);
TF1 *f6 = new TF1("f6", "TMath::Poisson(x,[4])",0,10000);
f6->SetParameter(4,bin4);
TH2F *h5 = new TH2F("h5", "d=0.8 and t = 0.4mm", Nx, edgesx, Ny, edgesy);
h5->Fill(4.7,4.7, f3->GetRandom());
h5->Fill(7.9,4.7, f4->GetRandom());
h5->Fill(4.7,7.9, f5->GetRandom());
h5->Fill(7.9,7.9, f6->GetRandom());
h5->Draw();
Thank you so much for your help.
Regards,
Kajal