There are two examples here. One is a ROOT script to read a SpecTcl ASCII data file and create an ROOT data file. The other is a compiled version.


Simple Example to run in ROOT CINT


Copy these files spec.C and 1d.asc to your current directory and bring up a root session.

root[] .L spec.C; (Loads script)

root[] spec("1d.asc"); (executes script and reads ASCII file w/ histogram named "d2")

root[] write_file("1d.root"); (writes ROOT file)

root[] TFile f("1d.root"); (Loads ROOT file)

root[] TBrowser mybrowser; (Opens new browser window named "mybrowser")

In the browser you can look in ROOT FILES and double click on the histograms to view them.

or type

root[] f.ls()

and then you will see the list of objects in the ROOT file. The object d2 is of the class TH1F and is the histogram of the data. To display it you can type

root[] d2->Draw(); (Draw histogram named "d2")

to fit the data type

root[] d2->FitPanel(); (Opens fitting panel)

You can do an interactive fit for more complex fitting. See the ROOT manual.


Stand Alone Program


This example contains 1 program, spectrum.cpp, that does the same thing as the script spec.C. However, this program is a stand-alone program and must be compiled and executed outside of the ROOT program CINT. The purpose of spectrum.cpp is to read in an ASCII formatted SpecTcl histogram file, create a ROOT histogram for each SpecTcl histogram in the file and then generate a ROOT file that contains them. This will allow you to do fitting or other analysis of the histograms in ROOT. To use this example UnZip this file "spec.tar.gz" and read the README. If you use NetScape it will add an extra ".tar" onto the file name. Remove this extention and continue.

back