Warning, /EICrecon/AGENTS.md is written in an unsupported language. File is not indexed.
0001 # EICrecon Development Instructions
0002
0003 EICrecon is a JANA2-based reconstruction software for the ePIC detector.
0004
0005 **ALWAYS follow these instructions first and fallback to additional search and context gathering only if the information in these instructions is incomplete or found to be in error.**
0006
0007 ## Design Philosophy
0008
0009 **Reproducibility in Multi-threaded Execution:** EICrecon is designed to produce identical physics results regardless of the number of threads used. This is critical for physics validation and debugging.
0010
0011 ## Working Effectively with EICrecon
0012
0013 ### Essential Setup: Use eic-shell Environment
0014
0015 **Bootstrap the eic-shell environment:**
0016 ```bash
0017 curl --location https://get.epic-eic.org | bash
0018 ./eic-shell
0019 ```
0020
0021 **Alternative if /cvmfs is available:**
0022 ```bash
0023 singularity exec /cvmfs/singularity.opensciencegrid.org/eicweb/eic_xl:nightly eic-shell
0024 ```
0025
0026 **Setup geometry and clone EICrecon:**
0027 ```bash
0028 source /opt/detector/epic-main/bin/thisepic.sh
0029 git clone https://github.com/eic/EICrecon
0030 cd EICrecon
0031 ```
0032
0033 ### Build Process
0034
0035 **Configure and build (NEVER CANCEL - Build takes 30-60 minutes):**
0036 ```bash
0037 cmake -B build -S . -DCMAKE_INSTALL_PREFIX=install
0038 cmake --build build --target install -- -j8
0039 ```
0040
0041 **CRITICAL TIMING WARNING: Set timeout to 90+ minutes. Build can take 30-60 minutes even with ccache. NEVER CANCEL long-running builds.**
0042
0043 **Alternative debug build:**
0044 ```bash
0045 cmake -B build -S . -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Debug
0046 cmake --build build --target install -- -j8
0047 ```
0048
0049 **Setup environment to use the build:**
0050 ```bash
0051 source install/bin/eicrecon-this.sh
0052 ```
0053
0054 ### Testing
0055
0056 **Run unit tests (NEVER CANCEL - Tests take 15-30 minutes):**
0057 ```bash
0058 export LD_LIBRARY_PATH=$PWD/install/lib:$LD_LIBRARY_PATH
0059 export JANA_PLUGIN_PATH=$PWD/install/lib/EICrecon/plugins${JANA_PLUGIN_PATH:+:${JANA_PLUGIN_PATH}}
0060 ctest --test-dir build -V
0061 ```
0062
0063 ### Manual Validation Scenarios
0064
0065 **ALWAYS perform these validation steps after making changes:**
0066
0067 1. **Basic executable test:**
0068 ```bash
0069 eicrecon --version
0070 eicrecon --configs
0071 ```
0072
0073 2. **Plugin validation:**
0074 ```bash
0075 eicrecon -L # List factories
0076 ```
0077
0078 3. **Environment validation:**
0079 ```bash
0080 echo $JANA_PLUGIN_PATH
0081 echo $LD_LIBRARY_PATH
0082 ldd install/lib/EICrecon/plugins/*.so | grep -v "not found" || echo "Missing dependencies detected"
0083 ```
0084
0085 ### Build Configurations and Sanitizers
0086
0087 **Available build options (use in cmake configure step):**
0088 - `-DCMAKE_BUILD_TYPE=Release` (default, fastest)
0089 - `-DCMAKE_BUILD_TYPE=Debug` (for debugging)
0090 - `-DUSE_ASAN=ON` (Address Sanitizer)
0091 - `-DUSE_TSAN=ON` (Thread Sanitizer - cannot combine with ASAN)
0092 - `-DUSE_UBSAN=ON` (Undefined Behavior Sanitizer)
0093
0094 **Example with sanitizers:**
0095 ```bash
0096 cmake -B build -S . -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Debug -DUSE_ASAN=ON -DUSE_UBSAN=ON
0097 ```
0098
0099 ### Development Workflow
0100
0101 **After making code changes:**
0102 ```bash
0103 # Rebuild (incremental build is faster)
0104 cmake --build build --target install -- -j8
0105
0106 # Run relevant tests
0107 ctest --test-dir build -V -R "specific_test_name"
0108
0109 # Test functionality
0110 source install/bin/eicrecon-this.sh
0111 eicrecon --help
0112 ```
0113
0114 **Before committing changes - ALWAYS run:**
0115 ```bash
0116 # These must pass or CI will fail
0117 cmake --build build --target install -- -j8
0118 ctest --test-dir build -V
0119 ```
0120
0121 ## Repository Structure and Navigation
0122
0123 ### Key Directories
0124 - `src/algorithms/` - Core physics algorithms
0125 - `src/factories/` - JANA factory implementations
0126 - `src/services/` - Service components
0127 - `src/tests/` - Unit and integration tests
0128 - `src/benchmarks/` - Performance benchmarks
0129 - `docs/` - Documentation and tutorials
0130 - `cmake/` - CMake configuration files
0131
0132 ### Important Test Suites
0133 - `src/tests/algorithms_test/` - Algorithm unit tests (uses Catch2)
0134 - `src/tests/omnifactory_test/` - Factory framework tests
0135
0136 ### Commonly Modified Files
0137 When making physics algorithm changes:
0138 1. Check `src/algorithms/` for the relevant algorithm
0139 2. Look for corresponding factory in `src/factories/`
0140 3. Check for tests in `src/tests/algorithms_test/`
0141 4. Update documentation in `docs/` if needed
0142
0143 ## Code Review Guidelines for Reproducibility
0144
0145 **When reviewing or writing code, pay special attention to:**
0146
0147 1. **Map iteration ordering:** Maps with pointer keys (e.g., `std::map<T*, V>`) produce iteration order that depends on memory allocation and can vary across runs with different thread counts. For maps that are iterated and whose iteration affects output, avoid pointer keys and instead use stable, non-pointer keys or an ordered container with an explicit comparator that does not depend on memory addresses. `std::unordered_map` is only appropriate when the map is not iterated in a way that affects output, and this should be verified.
0148
0149 2. **PODIO object keys:** Maps with PODIO objects (edm4hep, edm4eic) as keys use pointer-based default ordering. When iterating such maps, provide explicit ordering (e.g., by object ID or physics properties) to ensure reproducible results.
0150
0151 ## Timing Expectations and Critical Warnings
0152
0153 **NEVER CANCEL these operations - they are expected to take significant time:**
0154
0155 | Operation | Expected Time | Minimum Timeout |
0156 |-----------|---------------|-----------------|
0157 | Initial build | 30-60 minutes | 90 minutes |
0158 | Incremental build | 5-15 minutes | 30 minutes |
0159 | Full test suite | 15-30 minutes | 45 minutes |
0160 | Individual test | 1-5 minutes | 10 minutes |
0161 | Manual dependency build | 4-8 hours | Not recommended |
0162
0163 **Use appropriate timeouts for all long-running commands. The CI system uses ccache and parallel builds which can still take significant time.**
0164
0165 ## Common Issues and Solutions
0166
0167 **Build fails with missing dependencies:**
0168 - Ensure you're in eic-shell environment
0169 - Run `source /opt/detector/epic-main/bin/thisepic.sh`
0170 - Check CMake configuration output for specific missing packages
0171
0172 **Tests fail:**
0173 - Verify environment setup: `source install/bin/eicrecon-this.sh`
0174 - Check library paths are correct
0175 - Run individual failing tests for detailed output
0176
0177 ## Data Files and Physics Validation
0178
0179 **Physics reconstruction requires specific input data formats:**
0180 - Input: `.edm4hep.root` files (simulated physics events)
0181 - Output: `.edm4eic.root` files (reconstructed physics data)
0182
0183 **Sample reconstruction command:**
0184 ```bash
0185 export DETECTOR_CONFIG=${DETECTOR}_craterlake
0186 eicrecon -Ppodio:output_file=output.edm4eic.root input_simulation.edm4hep.root
0187 ```
0188
0189 For physics validation, you need appropriate simulation files. Generate one for single particles using:
0190
0191 ddsim --compactFile $DETECTOR_PATH/$DETECTOR_CONFIG.xml --numberOfEvents 10 --enableGun --gun.thetaMin 'pi/2' --gun.thetaMax 'pi/2' --gun.distribution uniform --gun.phiMin '0*deg' --gun.phiMax '0*deg' --gun.energy '1*GeV' --gun.particle 'e-' --outputFile sim.edm4hep.root
0192
0193 or using full physics events with multiple particles:
0194
0195 ddsim --compactFile $DETECTOR_PATH/$DETECTOR_CONFIG.xml --numberOfEvents 10 --inputFiles root://dtn-eic.jlab.org//volatile/eic/EPIC/EVGEN/DIS/NC/10x100/minQ2=10/pythia8NCDIS_10x100_minQ2=10_beamEffects_xAngle=-0.025_hiDiv_1.hepmc3.tree.root --outputFile sim.edm4hep.root
0196
0197
0198 ## Conventional Commits and Breaking Changes
0199
0200 ### Commit Message Format
0201
0202 It is acceptable to use [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/)
0203
0204 **Standard commit message format:**
0205 ```
0206 <type>[optional scope]: <description>
0207
0208 [optional body]
0209
0210 [optional footer(s)]
0211 ```
0212
0213 **Common commit types:**
0214 - `feat:` - New features
0215 - `fix:` - Bug fixes
0216 - `docs:` - Documentation changes
0217 - `style:` - Code style changes (formatting, etc.)
0218 - `refactor:` - Code refactoring without functional changes
0219 - `test:` - Adding or modifying tests
0220 - `chore:` - Maintenance tasks, build changes
0221 - `perf:` - Performance improvements
0222
0223 ### Breaking Changes in EICrecon Context
0224
0225 **CRITICAL: Use `BREAKING CHANGE:` footer or `!` suffix for any changes that affect user workflows.**
0226
0227 **Consider as breaking changes:**
0228
0229 1. **Command-line interface changes:**
0230 - Changes to argument parsing that affect existing scripts
0231 - Modifications to configuration parameter names or behavior
0232 - Changes to plugin loading syntax or requirements
0233
0234 2. **Output collection changes:**
0235 - Renaming of output collection names (e.g., `EcalBarrelClusters` → `ECALClusters`)
0236 - Removal of existing output collections that users depend on
0237 - Significant changes to collection content structure or data members
0238 - Changes to default output file naming conventions
0239
0240 **Non-breaking changes (safe to implement without `BREAKING CHANGE`):**
0241 - Algorithm improvements that produce better but compatible results
0242 - Addition of new optional command-line arguments
0243 - Addition of new output collections alongside existing ones
0244 - Performance optimizations that don't change interfaces
0245 - Internal refactoring that doesn't affect user-facing APIs