Exercises based on data from IRMM

Exercise 1: Analyze and Fit Spectrum Data

  • We start from an Excel file containing spectrum data. We consider for the moment only the data in the first two columns. If you have problem using the Execl file you can use directly the .csv file which can be read from the macro( csv file ).

  • Create first a ROOT macro able to read the data from the Excel spreadsheet.

Save data from Excel in a text format (like .csv) and then read the csv file in C++

You can download an example macro reading the data from Excel here

  • Once you are capable of reading the data, fill an histogram with the spectrum. The data contains energy values and count. You need then to create an histogram with the number of bins equal to the number of data rows and then fill the spectrum using the second column as a weight for the histogram.

  • The next thing is then to select the data in the range [480,530] KeV. You can then either directly fill a big histogram and then create a sub-histogram (as we did in an exercise two days ago), or select the data while reading and fill directly a histogram with a smaller axis. In the solution we will do the second case.

  • Next is to fit the histogram in its full range [480,530] using background ( a polynomial of degree 2) plus signal peaks ( two gaussians) In order to do that it is better to fit first only a polynomial background (“pol2”), then each single gaussian peak at approximately 510 and 497 KeV. This allows to compute an initial estimate of the parameters which you can use for the global fit. Knowing the initial parameters, makes it it easier to do the fit with an overall function representing the two signals plus the background.

  • Try now to use a more complicated function for the sec on peak (the higher one). We fit with a modified signal Gaussian with a left larger tails defined as in the following formula:

formula.png
Definition of second peak signal

The result of the fit should be the one shown in the figure below.

fullfitNew.png
Fit of the spectrum

  • Afterwards, compute the number of events in the 497 KeV peak and its error.

You can do in two ways:
  • Use TF1::Integral to compute the integral of the function and TF1::IntegralError to compute the error. For computing the integral error you need the correlation (or covariance) matrix of the parameters of the gaussian signal shape. What you get from the fit is the matrix containing all the parameters, also the background ones. You need to extract the sub-matrix for the three gaussian parameters.

  • Use a normalised definition for the signal shape and fit directly the number of events.

Exercise 2: Create a Tree and Analyze Pacman Spectrum Data

We will now create a TTree from the data files (test files) of Pacman. We have a set of text files contained in an archived tar file.

We have the following data file (in Text format):

  • peru_1_Ge10.dat from Ge10
  • peru_1_Ge11.dat from Ge11
  • peru_1_NaI.dat from Compton suppression shield

Each file contains: time stamps in 0.1 microseconds unit (Measurement time is 6.84395 days ) and ADC value (ADC have 8192 channels).

We have then also Energy calibration data with the same format as the previous files.

  • QA_Ge10.dat for Ge10
  • QA_Ge11.dat for Ge11

The first aim is to read the text file and create a TTree containing all these data (or several TTree if you prefer).

The solution we choose is to create a TTree made of several branches, one for each type of data file. The branch is made of a collection (a vector of detector data, which consists of time and ADC. The tree then contains a single entry.

To make the Tree, creates first your own class defining the branch data, thus a vector of time and ADC values. You can do as we did in exercise 3 of the Tree session.

Here you can download the macro, pacman.C, which contains the class definition for the Tree branches and reads the file, creates the tree and eve it in a ROOT file, called pacman.root

Once we have the data in the Tree we can then analyse. The first goal is to determine the calibration of the ADC, by using some known location of the peaks. We need therefore to create a spectrum with the calibration data and fit those peaks. The known peaks to be used for calibration are:

  • 59.5409 keV (Am241) [Not visible on Ge11]
  • 661.657 keV (Cs137)
  • 1173.228 keV (Co60)
  • 1332.492 keV (Co60)

In order to quickly find them in term of ADC counts, we have, for the Ge10 detector:

  • channel 118 -> 59.5409 keV
  • channel 1463 -> 661.657 keV
  • channel 2606 -> 1173.228 keV
  • channel 2961 -> 1332.492 keV

For the Ge11 detector ( no 59.5409 keV since Ge11 has a thicker deadlayer than Ge10 and Cu endcap instead of Al for Ge10) :

  • channel 1417 -> 661.657 keV
  • channel 2520 -> 1173.228 keV
  • channel 2860 -> 1332.492 keV

Fit the peak in the histograms created by the spectrum of the calibration data. You can then save the peak fitted positions (and its error) in a TGraphErrors together with the true known energy of the peaks. By fitting this Graph we can then build the calibration curve (Energy vs ADC) that we can use to convert ADC counts in energy for the other data sets.

Correct then the other data set and plots the spectrum in term of Energy and not ADC counts.

Here (Calibrate.C) is the ROOT macro fitting the spectra from the calibration detectors and then making the calibration curve.

calibration peaks.png
Peak used for calibration

calibration curve.png
Calibration curve
Topic attachments
I Attachment History Action Size Date Who Comment
C source code filec Calibrate.C r1 manage 1.5 K 2013-02-28 - 12:02 LorenzoMoneta Macro to read the tree, make calibration histograms to fit and then fit a calibration curve (ADC vs Energy)
C source code filec FitIRMMSpectrum.C r1 manage 3.6 K 2013-02-28 - 10:40 LorenzoMoneta Macro fitting and analyzing the spectrum ROOT file
C source code filec ReadSpectrum.C r1 manage 2.6 K 2013-02-28 - 09:18 LorenzoMoneta Macro to read .csv file from Excel
PNGpng calibration_curve.png r1 manage 13.1 K 2013-02-28 - 12:02 LorenzoMoneta Macro to read the tree, make calibration histograms to fit and then fit a calibration curve (ADC vs Energy)
PNGpng calibration_peaks.png r1 manage 16.4 K 2013-02-28 - 12:02 LorenzoMoneta Macro to read the tree, make calibration histograms to fit and then fit a calibration curve (ADC vs Energy)
Microsoft Excel Spreadsheetxls data-InCl3.xls r1 manage 1132.5 K 2013-02-28 - 02:53 LorenzoMoneta Excel Data File
PNGpng formula.png r1 manage 25.6 K 2013-02-28 - 01:08 LorenzoMoneta FIt spectrum and function formula for modified gaussian peak
PNGpng fullfit.png r1 manage 13.0 K 2013-02-28 - 15:09 LorenzoMoneta Fitted spectrum
PNGpng fullfitNew.png r1 manage 13.0 K 2013-02-28 - 15:11 LorenzoMoneta Fitted spectrum
C source code filec pacman.C r1 manage 1.8 K 2013-02-28 - 11:48 LorenzoMoneta Macro reading all the text file and creating a ROOT Tree
Compressed Zip archivetgz pacman_data.tgz r1 manage 48973.7 K 2013-02-28 - 09:36 LorenzoMoneta Tar file with Pacman text data files
Unknown file formatcsv test.csv r1 manage 256.4 K 2013-02-28 - 10:43 LorenzoMoneta csv file created from Excel
Edit | Attach | Watch | Print version | History: r7 < r6 < r5 < r4 < r3 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r7 - 2013-02-28 - LorenzoMoneta
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Main All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright &© 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback