Back to home page

EIC code displayed by LXR

 
 

    


Warning, /tutorial-jana2/episodes/02-work-environment.md is written in an unsupported language. File is not indexed.

0001 ---
0002 title: "Work Environment for ePIC Reconstruction Software"
0003 teaching: 10
0004 exercises: 10
0005 ---
0006 
0007 ::::::::::::::::::::::::::::::::::::::::::::: questions
0008 
0009 - How do I setup a development copy of the EICrecon repository?
0010 
0011 :::::::::::::::::::::::::::::::::::::::::::::
0012 
0013 ::::::::::::::::::::::::::::::::::::::::::::: objectives
0014 
0015 - Clone EICrecon repository and build with eic-shell.
0016 - Obtain a simulated data file.
0017 
0018 :::::::::::::::::::::::::::::::::::::::::::::
0019 
0020 ## How do I setup development copy for EICrecon?
0021 
0022 A development copy includes a working directory and the EICrecon code. By far, the easiest way to set this
0023 up is using `eic-shell` as outlined in the [Setting up your environment tutorial](https://eic.github.io/tutorial-setting-up-environment/).
0024 
0025 Although `eic-shell` comes with a prebuilt copy of EICrecon (`eicrecon`), we will clone the EICrecon repository
0026 so we can modify it and submit changes back to GitHub later:
0027 
0028 ```bash
0029 git clone https://github.com/eic/EICrecon
0030 ```
0031 
0032 or, if you have SSH keys set up on github
0033 
0034 ```bash
0035 git clone git@github.com:eic/EICrecon
0036 ```
0037 
0038 Check that you can build EICrecon using the packages in `eic-shell` (this may take a while...):
0039 
0040 ```bash
0041 cd EICrecon
0042 cmake -S . -B build
0043 cmake --build build --target install
0044 ```
0045 
0046 If you are not familiar with cmake, the first command above (`cmake -S . -B build`) will create a directory `build`
0047 and place files there to drive the build of the project in the source directory `.` (i.e. the current dirctory).
0048 The second cmake command (`cmake --build build --target install`) actually performs the build and installs
0049 the compiled plugins, exectuables, etc.
0050 
0051 ::::::::::::::::::::::::::::::::::::::::::::: callout
0052 
0053 Note: The `-j8` option can be added to tells CMake to use 8 threads to compile. If you have more cores available,
0054 then set this number to an appropriate value.
0055 
0056 ```bash
0057 cmake --build build --target install -- -j8
0058 ```
0059 
0060 :::::::::::::::::::::::::::::::::::::::::::::
0061 
0062 ::::::::::::::::::::::::::::::::::::::::::::: challenge
0063 
0064 ## Exercise
0065 
0066 - Use the commands above to setup your working directory and build *EICrecon*.
0067 
0068 ::::::::::::::: solution
0069 
0070 After `cmake --build build --target install` finishes, you should have an `EICrecon/build`
0071 directory and an installed `eicrecon` executable together with an `EICrecon/bin/eicrecon-this.sh`
0072 environment script. The build completes without errors (it may take several minutes).
0073 
0074 :::::::::::::::
0075 
0076 :::::::::::::::::::::::::::::::::::::::::::::
0077 
0078 ## How do I run EICrecon?
0079 
0080 `eicrecon` is the main reconstruction executable. To run it though, you should add it to your `PATH` and set up
0081 any other environment parameters needed. Do this by sourcing the `eicrecon-this.sh` file that should have been
0082 created and installed into the `bin` directory in the previous step. Once you have done that, run `eicrecon` with
0083 no arguments to see that it is found and prints the usage statement.
0084 
0085 ```bash
0086 source bin/eicrecon-this.sh
0087 ```
0088 
0089 ::::::::::::::::::::::::::::::::::::::::::::: callout
0090 
0091 Note: If you are using the prebuilt `eicrecon` executable in `eic-shell`, the environment will aready be set.
0092 
0093 :::::::::::::::::::::::::::::::::::::::::::::
0094 
0095 Now you should be able to run the `eicrecon` command, and without options it will give information on how to run it:
0096 
0097 ```bash
0098 $ eicrecon
0099 
0100 Usage:
0101     eicrecon [options] source1 source2 ...
0102 
0103 Description:
0104     Command-line interface for running JANA plugins. This can be used to
0105     read in events and process them. Command-line flags control configuration
0106     while additional arguments denote input files, which are to be loaded and
0107     processed by the appropriate EventSource plugin.
0108 
0109 Options:
0110    -h   --help                  Display this message
0111    -v   --version               Display version information
0112    -j   --janaversion           Display JANA version information
0113    -c   --configs               Display configuration parameters
0114    -l   --loadconfigs <file>    Load configuration parameters from file
0115    -d   --dumpconfigs <file>    Dump configuration parameters to file
0116    -b   --benchmark             Run in benchmark mode
0117    -L   --list-factories        List all the factories without running
0118    -Pkey=value                  Specify a configuration parameter
0119    -Pplugin:param=value         Specify a parameter value for a plugin
0120 
0121    --list-default-plugins       List all the default plugins
0122    --list-available-plugins     List plugins at $JANA_PLUGIN_PATH and $EICrecon_MY
0123 
0124 
0125 Example:
0126     eicrecon -Pplugins=plugin1,plugin2,plugin3 -Pnthreads=8 infile.root
0127     eicrecon -Ppodio:print_type_table=1 infile.root
0128 ```
0129 
0130 The usage statement gives several command line options. Two of the most important ones are the
0131 `-l` and `-Pkey=value` options. Both of these allow you to set *configuration parameters*
0132 in the job. These are how you can modify the behavior of the job. Configuration parameters
0133 will pretty much always have default values set by algorithm authors so it is often not necessary
0134 to set this yourself. If you need to though, these are how you do it.
0135 
0136 - Use the `-Pkey=value` form if you want to set the value directly on the command line.
0137   You may pass mutiple options like this.
0138 - The `-l` option is used to specify a configuration file where you may set a large number
0139   of values. The file format is one parameter per line with one or more spaces separating the
0140   configuration parameter name and its value. Empty lines are OK and `#` can be used to specify
0141   comments.
0142 
0143 ## Get a simulated data file
0144 
0145 The [Simulations with npsim and Geant4 tutorial](https://eic.github.io/tutorial-simulations-using-npsim-and-geant4/)
0146 described how to generate a simulated data file. If you
0147 followed the exercises in that tutorial you can use a file you generated there. If not, then
0148 you can quickly generate a small file with the following command:
0149 
0150 ```bash
0151 ddsim -N 100 \
0152   --compactFile $DETECTOR_PATH/$DETECTOR_CONFIG.xml \
0153   --outputFile pythia8NCDIS_10x100_minQ2=1_beamEffects_xAngle=-0.025_hiDiv.edm4hep.root \
0154   --inputFile root://dtn-eic.jlab.org//volatile/eic/EPIC/EVGEN/DIS/NC/10x100/minQ2=1/pythia8NCDIS_10x100_minQ2=1_beamEffects_xAngle=-0.025_hiDiv_1.hepmc3.tree.root
0155 ```
0156 
0157 ::::::::::::::::::::::::::::::::::::::::::::: callout
0158 
0159 Note: The backslash characters, `\`, allow the line to be continued on the next line.
0160 
0161 :::::::::::::::::::::::::::::::::::::::::::::
0162 
0163 ::::::::::::::::::::::::::::::::::::::::::::: challenge
0164 
0165 ## Exercise
0166 
0167 - Run `eicrecon` over your simulated data file by giving it as an argument to the program, e.g.
0168 
0169 ```bash
0170 eicrecon pythia8NCDIS_10x100_minQ2=1_beamEffects_xAngle=-0.025_hiDiv.edm4hep.root
0171 ```
0172 
0173 ::::::::::::::: solution
0174 
0175 `eicrecon` processes the events in the file and prints progress to the terminal, finishing without
0176 errors. By default no output file is written; the next section shows how to request output
0177 collections.
0178 
0179 :::::::::::::::
0180 
0181 :::::::::::::::::::::::::::::::::::::::::::::
0182 
0183 ## Generating a podio output file
0184 
0185 To write reconstructed values to an output file, you need to tell *eicrecon* what to write.
0186 There are several options available, but the mosrt useful one is *podio:output_collections*.
0187 This is a comma separated list of colelctions to write to the output file. For example:
0188 
0189 ```bash
0190 eicrecon -Ppodio:output_collections=ReconstructedParticles pythia8NCDIS_10x100_minQ2=1_beamEffects_xAngle=-0.025_hiDiv.edm4hep.root
0191 ```
0192 
0193 To see a list of possible collections, run `eicrecon -L`.
0194 
0195 ::::::::::::::::::::::::::::::::::::::::::::: challenge
0196 
0197 ## Exercise
0198 
0199 - Use `eicrecon` to generate an output file with both `ReconstructedParticles` and `EcalEndcapNRawHits`.
0200 
0201 ::::::::::::::: solution
0202 
0203 Pass both collection names as a comma-separated list to `podio:output_collections`:
0204 
0205 ```bash
0206 eicrecon -Ppodio:output_collections=ReconstructedParticles,EcalEndcapNRawHits pythia8NCDIS_10x100_minQ2=1_beamEffects_xAngle=-0.025_hiDiv.edm4hep.root
0207 ```
0208 
0209 :::::::::::::::
0210 
0211 :::::::::::::::::::::::::::::::::::::::::::::
0212 
0213 ::::::::::::::::::::::::::::::::::::::::::::: keypoints
0214 
0215 - Use eicrecon executable to run reconstruction on a podio input file and to create podio output file.
0216 
0217 :::::::::::::::::::::::::::::::::::::::::::::