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

feat: convert several DDRec constructors to use const Detector& #1148

Merged
merged 4 commits into from
Oct 19, 2023

Conversation

wdconinc
Copy link
Contributor

This started as an attempt to use a CellIDPositionConverter in a class that only has access to a const Detector&, but then turned in to figuring out a few other constructors where we can add const-ness.

The main hurdle is addressed in 4c26c03, where the former approach was returning the map entry m_detectorTypes[type] whenever type is not a valid key, creating a new entry in the process. This doesn't work when const.

I changed this to adding an empty key entry when m_detectorTypes is first filled, m_detectorTypes[""] = {}, and this one can be returned when type is not a valid key, without violating const-ness.

Potential implications

If a sensitive detector doesn't specify a type, then type() returns "" too,

string DetElement::type() const {
  return m_element ? m_element->GetTitle() : "";
}

There doesn't seem to be any guards (that I could find) against someone defining a sensitive detector with an empty string as type. Feedback welcome. I'm filing this as draft first.

BEGINRELEASENOTES

  • Allow several DDRec c'tors to work on const Detector& instead of Detector&

ENDRELEASENOTES

@github-actions
Copy link

Test Results

       6 files         6 suites   7h 35m 42s ⏱️
   358 tests    358 ✔️ 0 💤 0
1 058 runs  1 058 ✔️ 0 💤 0

Results for commit 1ae088d.

github-merge-queue bot pushed a commit to eic/EICrecon that referenced this pull request Oct 5, 2023
… const pointers (#1045)

### Briefly, what does this PR introduce?
While looking into #1032, #1035, #1036 I started realizing two things:
- cell ID position converters are created by algorithms from geometry
instead of doing this once in the service,
- there is no const protection in the detector pointers passed to
algorithms (i.e. an algorithm could change geometry),
- there is no protection against null pointers being passed from
geometry.

The first two points are related since the interface for creating a cell
ID position converter requires a non-const detector (see also
AIDASoft/DD4hep#1148).

This PR centralizes the creation of cell ID position converters,
clarifies ownership through unique_ptrs, and makes sure no null pointers
are passed to the algorithms. In places where the constructor gets the
const not_null pointer, we can also impose this in the class on the
relevant member variable.

### What kind of change does this PR introduce?
- [x] Bug fix (issue: avoid creation of cell ID position converters in
algorithms)
- [ ] New feature (issue #__)
- [ ] Documentation update
- [ ] Other: __

### Please check if this PR fulfills the following:
- [ ] Tests for the changes have been added
- [ ] Documentation has been added / updated
- [x] Changes have been communicated to collaborators:
  - @simonge reordered MatrixTransferStatic init arguments
  - @c-dilks @chchatte92 this also affects RichGeo_service etc.

### Does this PR introduce breaking changes? What changes might users
need to make to their code?
Yes, now requires GSL (which has always been in eic-shell and is a
requirement).

### Does this PR change default behavior?
No.

---------

Co-authored-by: Christopher Dilks <[email protected]>
Co-authored-by: Dmitry Kalinkin <[email protected]>
@MarkusFrankATcernch
Copy link
Contributor

@wdconinc Wouter, can we merge this PR ?

@wdconinc
Copy link
Contributor Author

Ah, yeah, I didn't realize this was marked as draft still.

@andresailer andresailer marked this pull request as ready for review October 19, 2023 14:02
@andresailer andresailer merged commit f6d10f9 into AIDASoft:master Oct 19, 2023
13 checks passed
@wdconinc wdconinc deleted the ddrec-const-detector branch October 19, 2023 14:03
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.

3 participants