Calibration Binning Issues

I am running into some problems when calibrating raw ADC channel data. Here is the code I use:

TFile *rawhists = new TFile("/not_backed_up/user/paddy/KURF_LBC/scripts/rawhists.root"); TFile *calhists = new TFile("/not_backed_up/user/paddy/KURF_LBC/scripts/calhists.root", "recreate"); rawhists->cd(); TH1F *Sample_hist = (TH1F*)rawhists->Get("Sample_hist"); TH1F *BG_hist = (TH1F*)rawhists->Get("BG_hist"); Int_t numbins = Sample_hist->GetXaxis()->GetNbins(); MAXE = numbins*numbins*A + numbins*B + C; MAXE_bg = numbins*numbins*A_bg + numbins*B_bg + C_bg; TH1F *Sample_hist_calib = new TH1F(calib_histname_sample, "Calibrated Sample Spectrum", histbins, 0, MAXE); TH1F *BG_hist_calib = new TH1F(calib_histname_bg, "Calibrated Background Spectrum", histbins, 0, MAXE_bg); for (int i=1;i<=numbins;i++) { Double_t Cts_s = Sample_hist->GetBinContent(i); Double_t bin_s = Sample_hist->GetXaxis()->GetBinCenter(i); Double_t bin_bg = BG_hist->GetXaxis()->GetBinCenter(i); Double_t Cts_bg = BG_hist->GetBinContent(i); Double_t E_s = A*bin_s*bin_s + B*bin_s + C; Double_t E_bg = A_bg*bin_bg*bin_bg + B_bg*bin_bg + C_bg; BG_hist_calib->Fill(E_bg, Cts_bg); Sample_hist_calib->Fill(E_s,Cts_s); }

I get the A,B, and C parameters from another function that calibrates the spectrum for me.

THE PROBLEM I am running into is that when I draw the calibrated histogram, it looks like some bins are not getting filled in the calibrated histogram. I think this is a rounding error of some sort, but I’m not sure. If you want to see what it looks like go here:

You can see that there are bins with 0 content in them. It looks like they are spaced evenly, but they are not.

Does anyone know a better way to calibrate a histogram without seeing this?

Thanks!

  • Paddy

This sort of thing typically happens when you GetBinContent from histogram “A” with N bins and you “Fill” to histogram “B” with M bins, where N!=M. If M>N, you end up with bins that have zero content; if N>M, you end up with bins that are “double filled” and have many more counts than you expect. You should check on whether “histbins” is the same as “numbins” … in the code snippet you provide, histbins is not set when you instantiate the TH1F’s, so it’s hard to tell whether this is the problem or not.