Example of how to add together histograms from separate runs

These are data from /data/q2_5/842 on the epstein computer.  We will add together the electron spectra from runs 1321 to 1317. Information will need to be typed into the paw++ input pad .

Your responses will be in bold.
Any time you need help on a command type ' help command/action', where 'command is
an object ( like a vector or histogram etc.) and 'action' is an action such as plot,
write, read etc.

*My comments will be preceded by the asterisk ' * '.

*From  Juan's table for this energy and q2 = 5 we extract the live time factors  for the runs we will use in this example:
*run            live time
*1321            169.9
*1320            82.19
*1318            69.15
*1317            56.85

*The cuts we will use are on ntuple 50
*800<e.p_kin<810
*0.02< abs(reactez)
*0.02< abs(ph_tgte)
*0.08< abs(th_tgte)

*1) Go to the /data/q2_5/842 directory and open paw++
*2) Open the 1321 hbook and make the spectrum on epkin with the above cuts. There are two ways to implement the cuts. Either you
*enter them by hand as you normally do or you can use the cutss.kumac file in placed in this directory, as below

exe cutss  * this command goes in the input pad of paw++

*3) If you have opened the "Ntuple Viewer" window you will see that the histogram you created has an ID of 1000000.

his/copy 1000000 1321  * this command will copy his id# 1000000 into a new histo that we call id# 1321. It goes in the input pad.

*4) Now either read in the next hbook onto lun2 and use the cuts in the 'cuts editor', or close hbook 1321 and open 1320 onto lun1.

* To close the hbook file click on  File in the 'Paw++ Main Browser' , click on close hbook file option, enter the hbook name, and
*click on ok.

*5) Assuming you have decide to close hbook 1321, you now have hbook 1320 on lun1. Again, enter the command

exe cutss  * this command goes in the input pad of paw++

*6) You will see that a new spectrum for hbook 1320 is plotted. We will copy this into id# 1320.

his/copy 1000000 1320  * this command will copy his id# 1000000 into a new histo that we call id# 1320. It goes in the input pad.

*7) We now have runs 1321 and 1320 stored in his id#s 1321 and 1320. We want to add them together and store them in a new histogram
*with id# 1000.

his/oper/add 1321 1320 1000 169.9 82.19  * the numbers '169.9' and '82.19' are the live time factors come from above.

*8) Now we can close hbook 1320 and open hbook 1318 on lun1. Again, enter the 'cutss' command to setup the cuts and plot run 1318.

exe cutss * We will save this hbook run to id# 1318

his/copy 1000000 1318  * We can now add this histogram to hist 1000.

his/oper/add 1000 1318 1000 1.0  69.15  * notice histogram 1000 is being multplied by 1.0, his 1318 by the live time factor.
* The result is stored in his #1000 again.

*9) Close hbook 1318, and open hbook 1317 on lun1

exe cutss  * We will save this hbook run to id# 1317
 

his/copy 1000000 1317  * We can now add this histogram to hist 1000.

his/oper/add 1000 1317 1000 1.0  56.85  * notice histogram 1000 is being multplied by 1.0, his 1317 by the live time factor.
* The result is stored in his #1000 again.

*We could keep on going like this for the whole set of data. Histogram #1000 contains the normalized running sum . The cursor can be used on
*it ( id# 1000) to add up the counts.

*It would be wise to save the results of your summing into a vector that can be stored onto disk and read off the disk. Do this every so often so that *you don't lose your work if the computer hangs up.

*The preparation to save the histogram #1000 is to display it first.

his/plo  1000
* Note that the low value from the plot is epkin=799, the high value is 810. Record these numbers for reference. Next go to the left most corner
* of the plot and click on it. In the 'Paw++ locate' pop up window the 'X channel ' should show '1'. Next click on the righ most corner to find
*the bin number for that location. You should see 'X channel 110'. This tells you that there are 110 bins in this histogram. You need to create a vector *of 110 bins to save a histogram of this size.

vec/cre  x(110)  r  * This creates a  'real' vector called 'x' which has the capacity for 110 entries.

hist/get/contents  1000  x  * This transfers the contents of the histogram #1000 into vector x.

vec/write x  /home/fchacon/q2_5_example.dat * In this case the vector is saved in Frank's directory
*as a file name 'q2_5_example.dat. Of course, only Farnk can write to his directory. In the paw_info directory you will find a copy
*the q2_5_example.dat file against which you can compare your result.  This vector is written as a text file so you can open it with
*any editor or display it with the 'cat' command.
* You can check if the stored vector really is a faithful copy of hist #1000 by copying it back from the disk into paw++ as follows.

vec/cre y(110) r  * create a vector y to receive the file from the disk.
vec/read y  /home/fchacon/q2_5_example.dat * store the disk file into vector y.
his/cre/1dhist 2000 'runs 1317 to 1321'  110  799  810  * This prepares a histogram of 110 bins with x axis from
*799 to 810. The hist number is 2000, the tile is in the single quotes ' title '.
his/put/contents  2000   y  * This transfers the vector y into hist id# 2000.
his/plo  2000  * plot hist 2000. It should look identical to his 1000 except for the title. Try integrating over the same range in both to
*verify that this is the case.