exercises » History » Version 11

« Previous - Version 11/42 (diff) - Next » - Current version
Eric Church, 02/08/2014 05:54 PM

LArSoft Exercises

Run a simple lar job to create mu-'s of momentum 1.5 GeV/c from a point source.

We will create a file containing events that each have a single muon using the code in a public place. That means you will not need to build any code at this stage. So, go to your test release, that is your working directory. You made this in the guide. Set yourself up to run there with an appropriate mrb working directory, which we call lgm here. All this is explained at In this first exercise you are going to run from fcl files and .so libraries -- files that form the heart of the framework -- that live in the official places. You will setup to run against uboonecode nightly (or v1_00_02, say) and against larsoft nightly (or v1_00_02). Namely, you are not using your own code. So, let's first show the setup, which we urge you perform via an alias, like the following. Have a line like the below line starting alias in your ~/.bashrc. (Use an alias and hand-execute the alias each login; do not execute this stuff in your shell-initiated start up scripts like ~/.profile or ~/.bashrc.)

<> alias ulgmr='source /grid/fermiapp/uboone/software/; cd /uboone/app/users/username/lgm/build; setup uboonecode nightly -qe4:prof; source mrb slp;'  # a potential setup alias
<> ulgmr # actually execute the commands in the alias

And now, run the executable on this canned fcl job script file.

lar -c prodsingle_uboone.fcl

This fcl file will produce 5 muons through the set of modules SingleGen, LArG4, and DetSim. That's pretty cool. But where did it find prodsingle_uboone.fcl? How do I know it will run 5 events?
The answer comes from looking at our job script fcl file. We find our fcl files from sleuthing from the key environment variable $FHICL_FILE_PATH.

<> more /grid/fermiapp/uboone/software/products/uboonecode/nightly/job/prodsingle_uboone.fcl 

The job starts each event with a clean slate as indicated by the EmptyEvent key word. If you're running a job with recon modules in it only, EmptyEvent instead says RootInput, as you'll be sucking up an already-written root file in a previous job. Note that in prodsingle_uboone.fcl maxEvents is 5. Note the output root file full of histograms (that we declared and filled in the source code) is specified to be at single_hist_uboone.root and the output ART root file (which serves is the one that we'll pass onto any further modules in subsequent lar jobs) is to be called single_gen_uboone.root. Note, that these did indeed appear in your directory!

How did I make 1.5GeV/c muons and not, say, Higgsinos? The answer comes from drilling down into the included fcl files. From the job script we note that for the generator we need the fcl parameter set called microboone_singlep. fcl parameter sets are in fcl files in the same places as the job script fcl files: at all possible directories in $FHICL_SEARCH_PATH. So, let's search

<> grep microboone_singlep /grid/fermiapp/uboone/software/products/uboonecode/nightly/job/*
grep microboone_singlep /grid/fermiapp/products/larsoft/lar*/nightly/job/*
The relevant return line is from the second effort: /grid/fermiapp/products/larsoft/larsim/nightly/job/singles.fcl:microboone_singlep: @local::standard_singlep. That's the only place where microboone_singlep appears on the left hand side of a colon, and that's where the parameter set is defined. Although, what we've learned is that this parameter set is equated to standard_singlep, which we must now hunt down, in turn. Note that the return from the greps shows us that after defining microboone_singlep to be standard_singlep, we then proceed to over-write some parameters like X0 and Z0, meaning we force the particles to be generated from a particular point in the TPC. We will return to this idea. We grep the lar* job areas again for singlep and discover the motherlode at /grid/fermiapp/products/larsoft/larsim/nightly/job/singles.fcl, which upon investigation shows the full single particle parameter set, including the line PDG: [13]. Hence, we have generated mu-s.

Change the mu-'s to K+'s of lower momentum and originating throughout the TPC.

Here we want to still use canned code: stuff from the nightly's or the vX_YY_ZZ's.

But we have to get ahold of the prodsingle_uboone.fcl to alter a couple parameters to do what we want to do in this exercise. For now, let's just grab a copy and put it in our local area and use that. (We know this will work, cuz the very first item in $FHICL_SEARCH_PATH is "."). So, in your working area go cp /grid/fermiapp/uboone/software/products/uboonecode/nightly/job/prodsingle_uboone.fcl .

Remembering that we can overwrite parameters at this stage, and that the generator module lives in the producers clause of the physics parameter set, open an editor on your new copy of prodsingle_uboone.fcl and put these lines at the bottom in order to run 0.2 GeV/c K+s generated throughout the TPC, and not 1.5 GeV/c mu-s from a fixed point:

physics.producers.generator.PDG: [321] # K+ 
physics.producers.generator.P0: [ 0.2 ]
physics.producers.generator.SigmaX: [ 125.0 ] # width of Gaussian distribution, in cm
physics.producers.generator.SigmaY: [ 125.0 ]
physics.producers.generator.SigmaZ: [ 500.0 ]

Parameters in brackets are vectors. If I say

 @physics.producers.generator.PDG: [321, 13, 22, 2112] # K+, mu-, gamma, n 

we'll choose randomly (flat distribution) to generate any of those 4 particle types. However, if we do that, we should now go overwrite every possible parameter in that set, as inherited from standard_singlep and make sure all of them are 4-elements long.

Let's note one more thing we have done with our canned code. We have run the module we label largana in prodsingle_microboone.fcl. It is an analyzer, meaning it puts nothing on the event. This is in contrast with the producers which do put persistent data onto the event. largana runs after all the producers. The key word trigger_paths runs the producers, which you'll note are all captured in the simulate array of modules, and the key word end_paths holds the analyzers (held in analyzeIt) and the output. We remind you that you will always run producers or analyzers or filters in your fcl scripts.

If we go open the output single_hist_uboone.root file we'll find a directory corresponding to largana, in which its histograms and a TTree reside.

root [0] TFile f("single_hist_uboone.root")
root [1] TDirectoryFile* l = f->Get("largana")
root [2] l->cd()
root [3] MCTTree->Show(0)
======> EVENT:0
 MCEvt           = 1
 MCSub           = 0
 MCRun           = 1

The natural question that follows might be Do these module labels, generator, largeant, daq, etc, mean anything? In fact, they don't mean anything per se, but they do mean something in a relative sense. The data from one producer module might well be used in subsequent modules. And thus, among the parameter set information for a producer is generally a label, or series of labels, that specifies which previous modules are needed from which the current module will get data. Those labels then are the names of the previously-run modules from this or a previous job. So, yes, those module labels generally have meaning down the line.
  • Note that each module's parameter set, first and foremost, gives a module_type field, which is the name of the * file that holds the producer/analyzer class whose main produce()/analyze() method is run each event-- finally, we make contact with the C++!
  • Note also the DriftEModuleLabel field. You'll find that this is largeant, by default. That means the daq module needs the data from largeant, which it happens is exactly the module that runs before it in our prodsingle_uboone.fcl. If we'd called that module largeeeeeant in prodsingle_uboone.fcl instead, we'd need to overwrite this, which is done by tacking on physics.producers.daq.DriftEModuleLabel: "largeeeeeant" at the bottom.
Let us urge at this point that you go chase the daq module's parameter set  microboone_simwire.

Edit the module that captures the truth information into histograms and TTree branches.

Alright, we've established above that this means we need to edit the code corresponding to the largana module. That module is, after some exploration,