README files

Mayank wrote a bunch of READEME files as documentation of program use cases. I am listing them here for convenience.
INITIAL CHECKS
--------------
1) $CRT/ScanTests/special_cases/README 
(for going to a point / pad, checking if all pads are working and 
correcting the coordinate system)


START SCAN
-----------
2) $CRT/ScanTests/README (for starting a scan using testmain)

3) $CRT/daq/doc : (for starting scan thru' daq system, it's output is 
inter_file directly)
description_how_to_start_a_scan.txt 
description_pmtscan_software_applications.txt (what can one change about 
the scanning mechanism)
note_for_configuration_file.txt
note_for_pmtscan_commander.txt
note_for_treerootwriter.txt

ANALYSIS
--------
4)  $CRT/ScanTests/daq_programs/README (for analysis that can be done on 
flat_tube_results_date*_time*.root file only, such as make_inter_file) 
(FLAT FILE)

5) ssh to kangaroo. (INTER FILE)
/u1/mayankj/scripts/README_before_analysis and
/u1/mayankj/scripts/README_analysis 
(for analysing inter_file)

kskpi: /u1/data

STEPS FOR RUNNING A SET OF SCANS:-


a) ENSURE CORRECTNESS OF FILES TestMsgBox.cc in $CRT/ScanTests
b) compile using "gmake testmain" there 
c) copy testmain and libtestmsgbox.so from there to /u1/data on kskpi
d) open the file "making_todo.cpp" and edit it as desired (i.e. the
information on linescans, such as x, y values) 

e.1) g++ making_todo.cpp
e.2) a.out (then, file "todo_copy" is made)

f) open the file "todo_copy" and then, check it's correctness
g) if perl script "run.pl" is running, then no need of further efforts
h) execute the scans by (if perl script isn't running) :
perl run.pl > & ! opfile < /dev/null &  

$CRT/ScanTests/special_cases/README

ENSURE THAT PREVIOUS INVOCATION OF testmain ISN'T RUNNING:
----------------------------------------------------------
log onto kskpi machine
ps -aux | grep testmain
if output is only of type :
 mayankj  19145  0.0  0.0  1744  588 pts/0    S    15:31   0:00 grep testmain
Then, you can go ahead with analysi below, else contact who is runnign testmain


1) YOU WANT TO GO CENTRE OF A PAD (here, pad 1) :-
----------------------------------------------

cd $CRT/ScanTests/special_cases
mayankj@kskpi $ $ROOTSYS/bin/root -b
  *******************************************
  *                                         *
  *        W E L C O M E  to  R O O T       *
  *                                         *
  *   Version   3.00/06       28 May 2001   *
  *                                         *
  *  You are welcome to visit our Web site  *
  *          http://root.cern.ch            *
  *                                         *
  *******************************************

Compiled with thread support.

CINT/ROOT C/C++ Interpreter version 5.14.79, Feb 24 2001
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] .L set_at_pad_centre.C 
root [1] set_at_pad_centre(1);  

1.2) YOU WANT TO KNOW WHETHER THIS PAD IS WORKING OR NOT:
cd $CRT/examples
checkTDCADC

The result will be the number of hits repoted in each channel of the 3
TDCs that we are considering. Also, a file store.root is created, with
time distribution histograms : pad1,... pad64 and calib1, calib2  

1.3) YOU WANT TO CHECK IF ALL PADS ARE WOKING OR NOT:

rm -f *.root
rm -f datafile
cp $CRT/ScanTests/testmain .
cp $CRT/ScanTests/libtestmsgbox.so .
cp $CRT/ScanTests/daq_programs/make_inter_file_kskpi .
testmain 57 -7.75 11.5 37.25 6.5 6.5 40000 0 0 0 test 0 
(WAIT FOR IT"S COMPLETION)

g++ testing_all_pads.cc
a.out 

The result will be a file store_signal.root. Refer README_analysis in
/net/kangaroo/u1/mayankj/scripts for seeing efficiency plot 


2) YOU WANT TO GO TO POSITION (X, Y) :-
----------------------------------------

