apt-sim/AdePT

Improve organization of AdePT headers/implementation

Closed this issue · 5 comments

At present, the AdePT "library" code is a bit scattered around the repo, with directories:

<root>/
  - base/
    - inc/
      - AdePT/
        - *.h 
      - CopCore/  
  - magneticfield
    - inc
      - *.h
  - physics
    - processes
      - inc  
  - tracking
    - inc

Since these are mixed in with other directories for examples, tests, infrastructure, it's a little awkward to parse and find what 's needed. The additional inc dirs also result in declaration of header paths in the build and in code that can be unclear (just the file name rather than a project name qualified path). To simplify things and make it clearer where new developments can go, I'd suggest we move the following organization:

<root>/
  - CopCore/
  - AdePT/
    - base/
      - *.h
    - magneticfield/
      - *.h
    - physics/
    - tracking/

Since we're header-only at the moment we can worry about where C++/CUDA implementation files go later.

Thoughts?

+1 on the issue and I'm in favor of moving to a better structure. Are you going to add the AdePT top-level directory to the include path? (so includes get magneticfield/fieldPropagatorConstBz.h) If not, what do we need it for?

Yes, the AdePT target as implemented in #88 would become:

add_library(AdePT INTERFACE)
target_include_directories(AdePT INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
...

Code using an AdePT header would then #include as, e.g., #include <AdePT/magneticfield/fieldPropagatorConstBz.h". This is purely organizational so that #includes are the same in AdePT as in client code, and to maximise separation of directories. If you ls in the AdePT root directory, it shows

AUTHORS.md  cmake           CODE_OF_CONDUCT.md  CTestConfig.cmake  external  Jenkinsfile  LICENSES       physics    test
base        CMakeLists.txt  CONTRIBUTING.md     examples           jenkins   LICENSE      magneticfield  README.md  tracking

so library code, test code, example code, licences, jenkins etc directories are all at the same level. Moving the AdePT library code under a directory of the same name just makes navigation and intent easier to see.

Then I think I would prefer to have it in another include/ top-level directory with AdePT living below it. IMHO it's a misconception to add directories to the include paths that have files that should not be in there.

EDIT: Basically the same as CopCore has it, not sure why that needs to live in base/inc/ instead of just base/.

Yep, that's a good point, and making that "top level" include/AdePT puts the structure in line with CopCore (having that at top level should be fine in this sense as it's strictly a subproject).

The structure is fine for the first prototype.