..............................................................................
1. GENERAL

This is a test code for a monitor application under development. The code is 
arranged in a client-server architecture, the two parts communicate through 
a socket, i.e. the server runs in one pc and receives and displays the info 
that the client sends to it, the client may run in a different pc and its 
task is to process the data that the daq writes out.    

The graphical user interface is arranged in one main panel to the left to 
display plots that should be always visible, and a panel to the right 
with multiple overlayed tabs, currently DAQ, Display, TDC, Chambers, 
Status, Messages, Options. Also there are some buttons with basic functions,
Start, Exit, Pause, Print. 


The following info is transmitted and displayed

.  event time, run, index

.  8 status counters (#ofevents processed, #ofevents found with "NOTRIGGER",
   "BadTrigger", "BadReadout", #of good pedestal and trigger events, #of 
   events found with "TdcOverflown", "BadTrack")

.  3d event display

.  hist number of hits hit per event
   hist energy per event

.  hist number of hits hit per layer
   hist energy per layer

.  hist daq rate in Hz vs time 
   hist average pedestal vs time 
   hist number of channels read

.  tdc time per chamber (8 histos)
   track coordinates  (8 histos)


The purpose of the test is first of all to check the code is running 
smoothly. Then given the main framework is in place to get feedabck from 
potential users on issues like what sort of histograms would be 
useful/vital to have during a testbeam, what sort of output one would 
like to have that can be accessed in more detail and in short time after 
the end of a run? What is shown is adequate or not, what to add, what 
to omit. Is the functionality transparent or error prone (how to install 
and run, settings-options, buttons, etc) 

For the current test the client transmits about 35 histos (only 23 
displayed) every 100 events. For the real testbeam a transmission every 
3 to 5 minutes is expected.   


..............................................................................
2. HOWTO INSTALL

ROOT 4.02/04 or higher and LCIO 01-04 or higher should have been installed 
in your system. 

The source of the code can be downloaded from:

www.hep.phy.cam.ac.uk/~gmavroma/temp/testcode.tgz


Get a sample of a run (Run100122) from last year's testbeam with a couple 
of thousands events, just to test that the code is running, from:

www.hep.phy.cam.ac.uk/~gmavroma/temp/testsample.tgz


To install:

tar zxvf testcode.tgz;
tar zxvf testsample.tgz;
cd testcode;
make clean;
make;


..............................................................................
3. HOWTO RUN

Open 2 window terminals, one for the gui-server and the other for the 
client. Go to directory testcode in both terminals.
In the gui-server, open the gui with ./gui_monitor/MyGUI&
then press button "Start" to open a socket where the client will connect 
and send the data.
In the client window, start the client with the command
cd ./raw2cnc/raw2cnc_v00_01;
./bin/raw2cnc 100122 -threshold 0.5 -sample 10000;
where 0.5 is the cell threshold (in mips) applied  

Then you should see the generated histograms and plots at the gui panels.
If you press "Pause" the updating is paused and you can invoke root 
interactively i.e. you can click on histos, do fit, change scale, save it 
and so on. You can continue updating with "Continue".
If you press "Print" the current plots are dumped in a postscript file 
and gv is launched to open it. When the client is finished the socket is 
closed, so in order to run again, say for another sequence of runs,
you should press "Start" and then start the client. 


..............................................................................
4. INPUT - OUTPUT

The input to the client is the binary files that the daq produces, along 
with the mapping files and tentative calibration constants. 

At the end of each run the client saves the histos in a root file 
with name MonitorXXXX.root, where XXXX is the run number, so that can be 
checked later. It produces also an lcio file with name SelectRunXXXX.slcio
which contains clean and calibrated data ala mokka format for later 
analysis. 

The gui does not produce any persistent output per run. For every 
transmission it dumps graphically the info on screen and also it saves 
some key plots as gif files that can be accessed from a web page. You can 
check this by pointing your web browesr to the file testbeam/testbeam.html 
under directory testcode, then click "Monitor" and if the gui is running 
you should see the plots updating accordingly every xxx seconds.   


..............................................................................
5. HOWTO TRANSMIT BETWEEN 2 PC's 

If you want to try to run the client in one pc (say pc_client) where it 
will
process the data and transmit the info to a different pc (say pc_gui) 
where 
the gui is running to display it then do the following

in pc_gui
.  install the gui only (the client+data are not needed here)
   tar zxvf testcode.tgz;
   cd testcode;
   make clean;
   make gui;

.  find the pc's name or ip address 
   host $HOSTNAME;    

.  run the gui
   ./gui_monitor/MyGUI&;
   then press button "Start" 


in pc_client 
.  put the code and the data in a dir
   tar zxvf testcode.tgz;
   tar zxvf testsample.tgz;
   
.  edit the file testcode/raw2cnc/raw2cnc_v00_01/package/inc/SocketClient.hh
   line ... sock = new TSocket("localhost", 9097); In place of localhost
   put the name or ip address of pc_gui
   
.  then install       
   cd testcode;
   make clean;
   make;

.  run the client
   cd ./raw2cnc/raw2cnc_v00_01;
   ./bin/raw2cnc 100122 -threshold 0.5 -sample 10000;





<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<