This tutorial is out of date, use this Tutorial

Creating your analysis package

Last update: 16 Aug 2024 [History] [Edit]

Now it is time to create your own package. For RootCore and cmt we had scripts that would create new packages for you, but for cmake we don’t have such a script yet. Once such a script is available we highly recommend you use it, but for now we have to create the package manually.

We’ll call the package MyAnalysis, but you can name it anything you want. If you give it a different name, be aware that you will need to update paths in the rest of the tutorial accordingly (so for the first time it is probably best to stick with this name).

Let’s create the basic directory structure first:

cd ../source/
mkdir MyAnalysis
mkdir MyAnalysis/MyAnalysis
mkdir MyAnalysis/Root
mkdir MyAnalysis/src
mkdir MyAnalysis/src/components
mkdir MyAnalysis/share

We are creating a number of directories here:

  • MyAnalysis directory: This is where all of your C++ header files go. By ATLAS convention it is always named the same as the package itself. This makes it easy for users to identify what package a header file goes with.

  • Root directory: This is where all of your C++ source files go, as well as any private header files. A private header file is a header file that your users do not need to include, e.g. an interface definition would be a public header file while the actual implementation would be in a private header file. If you have no clue what we are talking about here, don’t worry about it for now. For AnalysisBase it may also hold the LinkDef.h file that ROOT uses to build dictionaries (it was mostly used with older versions of EventLoop and is no longer used in the tutorial).

  • src directory: This is where athena sources and private header files go. We are not actually creating any athena sources in this tutorial (as of 24th April 2017), but it doesn’t hurt to have the directories already. It also contains a sub-directory src/components which holds the source files for component libraries. The latter is used if you go through the Athena path of this tutorial, and will be discussed when setting up an algorithm.

  • share directory: This is where configuration and small data files go that you need to pick up at run time. Note as these files will be recorded by your version control system this should really only contain small files, and ideally no binary files. Particularly if this package is meant to go into the offline release there are strict restrictions as to what you can put in there.

Now create a file MyAnalysis/CMakeLists.txt for the package. This file contains the information about how your package gets compiled, but since we are not yet compiling anything yet, let’s put a placeholder here:

# The name of the package:
atlas_subdir (MyAnalysis)

Now let’s just ask cmake to pick up this new package:

cd ../build/
cmake ../source/
make

Technically you don’t have to rebuild after every step, since you won’t be running code until you are further through the tutorial, but it is good practice to check in regular intervals whether your code still compiles even if you don’t run it. At this point we haven’t declared any files to be compiled for your package, so you shouldn’t see any actual compilation happening. However, you should see your new package being mentioned in a couple of lines.

Very Important: Since you created a new package you also must call in the build directory:

source x86_64-*/setup.sh

You should do this whenever you add a new package.