SBN Ana Files (Formerly known as CAF files)

The Common Analysis Files (CAF files or Ana files for short), are structured root files containing the event information needed to perform analyses on SBN. Which analysis? You ask. Any beam-related analysis! The CAF files and infrastructure were first developed by collaborators on the NOvA experiment. The SBN AnaFiles are a re-work of the CAFMaker structure for SBN experiments.

The basic structure of the Ana files consists of a few branches, mostly filled at the SLICE level. The files do contain information about multiple tracks, showers, etc. per slice, but they exist in arrays on the slide level.

Here is an example of the basic structure of an Ana file:

recTree      ///  The main tree filled at the slice level variables 
       --> hdr       /// Metadata container: run, suborn, etc.
       --> slc        /// The tree with summary information about each slice. 
       --> mc       /// A branch with the MCTruth information of the neutrino interaction (or cosmic) most closely associated to the slice 
       --> reco     /// A branch with variables from the reconstructed objects like tracks, showers, etc. 
       --> crt_hits     /// CRT hits in the event
       --> pass_flashtrig     /// Whether this record passed the flash trigger requirement

WORK IN PROGRESS: Ana files are a work in progress. The goal is to settle on a structure and a set of variables to include in the files (the ones we know are needed by the oscillations analyses and more!) and add those variables to the existing CAFs as soon as possible.

The SBN Ana Files Structure wiki contain a list of variables in the current file version.

Join the conversation on the #sbn-ana slack channel!

Adding a variable to the Ana files.

Before you start

To increase efficiency and close collaboration, CAFMaker-v0 is being developed in a shared branch.

Because we are all developing on the same branch, please be courteous and conscious of the work of others.

Here are a few basic rules that can help:

  • Communicate with others about what you are working on. No need to ask for permission, but a general understanding of what everyone is doing is useful to have.
  • Ask question, ask for help if you need it, and offer a helping hand to those who ask.
  • Never make a change that changes the content of an existing variable or output of an existing function you did not create. Exception: Bug fixes, agreement with other developers and accompanying slack message.
  • When adding inputs to a function:
  • Maintain the order of the inputs others are using and add your inputs at the end of the list.
  • Give your inputs default values, so that the function doesn't break for others.
  • Follow the implied naming conventions and style of the modules you are editing.


<current_working_branch> develop
<icarus_version> v09_09_01
<sbnd_version> v09_09_01
<larsoft_version> v09_09_01
<larsoft_qualifiers> e19:prof

To see the available product versions and qualifiers in your working {icarus, sbnd}gpvm use

$ ups list -aK+ <productname>

Step 0 Get the repo

First of all make sure to source the MicroBooNE, SBND and ICARUS products:

$ source /cvmfs/
$ source /cvmfs/
$ source /cvmfs/

Set up the appropriate experiment's software version. This depends on what CAFAna files you intend to produce:

$ setup {icarus,sbnd}code <{icarus,sbnd}_version> -q <{icarus,sbnd}_qualifiers>

Now you can start a new repository with sbncode and checkout the <current_working_branch> branch. Explicitly,

$ setup larsoft <larsoft_version> -q <larsoft_qualifiers>
$ mkdir <my_directory>
$ cd <my_directory>
$ mrb newDev
$ source localProducts_larsoft_<larsoft_version>*/setup # depends on qualifiers
$ cd srcs
$ mrb g
$ cd sbncode
$ git fetch origin
$ git checkout <current_working_branch>
$ cd sbncode
$ mrbsetenv
$ mrb install -j 4

As usual, whenever you log in to work on this branch, you will do:

$ source localProducts_larsoft_<larsoft_version>*/setup # depends on qualifiers
$ cd srcs/sbndcode/sbndcode
$ mrbsetenv

If you are a developer, it is good practice to check that your local changes work before pushing them to the repository. Build your local branch, in <my_directory>/srcs/sbndcode/sbndcode, by typing the following command:

$ mrb install -j 4

There are two main packages that are important to the AnaFile production and content:

  • CAFMaker : A LArSoft module that gets the Analysis variables from slices in LArSoft files and creates an AnaFile per LArSoft input file.
  • StandardRecord : The "record" we keep of the AnaFile structure. The contents and arrangement of the branches in the file.

Adding a variable to the AnaFiles requires the following:

1. If you want to start a new branch, you will first need to add the branch to StandardRecord.

2. Add your leaf/variable to the right StandardRecord branch or product.

3. Modify CAFMaker to fill the leaf/variable you created.


The instructions below, teach you how to make the two changes seen in the figure: adding a new branch with new variables, or adding a variable to an existing file.

Step 1.1 Edit StandardRecord

  • To add a branch, start by creating new files SR<your branch>.h and SR<your branch>.cxx. You can copy the style from the existing ones. These files define the structure of the branches. Then, add variables to your branch.
  • To Add a variable to a branch, edit the include file (SRshower.h / SRSlice.h) and add your variable to it. Always provide a description of variables in the comments.
  • Edit SR<your branch>.cxx, initializing your variable with a value (for positive numbers, the convention is -5).*
  • Add any new branches to the classes_def.xml file in StandardRecord

Step 2 Edit CAFMaker

  • Fill your variables by creating new or edit existing filling function in CAFMaker. For this example, edit CAFMaker/FillReco.cxx, look for the function that fills the branch you want or make a new one.
  • If you created a new function, remember to add it to FillReco.h and add it to the code inside CAFMaker where you want it to fill the variable.

Step 3 Re-build and test

  • Always verify that your added variables get filled correctly.

Step 4 Commit AND Push early and often

Producing and opening AnaFiles

Run the cafmakerjob fcl (located in sbncode/CAFMaker) on a file with all the dataproducts, including reconstruction.

lar -c cafmakerjob_{icarus,sbnd}.fcl <input_filename>

To open an AnaFile, you can do simple checks with the Root TBrowser. You can also run on the file with an anautils macro COMING SOON!!!