Analyzing a Spectrum
 Fitting a Peak in Roody
- Open the spectrum in Roody.
- Increase the size of the window so that it is at least half the height of the screen. This way you will be able to read the small numbers of the fit before Roody crashes.
- Zoom in around the peak to be fitted. Zoom in by moving the curser over the numbers along the x-axis until the curser changes to a hand. Click and hold the left mouse button for the region you want to zoom in on.
- In the main Roody window open the Refresh menu at the top and ensure refresh is set to off or roody will crash.
- Move the curser over the data in the spectrum window so that the curser changes from a cross to an arrow. Right-Click to bring up a menu.
- Select FitPanel on the menu to bring up a new window.
- Click the Fit button in the new window. A blue fit line should appear in the spectrum.
- Click the Close button in the fit window (or Roody will crash!!).
- The parameters of the fit are displayed in the top right of the spectrum window. Alternatively they are printed in the roody terminal tab
- Mean is the centroid of the fit.
- The FWHM and therefore the resolution is related to sigma by: fwhm=sigma*(2*sqrt(2*ln(2))) = sigma*2.3548
- Close the spectrum display window before opening another spectrum or calling the fit program again, or roody will crash.
- Roody will probably now crash.
 Fitting a Peak in ROOT
There was no way to reliably get a meaningful peak fit for the BGO spectra within ROODY. It needs to be done in an interactive ROOT session for now.
First, you need to determine the name of the spectrum you want to analyze and the name of the spectrum within that file. The spectrum will have a name like Sum00. The file name will look something like /tig/midtig01_data2/tigress/his00059.root. The path name is set by a variable in the MIDAS ODB, /Logger/Data dir. Note that this is the path name on he logging computer. If you are trying to analyze the data on a different computer you may need to use a full NFS path; e.g., /data2/tigress/*.root will work on midtig01, but you will have to use /tig/midtig01_data2/tigress/*.root if you are on mother8pi. The file with the spectra is the ROOT histogram file, his00059.root. The 00059 part is the run number. The method described below cannot work on the run in progress, so you must end the run and then analyze the data.
Next, in a terminal window, go to the BGO testing directory, cd ~/bgo_fe. Start up root. Load in the fitting routine by typing .L fittest.C. Declare a histogram and fit-function object by typing TH1F* h and TF1* g . Open the file of interest by typing in a command like TFile* F = TFile::Open("/tig/midtig01_data2/tigress/his00059.root"). Replace the part in quotes with the name of the file with the spectrum you want to analyze. Load all the files into memory by typing F->ReadAll() .
Next, to pull out and display a specific spectrum, type in something like h=(TH1F*)gROOT->FindObject("Sum00"). Replace Sum00 with the name of the spectrum you want. Display the spectrum by typing h->Draw().
You are now ready to fit. Zoom in on the fitting range by click-and-drag on the horizontal axis. Then type g=fittest(h). The fit will automatically overlay on the spectrum and the parameters will be printed out in the terminal window. The parameters, in order, are the height, centroid and sigma of the best-fit Gaussian, followed by the abc of a polynomial in a background. The fit is overlaid on the spectrum, showing the Gaussian peak in green, the polynomial background in blue, and the sum in red.