Warning, /jana2/docs/howto/other-howtos.md is written in an unsupported language. File is not indexed.
0001 # Other HowTos
0002
0003 This section walks the user through specific steps for solving a real-world problem.
0004
0005 Table of contents
0006 -----------------
0007
0008 1. [Download](Download.html) and [install](Installation.html) JANA
0009 2. [Use the JANA command-line program](#using-the-jana-cli)
0010 3. [Configure JANA](#configuring-jana)
0011 6. [Benchmark a JANA program](benchmarking.html)
0012 4. [Generate code skeletons](#creating-code-skeletons) for projects, plugins, components, etc
0013 5. [Run the JANA Status/Control/Debugger GUI](#run-the-status-control-debugger-gui)
0014 7. Create a service which can be shared between different plugins
0015 8. Handle both real and simulated data
0016 9. Handle EPICS data
0017 10. [Detect when a group of events has finished](howto_group_events.md)
0018 11. Use JANA with ROOT
0019 12. Persist the entire DST using ROOT
0020 13. Checkpoint the entire DST using ROOT
0021 14. [Stream data to and from JANA](howto_streaming.html)
0022 15. Build and filter events ("L1 and L2 triggers")
0023 16. Process subevents
0024 17. Migrate from JANA1 to JANA2
0025 18. [Contributing to JANA2](Contributing.html)
0026
0027
0028 Using the JANA CLI
0029 ------------------
0030
0031 JANA is typically run like this:
0032
0033 ~~~ bash
0034 $JANA_HOME/bin/jana -Pplugins=JTest -Pnthreads=8 ~/data/inputfile.txt
0035 ~~~
0036
0037 Note that the JANA executable won't do anything until you provide plugins.
0038 A simple plugin is provided called JTest, which verifies that everything is working and optionally does a quick
0039 performance benchmark. Additional simple plugins are provided in `src/examples`. Instructions on how to write your
0040 own are given in the Tutorial section.
0041
0042 Along with specifying plugins, you need to specify the input files containing the events you wish to process.
0043 Note that JTest ignores these and crunches randomly generated data instead.
0044
0045
0046 The command-line flags are:
0047
0048 | Short | Long | Meaning |
0049 |:------|:-----|:---------|
0050 | -h | --help | Display help message |
0051 | -v | --version | Display version information |
0052 | -c | --configs | Display configuration parameters |
0053 | -l | --loadconfigs <file> | Load configuration parameters from file |
0054 | -d | --dumpconfigs <file> | Dump configuration parameters to file |
0055 | -b | --benchmark | Run JANA in benchmark mode |
0056 | -P | | Specify a configuration parameter (see below) |
0057
0058
0059
0060 Configuring JANA
0061 ----------------
0062
0063 JANA provides a parameter manager so that configuration options may be controlled via code, command-line args, and
0064 config files in a consistent and self-documenting way. Plugins are free to request any existing parameters or register
0065 their own.
0066
0067 The following configuration options are used most commonly:
0068
0069 | Name | Type | Description |
0070 |:-----|:-----|:------------|
0071 | nthreads | int | Size of thread team (Defaults to the number of cores on your machine) |
0072 | plugins | string | Comma-separated list of plugin filenames. JANA will look for these on the `$JANA_PLUGIN_PATH` |
0073 | plugins_to_ignore | string | This removes plugins which had been specified in `plugins`. |
0074 | event_source_type | string | Manually specify which JEventSource to use |
0075 | jana:nevents | int | Limit the number of events each source may emit |
0076 | jana:nskip | int | Skip processing the first n events from each event source |
0077 | jana:status_fname | string | Named pipe for retrieving status information remotely |
0078 | jana:loglevel | string | Set the log level (trace,debug,info,warn,error,fatal,off) for loggers internal to JANA |
0079 | jana:global_loglevel | string | Set the default log level (trace,debug,info,warn,error,fatal,off) for all loggers |
0080 | jana:show_ticker | bool | Controls whether the status ticker is shown |
0081 | jana:ticker_interval | int | Controls how often the status ticker updates (in ms) |
0082 | jana:extended_report | bool | Controls whether to show extra details in the status ticker and final report |
0083
0084 JANA automatically provides each component with its own logger. You can control the logging verbosity of individual components
0085 just like any other parameter. For instance, if your component prefixes its parameters with `BCAL:tracking`,
0086 you can set its log level to `DEBUG` by setting `BCAL:tracking:loglevel=debug`. You can set the parameter prefix by calling `SetPrefix()`,
0087 and if you need the logger name to differ from the parameter prefix for any reason, you can override it by calling `SetLoggerName()`.
0088
0089
0090 The `JTest` plugin lets you test JANA's performance for different workloads. It simulates a typical reconstruction pipeline with four stages: parsing, disentangling, tracking, and plotting. Parsing and plotting are sequential, whereas disentangling and tracking are parallel. Each stage reads all of the data written during the previous stage. The time spent and bytes written (and random variation thereof) are set using the following parameters:
0091
0092 | Name | Type | Default | Description |
0093 |:-----|:-----|:------------|:--------|
0094 | jtest:parser:cputime_ms | int | 0 | Time spent during parsing |
0095 | jtest:parser:cputime_spread | int | 0.25 | Spread of time spent during parsing |
0096 | jtest:parser:bytes | int | 2000000 | Bytes written during parsing |
0097 | jtest:parser:bytes_spread | double | 0.25 | Spread of bytes written during parsing |
0098 | jtest:disentangler:cputime_ms | int | 20 | Time spent during disentangling |
0099 | jtest:disentangler:cputime_spread | double | 0.25 | Spread of time spent during disentangling |
0100 | jtest:disentangler:bytes | int | 500000 | Bytes written during disentangling |
0101 | jtest:disentangler:bytes_spread | double | 0.25 | Spread of bytes written during disentangling |
0102 | jtest:tracker:cputime_ms | int | 200 | Time spent during tracking |
0103 | jtest:tracker:cputime_spread | double | 0.25 | Spread of time spent during tracking |
0104 | jtest:tracker:bytes | int | 1000 | Bytes written during tracking |
0105 | jtest:tracker:bytes_spread | double | 0.25 | Spread of bytes written during tracking |
0106 | jtest:plotter:cputime_ms | int | 0 | Time spent during plotting |
0107 | jtest:plotter:cputime_spread | double | 0.25 | Spread of time spent during plotting |
0108 | jtest:plotter:bytes | int | 1000 | Bytes written during plotting |
0109 | jtest:plotter:bytes_spread | double | 0.25 | Spread of bytes written during plotting |
0110
0111
0112
0113 The following parameters are used for benchmarking:
0114
0115 | Name | Type | Default | Description |
0116 |:-----|:-----|:------------|:--------|
0117 | benchmark:nsamples | int | 15 | Number of measurements made for each thread count |
0118 | benchmark:minthreads | int | 1 | Minimum thread count |
0119 | benchmark:maxthreads | int | ncores | Maximum thread count |
0120 | benchmark:threadstep | int | 1 | Thread count increment |
0121 | benchmark:resultsdir | string | JANA_Test_Results | Directory name for benchmark test results |
0122
0123
0124 The following parameters are more advanced, but may come in handy when doing performance tuning:
0125
0126 | Name | Type | Default | Description |
0127 |:-----|:-----|:------------|:--------|
0128 | jana:max_inflight_events | int | nthreads | The number of events which may be in-flight at once. Should be at least `nthreads`, more gives better load balancing. |
0129 | jana:affinity | int | 0 | Thread pinning strategy. 0: None. 1: Minimize number of memory localities. 2: Minimize number of hyperthreads. |
0130 | jana:locality | int | 0 | Memory locality strategy. 0: Global. 1: Socket-local. 2: Numa-domain-local. 3. Core-local. 4. Cpu-local |
0131 | jana:enable_stealing | bool | 0 | Allow threads to pick up work from a different memory location if their local mailbox is empty. |
0132
0133
0134 Creating code skeletons
0135 -----------------------
0136
0137 JANA provides a script, `$JANA_HOME/bin/jana-generate.py`, which generates code skeletons for
0138 different kinds of JANA components, but also entire project structures. These are intended to
0139 compile and run with zero or minimal modification, to provide all of the boilerplate needed, and
0140 to include comments explaining what each piece of boilerplate does and what the user is expected
0141 to add. The aim is to demonstrate idiomatic usage of the JANA framework and reduce the learning
0142 curve as much as possible.
0143
0144 #### Complete projects
0145 The 'project' skeleton lays out the recommended structure for a complex experiment with multiple
0146 plugins, a domain model which is shared between plugins, and a custom executable. In general,
0147 each experiment is expected to have one project.
0148
0149 ```jana-generate.py project ProjectName```
0150
0151 #### Project plugins
0152 Project plugins are used to modularize some functionality within the context of an existing project.
0153 Not only does this help separate concerns, so that many members of a collaboration can work together
0154 without interfering with another, but it also helps manage the complexity arising from build dependencies.
0155 Some scientific software stubbornly refuses to build on certain platforms, and plugins are a much cleaner
0156 solution than the traditional mix of environment variables, build system variables, and preprocessor macros.
0157 Project plugins include one JEventProcessor by default.
0158
0159 ```jana-generate.py ProjectPlugin PluginNameInCamelCase```
0160
0161
0162 #### Mini plugins
0163 Mini plugins are project plugins which have been stripped down to a single `cc` file. They are useful
0164 when someone wants to do a quick analysis and doesn't need or want the additional boilerplate. They
0165 include one JEventProcessor with support for ROOT histograms. There are two options:
0166
0167 ```
0168 jana-generate.py MiniStandalonePlugin PluginNameInCamelCase
0169 jana-generate.py MiniProjectPlugin PluginNameInCamelCase
0170 ```
0171
0172 #### Standalone plugins
0173 Standalone plugins are useful for getting started quickly. They are also effective when someone wishes to
0174 integrate with an existing project, but want their analyses to live in a separate repository.
0175
0176 ```jana-generate.py StandalonePlugin PluginNameInCamelCase```
0177
0178 #### Executables
0179 Executables are useful when using the provided `$JANA_HOME/bin/jana` is inconvenient. This may be
0180 because the project is sufficiently simple that multiple plugins aren't even needed, or because the project is
0181 sufficiently complex that specialized configuration is needed before loading any other plugins.
0182
0183 ```jana-generate.py Executable ExecutableNameInCamelCase```
0184
0185 #### JEventSources
0186
0187 ```jana-generate.py JEventSource NameInCamelCase```
0188
0189 #### JEventProcessors
0190
0191 ```jana-generate.py JEventProcessor NameInCamelCase```
0192
0193 #### JEventProcessors which output to ROOT
0194
0195 This JEventProcessor includes the boilerplate for creating a ROOT histogram in a specific
0196 virtual subdirectory of a TFile. If this TFile is shared among different `JEventProcessors`,
0197 it should be encapsulated in a JService. Otherwise, it can be specified as a simple parameter.
0198 We recommend naming the subdirectory after the plugin name. E.g. a `trk_eff` plugin contains
0199 a `TrackingEfficiencyProcessor` which writes all of its results to the `trk_eff` subdirectory
0200 of the TFile.
0201
0202 ```jana-generate.py RootEventProcessor ProcessorNameInCamelCase directory_name_in_snake_case```
0203
0204 Note that this script, like the others, does not update your `CMakeLists.txt`. Not only will you
0205 need to add the file to `PluginName_PLUGIN_SOURCES`, but you may need to add ROOT as a
0206 dependency if your project hasn't yet:
0207
0208 ```
0209 find_package(ROOT)
0210 include_directories(${ROOT_INCLUDE_DIRS})
0211 link_directories(${ROOT_LIBRARY_DIR})
0212 target_link_libraries(${PLUGIN_NAME} ${ROOT_LIBRARIES})
0213 ```
0214
0215 #### JFactories
0216
0217 Because JFactories are templates parameterized by the type of JObjects they produce, we need two arguments
0218 to generate them. The naming convention is left up to the user, but the following is recommended. If the
0219 JObject name is 'RecoTrack', and the factory uses Genfit under the hood, the factory name should be
0220 'RecoTrackFactory_Genfit'.
0221
0222 ```jana-generate.py JFactory JFactoryNameInCamelCase JObjectNameInCamelCase```
0223
0224 Run the Status Control Debugger GUI
0225 -----------------------------------
0226
0227 The JANA Status/Control/Debugger GUI can be a useful tool for probing a running process. Details can
0228 be found on the [dedicated page for the GUI](GUI_Monitor_Debug.md)
0229
0230
0231
0232
0233
0234