Note: This tutorial is most likely to be helpful to you if you have not run any Beta job in many months (or at all). If you have run Beta successfully in the last two or three months, you probably already know most of what's here.
This tutorial is created partially from material found in the BaBar Offline Workbook, the Kanga Home Page, and the Physics Analysis Recipes.
To execute this tutorial successfully, you will need:
In Exercise 1 we will:
shire or tersk.
To initialize the software release tools for this release, called 8.6.2d-physics-1, and your platform, type:
> srtpath 8.6.2d-physics-1 Select/enter BFARCH (CR=1): 1) SunOS5 2) SunOS5-noOptimize-Debug(Text in brown indicates output from the shell or other program. Also, a carriage-return is always implied at the end of each line of user input.)
Choose SunOS5 (or OSF1V4 or Linux2, depending on your platform) by typing "1" and hitting return.
The srtpath command modifies your unix path so that any files you need while you work with
BaBar code will obtained from the right place. Different files may be required for different architectures
(Sun, Linux, OSF) or different configurations of the software (versions with or without debugging information,
for example). We have chosen the version of the code that is optimized and contains no debug info, for speed
and compactness.
mybabar, but
you may choose any other, even your home directory. cd to this directory now.
> cd mybabar
> mkdir $BFROOT/work/r/rfcCreate your test release directory using the newrel command. Use the option
-s $BFROOT/work/<first_letter>/<userid>to specify your scratch area. For example, user rfc would type:
mybabar> newrel -s $BFROOT/work/r/rfc -t 8.6.2d-physics-1 Beta_ttThe last argument provides the (arbitrary) name for the new directory that will contain the test release.
(The unix prompt will be indicated by ">" unless the command must be issued from a particular directory, in which case, the deepest subdirectory will appear, in this case, "mybabar>.")
It is possible to incorporate several executable versions of the code in the same test release, for different architectures, for example. For more information on this click here.
mybabar> cd Beta_tt
Beta_tt> addpkg workdir Beta_tt> addpkg BetaUser
Beta_tt> analboot2But, if the production federations are blocked, as they would ordinarily be during the hour of this tutorial, type instead:
Beta_tt> setenv OO_FD_BOOT /nfs/objyserv6/objy/databases/test/physics-demo/V1/BaBar.BOOT
Beta_tt> cd BetaUser BetaUser> cp $BFROOT/www/doc/workbook/examples/NTrkExample/* . BetaUser> cd ..(Note: the "." at the end of the second line is part of the copy command!)
bldrecoq queue:
Beta_tt> bsub -q bldrecoq -o Exercise1.log gmake lib ROPT=-noDebug-Shared(The procedure at non-SLAC sites may be different; check with your local guru.)
"-noDebug" turns off debugging symbol generation, for speed and code size,
and "-Shared" allows you to use shared libraries, which means that if you
modify your own code, you need only re-compile it, and re-linking is not necessary.
The ROPT variable may be set to achieve the same effect:
> setenv ROPT -noDebug-Shared
> bjobs (use option -l for more info)(Text in green is informational; you don't type it.)
Beta_tt> bsub -q bldrecoq -o Exercise1.log gmake BetaUser.bin ROPT=-noDebug-Shared
Beta_tt> cd workdir
workdir> gmake setupThis need be done only once, before the first time you run from it.
.tcl file containing the necessary instructions.
To do this for run 12125, type:
workdir> getdata -t allevents -b12125 -e12125 -vThis will produce a file called
allevents_12125-12125.tcl,
containing the tcl commands
which can be source'd at run time to choose your file(s). To examine the contents
of this file, type:
workdir> cat allevents_12125-12125.tcl
# allevents collections from analboot2
mod talk BdbEventInput
input add /groups/isPhysicsEvents/0001/2100/P8.6.1aV00fb/00012125/cb001/allevents
exit
# No. of allevents events is 50564 for runs 12125-12125
# The production federation for these collections is analboot2
If the production database is blocked, we instead do the following:
Beta_tt> setenv BdbInputCollection /groups/isMultiHadron/0001/2100/P8.6.1aV00fb/00012125/cb001/allevents(If you'd like more information on finding and setting input collections, click here.)
betarun with the name of
the relevant .tcl file as an argument:
workdir> betarun ../BetaUser/bdbMicro.tcl
BdbInputCollection variable.
Otherwise, do this now by typing:
> source allevents_12125-12125.tcl
> ev beg -nev 3
> ev continue -nev 47
> exit
workdir> pawX11 ...Hit a carriage return to select the default Xwindows output.
PAW > h/fil 1 framework.hbook PAW > h/lis
PAW > opt stat PAW > set stat 111111 PAW > h/pl 1
PAW > exit
In Exercise 2 we will:
Kanga (a Kinder ANd Gentler Analysis) provides files containing the same information as that in the Objectivity event store and conditions database, but without the complexities of Objectivity. User code is exactly the same in each case, but the executable must be remade for Kanga. (It's also possible to make a dual-purpose executable that can be used for both types of data, depending on the settings of some environment variables.) The advantages of using Kanga are increased throughput and access to data when the production databases are blocked.
Kanga files can be used in any analysis that depends only on variables contained in the micro-dst. If you need to study hits in the drift chamber, for example, you must get your events from Objectivity raw data.
ROOT is a histogram and analysis package from CERN, and is supposed to be a modern replacement for HBook/PAW (although HBook files can be converted to be used in ROOT). The data in Kanga files are stored in ROOT trees (similar to HBook ntuples), but reading Kanga files doesn't commit you to using ROOT to make your histograms. You can read Kanga files and produce HBook output, and you can read Objectivity files and produce ROOT output.
Let's begin:
> cd ~/mybabar
mybabar> srtpath 8.6.2d-physics-1Choose SunOS5 (or OSF1V4 or Linux2) by typing "1" and hitting return.
mybabar> newrel -s $BFROOT/work/r/rfc -t 8.6.2d-physics-1 Kanga_tt mybabar> cd Kanga_tt
Kanga_tt> addpkg BetaUser Kanga_tt> addpkg workdir Kanga_tt> gmake workdir.setup
> setenv BetaKanga yes (allows reading from Kanga File) > setenv BetaBdbMicro no (disables reading from the database) > setenv BetaRootTuple yes (make a ROOT, rather than an Hbook, file)As before, for convenience and speed:
> setenv ROPT -Shared-noDebug
Kanga_tt> cp $BFROOT/www/doc/workbook/examples/NTrkExample/* BetaUser/
Kanga_tt> bsub -q bldrecoq -o Exercise2.log gmake lib BetaUser.bin(The
ROPT option has been taken care of in by setting the environment variable.)
.tcl to select the input collection (we will use run 12125 again):
Kanga_tt> cd workdir workdir> getdata -t kanga -b12125 -e12125 -vThis will produce the file
kanga_12125-12125.tcl, which will be source'd as above.)
workdir> betarun ../BetaUser/kanga.tcl
> source kanga_12125-12125.tcl > module talk RooBuildEnv RooBuildEnv> FixedFieldStrength set 1.51007 RooBuildEnv> exitAlso, to avoid a bunch of annoying messages you can type:
> module disable DefaultKlongMicroSelectionbut there's no harm if you don't.
> ev begin -nev 100 > exit
workdir> bbrroot
...
root [0] in = TFile("framework.root"); (read in the file)
root [1] in.ls(); (list the histograms and ntuples)
root [2] h1d1->Draw(); (display a histogram; those are "ones," not lower-case "L"'s.)
root [3] .q (exit Root)
JpsiK0sMicroFilter.cc from the BetaExamples package.
By adding the package, you will be able to examine the routine.
workdir> cd .. Kanga_tt> addpkg BetaExamples
AppUserBuild.cc, myAnalysis.tcl,
kanga.tcl (which we will rename kanga_batch.tcl), and bin_BetaUser.mk. We will do this below.
However, you can
skip this if you want: already modified versions of these files may be found in
$BFROOT/www/doc/tutorials/15May2000_BetaKanga_Tutorial/kanga_batch.
If you'd rather, just copy the contents of this directory into
BetaUser and then skip to the
compile and link step below.
Otherwise switch to the
BetaUser directory
> cd BetaUserand begin editing:
AppUserBuild.cc. This is where we specify which analysis routines should be linked into the job. Two lines need changing here.
Replace:
#include "BetaUser/NTrkExample.hh"with:
//#include "BetaUser/NTrkExample.hh" #include "BetaExamples/JpsiK0sMicroFilter.hh"and:
add( new WorkBook1( "NtrkExample", "trks/evt" ) );with:
//add( new WorkBook1( "NTrkExample", "trks/evt" ) ); // Filter using micro info. add( new JpsiK0sMicroFilter( "MicroFilter", "filtering with micro info" ) );The name "MicroFilter" is arbitrary, but it must match the entry in
myAnalysis.tcl below.
bin_BetaUser.mk.
To ensure that the linker can find the routine from the
BetaExamples package,
a line must be added to
bin_BetaUser.mk.
Just at the end of the file, before:
# BetaSequences provides the Beta-specific makefiles #include BetaSequences/BetaExecutable.mkadd:
override LINK_BetaExamples += $(PACKAGE)GNUmakefile
myAnalysis.tcl. The
JpsiK0sMicroFilter routine
must be added to the analysis sequence. This is done in myAnalysis.tcl.
Replace:
sequence append MyAnalysis WorkBook1with:
#sequence append MyAnalysis WorkBook1 sequence append MyAnalysis MicroFilter
kanga.tcl to kanga_batch.tcl and
then edit kanga_batch.tcl.
BetaUser> cp kanga.tcl kanga_batch.tclThe preceding edits were required to incorporate our new analysis routine. Changes to
kanga_batch.tcl
are specifically to turn our interactive job into a batch job.
We add code to kanga_batch.tcl to reproduce what we typed interactively before.
Add, at the end of the file:
module talk RooBuildEnv
FixedFieldStrength set 1.51007
exit
module disable DefaultKlongMicroSelection
source kanga_12125-12125.tcl
ev beg -nev 1000
exit
and save it.
Here we assume that the relevant variables have not been changed since
Exercise 2.
BetaUser> cd ..
Kanga_tt> bsub -q bldrecoq -o Exercise3.log gmake libwhen it completes, do
Kanga_tt> bsub -q bldrecoq -o Exercise3.log gmake BetaUser.binor, again, if you're brave, you can do both at once:
Kanga_tt> bsub -q bldrecoq -o Exercise3.log gmake lib BetaUser.binand save yourself one "
PENDING".
workdir directory.
Kanga_tt> cd workdirTo run the job, type:
workdir> bsub -q kanga -o Exercise3.log ./betarun ../BetaUser/kanga_batch.tclThe batch queue
kanga is specially set up to have access to a
local copy of the kanga datasets, and therefore runs more efficiently.
Note: To run a batch job reading an Objectivity collection, follow a similar procedure, but
the job must be submitted to the bfobjy batch queue.
Also the collection name must be specified using one of the methods suitable
for the
BdbEventInput module as in Exercise 1.
framework.root.
If we don't have time today to actually run the job, a copy of this output file can be
found in $BFROOT/www/doc/tutorials/15May2000_BetaKanga_Tutorial/Exercise3.root.
To look at the output:
workdir> bbrroot
...
root [0] in = TFile("framework.root"); (read in the file)
root [1] in.ls(); (list the histograms and ntuples)
root [2] h1d3->Draw(); (display a 1-d histogram)
root [3] h2d4->Draw(); (display a 2-d histogram)
etc...
root [n] .q (exit Root)