# Calibration to energy level

we have channel number on x axis and i want to calibrate it and and change it to energy axis…Co60(1).txt (92.8 KB) cofit.cpp (2.0 KB)

Sorry, but I don’t understand what you’re trying to do. Could you explain a bit more?

I need to do calibration of channel number and convert it to energy .Here I am attaching the calibration curve of both detectors and my data of Co-60 of two detectors . Idet1graph.pdf (14.2 KB)det2graph.pdf (14.1 KB) Co60(1).txt (92.8 KB)

I’m sorry, I still don’t understand… Maybe @Axel can take a look once back from vacation

I run you script and I get the following:

In the above plot, I assume you want to convert the horizontal axis (channel number) into energy. To do that, we need some data to fit to get the energy as a function of channel number. You provide 2 calibration pdfs. We need one, so which one to use? And we would need the fit parameters of whichever one corresponds to the plot shown above.

1 Like

we will use second

Please tell me the specific numerical values of the fit parameters of the second calibration pdf. In general though, I estimate the fit parameters to be something like
p0 = 20
p1 = 1
so you can just fill the values into the histogram accordingly, like so:

`````` TH1F *hist1 = new TH1F("hist1","title1", 100, 0., 2000);
TH1F *hist2 = new TH1F("hist2","title2", 100, 0., 2000);

std::ifstream infile("Co60.dat");
int x1,x2;

while (infile >> x1 >> x2) {hist1->Fill((x1));hist2->Fill(x2+20);cout << x1 << "\t" << x2+20 << endl;}

double p2,p3;
TF1 *f4 = new TF1("f4","*exp(-0.5*pow((x-)/,2))+*exp(-0.5*pow((x-)/,2))+*exp(-*x)",1020,1620);

f4->SetParLimits(9,1060,1180);
f4->SetParLimits(11,1205,1430);
f4->SetParLimits(10,10,80);
f4->SetParLimits(13,10,80);
hist2->Draw();

hist2->Fit("f4","","",1020,1620);
f4->Draw("Same");
p2=f4->GetParameter(14);
p3=f4->GetParameter(15);
``````

And I get the below plot

where you can see the mean is shifted by 20 according to the calibration function f(x) = x+20. Of course you can use your actual parameters to make this more accurate, and adjust the fitting parameters to account for the new calibration.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.