cd $CRT/ScanTests/special_cases
mayankj@kskpi $ $ROOTSYS/bin/root -b
  *******************************************
  *                                         *
  *        W E L C O M E  to  R O O T       *
  *                                         *
  *   Version   3.00/06       28 May 2001   *
  *                                         *
  *  You are welcome to visit our Web site  *
  *          http://root.cern.ch            *
  *                                         *
  *******************************************

Compiled with thread support.

CINT/ROOT C/C++ Interpreter version 5.14.79, Feb 24 2001
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] .L setposition.C   
root [1] setposition(55, -5)

3) YOU WANT TO GET CURRENT POSITION :-
--------------------------------

cd $CRT/ScanTests/special_cases 
$ROOTSYS/bin/root -b getposition.C



4) EXECUTE COORDINATE SYSTEM RESTORE PROGRAM :-
---------------------------------
cd $CRT/ScanTests/special_cases
$ROOTSYS/bin/root -b execute_after_power_outage.C


5)  EXECUTE COORDINATE SYSTEM RESTORE PROGRAM FOR TOP MOTION CONTROLLER ONLY :-
-------------------
cd $CRT/ScanTests/special_cases
$ROOTSYS/bin/root -b execute_after_power_outage_for_top.C

6) EXECUTE COORDINATE SYSTEM RESTORE PROGRAM FOR BASE MOTION CONTROLLER ONLY :-
-----------------------
cd $CRT/ScanTests/special_cases
$ROOTSYS/bin/root -b execute_after_power_outage_for_base.C

$CRT/ScanTests/README
PREREQUISITES:-
-----------
1) We need to set the ROOTSYS env variable to:-
/afs/slac.stanford.edu/g/babar/package/root/3.00-06/Linux2
For details, please see my .cshrc file.

2)  CHECKING IF A PAST INVOCATION OF PROGRAM IS ALREADY RUNNING:-
type ./testmain on the command prompt only ON A KSKPI LOGIN "WHEN NO
PREVIOUS INVOCATION OF SAME PROGRAM IS RUNNING" and see help there. 
type ps -aux on kskpi and not on other machines

3) Execute the scan : 
 ./testmain in $CRT/ScanTests/ or wherever libtestmsgbox.so and
testmain executable are present 
./testmain start_x start_y end_x end_y step_x step_y
  per_point_readings calibrate_indicator intelligent_measure_indicator
  scan_calibn_region input_comment indicate_accuracy_correction 
--where x,y values tell the diagonally opposite corners of the
  rectangle to be scanned 
--where step sizes have to be given in absolute values
--where calibrate_indicator = 0 / 1 means : CALIBRATE NOWHERE / ONCE EVERY ROW
--where setting intelligent_measure_indicator will mean reading from
  only a 3377 tdc for points not in _middle region_ (refer program for
  details) of pad 
--where setting scan_calibn_region to 1 will mean that we are in the
  region around calibration PMTs and we don't need to read from 3377
  TDC's connected to flat tube PMT 
--give input comment without spaces eg: for_calibration

TIME ESTIMATES:-
-------------
1) 3 minutes for movement from a flat tube point to the area of
calibration PMTs. 

2) It takes about 8 seconds per point to finish the measurements,
motion and writing to flat_tube_*.root file when the distance between
steps is 0.1 mm and 40,000 gates occur and 2228A is used 

- About 1 hour 40 minutes for a linescan of length 57 mm, step 0.1 mm in x

MEASUREMENT PROCEDURE:-
--------------------
TDC counts at all TDCs are read out at each point where measurement is taken.

We can change the TDC being used by making following changes in
TestMsgBox.cc and : 
Constructor: adc_2249_14 = new Crt_NEW_Board("tdc224914", 14, camac); 
Measure() method: Ensure that the length of data23 array is sufficient
for putting all readouts from this new TDC  

We can change the measurement parameters (such as arguments to
ReadModuleAndClear() method) by going to Measure() method in
TestMsgBox.cc 


