Getting a ped4 for the EEMC

Since this is the first time I've done this, I'm likely to forget what I've done.  So I'll document it here.

Getting ADC distributions

I'm on shift, so Dave and I took a pedAsPhys run with the RHIC clock as trigger.  We included DAQ, trigger, and ETOW and took 100k events.  The run is numbered 14061084.

While waiting for the run to get to HPSS, I followed these instructions and got the code complied. I also make a directory to place the daq file:
mkdir /star/data03/daq/2013/061/14061084
I also made this blog to remind myself how to get a DAQ file from HPSS.  After waiting a while, Dave U, the shift leader, took a longer run (1M events) and this pushed the smaller run to HPSS.

Once the run was on HPSS, I did
hpss_user.pl /home/starsink/raw/daq/2013/061/st_physics_14061084_raw_0450001.daq /star/data03/daq/2013/061/14061084/st_physics_14061084_raw_0450001.daq
I then went to the monitering page to see how the file transfer was going.  I couldn't find the monitering page.  Finally I google searched "star hpss_user.pl" and eventually found that the monitering page is called an accounting page and is here.  My request failed.  Trying again with
hpss_user.pl /home/starsink/raw/daq/2013/061/14061084/st_physics_14061084_raw_0450001.daq /star/data03/daq/2013/061/14061084/st_physics_14061084_raw_0450001.daq
which I got from using this list generator.  This worked. 

Next, I did this
./emchist /star/data03/daq/2013/061/14061084/st_physics_14061084_raw_0450001.daq
and it did something.  No obvious errors.  I now have a file called
st_physics_14061084_raw_0450001.ushist.root


Next Step

Now I start following this other blog.  Step 1 and 2 went OK.  Step 3, failed.  The blog didn't mention that the script
./procPedStat.sh
needs to be edited to adjust the files that are looped over.  I changed the line
ls='/star/institutions/iucf/stevens4/eemc/ped12/200GeV/emc-check/13071063.hist.root'
It failed, with the message
st_physics_14061084_raw_0450001.ushist.root
day phy run t_physic
Error in <TFile::TFile>: file st_physics_14061084_raw_0450001.ushist.root.hist.root does not exist
Rnnnped.hist.root file complete
Error in <TFile::TFile>: file Rnnnped.hist.root does not exist
Rnnnpedfit.hist.root file complete
mv: cannot stat `Rnnnped.hist.root': No such file or directory
mv: cannot stat `Rnnnpedfit.hist.root': No such file or directory
mv: cannot stat `ped.sector*': No such file or directory
mv: cannot stat `Mpt.log': No such file or directory
mv: cannot stat `T.log': No such file or directory
mv: cannot move `out/' to a subdirectory of itself, `dayphy/outPedRt_physic/out'
I tried isntead
I tried using
ls='/star/u/sgliske/EEMC/2013-Mar/peds/*.root'

instead, and it failed with the message

