CWNFramework: Column-wise ntuples in suez
CWNFramework is a package designed to make creating column-wise ntuples
easy in both HBOOK and ROOT. The variables of the ntuple are specified in
a separate text file; the ntuple structures and the interface with HBOOK/ROOT
are taken care of automatically.
Here's a quick-start guide on how to use the framework. Assume that
your processor is called MyProc, and you want your tuple class to be
MyTuple.
- Check out the module CWNFramework from the CLEO CVS.
- In the MyProc/MyProc directory, create the file TUPLE_DEFINITION.
The format will be documented later, but you can follow the
example in HadronicDNtupleProc/HadronicDNtupleProc/TUPLE_DEFINITION.
Some hints:
DOC begins a comment, and can be anywhere.
- The first non-
DOC line must be
NTUPLE shortname description.
- All variables must be in blocks. Blocks are started with the
BLOCK
blockname [OPTIONAL] keyword, and are ended either by another
BLOCK
statement or the end of the file. Blocks cannot be empty.
- Array variables must be "indexed" by another variable; this specifies how large the
array can be. Index variables are created with the statement
INDEX varname min max; min
and max specify the range of the index
variable and must be nonnegative.
- Integer variables are created with the statement
INTEGER varname
[indexvar] and floating-point variables with the statement
FLOAT varname
[indexvar]. The optional indexvar argument specifies that varname is
an array indexed by the variable indexvar.
- From the MyProc/MyProc directory, run the script CWNFramework/Test/genDefinitions.py .
This will autogenerate the header files for the tuple.
- From the MyProc directory, run the script CWNFramework/Test/genSkels.py .
This will ask you a couple of questions and ask you to specify the
class name of the tuple class you want to create. It will then
generate some C++ files which specify the tuple; in this example they
will be MyProc/Class/MyTuple.cc and MyProc/MyProc/MyTuple.h .
- You are now ready to use the tuple in your processor.
An example of such use can be seen in
HadronicDNtupleProc/Class/HadronicDNtupleProc.cc, although this
file is rather long and involved. General principles:
- Create an instance of either RootCWNtupler or HbookCWNtupler
depending on which type you wish to produce.
- Create an instance of your tuple class (e.g. MyTuple). You want
to use only one instance of your tuple during your processor run.
- Before you process any data (e.g. in your init() function),
initialize the ntupler helper using the CWNtupler::init(string filename,
CWNTuple* tuple) function.
- Each time before you fill your tuple, call the clear() function
of the tuple to set everything to zero.
- The tuple variables are accessible as data members of the tuple
class. (The array variables are just array data members.)
- To fill the ntuple with the current entry, call CWNtupler::fill().
- Before your processor quits (e.g. in your terminate() function),
call CWNtupler::finalize().
- In your Makefile, alter the line
USER_LFLAGS :=
$(XTRA_LFLAGS) to USER_LFLAGS := $(XTRA_LFLAGS)
$(shell exec $(C3_OTHER)/Root/bin/root-config --libs)
- That's it!