--=Index=--

CERN notes page
Getting files from HPSS
Shell commands
PbGl notes
Root notes
Long Island map

--=Getting files from HPSS=--

Updated!
1. Login to rcas machine.
2. write a list file with lines like this: /home/phnxsink/run8/ppgdata/run_0000256000_0000257000/EVENTDATA_ppg_P00-0000256442-0000.PRDFF pftp://blau@rcas2064/phenix/scratch/blau/EVENTDATA_ppg_P00-0000256442-0000.PRDFF
3. hpss_user.pl -f file.lst -g phnxemc
4. Wait for files to appear in destination path. You can use this page to look for status of your job or use mysql to do the same (in mysql they appears earlier). To use mysql you need to run:
mysql -hphnxdata1.rhic.bnl.gov -uphenix_c_user -pBrass_Ring phenix_carousel
and then:
select User, Status, ID from Entries where User="blau";
This will give a numbers of jobs IDs and statuses of each. status=0 means it's not working yet, status=1 means it's currently processing, status=2 means it's done, status=3 means it's failed. When it's failed try step 3 with switch -upd.
P.S. hpss is not working on va machines!

--=Shell commands=--

Print files (example for MCR @ PHENIX, color printer)
Print: lpr -Pphoncslp1 filename
Orders list: lpq -Pphoncslp1
Remove order: lprm -Pphoncslp1 job_ID

Ls switches:
Order by time ls -t
Count files ls | wc

Run files:
To run file and continue work in terminal use & at the end of command, example:
root -l run_h.C&
To run file so that it will continue work after closing of terminal use nohup:
nohup root -l run_h.C
To run multiply root commands that should work one after another use -q switch:
root -l -q run_h1.C
root -l -q run_h2.C
You will need to make a batch file for this
#!/bin/tcsh
cd /home/phnxpbgl/blau
...(your commands here)...

Don't forget to chmod it to executable mode (chmod 700 filename)
If you don't need output to screen you can forward it to filename:
nohup root -l -q run_h.C >>& log
or if you don't need output at all, use
nohup root -l -q run_h.C >>& /dev/null
It is faster than others.

Ps:
ps command show current programs that are running on your computer by you.
If you need all programs, use ps -aux instead. You can grep name of your program from output like this:
ps aux | grep "root"

Debugging:
If you want to know why your programm crashes, use command
limit coredumpsize unlimited
Than after you run your programm and it crashes you will have huge file core.????
Than use command
gdb programm_name core.????
Than write bt (back tracing)
You will see last functions which were executed by your program.
After it don't forget to set coredumpsize to 0!
limit coredumpsize 0

LaTeX on Linux
latex main.tex
dvips -o main.ps main.dvi
ps2pdf main.ps main.pdf

Disk usage
You can see the sizes of directories on your device by command du
Command df directory_name will tell you the free and total memory on device on which this directory is located.

Useful stuff
For creating list of files with full path to them at the name of each file use:
ls -l /data2/PHOS-data | awk '{ print "/data2/PHOS-data"$9 }'

tail -f - updated output of last lines of the file.

--=PbGl Notes=--

Packets of EmCal are:
PbSc 8001-8108
PbGl 8109-8172
Referense packets:
8173 - W0 W1
8174 - W2 W3
8175 - E1 E2
8177, 8178 - E0
8179, 8180 - E1
Trigger packet is 14001.

Comments on Andrey Kazantsev PbGl Calibration notes (
http://www.phenix.bnl.gov/~stkav)
About pedestals:
2. This is step by step orders what to do:
Exit RunControl PbGl if it was open.
Run Control Standalone->Emc.E.B->Download->OK ->Fill->Load ModeBits
find .gtm file that you need (GTM.pbgl_init_shortlong_IY.gtm)
->Open
->Start
->Calibration
Take ~4000 events
->Stop
Combine events using eventcombiner output_filename input_filenames

About zero suppression tresholds:
root -l writeTresholds.C
cd Run???/tresholds2
For first 2 doors on each sector the limit is 75, for others 50.
After finding tresholds you will need to correct configuration file for DCM
$RC_HW_CONF/emc.e.bottom.pcf and copy tresholds files from tresholds2 to
$DCM_TRESHOLDS/emc.e.bottom
You can write them only on account phoncs (with old password tat%zeit).

About High-low ratios:
13. You will need to check every bad channel. For this go to pics and write view. If channel is not very bad, correct 5th column to average of nearby channels (in this ASIC) and rewrite error to 0.
14. Before starting this correct dates in writeTracerHiloRatios.C. Output of this macro will be in the Run9999 directory. Macro findProblems.C will show errors on the channel map. Print it.

About Least Counts:
8. Also correct MakeFits.C and write there delays in the same order that they are going in the .list file.
10. Open badmodules0.txt and badmodules1.txt and go to Figs directory and run view. For channels that have only one bad point count the slope and offset by hand and write it to badmodules files. Macro findProblems.C will show errors on the channel map. Print it.
Than convert it to ASCII by command writeCorrected.C. Output will be in Data and QA.

--=Root Notes=--

gSystem->SetPalette(1) - use normal palette instead of default
gSystem->Which("","filename") - check if file exist (TFile do this crappy)
histo->ProjectionY("new",0,100) - make projection of 2D histo to new 1D histogram, where each bin is integral of X axis of histo, from bin 0 to bin 100.

If you have data in for example 100 array and need to fill histogram with it which has scale up to lets say 50 GeV and 100 bins you will need to be careful in filling it! That is you have to Fill((float(n)*64./100.)+0.001). This is because you cannot place anything between the bins and you will have some empty bins if you won't do small increment.

Writing histograms to file and reading from it
Writing:
TString name=out; //out is a name of your output .root file
TFile *newfile = new TFile(name.Data(),"recreate"); //actually creating it
h_pos1[j]->Write(); //write your histograms like this
newfile->Close(); //close file
Reading:
TString fname=in; //in is your .root file that you want to open
if(gSystem->Which("",fname2)){ //check if it exists (read note about it above)
TFile f(fname);// actually opening it
TH1F*  time=(TH1F*)f.Get("time"); //get your histos like this. Don't forget to close your file afterwards!
Merging histograms
If you have number of similar .root files (with the same histograms in them) and want to merge it to one, than you should check
this macro . By using it you can merge about 230 histograms at once. If you want more, merge packs of 230 files and then merge result files too.

Dmitry Blau, 2006-2007. blau@rcf.rhic.bnl.gov