Skip to content
Nick Chapman edited this page Feb 23, 2017 · 35 revisions

Table of Contents

Guideline

If you want to develop trigger algorithms that should run in the PC-farm, you need to clone this repository and na62-farm-lib. As these are eclipse projects you should import them into your eclipse workspace (see this). Testing the algorithms should be done by cloning na62-trigger-test which links this project and na62-farm-lib.

Getting the code

For a more advanced way to clone the code within the PC-farm see this link

Forking within github

The best way to start with your trigger implementations is to create a github account and then fork this project (See this link on the top right hand corner).

Then you can clone your forked repository via (please adjust YourUserName with your github user name)

git clone git@github.com:YourUserName/na62-trigger-algorithms.git

NB: To ease setup make sure you clone inside your Eclipse workspace.

Don't forget to upload your ssh-key before cloning!

After you've implemented your changes you can send a Pull Request. I will have a look at your commits and accept the request asap.

Cloning directly

If you don't want to contribute to the project but only run it you can directly clone the code via

git clone https://github.com/NA62/na62-trigger-algorithms.git

NB: To ease setup make sure you clone inside your Eclipse workspace.

git branches

All PC-Farm frameworks are developed based on the git flow paradigm. To get familiar with git and git flow please see following links:

The short summary would be: Always code in specific branches like feature/yourFeature where yourFeature should describe the feature you're currently developing. I recommend to install the git-flow package so that you can use following commands:

  • git flow init (use standard settings)
  • git flow feature start yourFeature
  • git flow feature finish yourFeature

Dependencies

The trigger-algorithms project is only a library linked by na62-trigger-test and linking another library called na62-farm-lib. To install these dependencies please do following from inside your Eclipse workspace:

git clone https://github.com/NA62/na62-farm-lib.git
git clone https://github.com/NA62/na62-trigger-test.git

Additionally you need to have boost 1.55 and tbb installed:

# Debian:
sudo apt-get install libtbb-dev libboost1.55-all-dev

# OSX:
brew install tbb
brew install boost

The XMLPreProcessor library is also required. You will need to download this to your workspace and then make it.

Running on lxplus.cern.ch you can use the lxplus configuration of na62-trigger-test and add following to your .bashrc:

source /afs/cern.ch/sw/lcg/contrib/gcc/4.8.0/x86_64-slc6/setup.sh > /dev/null

export LD_LIBRARY_PATH=/afs/cern.ch/sw/lcg/external/Boost/1.55.0_python2.7/x86_64-slc6-gcc47-opt/lib/:$LD_LIBRARY_PATH

Example installation

If YourGitHubUserName is your github username, you've forked na62-trigger-algorithms and YourFeature is the name of the detector or special feature you'd like to write code for, following should be the right commands for you:

mkdir ~/workspace
cd ~/workspace
git clone https://github.com/NA62/na62-trigger-test.git
git clone https://github.com/NA62/na62-farm-lib.git
git clone git@github.com:YourGitHubUserName/na62-trigger-algorithms.git
cd na62-trigger-algorithms
git flow feature start YourFeature
git push --all
# Write your code
# Commit as often as possible (typically O(10) times a day)
git commit -am "Your commit message"
git push

Compiler

So far all na62-farm projects are tested with gcc 4.6, 4.8 and 4.9. As c++11 is heavily used it is not possible to use any gcc compiler below 4.6.

At CERN

On SLC6 with AFS running you can activate gcc 4.9 as follows

source /afs/cern.ch/sw/lcg/contrib/gcc/4.9.0/x86_64-slc6/setup.sh

It is recommended to add this to your .bashrc:

echo "source /afs/cern.ch/sw/lcg/contrib/gcc/4.9.0/x86_64-slc6/setup.sh" >> ~/.bashrc

gcc 4.6

To use gcc 4.6 you need to compile with --std=c++0x instead of --std=c++11. This is easily possible by using the gcc4.6 configuration in eclipse: Just activate the gcc4.6 configuration by right-clicking the na62-trigger-test project and selecting Build Configurations -> Set Active -> gcc4.6

llvm 3.5 / OS X

If you have a MAC you most probably need to switch to the llvm 3.5 setting similar to what is described in gcc 4.6

Installation using fink

Using fink on a MAC running OS X the installation should roughly look like following:

fink install eclipse
fink install gdb

Then you have to sign gdb as explained here: https://sourceware.org/gdb/wiki/BuildingOnDarwin

Compiling

Installing Eclipse

As all projects are Eclipse projects, please install Eclipse with CDT (link):

wget http://ftp.fau.de/eclipse/technology/epp/downloads/release/luna/R/eclipse-cpp-luna-R-linux-gtk-x86_64.tar.gz
sudo tar -xvzf eclipse-cpp*.tar.gz -C /usr/share/
sudo ln -s /usr/share/eclipse/eclipse /usr/bin/

Afterwards you should install the git plugin:

  • Go to Help -> Install New Software
  • Select the Luna URI in the "Work with:" drop-down menu
  • Select Collaboration -> Eclipse Git Team Provider

Importing the projects

In eclipse click File->Import->General->"Existing Projects into Workspace"

Now click Browse and select the folder with all the cloned projects. After pressing OK you should see something like this:

Now Click Finish and you should see the projects in the "Project Explorer" view.

Building and running

For the initial building you should select any cpp file of the na62-trigger-test project and click Project->Build Project or build all Projects by pressing CTRL+b.

If you want to test trigger algorithms you have to execute the trigger-test project project. Therefore select any file out of this project and click the green run button at the bar at the top.

Configuring trigger-test

The trigger-test binary must be called with a list of header files (see InputFileFormat) like files/cedar*.txt and a list of parameters:

activeSourceIDs
Coma separated list of Source IDs to be used
timestampSourceID
The sourceID of the detector used to define the global event timestamp
maxEventNum (optional)
Maximum number of events to be processed
To specify these options while running within eclipse, you should click the right button next to the run button and then `Run Configurations`:

After selecting the na62-trigger-test under C/C++ Application you need to select the Arguments tab where you can add all the arguments you like:

Conventions

Before starting to code please visit the Conventions page here!