Daniel Sigg, May 2001
The interactive DMT environment is based on ROOT/CINT. ROOT is a scientific software package developed for high energy physics. CINT is a C++ interpreter which is distributed as part of ROOT. The interactive DMT environment uses the ROOT command line and loads the standard DMT libraries during initialization. A good place to start is the ROOT User's Guide which explains all major features of ROOT.
The most important features of the DMT libraries are:
Since the ROOT command line is a C++ interpreter, macros developed in the interactive shell can easily compiled into a library module or program to gain efficiency.
Before starting make sure you have the DMT software installed on your machine and you are running a compatible version of ROOT. To setup the DMT run
root-setupfrom the UNIX prompt (root-setup is located in the bin directory of the DMT distribution). This script will perform the following:
source /export/home/dmt/pro/bin/root-setupto your ~/.cshrc file. Change the path to reflect the DMT setup on your machine. Working on a system which gets live data through the frame broadcast network also requires to setup a shared memory partition; specify it with
setenv DMTINPUT /online/LHO_Onlineand correspondingly for LLO. For off-line use this variable can be pointed to a set of frame files:
setenv DMTINPUT "/export/raid3/E3/*/*.F"This will read all frame files from all directories in /export/raid3/E3 (Note the use of quotes to avoid expanding the wild card by the shell).
Now the DMT command line can be invoked by simply typing:
rootThis should launch the ROOT command line with the DMT libraries preloaded. You can type normal C++ statements to test if it works. There are a few special commands one has to know. They all start with a period:
.q : Quit
.? : Help
.x mymacro.cc : Execute the script mymacro.cc
.L mystuff.cc : Load the file mystuff.cc
.! ls : Executes a shell command (ls in this example)
First declare a new time series object pointer:
TSeries* ts = 0;Now add it to the online data access class:
In.addChannel ("H0:PEM-MX_SEISZ", 1, &ts);where the first parameter must correspond to a valid channel name and the second parameter denotes an optional decimation rate. Now we can fill the time series object with some data from the default input
In.fillData (8);This will load eight seconds worth of data into ts. Let us now compute the power spectrum
FSeries fs (*ts);and display it with
FSpectrum ps (fs);
Spectrum (ps);We can now automate this so that data is loaded every eight seconds, the power spectrum calculated and the plot updated. Here is the macro
{Note the additional brackets around the for loop. This tells the ROOT command line interpreter to expect multiple lines of statements. Break out of the loop with
for (;;) {
In.fillData (8, true);
fs = FSeries (*ts);
ps = FSpectrum (fs);
Spectrum (ps);
}
}
Ctrl-cNow get some more data and compute the minimum and maximum of the data points
In.fillData (8);Now print the values
int min = ts->getMinimum();
int max = ts->getMaximum();
cout << "Minimum = " << min << endl;Let's build a histogram of the sampled values. First define the histogram with
cout << "Maximum = " << max << endl;
TH1F* h1 = new TH1F ("h1", "Sampled Values", 30, min, max);Get the number of samples and load the data into an array:
int N = ts->getNSample();Now fill the histogram and display it:
float f [N];
ts->getData (N), f);
for (int i = 0; i < N; i++) h1->Fill(f[i]);This should display the distribution of the sampled values together with a small statistics window on the right top corner.
h1->Draw();
The script of this session can be found here.