Project

General

Profile

Getting Started with Modules

This tutorial is a step-by-step example of analyzing a LArSoft event file using a module. It is meant for newcomers to LArSoft. It was tested using LArSoft v07_11_00. Last updated January 10, 2019.

Setting up

Before starting this tutorial, get a Fermilab account and set up your environment and working area with the Dune software following the tutorial:

https://web.fnal.gov/collaboration/DUNE/SitePages/Getting%20Started%20with%20LArSoft.aspx

Steps 2 and 3 of the tutorial linked below cover generating events and looking at event displays. Step 4 is another analysis module example. These are helpful to go through as well, but not necessary to do before this tutorial:

https://cdcvs.fnal.gov/redmine/projects/dunetpc/wiki/_Getting_Started_Examples_

Generating events

First, we will generate the events that we will analyze using the module. Set up a directory to run jobs from:

cd $MRB_TOP
mkdir job

Download the file “prod_eminus_5MeV_isotropic_dune10kt_1x2x6.fcl” at the bottom of this page and put it in the directory you just created (./job). This file is used to generate single-electron events in the 10kt detector.

Generate 10 events with the file “prod_eminus_5MeV_isotropic_dune10kt_1x2x6.fcl” by typing

lar -c prod_eminus_5MeV_isotropic_dune10kt_1x2x6.fcl -n 10

This will create an event file called “prod_eminus_5MeV_isotropic_dune10kt_1x2x6_gen.root” and a file of root histograms called “single_hist.root”.

Note: The file “prod_eminus_5MeV_isotropic_dune10kt_1x2x6.fcl” generates 5 MeV electron events. To change the parameters, open “job/prodsingle_dune10kt.fcl” in a text editor and edit the final lines that start with “physics.producers.generator”. A full list of parameters you can change and add here are in the file “$LARSIM_DIR/job/singles.fcl”.

Next, simulate the particles in those 10 events by typing

lar -c supernova_g4_dune10kt_1x2x6.fcl prod_eminus_5MeV_isotropic_dune10kt_1x2x6_gen.root -n 10

This will create an event file called “prod_eminus_5MeV_isotropic_dune10kt_1x2x6_gen_g4.root” and a file of root histograms called “g4_hist.root”.

Next, simulate the detector response to those 10 events by typing

lar -c standard_detsim_supernova_dune10kt_1x2x6_nonoise.fcl prod_eminus_5MeV_isotropic_dune10kt_1x2x6_gen_g4.root -n 10

This will create an event file called “prod_eminus_5MeV_isotropic_dune10kt_1x2x6_gen_g4_detsim.root” and a file of root histograms called “detsim_hist.root”.

Next, reconstruct those 10 events by typing

lar -c standard_reco_dune10kt_1x2x6_fast.fcl prod_eminus_5MeV_isotropic_dune10kt_1x2x6_gen_g4_detsim.root -n 10

This will create an event file called “prod_eminus_5MeV_isotropic_dune10kt_1x2x6_gen_g4_detsim_reco.root” and a file of root histograms called “reco_hist.root”.

Analysis Module

We are going to use a module to create a histogram of the total charge collected in the collection plane for the events that were just generated.

Set up a directory:

cd srcs/dunetpc/dune
mkdir ChargeDist

Download the files “chargedist.fcl”, “ChargeDist_module.cc”, and “CMakeLists.txt” at the bottom of this page and put them in the directory you just created (./ChargeDist).

You need to edit the pre-existing “CMakeLists.txt” file in the directory srcs/dunetpc/dune to tell it to compile the new module. Note: this is not the one downloaded from this page. Open it in a text editor, and at the end of the add_subdirectory list, add the line:

add_subdirectory(ChargeDist)

Compile:

mrbsetenv
cd $MRB_BUILDDIR
mrb i

After you compile this way once, you can compile much faster in the future with:

mrbsetenv # Only needs to be used once per session, not every time you compile
cd $MRB_BUILDDIR/dunetpc/dune/ChargeDist
make install

(This works if the directory has been compiled with “mrb i” at least once since being created.)

The file “chargedist.fcl” is used to run the analysis module “ChargeDist_module.cc”. Run it on the events you just generated:

lar -c chargedist.fcl prod_eminus_5MeV_isotropic_dune10kt_1x2x6_gen_g4_detsim_reco.root

This creates a file called “ChargeDist.root”. Open it in root and look at the histogram of total charge:

root -l ChargeDist.root
ChargeDist->cd()
charge->Draw()

It should look something like this:

If you generate 50 events instead of 10 it should look something like this:

Attachments