Getting Started Examples

(copied from the 35-ton getting-started tutorial page on June 8, 2016) Tested on LArSoft v06_00_01.

Step 0: Some background reading...

Read the following page for helpful pointers on building/running/developing/committing DUNE code in LArSoft.

The rest of this page contains some specific instructions on getting started with 35t reconstruction and analysis.

Step 1: Set up your working area

You have to do this each time you log in or open a new shell.

First, set up the DUNE software:

source /cvmfs/

Then follow steps in either a. or b. below.

a. If you don't have a working area

Create one (inserting your own directory name into the example below):

my_name=mstancar        # The name of your /dune/app/users directory if you have one
mkdir -p ${my_installation}

Set up LArSoft in the working area (the example below uses LArSoft v06_00_01), then grab and build the corresponding version of dunetpc:


cd ${my_installation}
mrb newDev -v ${my_version} -q ${my_type}:${my_compiler} 
source localProducts_larsoft_${my_version}_${my_type}_${my_compiler}/setup
cd srcs ; mrb g -t ${my_version} dunetpc ; cd ../
cd $MRB_BUILDDIR ; mrbsetenv ; mrb i ; cd ../

You can get a list of versions of a ups product with this command (using larsoft as the example):

ups list -aK+ larsoft

The resulting list is not necessarily sorted.

b. If you already have a working area

Set up your existing working area:

my_installation=/path/to/your/working/area # Use the actual path


cd ${my_installation}
source localProducts_larsoft_${my_version}_${my_type}_${my_compiler}/setup

Step 2: Generate a sample of events

We'll use the single-particle generator to simulate a sample of events in the 35t detector. This uses the GEANT4 Particle Gun to inject particles into the 35t detector. By default, a sample of single muons is simulated.

lar -c prodsingle_dune35t.fcl
ls -ltr # See the files that you made, single35t_gen.root and single35t_hist.root

The particle gun can be configured with the type of particles, their distribution of energy and angle, and their distribution of vertex positions. A great manual for DUNE users can be found here:

You can change the configuration of the particle gun by creating your own local version of the "prodsingle_dune35t.fcl" file:

mkdir job # if you haven't already created this directory
cp srcs/dunetpc/dune/EventGenerator/prodsingle_dune35t.fcl ./job

For example, to change the angle of incident particles in the XZ plane, open up "job/prodsingle_dune35t.fcl" in a text editor and add the following line to the end of the file:

physics.producers.generator.Theta0XZ: [ 30.0 ]  # change the thetaXZ angle from 0 to 30 degrees

To see the full list of parameters you can change open the file "$LARSIM_DIR/job/singles.fcl". The parameters are defined under standard_singlep.

Step 3: Look at the event sample in an event display

Use the 35t event display to scan through your events:

lar -c evd_dune35t.fcl single35t_gen.root

You can modify the event display by creating your own local version of the "evd_dune35t.fcl" file.

mkdir job # If you haven't already created this directory
cp $DUNETPC_DIR/job/evd_dune35t.fcl ./job

Open up the file "job/evd_dune35t.fcl" in a text editor and add the following line at the end of the file:

services.user.ColorDrawingOptions.ColorOrGrayScale:  1