MOTION CONTROLLERS' LIMITS:- 
----------------------------
There are two actuators for motion in x, one stacked above the
other. The base actuator has motion in x and y both. The top actuator
has motion in x only. See their limits in
special_cases/execute_after_power_outage.C script. They are also set
in overallsettings.h file 

SEQUENCE OF POINTS AT WHICH MEASUREMENTS DONE :-
----------------------------------------------
1) Calibration 
2) y = ystart and x varying from xstart till xend at steps of xstep
3) Calibration
4) Motion along y axis by step of ystep
5)  y = (ystart + ystep) and x varying from xend till xstart at steps of -xstep
6) so on.. 

If number of ysteps is even, the last point visited is (xend, yend)
If number of ysteps is odd, the last point visited is (xstart, yend)


FINDING WHETHER PULSER INTEnSITY IS CHANGING WITH TIME :
--------------------------------------
1) change setting in testmain.cc of "EFFICIENCY_OVER_TIME" to 1

2) Execute testmain (where we take readings at a fixed point over time) :
     ./testmain x y readings_in_one_measurement number_of_measurements
period_between_two_measurements_in_seconds TDC_to_be_read
input_comment indicate_accuracy_correction  
     -- where TDC to be read is told by slot : 19 / 16 / 23
     -- current setting is: 3377 TDC's at slots 16, 19 & 7186 TDC at slot 23
     -- give input comment without spaces eg: for_calibration 

3) Then, execute $CRT/ScanTests/daq_programs/hgram_efficiency_over_time 
$CRT/ScanTests/daq_programs/README

BASIC QUESTIONS:
----------
1) Where should I run the daq analysis programs ?
Log onto a LINUX machine other than kskpi. 
go to CosmicRayTelescope/ScanTests/daq_programs

3) Where are the settings like the cuts made on TDC readouts, the
corner coordinates ? 
  overalldataanalysis.h in CosmicRayTelescope/ScanTests

5) What are the data analysis functions that I can do ?
   Type in the command in the directory told in 1) to know about arguments.

SCRIPTS:
-------
a) make_inter_file makes the inter_file from flat_tube_file
b) hgram_approp_tdc_channel makes plot of RMS of time distribution in
main_pad vs x, y  
c) make_inter_file_kskpi same as make_inter_file, but for kskpi



SPECIAL SCANS:-
-------------
a) OBSERVE EFFICIENCY AT A POINT (ASSUMED) AND A LABEL (AS TOLD BY
ANALYSIS USER) OVER TIME, DISTRIBUTION OF THAT EFFICIENCY AND CHI
COMPUTATION FOR THAT EFFICIENCY  
   ./hgram_efficiency_over_time date time label



kangaroo: /u1/mayankj/scripts/README_before_analysis
1) Add the following line to your ~/.cshrc file :
alias root '$ROOTSYS/bin/root'
and then, run
source ~/.cshrc

2) EXECUTE LINESCANS: Execute the scans either through testmain or
through pmtscan_commander. 

4) MAKE A DIRECTORY FOR ANALYSING THIS SET OF SCANS (say, in
/u1/mayankj on kangaroo) : 
ssh kangaroo
cd /u1/mayankj
mkdir jan12

3) MAKE INTER FILES  :
        a) If testmain was used to execute scans, execute :
	cp $CRT/ScanTests/libtestmsgbox.so jan12/
	cp $CRT/ScanTests/make_inter_file jan12/
	cp $CRT/ScanTests/make_inter_file_OVER_ALL_LINESCANS.cpp jan12/
	g++ make_inter_file_OVER_ALL_LINESCANS.cpp
	a.out first_scan_date first_scan_time last_scan_date last_scan_time > & ! opfile < /dev/null &
	// WAIT FOR COMPLETION OF AFORESAID COMMAND....... 
	cp inter_file_date*_time*.root /nfs/farm/g/eb/u06/dirc/inter_pmtscans2003/

        b) If pmtscan_commander was used to execute scans, then
          inter_file is automatically generated in /u1/data on kskpi (no
          flat_.root file is generated).  
	Remove unwanted files inter_files from net/kskpi/u1/data
	Execute the following command :
	cp /net/kskpi/u1/data/inter_file_date*_time*.root /nfs/farm/g/eb/u06/dirc/inter_pmtscans2003/

