Hi experts,
How to fill a histogram in which each bin will contain at least 5 counts.
Here is the macro:
TFile *f1 = new TFile("count.root", "RECREATE");
TTree *tr = new TTree("ntuple", "data");
tr->ReadFile("hist_plot.dat", "x");
TH1F *h1 = new TH1F("h1", "Gaussian Distribution", 20, -2.4, 2.9);
h1->GetXaxis()->SetTitle("log_{10}(Value)");
h1->GetYaxis()->SetTitle("Counts (Frequency)");
bool checkBins=true;
int count, sum;
for( int i=1; i<=20; i++) {
do {
if(h1->GetBinContent(i)<5)
checkBins=false;
// count = h1->GetBinContent(i);
// sum = count + h1->GetBinContent(i+1); }
// else { continue;}
}
while(checkBins && i <= h1->GetNbinsX());
tr->Project("h1", "log10(x)");
f1->Write();
h1->Draw("hist");
However first two bins contain less than 5 counts, other bins are fine. How do I add these two bins to the next bin?
Thanks!!
Anil