#------------------------------------------------------------------------------
# $Id: MyMiniAnalysis.tcl,v 1.29 2004/11/19 22:42:08 fnc Exp $
# Sample MyMiniAnalysis.tcl file
#------------------------------------------------------------------------------
This is the original MyMiniAnalysis.tcl file.
It is a bit different from the one used in the Quicktour.
# always source the error logger early in your main tcl script
sourceFoundFile ErrLogger/ErrLog.tcl
sourceFoundFile FrameScripts/FwkCfgVar.tcl
sourceFoundFile FrameScripts/talkto.tcl
Most main tcl files begin with sourceFoundFiles
of these standard setup scripts. These scripts define procs,
or new tcl commands.
# Disable the use of envvars
set ProdTclOnly true
FwkCfgVars were invented to
replace environment variables as the job configuration variables.
"set ProdTclOnly true" makes the interpreter ignore environment
variables.
# set the error logging level to 'warning'. If you encounter a configuration
# error you can get more information using 'trace'
ErrLoggingLevel warning
"ErrLoggingLevel" is a proc, defined in the ErrLog.tcl
script sourced earlier. It is not a standard tcl command.
STEP 1: SET FWKCFGVAR
## allowed values of BetaMiniReadPersistence are (currently) "Kan", "Bdb"
##
FwkCfgVar BetaMiniReadPersistence Kan
A few years ago, BaBar changed its database system.
"Bdb" is the old system, "Kan" is the new system. You want the modern
"Kan", of course.
## allowed (non-expert) values of levelOfDetail are "micro", "cache", "extend"
## or "refit"
##
FwkCfgVar levelOfDetail "cache"
The best mode for most users is "cache." The other
modes are for users who are doing things like testing reconstruction
algorithms.
## allowed values of ConfigPatch are "Run1", "Run2" or "MC". This MUST be set
## consistent ## with your input data type or you will get INCONSISTENT OR
## INCORRECT RESULTS
##
FwkCfgVar ConfigPatch "MC"
For data from any Run that is not Run1,
you should use Run2 for the ConfigPatch.
##
## Set the number of events to run. If this isn't set, all events in the
## input collections will be processed.
##
FwkCfgVar NEvent
If you look at the bottom of MyMiniAnalysis.tcl,
you will see where this parameter is used.
## choose the flavor of ntuple to write (hbook or root) and the file name
##
FwkCfgVar BetaMiniTuple "root"
FwkCfgVar histFileName "MyMiniAnalysis.root"
Set this to "root" to get output files that
can be analyzed in ROOT. "hbook" is an old format that is analyzed
using the older program, PAW.
STEP 2: ADD INPUT COLLECTION(S)
##
## You can enter input collections two ways: either append them to a list, or
## explicitly enter them in the input module. Do one or the other, BUT NOT
## BOTH.
## If inputList is set before executing btaMini.tcl, that will automatically
## add the collections to the appropriate input module, otherwise make sure you
## talk to the right one.
##
## lappend inputList collection1 collection2 ...
##
## OR THE FOLLOWING (choose the correct one based on persistence)
##
## talkto BdbEventInput {
## talkto KanEventInput {
## input add collection1
## input add collection2
## ...
## }
Most people input collections using the special
TCL files produced by BbkDatasetTcl. These TCL files are full
of "lappend inputList collection_name" commands. Once you have a
BbkDatasetTcl file ("MyBbkFile.tcl"), you can input all of its
collections with:
---------------------------------|---------------------------------
# MyMiniAnalysis.tcl | # snippet.tcl
sourceFoundFile $MyInputFile | set MyInputFile MyBbkFile.tcl
---------------------------------|---------------------------------
STEP 3: RUN STANDARD PHYSICS SEQUENCES
## create Everything path and add core sequences to it. btaMiniPhysics is the
## same as btaMini, just appending a few standard list generating modules. For
## reading data with stored composites, you may have a conflict running
## btaMiniPhyscs.tcl
##
## You can also run (most of) the PhysProdSequence, complete with its 3 gamma
## conversion finders, etc. Consider disabling the portion of this sequence
## that you do not need to save yourself some time. The BetaLumiSequence
## and TagProd sequences are left off, as they otherwise cause problems.
##
sourceFoundFile BetaMiniUser/btaMini.tcl
#sourceFoundFile BetaMiniUser/btaMiniPhysics.tcl
#sourceFoundFile BetaMiniUser/btaMiniPhysProdSequence.tcl
STEP 4: Other BetaMiniUser tasks
# Append QA sequence if requested, disable module otherwise to avoid empty histos
FwkCfgVar MyMiniQA
if [info exists MyMiniQA] {
"if [info exists VARIABLE] is a common structure
in BaBar tcl code. It means that the action should be performed if
the variable is defined at all, no matter what its value is.
sourceFoundFile BetaMiniQA/BetaMiniQaSequence.tcl
path append Everything BetaMiniQaSequence
talkto QaMiniBtaCandidates {
startPrint set 0
stopPrint set 3
printFreq set 1
}
path append Everything TagInspector
sourceFoundFile SkimMini/listOfTagBits.tcl
} else {
module disable QaMiniBtaCandidates
}
## Add Analysis module
##
path append Everything MyMiniAnalysis
MyMiniAnalysis.tcl is called MyMiniAnalysis.tcl
for a reason: the analysis path that it sets up uses MyMiniAnalysis
as the main analysis module. Further below, BetaMiniUser's other
modules (at least, the ones that don't perform any tasks useful
to the MyMiniAnalysis module) will be disabled.
Note that there is no need to enable MyMiniAnalysis - modules are enabled
by default. (You could if you wanted to, though.)
##
## If your job has a tag-level filter, here is how you should run it
## so as to avoid wasting time reading the mini when the tag filter fails
## Here's a simple example that restricts to just multi-hadron events
## on Kan input
module clone TagFilterByName TagBGFMultiHadron
module talk TagBGFMultiHadron
andList set BGFMultiHadron
assertIfMissing set true
exit
#sequence append BetaMiniReadSequence -a KanEventUpdateTag TagBGFMultiHadron
#
# Turn off some specialty items
#
module disable MyDstarAnalysis
module disable MyK0Analysis
The modules MyDstarAnalysis and MyK0Analysis are
both included in AppUserBuildBase.cc, so they will be loaded into the
Framework. In this case, it is not strictly necessary to disable them,
because they are not appended to analysis path anyway. But just
to be safe, MyMiniAnalysis.tcl turns them off with the "module disable"
command. That way, even if they were on the analysis path, the Framework
would just skip over them.
path list
Most main tcl files include the path list command.
That way, there will be a record of the analysis path in the job's log
file.
if [info exists NEvent] {
ev begin -nev $NEvent
} else {
ev begin
}
NEvent is one of the FwkCfgVar defined earlier.
You can set it in your snippet tcl file to set the number of events.
If you do not set NEvent, then all events are processed.
("ev begin" with no arguments processes all events.)
ErrMsg trace "completed OK"
ErrMsg is a proc, defined in ErrLog.tcl.
exit
The exit command exits the Framework. If this
command is in one of your TCL scripts, then the job will run without
stopping, and you will never get a Framework prompt.