Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use types of heterogeneous origins in interfaces #611

Closed
BrieucF opened this issue May 30, 2024 · 6 comments · Fixed by #714
Closed

Use types of heterogeneous origins in interfaces #611

BrieucF opened this issue May 30, 2024 · 6 comments · Fixed by #714

Comments

@BrieucF
Copy link

BrieucF commented May 30, 2024

  • OS version: Alma9
  • Environment: source /cvmfs/sw-nightlies.hsf.org/key4hep/setup.sh -r 2024-05-30
  • Goal: add an interface which includes types of heterogeneous origins (edm4hep and an extension):

This:

interfaces:
  extension::TrackerHit:
    Description: "Tracker hit interface class"
    Author: "Thomas Madlener, DESY"
    Members:
      - uint64_t cellID // ID of the sensor that created this hit
      - int32_t type // type of the raw data hit
      - int32_t quality // quality bit flag of the hit
      - float time [ns] // time of the hit
      - float eDep [GeV] // energy deposited on the hit
      - float eDepError [GeV] // error measured on eDep
      - edm4hep::Vector3d position [mm] // hit position
    Types:
      - edm4hep::TrackerHitPlane
      - edm4hep::TrackerHit3D
      - extension::DriftChamberDigi

Crashes with

/afs/cern.ch/user/b/brfranco/work/public/tracketHitInterface_drift_chamber/k4RecTracker/build/DCHdigi/src/TrackCollection.cc:12:10: fatal error: extension/TrackerHit3DCollection.h: No such file or directory
   12 | #include "extension/TrackerHit3DCollection.h"

There is a workaround which is to redefine those types in the extensions and use

interfaces:
  extension::TrackerHit:
    Description: "Tracker hit interface class"
    Author: "Thomas Madlener, DESY"
    Members:
      - uint64_t cellID // ID of the sensor that created this hit
      - int32_t type // type of the raw data hit
      - int32_t quality // quality bit flag of the hit
      - float time [ns] // time of the hit
      - float eDep [GeV] // energy deposited on the hit
      - float eDepError [GeV] // error measured on eDep
      - edm4hep::Vector3d position [mm] // hit position
    Types:
      - extension::TrackerHitPlane
      - extension::TrackerHit3D
      - extension::DriftChamberDigi
@tmadlener
Copy link
Collaborator

I can't reproduce the exact error you see (i.e. missing include). However, there is indeed a somewhat conceptual issue here. The main issue is that types that are used in interface declare that interface as friend, such that the interface can access its internals.

Since we can't change the headers of the upstream models, we will have to find another solution to this.

@m-fila
Copy link
Contributor

m-fila commented May 30, 2024

I think it would be another problem if a model and upstream used different getSyntax

@tmadlener
Copy link
Collaborator

That is true. However, I would say that that is something that needs to be documented, and I think that it would be a very niche use case to mix datamodels with different getSyntax values.

@m-fila
Copy link
Contributor

m-fila commented Nov 22, 2024

I can't reproduce the exact error you see (i.e. missing include). However, there is indeed a somewhat conceptual issue here. The main issue is that types that are used in interface declare that interface as friend, such that the interface can access its internals.

Did I miss something or the interfaces need access to object internals only for operator< that is done by comparing internal pointers?

@tmadlener
Copy link
Collaborator

tmadlener commented Nov 22, 2024

At least initially, they also needed it for setReferences. But that might have changed with #673. I haven't actually checked, whether that changes something.

@m-fila
Copy link
Contributor

m-fila commented Nov 22, 2024

Thanks, I'll take a look and maybe propose something

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants