key4hep / k4FWCore

Core Components for the Gaudi-based Key4hep Framework
Apache License 2.0
10 stars 26 forks source link

Does the `IOSvc` support pasing `std::vector<T>` via the TES? #238

Open tmadlener opened 1 month ago

tmadlener commented 1 month ago

I just stumbled over this question while looking at some tracking code. EDM4hep has the TrackerHit interface, which means that there is no TrackerHitCollection. Hence, if I want to move a heterogenous collection of TrackerHitPlane and TrackerHit3D around between algorithms, I have to do it via std::vector<TrackerHitPlane>. Is this possible at the moment?

m-fila commented 1 month ago

Not with k4FWCore:: functional algorithms as they require collections or std::vectors of collections

Gaudi::Functional algorithms with std::vector<TrackerHit> give compilation error from a template about AnyDataWrapper<std::vector<TrackerHit>>. Non-interface types give no error

tmadlener commented 1 month ago

Interesting. What does the compiler complain about in that case? I would have (naively) expected that interface types and non-interface types behave the same in this regard.

m-fila commented 1 month ago

The interface types have templated constructor and for some reason it's AnyDataWrapper wants to construct TrackerHit with vector<TrackerHit> rather than use move constructor (I guess) for the vector

tmadlener commented 1 month ago

Ah. I didn't foresee that. This constructor here would probably have to use some std::enable_if instead of a (late) static_assert

https://github.com/AIDASoft/podio/blob/64e87e153e8217375a167123d3567a765935333a/python/templates/Interface.h.jinja2#L92-L96

That should take care of matching a wrong constructor. We might have to add a default constructor as well.

m-fila commented 1 month ago

Yes, see linked PR 😁 aidasoft/podio#683

giovannimarchiori commented 1 month ago

I don't know if my problem is related to this issue, the title made me think so but the topic being discussed is different. I cannot pass to k4run the input files to process via --IOSvc.input blah.root. On the other hand IOSvc.output foo.root works like a charm. The difference between the two is that output is a string property while input is a vector property, so the problem seems to be in IOSvc parsing of vector<..>. Is there a special syntax to be used in the CLI that I am unaware of or is it a parsing problem in IOSvc?

m-fila commented 1 month ago

This is valid but different issue. Opened #241