Further use of PAW for BaBar physics analyses.
.pawlogon.kumacfile in your home directory. If you don't have such a file, create one with the single line:
macro/default '.,~/pawmacros' -auto
This means that PAW will look for macros first in the current
directory (.), then in the directory
While you're editing
, you should probably also add the line:
This command forces PAW to retain information about capitalisation in all files it reads in and write out. Otherwise PAW tends to assume that all filenames are given in lower-case characters - unlike unix.
You can also add the other command lines that are discussed in the pawlogon section of PAW I.
where myfirstmacro doesn't have to have the same name as the file. You then place the macro code below this line in the usual way, and you define the end of the macro with
Any code after this will be ignored until another macro is defined with, say,
You should put a
return at the end of your final macro in
your file also.
The macros are then executed from within a PAW session with
Where mymacrocollection is the name of the file
(i.e. mymacrocollection.kumac), and mysecondmacro is the name
of one of the macros defined in that file. We shall see several
examples of this in the sections below.
Although macros are extremely useful, and you will certainly use
them, the heart of a real publication-quality analysis in paw will be
fortran programs. This section assumes that you are using
BtaTupleMaker to produce the ntuples, as outlined in the cm2-ntuples
section of the workbook.
To produce an hbook (paw) ntuple, follow the instructions in the
workbook, but in your tcl snippet, set BetaMiniTuple "hbook" and change
the file name to be xxx.hbook instead of xxx.root. Here is the
snippet to generate a paw file from 1000 events of SP-989-Run1-3.tcl:
#..See Analysis.tcl for
description of FwkCfgVars.
set MCTruth "true"
set FilterOnTag "false"
set BetaMiniTuple "hbook"
set histFileName ntuples/SP-989-Run1-3.hbook
set NEvents 1000
Submit this to the batch system with the command
bsub -q kanga -o log/SP-989-Run1-3.log ../bin/$BFARCH/BtaTupleApp snippets/run_SP-989-Run1-3.tcl
Once the job completes successfully, you can move it to your
"successful" directory, or to your laptop, or where ever you intend to
do your analysis. Here is a gzipped
version in case you need it. Be sure to gunzip it before trying to
pawand then "enter" to accept the default workstation type. Now, to look at your ntuple, do:
PAW > hist/file 1 successful/SP-989-Run1-3.hbookThis gives you a list of ntuples in your hbook file. The one you are interested in is myNtuple. To see a list of its contents, type:
PAW > nt/list
===> Directory :
2 (N) myNtuple
1 (N) Analysis Ntuple
PAW > nt/print 2Here is the printout of the ntuple structure: ntuple-structure.txt
You will want to navigate between the different blocks and different candidates.
BLund tells you what type of B this
Bd1Lund is the particle type of the first
daughter; that is to say, the type assumed by the composition code when
it created the B, which may or may not be the same as the true particle
How do you know what the numbers mean? One way to find out is to look in the file:
workdir/PARENT/PDT/pdt.tableThe lund ID numbers of the different particles are given in the fifth column. For example, a J/psi has ID number 443.
Bd1Idx is the index of that daughter in the
(Jpsi in this case). Note that the indices all use C++
numbering, so that Bd1Idx = 0 refers to the first entry in
the Jpsi block. If you are actually going to use paw, you
will need to add 1 to all the indices. You will probably get
this wrong numerous times.
You can similarly navigate from the Jpsi block to the mu block (or e block, once you add Jpsi --> e e decays), and from the mu block to the TRK block.
When using electrons with bremsstrahlung recovery (in
radiated photons are added back into the reconstructed
electron), the navigation is a bit tricky. The
brem-recovered electron is a composite, consisting of an
electron plus one, two, or three photons. So it does not
point to the TRK block (the index is -1); you need to
navigate to the daughter electron, which does point to the
TRK block. This is the only case where a daughter of a
particle is the same type of particle.
PAW > hist/file 1 successful/SP-989-Run1-3.hbook PAW > nt/loop 2 smallcode.f(0) PAW > h/pl 100 PAW > pps JpsiMass.ps
This will give you a nice plot of the reconstructed Jpsi mass and
write it to the file JpsiMass.ps. pps
is a macro I have defined in my
.pawlogon.kumac file. The Paw-I tutorial gives another method of
doing the same thing.
On some systems, you can say
smallcode.f77(0) to compile the code before it is
A couple of things to note in this program. The "Include ?" is a
piece of paw magic that makes the entire ntuple structure accessible to
your code. I like to pass a histogram ID offset (id0) to the code, so I
can run it with id0 = 0 with signal MC, id0 = 1000 for BB MC,
2000 for real data, and so forth. I always use Implicit None; it
takes a tiny bit longer to type the code, but will save you lots of
time in the end. For this structure to work (i.e., where you are
running the same piece of code on both data and MC) you need to
make sure the the MC truth block is created in your data ntuples. Of
course, it will not contain any useful information. But if you don't,
your code will complain about undefined variables when you run on data.
The names such as JpsiMCIdx connect the reconstructed candidate to the MC truth block. However, the MC matching is a bit dicey for any state that can radiate. (And we use Photos not just for leptons, but also for hadrons in our MC). For example, if you plot JpsiMCIdx, you will see that it is -1 in many cases (i.e., no MC truth match was found). But if you plot the lund ID of the MC-truth matched partners of the muon daughters of the Jpsi, you see that they are actually muons:
(Why muons? Because the plots show that all entries fall in the bins [-12,-13] and [13, 14] - that is, they have ID numbers of +/-13. And looking in workdir/PARENT/PDT/pdt.table, you see that 13 = mu- and -13 = mu+.)
The problem is that in the MC truth, the Jpsi actually decayed to mu+ mu- gamma, while the reconstructed Jpsi contains only the muons. In principal, this gamma could be 1 MeV, and of no real consequence. The lesson is that you cannot blindly use the MC truth match for composites. Actually, it is probably better to avoid MC truth matching entirely if you can. (In this case, if I did need to match, I would say the Jpsi is matched if the two muons daughter match the MC-truth daughters of the Jpsi)
You will need the hbook file inclusive-fits-p52.hbook
There is not much to the kumac code. In this case, I find the defaults put the left title a little too close to the axis number labels, so I moved it a bit. Also, there is a bit of code to convert the ps file to an eps file with no preview. PAW believes it can directly produce an eps file, but I find that the bounding box is wrong.
* W E L C O M E to P A W *
* Version 2.13/08 19 September 2002 *
Workstation type (?=HELP) <CR>=1 :
Version 1.28/07 of HIGZ started
*** Using default PAWLOGON file "/Users/hearty/.pawlogon.kumac"
In private pawlogon.kumac.
PAW > exec pub-plot psi2smm-mass 1. 0.7
now calling psi2smm-mass.kumac
Postscript Output File = psi2smm-mass.ps
The first argument passed to
pub-plot is the name of the
macro that draws the specific plot. The other two arguments give the
size of the plot in x and y, where 1. = 15cm. This aspect ratio is
nice for PRL and PRD single-column figures.
Note that what you see on screen psi2smm-mass-screen.tiff is not the same as the final plot psi2smm-mass.eps which has the full formatting with superscripts and Greek characters.
Note that if you want to include the BaBar logo in this plot, and
in the two examples below, you will need to include a line in the
kumac before the lines which create the images (the
makeps... command to call the babar macro
from within your plot macro.
pub-plot.kumac. After producing a plot in PAW, for example by running the simple example below, you issue the command
exec pub-plot#babarIf you wish to change the position where the BaBar word appears and the size of the word, you can pass three arguments when you execute the babar macro. The defaults are 1. (scale), 68. (x-position) and 85. (y-position).
There's also a similar macro defined in
for adding the word "PRELIMINARY" below "BABAR". It is run using the
syntax as pub-plot#babar:
exec pub-plot#preliminary .5 58. 79.where in this example, the defaults parameters are passed to the macro.
In this case, we create an ntuple from an ascii list in the file,
fill a 2D histogram from this ntuple. In this way, we get the exact
(mes, DeltaE) locations, instead of the PAW default,
which plots a random location within the histogram bin. We then create
DeltaE and plot
as well. This is done for two different final states, giving six plots
in one figure.
To generate the plot, use the command:
exec pub-plot projdata3 1. 1.The square aspect ratio (15cm by 15cm) is more appripriate in this case. The resulting plot is here: projdata3.eps
In this case we read three
p* plots from an hbook
file, then plot them beside each other. Run it using
exec pub-plot pstarjpl 1. 1.
You will need the hbook file pstarjpl.hbook.
General Related documents: