---
options :
  # should getters / setters be prefixed with get / set?
  getSyntax: False
  # should POD members be exposed with getters/setters in classes that have them as members?
  exposePODMembers: False
  includeSubfolder: True

components:

  dd4pod::VectorXYZ:
    Members:
      - double x          // [mm] or [GeV]
      - double y          //
      - double z          //
    ExtraCode:
      includes: "#include <cmath>\n#include<tuple>"
      declaration: "
        VectorXYZ() : x{0}, y{0}, z{0} {}\n
        VectorXYZ(double xx, double yy, double zz) : x{xx}, y{yy}, z{zz} {}\n
        double& operator[](unsigned i) {return *(&x + i);}\n
        const double& operator[](unsigned i) const {return *(&x + i);}\n
        double mag() const {return std::hypot(x, y, z);}\n
        double r() const {return mag();}\n
        double theta() const {return acos(z/mag());}\n
        double phi() const {return atan2(y,x);}\n
        double eta() const {return -log(tan(0.5*theta()));}\n
        operator std::tuple<double, double, double>() {return {x, y, z};}\n
        double dot(const VectorXYZ& rhs) const {return x*rhs.x + y*rhs.y + z*rhs.z;}\n
        VectorXYZ add(const VectorXYZ& rhs) const {return {x+rhs.x, y+rhs.y, z+rhs.z};}\n
        VectorXYZ subtract(const VectorXYZ& rhs) const {return {x-rhs.x, y-rhs.y, z-rhs.z};}\n
        VectorXYZ scale(double f) const {return {f*x, f*y, f*z};}\n
      "

  dd4pod::MonteCarloContrib:
    Members:
      - int32_t   trackID // track id, -1 if none/invalid. Maps to Geant4Particle::ID.
      - int32_t   pdgID   // PDG Particle ID code 
      - double    deposit // energy deposit [GeV]
      - double    time    // time [ns]
      - double    length  // length [mm]
      - float     x       // x position [mm]
      - float     y       // y position [mm]
      - float     z       // z position [mm]
    ExtraCode:
      includes: "#include <cmath>"
      declaration: "
        MonteCarloContrib() : trackID{-1}, pdgID{0}, deposit{0}, time{0}, x{0}, y{0}, z{0} {}\n
        MonteCarloContrib(int32_t id, int32_t pdg, double e, double t,\n
                          double l, double xx, double yy, double zz)\n
            : trackID{id}, pdgID{pdg}, deposit{e}, time{t}, length{l}\n
            , x{static_cast<float>(xx)}, y{static_cast<float>(yy)}, z{static_cast<float>(zz)} {}\n
        double mag() const {return std::hypot(x, y, z);}\n
        double r() const {return mag();}\n
        double theta() const {return acos(z/mag());}\n
        double phi() const {return atan2(y,x);}\n
        double eta() const {return -log(tan(0.5*theta()));}
        bool valid() const {return trackID >= 0;}\n
        bool empty() const {return trackID < 0;}\n
      "

datatypes:

  dd4pod::Geant4Particle:
    Description: "Podio implementation of dd4hep's dd4hep::sim::Geant4Particle class"
    Author : "W. Armstrong, S. Joosten"
    Members:
      - int32_t                   ID                // unique identifier for this particle
      - int32_t                   g4Parent          // g4 parent particle
      - int32_t                   reason            // TODO document
      - int32_t                   mask              // TODO document
      - int32_t                   steps             // TODO document
      - int32_t                   secondaries       // TODO document
      - int32_t                   pdgID             // TODO document
      - int32_t                   status            // TODO document
      - std::array<int,2>         colorFlow         // TODO document
      - int32_t                   genStatus         // Generator status code
      - int32_t                   charge            // Particle charge
      - int32_t                   _spare            // extra int to have doubles properly aligned at 8 bytes
      - std::array<float,3>       spin              // Particle spin state
      - dd4pod::VectorXYZ         vs                // Start vertex [mm]
      - dd4pod::VectorXYZ         ve                // End vertex [mm]
      - dd4pod::VectorXYZ         ps                // 3-momentum at start vertex [GeV]
      - dd4pod::VectorXYZ         pe                // 3-momentum at end vertex [GeV]
      - double                    mass              // particle mass [GeV]
      - double                    time              // start vertex time [ns]
      - double                    properTime        // proper time
    VectorMembers:
      - int32_t                   parents           // parent IDs
      - int32_t                   daughters         // daughter IDs
    ConstExtraCode :
      declaration: "
        double px() const {return ps().x;}\n
        double py() const {return ps().y;}\n
        double pz() const {return ps().z;}\n
        double energy() const {return std::hypot(ps().mag(), mass());}
      "

  dd4pod::PhotoMultiplierHit:
    Description: "Podio implementation of a pmt hit "
    Author : "W. Armstrong, S. Joosten"
    Members:
      - int64_t                   cellID            // cellID
      - int32_t                   flag              // User flag to classify hits
      - int32_t                   g4ID              // Original Geant4 track identifier of the creating track (for debugging)
      - dd4pod::VectorXYZ         position          // hit position [mm]
      - dd4pod::VectorXYZ         momentum          // 3-momentum [GeV]
      - double                    length            // length [mm]
      - dd4pod::MonteCarloContrib truth             // truth info
      - double                    energy            // photon energy [GeV]

  dd4pod::TrackerHit:
    Description: "Podio implementation of dd4hep's dd4hep::sim::Geant4Tracker::Hit class"
    Author : "W. Armstrong, S. Joosten"
    Members:
      - int64_t                   cellID            // cellID
      - int32_t                   flag              // User flag to classify hits
      - int32_t                   g4ID              // Original Geant4 track identifier of the creating track (debugging)
      - dd4pod::VectorXYZ         position          // position [mm]
      - dd4pod::VectorXYZ         momentum          // 3-momentum [GeV]
      - double                    length            // length [mm]
      - dd4pod::MonteCarloContrib truth             // truth info
      - double                    energyDeposit     // energy deposit [GeV]

  dd4pod::CalorimeterHit:
    Description: "Podio implementation of dd4hep's dd4hep::sim::Geant4Calorimeter::Hit class"
    Author : "W. Armstrong, S. Joosten"
    Members:
      - int64_t                   cellID            // cellID 
      - int32_t                   flag              // User flag to classify hits
      - int32_t                   g4ID              // Original Geant4 track identifier of the creating track (debugging)
      - dd4pod::VectorXYZ         position          // position [mm]
      - dd4pod::MonteCarloContrib truth             // truth-info of one of the contributing hits
      - double                    energyDeposit     // energy deposit [GeV]
    VectorMembers:
      - dd4pod::MonteCarloContrib contributions     // All contributing hits. Not filled by default.

