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
PPS: code to copy-without-children moved from copy constructor to a named method #31492
Conversation
The code-checks are being triggered in jenkins. |
FYI @forthommel @ghugo83 |
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-31492/18428
|
A new Pull Request was created by @jan-kaspar for master. It involves the following packages: Geometry/VeryForwardGeometryBuilder @civanch, @Dr15Jones, @makortel, @cvuosalo, @ianna, @mdhildreth, @cmsbuild can you please review it and eventually sign? Thanks. cms-bot commands are listed here |
virtual ~DetGeomDesc(); | ||
|
||
DetGeomDesc* makeCopyWithoutChildren() const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be made to return std::unique_ptr<DetGeomDesc>
to make it explicit that the caller gets the ownership?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a return by value would work as well. If so, that is better than returning by pointer or unique_ptr.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current code works with pointers:
using Container = std::vector<DetGeomDesc*>; |
DetGeomDesc* alignedDetRoot = idealDetRoot.makeCopyWithoutChildren(); |
thus I proposed a function returning a pointer. Switching to unique_ptr is trivial. Let me know what your suggestion is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One option would be to add a (private) constructor that takes all
cmssw/Geometry/VeryForwardGeometryBuilder/src/DetGeomDesc.cc
Lines 65 to 76 in 0e26c4a
output->m_name = m_name; | |
output->m_copy = m_copy; | |
output->m_isDD4hep = m_isDD4hep; | |
output->m_trans = m_trans; | |
output->m_rot = m_rot; | |
output->m_params = m_params; | |
output->m_isABox = m_isABox; | |
output->m_diamondBoxParams = m_diamondBoxParams; | |
output->m_sensorType = m_sensorType; | |
output->m_geographicalID = m_geographicalID; | |
output->m_z = m_z; |
as parameters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking it might be better to remove makCopyWithoutChildren
and create a constructor that takes a DetGeomDesc const&
and a 'dummy' enum with the only value noChildren
. Then the calling code would become
DetGeomDesc* alignedDetRoot = new DetGeomDesc(idealDetRoot, DetGeomDesc::noChildren);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Dr15Jones Yes exactly
+10000
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many thanks for all the suggestions! I also like this one. I will give it a try tomorrow.
@@ -53,15 +53,17 @@ class DetGeomDesc { | |||
using RotationMatrix = ROOT::Math::Rotation3D; | |||
using Translation = ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double>>; | |||
|
|||
DetGeomDesc() = default; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why adding the default constructor?
A DetGeomDesc built with this, will not have interesting data members, and no way of setting them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A way of creating an "empty" object is needed here:
https://github.com/cms-sw/cmssw/pull/31492/files/0e26c4a0f7658a37176349a8e446492503cdf81c#diff-cae30eec6c3de96aa4e668edf94cf7a8R62
Would you have a better suggestion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make it private?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there should just be a custom copy constructor.
This in a sense is just 'trying to have' a constructor, with settings done in makeCopyWithoutChildren()
m_geographicalID = ref.m_geographicalID; | ||
m_z = ref.m_z; | ||
return (*this); | ||
DetGeomDesc* DetGeomDesc::makeCopyWithoutChildren() const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes the renaming is a good idea
The code-checks are being triggered in jenkins. |
4e4ac6d implements Dr15Jones 's suggestion #31492 (comment) |
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-31492/18455
|
Pull request #31492 was updated. @civanch, @Dr15Jones, @makortel, @cvuosalo, @ianna, @mdhildreth, @cmsbuild can you please check and sign again. |
please test |
The tests are being triggered in jenkins.
|
+1 |
Comparison job queued. |
Comparison is ready Comparison Summary:
|
+1 |
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) |
+1 |
PR description:
This is a technical PR to address issue #25434. The code to perform a shall copy (without children) is moved from copy constructor to a named method to avoid misunderstandings.
No change in results is expected due to this PR.
PR validation:
The two plots below (top for "direct" simu, bottom for reco) document that there is indeed no change due to this PR.