Empty bins after calibration

The latter one is easy to provide :slight_smile:

The histograms we talked about here are located in the directory E_cal.

I did tell you to make sure that you had not used: TH1::SetAxisRange

Now use:

hSpectrumUncalibrated->GetXaxis()->SetRange(0, 0); // reset the range

I added the line of code now and indeed the number of entries is now OK. However, I don’t know why that changed something. I don’t see where I should have changed the axis range on hSpectrumUncalibrated before the code mentioned here…

Still hSpectrumCalibrated2 shows this interesting behavior (but now with “zero” entries):
hSpectrumCalibrated2.pdf. (90.2 KB)

Try with:

TH1F *hSpectrumUncalibrated = new TH1F("hSpectrumUncalibrated", "Th-228 -- uncalibrated", nEnergyBins, 0, nEnergyBins);
Double_t dEU = hSpectrumUncalibrated->GetBinWidth(1) / 2.0; // half of the "fixed" bin width
// ...
hSpectrumUncalibrated->Fill(energy + dEU);
ENERGY_CAL[i] = channel2Energy(fCalibration, energy);

and:

TH1F *hSpectrumCalibrated = new TH1F("hSpectrumCalibrated", "Th-228 -- calibrated", nEnergyBins, channel2Energy(fCalibration, 0), channel2Energy(fCalibration, nEnergyBins));
Double_t dEC = hSpectrumCalibrated->GetBinWidth(1) / 2.0; // half of the "fixed" bin width
// ...
hSpectrumCalibrated->Fill(ENERGY_CAL[i] + dEC);

Doing this I get c1.pdf (88.9 KB).
Now the number of entries is 2.