Wierd behaviour of histogram

I am noticing something weird when I am changing the bin number in the histograms.
When it is let’s say 5000, frequency or the number of counts is high and when I increase the bin number to 10000 frequency goes down. I can’t understand why changing bin number should affect this?

#define Nothing_cxx
#include “Nothing.h”
#include <TH2.h>
#include <TStyle.h>
#include <TCanvas.h>

void Nothing::Loop()
{
// In a ROOT session, you can do:
// Root > .L Nothing.C
// Root > Nothing t
// Root > t.Loop(); // Loop on all entries

Long64_t nentries = fChain->GetEntries();
debut=time(NULL);
reste=0.;
gSystem->GetSysInfo(&infos);
cout<< “CPU speed “<<infos.fCpuSpeed<< " MHz”<< " | Physical RAM “<<infos.fPhysRam <<” MB”<<endl;
cout << “” << endl;
Long64_t nbytes = 0, nb = 0;

TCanvas *c1 = new TCanvas(“c1”,“c1”,500,500,800,800);
test = new TH1F(“Meter”,“Meter”,10000,0,2000);
test1= new TH1F(“single1”,“single1”,5000 ,0,1700);
test2= new TH1F(“single2”,“single2”,5000 ,0,1700);
test3= new TH1F(“single3”,“single3”,5000 ,0,1700);
test4= new TH1F(“single4”,“single4”,5000 ,0,1700);

for (Long64_t jentry=0; jentry<nentries;jentry++) { // loop over event
Long64_t ientry = LoadTree(jentry);
if (ientry < 0) break;
nb = fChain->GetEntry(jentry); nbytes += nb;

Meter=0;
float valf;

for(Int_t i =0 ; i<Energy.size(); i++){ //loop over all cristal of the event
if(Cristal.at(i)==0 && Number.at(i)==32 && Detector.at(i)==8){
valf=(0.0899152 + 0.224355 * (Energy.at(i) ));
//cout << (0.5-(rand())/2147483647.) << endl;
test1->Fill(valf);
test1->SetLineColor(1);
Meter=Meter+valf;}

  else if(Cristal.at(i)==1 && Number.at(i)==33 && Detector.at(i)==8){
  	valf=(0.109294 + 0.228245 * (Energy.at(i) ));
    	test2->Fill(valf);
    	test2->SetLineColor(2);
  	Meter=Meter+valf;}
  	
  else if(Cristal.at(i)==2 && Number.at(i)==34 && Detector.at(i)==8){
  	valf=(0.206293 + 0.23034 * (Energy.at(i) ));
    	test3->Fill(valf);
    	test3->SetLineColor(3);
  	Meter=Meter+valf;}
  	
  else if(Cristal.at(i)==3 && Number.at(i)==35 && Detector.at(i)==8){
  	valf=(0.00227491 + 0.229786 * (Energy.at(i) + (0.5-(rand())/2147483647.)));
    	test4->Fill(valf);
    	test4->SetLineColor(5);
  	Meter=Meter+valf;}

}
test->Fill(Meter);

  if(jentry%100000==0){
  printf("\r %2.1f per cent treated : ",(float)jentry*100.0/(float)nentries);cout.flush(); 

}
}
//test->Draw();
test1->Draw();
test2->Draw(“same”);
test3->Draw(“same”);
test4->Draw(“same”);
//test2->Draw(“”);

cout << "Total Entries test : " << test1->GetEntries() + test2->GetEntries() + test3->GetEntries() + test4->GetEntries() << endl;

}

You have the same number of entries (96404) on more bins. That automatically implies the maximum goes down.

1 Like