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

Add support for running with IOSvc #216

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open

Add support for running with IOSvc #216

wants to merge 27 commits into from

Conversation

jmcarcell
Copy link
Member

@jmcarcell jmcarcell commented Jan 14, 2025

BEGINRELEASENOTES

  • Add support for running the wrapper with IOSvc with a few tests:
    • Run the CLIC reconstruction with IOSvc
    • Run global_converter_maps with IOSvc, where a functional algorithm produces some output that is used by a Marlin processor and the output of the two is used by a Gaudi::Algorithm.
    • Run test_link_conversion_edm4hep with IOSvc, where links produced by functional algorithms are checked by Marlin processors.

ENDRELEASENOTES

Fix #202

k4MarlinWrapper/src/components/Lcio2EDM4hep.cpp Outdated Show resolved Hide resolved
k4MarlinWrapper/src/components/Lcio2EDM4hep.cpp Outdated Show resolved Hide resolved
k4MarlinWrapper/src/components/EDM4hep2Lcio.cpp Outdated Show resolved Hide resolved
k4MarlinWrapper/src/components/EDM4hep2Lcio.cpp Outdated Show resolved Hide resolved
for (const auto& pidCollMeta : pidCollections) {
const auto algoId = attachParticleIDMetaData(lcio_event, edmEvent, pidCollMeta);
auto algoId = attachParticleIDMetaData(lcio_event, edmEvent.value(), pidCollMeta);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this also needs a similar treatment as convertObjectParameters in k4EDM4hep2LcioConv? That would make it possible to simplify the code below a bit, but I am not sure if it's worth the effort.

@andresailer andresailer self-requested a review January 28, 2025 08:50
k4MarlinWrapper/CMakeLists.txt Show resolved Hide resolved
k4MarlinWrapper/k4MarlinWrapper/converters/EDM4hep2Lcio.h Outdated Show resolved Hide resolved
@@ -64,6 +67,9 @@ class EDM4hep2LcioTool : public AlgTool, virtual public IEDMConverter {

PodioDataSvc* m_podioDataSvc;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we have a one line description for each service under what circumstances which service is used?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like the ones I added?

Comment on lines 42 to 49
if (!root) {
thisClass->error() << "Failed to retrieve root object /Event" << endmsg;
}

auto pObj = root->registry();
if (!pObj) {
thisClass->error() << "Failed to retrieve the root registry object" << endmsg;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we exit early here, or throw an exception to avoid running into a seg-fault? Or does error() already do that in this case?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, error() doesn't, however I don't know if there are any circumstances under which error() will run. The same code can be found in the Writer from k4FWCore and I have never seen it happening. I can add one throw if you really want, but then all the checks in that function should also have a throw.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does a fatal throw or abort execution? The main potential issue I see here is that if these checks fail we will have a nullptr access and a segfault, and depending on if / when stdout / stderr has last been flushed we may or may not see the error message. If there are no visible error messages in case things fail, these checks are almost useless, I think. Obviously, if the messages are guaranteed to be there even in case of a seg fault, then there is at least some information where things went wrong.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fatal doesn't abort. endmsg writes the message so there should always be some information and it would happen right before the crash. As I said, I've never seen this fail because I think if it's in a state where that would fail something else will fail much earlier, like not being able to find /Event in the store. I'll just add the 3 or 4 throws since it's easier than continuing this conversation.

k4MarlinWrapper/src/components/Lcio2EDM4hep.cpp Outdated Show resolved Hide resolved
@jmcarcell
Copy link
Member Author

I just realised I made a mistake and key4hep/k4EDM4hep2LcioConv#102 is not needed, so it can be reverted. key4hep/k4EDM4hep2LcioConv#102 was needed before because I was incorrectly writing the event parameters to the metadata frame. I discovered a limitation (added in a warning) of the current implementation: when running Marlin processors with IOSvc without any input file, it's not possible to convert event parameters to EDM4hep as the frame that will be written doesn't exist yet; it will be created later by the Writer: https://github.com/key4hep/k4FWCore/blob/main/k4FWCore/components/Writer.cpp#L200.

@tmadlener
Copy link
Contributor

when running Marlin processors with IOSvc without any input file, it's not possible to convert event parameters to EDM4hep as the frame that will be written doesn't exist yet; it will be created later by the Writer:

This is mainly (only?) relevant for the LCIO to EDM4hep direction, right? As far as I can tell, the tests are unchanged apart from the additional infrastructure to switch between IOSvc and PodioDataSvc. In that case I would say this is OK for now and we check again in the future if someone runs into problems with this.

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 this pull request may close these issues.

Converters do not work with IOSvc
3 participants