Setting up the gm2 environment¶
This section is based on the official
Offline Computing and Software Manual
Only important steps are reproduced here.
First of all you need to login to the Fermilab virtual machine (
ssh -Y gm2gpvm0N.fnal.gov
where N runs from 1 to 4.
Once you have logged in, you need to choose a release for the Muon g-2 softwares (libraries, executables) every time you login or you can put it in your .profile on
If successful, you will get
Using g-2 release repository at /cvmfs/gm2.opensciencegrid.org g-2 software --> To list gm2 releases, type ups list -aK+ gm2 --> To use the latest release, do setup gm2 v9_41_01 -q prof For more information, see https://cdcvs.fnal.gov/redmine/projects/g-2/wiki/ReleaseInformation
Then follow the instruction and use the latest release of gm2 (v9_41_01 at the moment of revising this tutorial)
setup gm2 v9_41_01 -q prof
Now let's take some time exploring this
gm2 executable. You can generate the help message by
and you will get
Usage: gm2 <-c <config-file>> <other-options> [<source-file>]+ Basic options: -h [ --help ] produce help message --version Print art version (2.03.00) -c [ --config ] arg Configuration file. --process-name arg art process name. --print-available arg List all available plugins with the provided suffix. Choose from: 'module' 'plugin' 'service' 'source' --print-available-modules List all available modules that can be invoked in a FHiCL file. --print-available-services List all available services that can be invoked in a FHiCL file. --print-description arg Print description of specified module, service, source, or other plugin (multiple OK). Source options: -s [ --source ] arg Source data file (multiple OK); precludes -S. -S [ --source-list ] arg file containing a list of source files to read, one per line; precludes -s. -e [ --estart ] arg Event # of first event to process. -n [ --nevts ] arg Number of events to process. --nskip arg Number of events to skip. Output options: -T [ --TFileName ] arg File name for TFileService. --tmpdir arg Temporary directory for in-progress output files (defaults to directory of specified output file names). --tmpDir arg Synonym for --tmpdir. -o [ --output ] arg Event output stream file (optionally specify stream with stream-label:fileNa me in which case multiples are OK). --no-output Disable all output streams.
These options will become very important in the future when you are doing your data analysis. Pay more attention to these options:
-c [ --config ] arg Configuration file. -s [ --source ] arg Source data file (multiple OK); precludes -S. -S [ --source-list ] arg file containing a list of source files to read, one per line; precludes -s. -n [ --nevts ] arg Number of events to process. -T [ --TFileName ] arg File name for TFileService. -o [ --output ] arg Event output stream file (optionally specify stream with stream-label:fileNa me in which case multiples are OK).
Even though by default the name of the art output file, number of events and so on are specified in a fhicl file,
you can use these options to overwrite whatever is written in the fhicl file.
An example use case is
gm2 -c mdc0.fcl -o gm2ringsim_mdc0.root -n 100
and this is the command you will use to generate your own muon gas gun simulation file, hurray!
Running the gm2 codes¶
Soon after setting up, you can actually run the gm2 muon gas gun simulation by typing
gm2 -c mdc0.fcl -o gm2ringsim_mdc0.root -n 100
and you will get a log file and a root file storing all the truth information of 100 muon decays.
gm2 executable and libraries and
mdc0.fcl file are actually available through the cvmfs so even if you don't have them locally, you can still run the simulation! Of course you want to do more than that. You can look at all the available fhicl files at
Creating your own development area¶
Next to do is to go to a folder of your choice (usually ~/work) and then create a new development place.
cd ~/work mkdir myNewDev
Now go into the newly created folder
myNewDev and initialize it as a development area
cd myNewDev/ mrb n newDev
Follow the instruction to source the localproducts settings
source localProducts_gm2_v7_06_06_prof/setup . mrb s
Now we are ready to install all the packages for development purposes by cd into the srcs folder.
Some useful art commands¶
Each of the programs below is available if you have setup the art product (either directly, or by having setup our gm2 environment).
Each program accepts the flag --help, which prints out instructions for use. For more information regarding art, please go to https://cdcvs.fnal.gov/redmine/projects/art/wiki.
- gm2: this is the event-processing framework executable. Note the availability of --debug-config <file> and --config-out <file> to print out the configuration that you have just told art to use. Note also --annotate, which adds comments that say where each parameter value came from. This command takes into account command-line parameters specified to the art executable, which can insert or modify parameters. The lar and various experiment-specific framework executables all take these same arguments.
- gm2 --print-description ModuleName: this will print out the details about this module
- art_ut: this is the event-processing framework executable with built-in support for unit testing using the Boost library. It is intended for writing modules that are used for testing, not for production.
- config_dumper: this program will read an art/ROOT output file and print out configuration information for the process(es) that created that file.
- fhicl-dump: this program will read a FHiCL file, fully process it, and print out the FHiCL that describes the resulting ParameterSet. Note that it requires the environment variable FHICL_FILE_PATH to be set. Note that fhicl-dump does not take the large set of flags that the framework executable respects.
- fhicl-expand: this program will read a FHiCL file and perform all #include processing, printing the result as a single FHiCL document.
- file_info_dumper: this program will read an art/ROOT output file and has the ability to print the list of events in the file, print the range of events, subruns, and runs that contributed to making the file, and provides access to the internal SQLite database, which can be saved to an external database.
- count_events: this program will read an art/ROOT output file and print out how many events are contained in that file.
- product_sizes_dumper: this program will read and art/ROOT output file and print out information about the sizes of products.
- sam_metadata_dumper: The sam_metadata_dumper application will read an art-ROOT format file, and extract the information for possible post-processing and upload to SAM.
- cetskelgen: This modular script will generate skeleton source files for the selected module or plugin type. If an experiment designs their own plugin, they can produce a plugin for cetskelgen to generate a skeleton for same.