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

Fix DetElementCreator plugin #1138

Merged
merged 3 commits into from Jun 23, 2023

Conversation

tmadlener
Copy link
Contributor

@tmadlener tmadlener commented Jun 23, 2023

BEGINRELEASENOTES

  • Make the default return value of DetElementCreator::process non-zero to avoid erroneously raising an exception after finishing.
  • Add a test case that checks that things work

ENDRELEASENOTES

I am not entirely sure if the DDDB examples were turned off on purpose, there seem to be quite some test failures in there. It might be easier to move the new test case to somewhere else, I just put it into DDDB because it comes with a compact file that uses the DetElementCreator plugin. I can also move all the "noise" into a separate PR, so that this only contains what is really necessary.

The issue that is fixed by this

Without the (one line) fix, I run into the following issue:

[...]
RunPlugin        ERROR ++ Exception while executing plugin DD4hep_CompactLoader:
		dd4hep: apply-plugin: Failed to execute plugin DD4hep_PlacedVolumeProcessor
dd4hep: with plugin:DD4hep_PlacedVolumeProcessor
dd4hep: Error interpreting XML nodes of type <plugin/>
dd4hep: Error interpreting XML nodes of type <plugins/>
dd4hep: while parsing compact.xml
dd4hep: with plugin:DD4hep_CompactLoader
Application      ERROR geoPluginRun: Uncaught exception: RunPlugin: ++ Exception while executing plugin DD4hep_CompactLoader:
		dd4hep: apply-plugin: Failed to execute plugin DD4hep_PlacedVolumeProcessor
dd4hep: with plugin:DD4hep_PlacedVolumeProcessor
dd4hep: Error interpreting XML nodes of type <plugin/>
dd4hep: Error interpreting XML nodes of type <plugins/>
dd4hep: while parsing compact.xml
dd4hep: with plugin:DD4hep_CompactLoader

The exception is raised here:

result = *(long*) result;
if (result != 1) {
throw runtime_error("dd4hep: apply-plugin: Failed to execute plugin " + fac);
}

The return value in turn is set here:

DetElement det = detail::tools::findElement(description, path);
if ( det.isValid() ) {
pv = det.placement();
if ( pv.isValid() ) {
return PlacedVolumeScanner().scanPlacements(*proc, pv, 0, recursive) > 0 ? 1 : 0;
}

Which finally calls PlacedVolumeManager::process

ret += process(placement,level+1,recursive);

The process that is called in this case is DetElementCreator::process. One of the paths through this looks like this

int DetElementCreator::process(PlacedVolume pv, int lvl, bool recursive) {
int ret = 0;
string pv_nam = pv.name();
if ( detector_volume_level > 0 ||
( (!detector_volume_match.empty() &&
pv_nam.find(detector_volume_match) != string::npos) &&
(detector_volume_veto.empty() ||
pv_nam.find(detector_volume_veto) == string::npos) ) )
{
stack.emplace_back(Data(pv));
if ( 0 == detector_volume_level ) {
detector_volume_level = stack.size();
createTopLevelDetectors(pv);
}
ret = PlacedVolumeProcessor::process(pv,lvl,recursive);

the other looks like this

else if ( lvl < max_volume_level ) {
//printout(printLevel, "", "+++ Skip volume %s", pv_nam.c_str());
ret = PlacedVolumeProcessor::process(pv,lvl,recursive);
}
return ret;

If I am not mistaken, this means that even if the DetElementCreator does nothing (i.e. automatic success?), it still returns 0. That at some point signals failure to the machinery. Hence, changing the default return value to 1, would fix this. I am not entirely sure about all the assumptions in this, but this would fix things for me.

@MarkusFrankATcernch
Copy link
Contributor

@tmadlener Did you re-enable DDDB ?
I thought DDDB was not built anymore.
It is entirely obsolete.

@tmadlener
Copy link
Contributor Author

Ah, I wasn't aware of that. I will then move "my" test to somewhere non-obsolete. Any immediate suggestions for that?

@MarkusFrankATcernch
Copy link
Contributor

The generic container for all tests which are not really logically connected is "ClientTests".

Fixes the errenous(?) raising of an exception after the plugin has run
successfully
@tmadlener
Copy link
Contributor Author

I moved the compact and necessary input file to ClientTests and added the test there. I also removed the previous changes to DDDB and also disabled DD4HEP_BUILD_DEBUG again for CI.

@tmadlener
Copy link
Contributor Author

@github-actions
Copy link

Test Results

       6 files         6 suites   6h 16m 16s ⏱️
   349 tests    349 ✔️ 0 💤 0
1 037 runs  1 037 ✔️ 0 💤 0

Results for commit c78e087.

@MarkusFrankATcernch MarkusFrankATcernch enabled auto-merge (rebase) June 23, 2023 14:05
@MarkusFrankATcernch MarkusFrankATcernch merged commit f42ed10 into AIDASoft:master Jun 23, 2023
13 of 14 checks passed
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.

None yet

2 participants