Re-run the event display, and see what changed (it's now grey!). The colour version is shown below. The top panel show the collection plane, and the two lower panels show the induction planes. Note the effect of wire-wrapping in the induction planes.

Step 4: Reconstruction and analysis

Now we'll run the 35t reconstruction up to the hit-finding level, and make an analysis tree containing the hit information.

Some background information

First, a little larsoft/git/mrb discussion! The larsoft code is currently divided into nine pieces, and each piece is a separate git repository. The nine repositories currently are larana, larcore, lariat, lareventdisplay, larevt, larexamples, larpandora, larreco, and larsim. In addition, each experiment has at least one repository that contains experiment specific code, in our case "dunetpc". For each repository, git keeps a "master" version of the code (the master branch) that is safe - only certain competent people change things here. The working version that all users can modify is called "develop" or "the development branch". You pulled down (or copied, or checked out) a tagged version (v06_00_01) of dunetpc, which is more stable than the development branch. If you type "ls ${MRB_SOURCE}" you will see one directory for each repository you pulled down, only "dunetpc" if you followed these examples to the letter. If you go to the directory $MRB_SOURCE/dunetpc, and type "git status", it will tell you which branch you pulled down.

But now, you want to add something to what you pulled down, namely code that makes a tree with information about the events for you to do some analysis. Anything you add has to be associated with one of the repositories, even if it stays only in your own private copy of that repository and is never incorporated into the public development branch. The appropriate place for personal analysis code is the dunetpc repository. Note that the instructions below won't tell you how to commit code back to dunetpc yet.

If you want to know more about larsoft/git/mrb stuff, see
Also feel free to corner an expert and interrogate them!

Building and running the analysis tree code

Back to our analysis tree and the list of hits . . .

The analysis tree code and scripts are attached to this wiki page. Copy these files into your working area ($MRB_TOP), then copy (or move) them to their final locations:

cd $MRB_TOP/srcs/dunetpc/dune/
mkdir HitDumper
cp $MRB_TOP/CMakeLists.txt HitDumper/
cp $MRB_TOP/ HitDumper/

cd $MRB_TOP 
mkdir job # If you haven't already created this directory
cp hitdumper.fcl job/
cp hitdump_35ton.fcl job/
cp evd_35t_hit.fcl job/

You need to tell the builder to include new analysis module called "HitDumper". To do this, open the file "$MRB_TOP/srcs/dunetpc/dune/CMakeLists.txt" in a text editor and add the line add_subdirectory(HitDumper) to the end of the add_subdirectory list. Then, build the code as follows:

cd $MRB_BUILDDIR ; mrbsetenv ; mrb i
cd ../

Next, run the code over your simulated events as follows:

lar -c hitdump_35ton.fcl -o single35t_hits.root single35t_gen.root 
ls -ltr # See the files that you made, single35t_hits.root and reco_hist.root

Note that this script has been configured to cheat both the hit-finding and disambiguation! The output file "single35t_hits.root" contains the raw event, its Monte Carlo truth, and the reconstructed hits. take a moment to appreciate the large size of this file (several megabytes per event - Liquid Argon TPCs, assisted by LArSoft, output large volumes of data!). This output file can be switched off by opening "hitdump_35ton.fcl" in a text editor and removing "stream1" from "end_paths".

Looking at the reconstructed hits

You can take a look at the reconstructed hits in the event display as follows:

lar -c evd_35t_hit.fcl single35t_hits.root

An example display is shown below. The hits are shown with open black squares. You can toggle the raw signals onto the display by selection "Both" in the radio buttons at the bottom. You may need to zoom in on the vertical axis to see the squares. Note that the wrapped-wire ambiguities have now been disambiguated.

Looking at the analysis tree

Open the analysis tree in ROOT as follows:

root -l reco_hist.root
root [0]
Attaching file reco_hist.root as _file0..
root [1] hitdumper->cd()
root [2] hitdumper->Draw("hit_peakT:hit_wire","hit_tpc == 1 && hit_plane == 0") // tdc vs wire (TPC 1, Plane 0)
root [3] hitdumper->Draw("hit_peakT:hit_wire") // tdc vs wire (all TPCs and views superimposed)

The second plot should look something like this:

Things specific to v03_00_00

These parameters may not be set correctly in the default fcl files. You can add these lines at the end of your main fcl file to modify them.

services.user.DetectorProperties.TimeOffsetU:       0.
services.user.DetectorProperties.TimeOffsetV:       0.
services.user.DetectorProperties.ReadOutWindowSize: 3200
services.user.DetectorProperties.NumberTimeSamples: 3200
services.user.LArProperties.Electronlifetime:  99e3              #microseconds
services.user.TimeService.TriggerOffsetTPC:   30.

Note you need to add these lines to both the file that generates events (i.e. prodsingle_dune35t.fcl) and the file that analyses them (i.e. hitdump_35ton.fcl)

Older links and info.

Obsolete LBNE code getting-started wiki page:

Any questions?

Ask Michelle and Tom - they will be happy to help!