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

[DD4hep] Fix PPS simulation so physical volume names are recognized #32667

Merged
merged 1 commit into from Jan 14, 2021

Conversation

cvuosalo
Copy link
Contributor

In old DD, physical volume names have no prefix or suffix, but, with DD4hep, physical volume names are prefixed with the namespace and suffixed with the copy number. PPS code searches for specific physical volumes, and these searches were failing because of the additional prefix and suffix added by DD4hep. The solution is to search for a string that somewhere contains the base physical volume name, rather than requiring an exact match.

This PR fixes issue #32653. The exception described in the issue occurred because the intended physical volume was not found, resulting in an attempt to construct a nonsense DetId, which caused the exception. In addition to fixing the search for the volume, this PR changes the initialization of the data members used to create the DetId. These members had been initialized to -1, which was a poor choice since they were converted into unsigned ints for use in the DetId, which gave the maximum unsigned value instead of -1 and thus generated an exception. This PR changes the initialized values to 0, which will not generate an exception in the case that the physical volume cannot be found. Instead, this PR adds error messages to cover this case.

PR validation:

The sim step of DD4hep workflow 11642.911 was run to see the bug occur. After the code was fixed, the sim step was run again to see that it could successfully handle 50 events without the error occurring. Also, debug statements were checked to see that the fix was working.

No backport is planned.

@cvuosalo
Copy link
Contributor Author

FYI @forthommel @jan-kaspar @ianna @ghugo83

@cmsbuild
Copy link
Contributor

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-32667/20743

  • This PR adds an extra 12KB to repository

@cmsbuild
Copy link
Contributor

A new Pull Request was created by @cvuosalo (Carl Vuosalo) for master.

It involves the following packages:

SimG4CMS/PPS

@cmsbuild, @civanch, @mdhildreth can you please review it and eventually sign? Thanks.
@makortel, @rovere, @fabiocos, @slomeo this is something you requested to watch as well.
@silviodonato, @dpiparo, @qliphy you are the release manager for this.

cms-bot commands are listed here

@ianna
Copy link
Contributor

ianna commented Jan 14, 2021

please test

@cmsbuild
Copy link
Contributor

+1

Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-c06f50/12277/summary.html
COMMIT: 7ef37ed
CMSSW: CMSSW_11_3_X_2021-01-13-2300/slc7_amd64_gcc900

Comparison Summary

Summary:

  • No significant changes to the logs found
  • Reco comparison results: 8 differences found in the comparisons
  • DQMHistoTests: Total files compared: 37
  • DQMHistoTests: Total histograms compared: 2716967
  • DQMHistoTests: Total failures: 12
  • DQMHistoTests: Total nulls: 1
  • DQMHistoTests: Total successes: 2716932
  • DQMHistoTests: Total skipped: 22
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: -0.004 KiB( 36 files compared)
  • DQMHistoSizes: changed ( 312.0 ): -0.004 KiB MessageLogger/Warnings
  • Checked 156 log files, 37 edm output root files, 37 DQM output files

@davidlange6
Copy link
Contributor

do any of these codes get run in the event loop?

@civanch
Copy link
Contributor

civanch commented Jan 14, 2021

+1

I would guess none is run inside the event loop

@cmsbuild
Copy link
Contributor

This pull request is fully signed and it will be integrated in one of the next master IBs (tests are also fine). This pull request will now be reviewed by the release team before it's merged. @silviodonato, @dpiparo, @qliphy (and backports should be raised in the release meeting by the corresponding L2)

@qliphy
Copy link
Contributor

qliphy commented Jan 14, 2021

+1

@cmsbuild cmsbuild merged commit 17e3389 into cms-sw:master Jan 14, 2021
@cvuosalo
Copy link
Contributor Author

@jan-kaspar @ghugo83 I think those places in DetGeomDesc use the logical volume name that has already had the namespace stripped off, but it would be good if you would double-check that those lines of code are working correctly with DD4hep.

@cvuosalo
Copy link
Contributor Author

@davidlange6 @civanch The code changed in this PR is run during event simulation when there are hits in the corresponding PPS detectors. Simulation has to generate several events before one happens to create hits in the PPS detectors, so one can run DD4hep simulation on a few events without seeing the bugs fixed in this PR.

@davidlange6
Copy link
Contributor

davidlange6 commented Jan 14, 2021 via email

@cvuosalo
Copy link
Contributor Author

@davidlange6 SimG4CMS/PPS/src/PPSPixelOrganization.cc (line 42) already was using the contains string matching method prior to this PR. This string matching is not done for every event (otherwise the bug would have terminated simulation at event 1). It is only done for events that have hits in the PPS detectors.

If the contains method should not be used at all in simulation because of the performance cost, then that would be a task for the PPS simulation developers (@jan-kaspar @mundim) to optimize the code for better performance.

@davidlange6
Copy link
Contributor

davidlange6 commented Jan 14, 2021 via email

@cvuosalo
Copy link
Contributor Author

@ghugo83 Not only does the namespace have to be stripped off the physical volume name, but also the copy number, so that's why I used contains instead of noNameSpace.

@ghugo83
Copy link
Contributor

ghugo83 commented Jan 14, 2021

@cvuosalo Ok makes sense.

@jan-kaspar
Copy link
Contributor

jan-kaspar commented Jan 15, 2021 via email

@mundim
Copy link
Contributor

mundim commented Jan 15, 2021

@davidlange6 SimG4CMS/PPS/src/PPSPixelOrganization.cc (line 42) already was using the contains string matching method prior to this PR. This string matching is not done for every event (otherwise the bug would have terminated simulation at event 1). It is only done for events that have hits in the PPS detectors.

If the contains method should not be used at all in simulation because of the performance cost, then that would be a task for the PPS simulation developers (@jan-kaspar @mundim) to optimize the code for better performance.

Hi, Sorry for the delay, trying to catch up after vacations... So, this piece was introduced by the original developer (@fabferro ) or by the former ones because in some PPS sensors, due to the way the sensitive volumes where designed, there were hits almost everywhere in the PPS region. If this is a problem, I'm afraid we will have to go deeper in debugging the geometry.

@mundim
Copy link
Contributor

mundim commented Jan 15, 2021

@ghugo83 Not only does the namespace have to be stripped off the physical volume name, but also the copy number, so that's why I used contains instead of noNameSpace.

Oh.. ok. thanks Carl.

@cvuosalo
Copy link
Contributor Author

@mundim I think the conclusion is that string comparisons should be minimized in the simulation code, especially in loops and other sections that are executed many times. If they are essential, then they have to be kept. PPS developers can evaluate whether any changes need to be made.

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

Successfully merging this pull request may close these issues.

None yet

9 participants