# Energy calibration of gamma ray-detector

**URL:** <https://root-forum.cern.ch/t/energy-calibration-of-gamma-ray-detector/33852>\
**Category:** Newbie\
**Created:** [May 1, 2019, 4:15pm UTC](https://root-forum.cern.ch/t/energy-calibration-of-gamma-ray-detector/33852 "2019-05-01T16:15:29Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arshjot\_Kaur](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/arshjot_kaur/32/21055_2.png) [@Arshjot\_Kaur](https://root-forum.cern.ch/u/Arshjot_Kaur)\
**Post date:** [May 1, 2019, 4:15pm UTC](https://root-forum.cern.ch/t/energy-calibration-of-gamma-ray-detector/33852/1 "2019-05-01T16:15:29Z")

</div>

Hi,

I am working on project to calculate resolution of LaBr detector, I have my spectra in root format. I don’t know how to convert channel no. to Energy. I have spectra of Eu-152 and Co-60.  
Please guide me regarding this.

Thank you

---

<div class="post-metadata">

**Author:** ![amadio](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/amadio/32/12562_2.png) [@amadio](https://root-forum.cern.ch/u/amadio)\
**Post date:** [May 2, 2019, 7:36am UTC](https://root-forum.cern.ch/t/energy-calibration-of-gamma-ray-detector/33852/2 "2019-05-02T07:36:34Z")

</div>

You need to identify at least two peaks that have known energy, fit a gaussian to each one, and then use the resulting positions for a linear fit to convert channels to energy. Have a look [here](https://www.gammaspectacular.com/blue/Co-60-gamma-spectrum) for more information.

---

<div class="post-metadata">

**Author:** ![zhli](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/z/e68b1a/32.png) [@zhli](https://root-forum.cern.ch/u/zhli)\
**Post date:** [May 2, 2019, 8:31am UTC](https://root-forum.cern.ch/t/energy-calibration-of-gamma-ray-detector/33852/3 "2019-05-02T08:31:01Z")

</div>

The energy calibration curve for Ge or Scintillation detector is usually described by the following 2 degrees polynomial function:

 ![54](https://root-forum.cern.ch/uploads/default/original/3X/0/5/05b6e28ac966c7a9c8df16be65a6a7c7fac206c2.png)

```cpp
//suppose you have five gamma peaks for the calibration.

Float_t energy[5]={121.78, 244.7, 344.28, 411.12, 443.96};//fill with your 152Eu gamma peak energies
Float_t channel[5]={100,200,300,400,500};//fill with your channel numbers from gamma peak fitting
TGraph *g=new TGraph;
g->SetPoint(5, channel, energy);//fill data to a Graph
g->Fit("pol2");//fit the graph with pol2

```

then calibrate your spectrum with the parameters obtained above

```cpp
void calibration(TH1D *h0)
{
    double p0=0;//fill with your fitted parameter values
    double p1=1;//
    double p2=0;//
// TH1D *h0 - raw gamma spectrum
    TH1D *g0=new TH1D("g0","g0",2500,0,2500);//g0 - calibrated spectrum
    TRandom3 *r=new TRandom3(0);
    for(int i=0;i<2500;i++){
        Long64_t eN=h0->GetBinContent(i);
        Double_t e=h0->GetBinCenter(i);
        for(Long64_t j=0;j<eN;j++){
            Double_t ea=e+r->Rndm()*0.2-0.1;
            ea=p2*ea*ea+p1*ea+p0;
            g0->Fill(ea);
        }
        if(i%1000==0) cout<<i<<endl;
    }
    TFile *f=new TFile("gammacali.root","recreate");
    g0->Write();
    f->Close();
}

```

---

<div class="post-metadata">

**Author:** ![Arshjot\_Kaur](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/arshjot_kaur/32/21055_2.png) [@Arshjot\_Kaur](https://root-forum.cern.ch/u/Arshjot_Kaur)\
**Post date:** [May 2, 2019, 10:31am UTC](https://root-forum.cern.ch/t/energy-calibration-of-gamma-ray-detector/33852/4 "2019-05-02T10:31:53Z")

</div>

Thank you for the reply. I am using Co-60 spectra as a known energy spectra for calibration.

---

<div class="post-metadata">

**Author:** ![Arshjot\_Kaur](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/arshjot_kaur/32/21055_2.png) [@Arshjot\_Kaur](https://root-forum.cern.ch/u/Arshjot_Kaur)\
**Post date:** [May 2, 2019, 10:33am UTC](https://root-forum.cern.ch/t/energy-calibration-of-gamma-ray-detector/33852/5 "2019-05-02T10:33:13Z")

</div>

Thank you so much for your help. It really helped in getting the results.

---

<div class="post-metadata">

**Author:** ![Michell\_Martinez](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/michell_martinez/32/21023_2.png) [@Michell\_Martinez](https://root-forum.cern.ch/u/Michell_Martinez)\
**Post date:** [February 28, 2020, 6:31am UTC](https://root-forum.cern.ch/t/energy-calibration-of-gamma-ray-detector/33852/6 "2020-02-28T06:31:07Z")

</div>

What if i have two histograms with two different calibrations and I want to sum each other

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [February 28, 2020, 8:04am UTC](https://root-forum.cern.ch/t/energy-calibration-of-gamma-ray-detector/33852/7 "2020-02-28T08:04:09Z")

</div>

I think, you will first need to “calibrate” both “raw” data samples separately. Then create a new histogram, with the x-axis representing “energy” (i.e. not “channels”), and fill this new histogram with your “raw” data from both samples, applying the required (sample specific) “energy calibration” on the fly.

---

<div class="post-metadata">

**Author:** ![zhli](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/z/e68b1a/32.png) [@zhli](https://root-forum.cern.ch/u/zhli)\
**Post date:** [March 3, 2020, 8:22am UTC](https://root-forum.cern.ch/t/energy-calibration-of-gamma-ray-detector/33852/8 "2020-03-03T08:22:44Z")

</div>

If you have two calibrated energy spectra.  
For example, TH1D \*he1, \*he2, then  
TH1D \*hesum;  
hesum-\>Add(he1,he2,1,1);  
hesum-\>Draw();

---

<div class="post-metadata">

**Author:** ![Ravinder](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/3bc359/32.png) [@Ravinder](https://root-forum.cern.ch/u/Ravinder)\
**Post date:** [December 31, 2020, 5:28pm UTC](https://root-forum.cern.ch/t/energy-calibration-of-gamma-ray-detector/33852/9 "2020-12-31T17:28:28Z")

</div>

can you share with me your macro of this co-60 calibrated data

---

<div class="post-metadata">

**Author:** ![Arshjot\_Kaur](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/arshjot_kaur/32/21055_2.png) [@Arshjot\_Kaur](https://root-forum.cern.ch/u/Arshjot_Kaur)\
**Post date:** [December 31, 2020, 6:18pm UTC](https://root-forum.cern.ch/t/energy-calibration-of-gamma-ray-detector/33852/10 "2020-12-31T18:18:15Z")

</div>

Sorry, I don’t have the data with me now. I completed the above project.

---

<div class="post-metadata">

**Author:** ![ruchi](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ruchi/32/24368_2.png) [@ruchi](https://root-forum.cern.ch/u/ruchi)\
**Post date:** [January 19, 2021, 7:00pm UTC](https://root-forum.cern.ch/t/energy-calibration-of-gamma-ray-detector/33852/11 "2021-01-19T19:00:54Z")

</div>

> [@zhli](#):
>
> ```auto
> void calibration(TH1D *h0)
> 
> ```

Hi Zhli,  
Where we can define the raw spectra (TH1D\*h0).? I am working on a similar problem. I have fitted parameters and I want to generate the calibrated spectrum.
