2. C++ file usually has `createDetector(...)` function and `DECLARE_DETELEMENT` macro which binds the function to the name used in xml `<detector>` type attribute. C++ code looks like this:
3. How DD4Hep finds and loads compiled components?
> This is going into technical details which users usually don't need. Installation paths and environment variables are set by container/spack and should work out of the box.
DD4Hep uses modular plugin mechanism to load C++ code. When athena C++ is compiled, two files are created:
- `athena.components` - a text file stating what components one can find in athena.so. From our example, there will be a record like `v2:libathena.so:athena_DRICH` among other records.
- `libathena.so` - compiled C++ library with all detectors from athena repo
So when the type of the detector is given, like `athena_DRICH`. DD4Hep uses `LD_LIBRARY_PATH` to look through .components files and then figures out what .so file to load to get the correct C++ code executed.