/star/u/sgliske/EEMC/2013-Mar/peds/st_physics_14061084_raw_0450001.ushist.root
day EMC run /EEMC/20
Error in <TFile::TFile>: file /star/u/sgliske/EEMC/2013-Mar/peds/st_physics_14061084_raw_0450001.ushist.root.hist.root does not exist
Rnnnped.hist.root file complete
Error in <TFile::TFile>: file Rnnnped.hist.root does not exist
Rnnnpedfit.hist.root file complete
mv: cannot stat `Rnnnped.hist.root': No such file or directory
mv: cannot stat `Rnnnpedfit.hist.root': No such file or directory
mv: cannot stat `ped.sector*': No such file or directory
mv: cannot stat `Mpt.log': No such file or directory
mv: cannot stat `T.log': No such file or directory
mv: cannot move `out/' to `dayEMC/outPedR/EEMC/20': No such file or directory
So I did this
mkdir -p eemc/ped12/200GeV/emc-check/
cp *.ushist.root eemc/ped12/200GeV/emc-check/
and changed the line to this
eemc/ped12/200GeV/emc-check/*.root
and it did this:
eemc/ped12/200GeV/emc-check/st_physics_14061084_raw_0450001.ushist.root
day _ph run st_physi
Error in <TFile::TFile>: file eemc/ped12/200GeV/emc-check/st_physics_14061084_raw_0450001.ushist.root.hist.root does not exist
Rnnnped.hist.root file complete
Error in <TFile::TFile>: file Rnnnped.hist.root does not exist
Rnnnpedfit.hist.root file complete
mv: cannot stat `Rnnnped.hist.root': No such file or directory
mv: cannot stat `Rnnnpedfit.hist.root': No such file or directory
mv: cannot stat `ped.sector*': No such file or directory
mv: cannot stat `Mpt.log': No such file or directory
mv: cannot stat `T.log': No such file or directory
OK--something imporant is missing in the instructions.  After a bunch more tries, this finally worked.  Change the file name
mv st_physics_14061084_raw_0450001.ushist.root r14061084.hist.root 
And edit the script to have
ls='r14061084.hist.root'
Then it did something, including making a directory
pwd
/star/u/sgliske/EEMC/2013-Mar/peds/day061/outPedR14061084

ls day061/outPedR14061084/ -l
total 11896
-rw-r--r-- 1 sgliske rhstar   43099 Mar  2 22:49 log1
-rw-r--r-- 1 sgliske rhstar    2503 Mar  2 22:49 log2
-rw-r--r-- 1 sgliske rhstar  226890 Mar  2 22:49 Mpt.log
-rw-r--r-- 1 sgliske rhstar      21 Mar  2 22:49 ped.sector01
-rw-r--r-- 1 sgliske rhstar      21 Mar  2 22:49 ped.sector02
-rw-r--r-- 1 sgliske rhstar      21 Mar  2 22:49 ped.sector03
-rw-r--r-- 1 sgliske rhstar      21 Mar  2 22:49 ped.sector04
-rw-r--r-- 1 sgliske rhstar      21 Mar  2 22:49 ped.sector05
-rw-r--r-- 1 sgliske rhstar      21 Mar  2 22:49 ped.sector06
-rw-r--r-- 1 sgliske rhstar      21 Mar  2 22:49 ped.sector07
-rw-r--r-- 1 sgliske rhstar      21 Mar  2 22:49 ped.sector08
-rw-r--r-- 1 sgliske rhstar      21 Mar  2 22:49 ped.sector09
-rw-r--r-- 1 sgliske rhstar      21 Mar  2 22:49 ped.sector10
-rw-r--r-- 1 sgliske rhstar      21 Mar  2 22:49 ped.sector11
-rw-r--r-- 1 sgliske rhstar      21 Mar  2 22:49 ped.sector12
-rw-r--r-- 1 sgliske rhstar 5958329 Mar  2 22:49 R14061084fit.hist.root
-rw-r--r-- 1 sgliske rhstar 5872245 Mar  2 22:49 R14061084.hist.root
-rw-r--r-- 1 sgliske rhstar   18090 Mar  2 22:49 T.log

but all the pedestal files are empty.  In log2 it also states

ped.sector01 .... nOK=0
ped.sector02 .... nOK=0
ped.sector03 .... nOK=0
ped.sector04 .... nOK=0
ped.sector05 .... nOK=0
ped.sector06 .... nOK=0
ped.sector07 .... nOK=0
ped.sector08 .... nOK=0
ped.sector09 .... nOK=0
ped.sector10 .... nOK=0
ped.sector11 .... nOK=0
ped.sector12 .... nOK=0

Well, not sure I can do anything else here.  Time to ask for help.

[pause]

Now I got some help from Justin.  I need to edit the trigID value in eemchist.C to be { 1, anything } and recompile and rerun.  This I did.  The end of the output has
INFO: emchist.C [line 139]: End of File reached...100000 good events processed
INFO: emchist.C [line 140]: bit 1 = 100000 events processed
INFO: emchist.C [line 141]: bit 2048 = 0 events processed

It has one of the bits with the total number of events processed--this looks like it worked.  I copy the output to the other file name as before and rerun

./procDAQ2Ped.sh

This time, I see the ped files are populated.
 


Ped4 from Ped

This email suggest that I can take the pedestal file and convert it to ped 4 file via some simple logic.  I'll assume the pedestal value is the mean.  I wrote the following zsh/awk script and saved it in the file makePed4.sh
#!/bin/zsh

for file in day061/outPedR14061084/ped.sector*; do
     awk '{
          if( NF == 3 ){
                  rMean = 0.5+$2;
                  if( rMean > 24){
                       ped4 = (22 - int(rMean))/4;
                  } else {
                       ped4 = (25 - int(rMean))/4;
                  }
                  print $1, ped4
             } else {
                  print $0
             }
          }' $file > ${file:h}/ped4.${file:e}
done
I then did
chmod u+x makePed4.sh
./makePed4.sh
and it did.  Job accomplished.