- Table of contents
- How to put a variable into CAF
How to put a variable into CAF¶
This wiki is intended to be an updated and more reliable version of docdb-12273.
In the following lines we introduce a step-by-step approach on how to include a given variable into CAFs.
Comments and feedback are welcome. The if you see something, say something policy applies here, it's a wiki!
Goal¶
Our goal is to add a variable that stores the number of bad channels in a subrun, for example. For illustration purposes, we have decided we are going to include that variable in the header branch.
Step 1: Download packages¶
Under development release (if you think you will be committing your work to the repository) or in any stable tag (if you do not know yet) and after setting up your environment
srt_setup -adownload the following packages (for this example)
- StandardRecord
- CAFMaker
using the command
addpkg_svn -h <pkg name>
Step 2: Define the object¶
Note: In this example, this step is equivalent to step 7 in the pdf version (docdb-12273).
Since we want to put our variable into the header branch (hdr) we open StandardRecord/SRHeader.h and add the type, name and a brief description of it at the end of the file
namespace caf { class SRNumuSandbox{ public: ... unsigned int nbadchan; ///< Number of bad channels in a subrun. This is our new variable! void setDefault(); }; }
Step 3: Update class version (Deprecated)¶
Open StandardRecord/classes_def.xml and update the class version index from i to i+1
<lcgdict> ... <class name="caf::SRHeader" ClassVersion="22" > ... </lcgdict>
<lcgdict> ... <class name="caf::SRHeader" ClassVersion="23" > ... </lcgdict>
Step 4: Compile¶
After saving file the previous changes, go to your $SRT_PRIVATE_CONTEXT area compile StandardRecord package
<novagpvm08.fnal.gov> make StandardRecord.all
You will get an error message like this (NOTE: that was the case at the time of writing the pdf version of this tutorial)
... class caf::SRLid <**compiling**> StandardRecord_dict.cc <**linking**> libStandardRecord_dict.so <**checking class version numbers**> libStandardRecord_dict.so INFO: adding version info for class 'caf::SRHeader': <version ClassVersion="23" checksum="2291111394"/> WARNING: classes_def.xml files have been updated: rebuild dictionaries. make[1]: *** [/nova/app/users/jasq/devel/lib/ Linux2.6-GCC-maxopt/libStandardRecord_dict.so] Error 2 make: *** [StandardRecord.all] Error 2
Step 5: Compile again¶
The solution to the previous error is simply compile again
<novagpvm08.fnal.gov> make StandardRecord.all ... class caf::SRLid <**compiling**> StandardRecord_dict.cc <**linking**> libStandardRecord_dict.so <**checking class version numbers**> libStandardRecord_dict.so <**compiling**> StandardRecord_map.cc <**linking**> libStandardRecord_map.so <novagpvm08.fnal.gov>
Step 6: Add into CAFMaker¶
Open CAFMaker/CAFMaker_module.cc but be aware that this is gonna be a huge file. The trick is search for keywords (i.e. header).
This is one of the most important parts since is in here where you are defining the instructions to put your variable into the CAF framework.
... //####################################################### // Fill header. //####################################################### // Get metadata information for header unsigned int run = evt.run(); ... unsigned int nbadchan = bc->NBadInSubRun(subrun); // This is our new variable! ... rec.hdr = SRHeader(); rec.hdr.run = run; ... rec.hdr.nbadchan = nbadchan; // This is our new variable! ...
After this, save it. Compile
make CAFMaker.all
You should not get any error messages.
Step 7: Almost done¶
In order to test that your variable is producing reasonable values, let's test it. You will need two things
- An input ART root file (i.e. reco/pid)
- A .fcl file (for example, CAFMaker/cafmakerjob.fcl or the one in the job/ folder)
Step 8: Produce the CAF¶
In the area you have been working, you can produce the CAF by doing
nova -c job/cafmakerjob.fcl -n 2 <input ART root file>
after that, open it
cafe <file_name>
Your variable has been added and filled!
Making it real¶
Thinking your variable is ready for submission? Send an email to nova_offline or contact any group convener before commit.
References/Documentation¶
The following material was consulted when preparing this tutorial