3) COMBINED INTER FILE FOR SCANS OF INTEREST: 
	a) Obtain the list of all scans done :
   	ls -altr /nfs/farm/g/eb/u06/dirc/pmtscans2002/flat* | awk '{print $9}' > datafile2002
  	ls -altr /nfs/farm/g/eb/u06/dirc/pmtscans2003/flat* | awk '{print $9}' > datafile2003
  	cat datafile2002 datafile2003 > datafile2
	
	b) The script chain_OVER_ALL_LINESCANS_2003.C processes all
          files between between two date_time's. We may have some useless files
          between first linescan and last linescan of this set. Remove those
          unwanted scans from datafile2 

	c) Make a combined inter file :
	root
	.L chain_OVER_ALL_LINESCANS_2003.C
	chain_OVER_ALL_LINESCANS_2003.C(first_scan_date first_scan_time last_scan_date last_scan_time) 


4) Copy all scripts from scripts directory to this directory :
cp /u1/mayankj/scripts/*.* /u1/mayankj/jan12/

5) Generate the cuts for the pad boundaries :
        a) Put correct values of the boundary related parameters into the make_cuts.C file
        b) Execute :
		root make_cuts.C
        c) Then, a file make_cuts_run.C will be generated

kangaroo: /u1/mayankj/scripts/README_analysis
PREREQUISITES:
------------
Refer README_before_analysis file 


NUMBER OF HITS IN A PAD FOR ENTIRE SCAN (AN EXAMPLE)
------------------------------------------
root combined.root
main_scan->Draw("y:x>>h(600, 0.05, 60.05, 60, -15.5, 44.5)", "hits_values_pad1 >= 60 && hits_values_pad1 <= 72");

NUMBER OF HITS IN A PAD WHEN LED AT THAT PAD (AN EXAMPLE)
--------------------------------------------
root combined.root
main_scan->Draw("y:x>>h(600, 0.05, 60.05, 60, -15.5, 44.5)", inpad1 && "hits_values_pad1 >= 60 && hits_values_pad1 <= 72");

OVERALL RELATIVE EFFICIENCY PLOT (NORMALIZED WITH RESPECT TO THE CALIBRATION POINT 1)
------------------------
In this plot, the efficiency at a point is the ratio of 
number of hits in the pad containing this point to
number of hits in the calibration corresponding to this point (which
is obtained by fitting a line between the hits reported by calibration
point at start and end of this line) 

i) Check 'const' settings in overall_efficiency.C script :-
        - boundaries for the flat tube (defined thru'
        FLAT_TUBE_TOP_LEFT_CORNER_X, FLAT_TUBE_TOP_LEFT_CORNER_Y and
        DIMENSION); refer the code of overall_efficiency.C for details 
        - TDC time cuts for defining what we mean by a hit in all the
        flat tube pads and in the calibration PMTs' 
        - the minimum and maximum x, y values in the set of scans;
        these are required to know main_x, main_y values where calibration
        data has been stored in inter_date*_time*_calib.root file 
        These can be performed using the inter_file.

ii) Then, we run :
root overall_efficiency.C 
to make an executable for the overall efficiency plot. It is named
overall_efficiency_run.C 

iii) Then, we make overall_efficiency plot by :
root -b -l combined.root overall_efficiency_run.C > & ! opfile < /dev/null &

iv) Then, a file store_signal.root is created which can be seen:
	root store_signal.root
        gStyle->SetPalette(1, 0);
	overall->Draw("COLZ"); // value at a point = number of hits in the pad containing that point
	caliboverall->Draw("COLZ"); // value at a point = interpolated
value between calibration reading at start and end of linescans that
contains this point 
	normalized->Draw("COLZ"); // = ratio of overall to caliboverall


SIGNAL TO NOISE RATIO PLOT
--------------------------------------
1) Make OVERALL RELATIVE EFFICIENCY PLOT as told above 
2) Use overall_efficiency_without_time_cuts.C instead of
overall_efficiency.C and do as told above. 
Then, a file store_signal_without_time_cuts.root is created.
3) We can make a plot of signal to noise ratio as follows:
	root
        gStyle->SetPalette(1, 0);
        TFile* g = new TFile("store_signal.root");
        TH2F* ov = (TH2F*)gDirectory->Get("normalized");
        TFile* f = new TFile("store_signal_without_time_cuts.root");
        TH2F* ov2 = (TH2F*)gDirectory->Get("normalized");
        ov->Divide(ov2);
        ov->Draw("COLZ");
You might want to store the canvas as a .ps file


TIME DISTRIBUTION IN A REGION AND WITH CUTS (AN EXAMPLE) 
-------------------------------------------------------
root combined.root -x make_cuts_run.C
main_scan->Draw("hits_values_pad1", inpad1 && "hits_values_pad1 >= 60 && hits_values_pad1 <= 72");

TIME DISTRIBUTION OF ALL PADS WHEN LED SITTING AT THAT PAD
-------------------------------------------------------
root time_distribution.C

DISTRIBUTION OF DIFFERENCE IN TDC READOUTS IN RESPONSE TO SAME GATE SIGNALS :
--------------------------------------------
root combined.root
main_scan->Draw("hits_values_pad1 - hits_values_pad2", "hits_values_pad1 >= 60 && hits_values_pad1 <= 72 && hits_values_pad2 >=
60 && hits_values_pad2 <= 72 && hits_indices_pad1 == hits_indices_pad2");

CROSSTALK
----------
	i) CROSSTALK IN A PARTICULAR PAD WHEN LED AT SOME REGION: 
	 We can see the hits in a neighbouring pad with cuts on x and
y values, just by making proper cuts on the main_scan tree in
combined.root. An example is as follows:- 
	root combined.root	
	gStyle->SetPalette(1, 0);
	main_scan->Draw("y:x >> h(600, 0.05, 60.05, 60, -15.5, 44.5)", "x >= 5 && y <= 7 && hits_values_pad1 <= 72 && hits_values_pad1 >= 60", "COLZ");
	 main_scan->Draw("y:x >> h(600, 0.05, 60.05, 60, -15.5, 44.5)", inpad1 && "hits_values_pad1 <= 72 && hits_values_pad1 >= 60", "COLZ");

	ii) CROSSTALK IN ALL PADS WHEN LED AT MID OF A PAD:
	STEP 1: Generate the script using another root script :
	root
	.L crosstalk_when_at_mid_of_pad.C
	crosstalk_when_at_mid_of_pad(1);
	.q
	STEP 2: Execute the generated script :
	root -b -l combined.root crosstalk_when_at_mid_of_pad1_run.C > & ! opfile < /dev/null &
	STEP 3: Wait for completion and Observe the results 
	root store_crosstalk_at_pad1.root
	gStyle->SetPalette(1, 0);
	crosstalk->Draw("COLZ");

	iii) CROSSTALK IN ALL PADS WHEN LED AT PARTICULAR POINTS: 
	The script crosstalk_when_at_mid_of_pad.C could be changed (as
has been mentioned in it) to put any other condition on position of
LED. Then, the procedure is as told in (ii). 

	iv) CROSSTALK WHERE ALL HITS IN RESPONSE TO A GATE ARE COUNTED
: ("overall" histogram in store_add_hits_in_all_pads.root  - "overall"
histogram in store_signal.root) 
	root
        gStyle->SetPalette(1, 0);
        TFile* g = new TFile("store_add_hits_in_all_pads.root");
        TH2F* ov = (TH2F*)gDirectory->Get("overall");
        TFile* f = new TFile("store_signal.root");
        TH2F* ov2 = (TH2F*)gDirectory->Get("overall");
        ov->Add(ov2, -1);
        ov->Draw("COLZ");
You might want to store the canvas as a .ps file

	v) CROSSTALK WHERE ALL HITS IN RESPONSE TO A GATE ARE COUNTED
JUTS ONCE: (i.e. "overall" histogram in
store_efficiency_over_all_pads.root - "overall" histogram in
store_signal.root ) 
	root
        gStyle->SetPalette(1, 0);
        TFile* g = new TFile("store_efficiency_over_all_pads.root");
        TH2F* ov = (TH2F*)gDirectory->Get("overall");
        TFile* f = new TFile("store_signal.root");
        TH2F* ov2 = (TH2F*)gDirectory->Get("overall");
        ov->Add(ov2, -1);
        ov->Draw("COLZ");
You might want to store the canvas as a .ps file

COMBINED EFFICIENCY PLOTS (WHERE HITS FROM MULTIPLE PADS IN RESPONSE
TO A GATE ARE COUNTED NOT ONCE) 
-----------------------------------------------
same execution with "add_hits_in_all_pads.C" as with "overall_effiency.C"

The results are in file store_add_hits_in_all_pads.root


COMBINED EFFICIENCY PLOTS (WHERE HITS FROM MULTIPLE PADS IN RESPONSE
TO A GATE ARE COUNTED ONCE) 
-----------------------------------------------
i) Generate a class for the main_scan tree as follows:-
root combined.root
main_scan->MakeClass()
.q

ii) Execute the following command to ensure that the hits_values_pad*
array has correct length :- 
perl -e 'while(<>){ s/\[[0-9]+\]/[40000]/; print}' < main_scan.h >ms.h
mv ms.h main_scan.h

iii) Execute : 
root -b -l efficiency_in_all_pads.C > & ! opfile < /dev/null &

iv) Wait for it's completion and generation of
store_efficiency_over_all_pads.root file. It may take about 15 hours
for a set of 50 linescans.  

v) Observe the plots by :
   root store_efficiency_over_all_pads.root
   gStyle->SetPalette(1, 0);
   overall->Draw("COLZ"); // For each point, total number of hits
reported (by any pad, including main pad - the pad on which LED is
standing)  
   neigh_overall->Draw("COLZ"); //  For each point, total number of
hits reported (by main pad or one of neighboring pads) 
   together->Draw(); // refer FREQUENCY OF "NUMBER OF PADS REPORTING HITS TOGETHER"

vi) The efficiency relative to calibration points can be obtained by :
	root
	gStyle->SetPalette(1, 0);
	TFile* g = new TFile("store_efficiency_over_all_pads.root");
	TH2F* ov = (TH2F*)gDirectory->Get("overall");
	TFile* f = new TFile("store_signal.root"); 
	TH2F* ov2 = (TH2F*)gDirectory->Get("caliboverall");
	ov->Divide(ov2);
	ov->Draw("COLZ");
You might want to store the canvas as a .ps file


FREQUENCY OF "NUMBER OF PADS REPORTING HITS TOGETHER"
-----------------------------------------------------
This histogram tells the frequency with which a given number of pads
(will be between 0 and 64) report a hit together in response to  a
gate. 
Refer COMBINED EFFICIENCY PLOTS for plotting it


BOUNDARIES
---------
i) Put right boundaries into const settings of make_pad_boundaries.C

ii) execute :
root  make_pad_boundaries.C

iii) store_pad_boundaries.root file will be generated

NOTES TO SUPERIMPOSE PAD BOUNDARIES, LABELS ON A 2D HISTOGRAM (h)
in a root shell:
---------------------------------------------------------------
i) Ensure that there's no more analysis to be done on histogram 'h'
ii) Ensure that store_pad_boundaries.root file is present in current directory
iii) From the current root shell where h is currently visible, execute :
TFile* f = new TFile("store_pad_boundaries.root")
boundary->Draw("SAME BOX");
Pads->Draw("TEXT SAME");
iv) Now, we may want to store the current canvas to a .ps file

Last modified: July 15, 2003, by Joe