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

PPS: code to copy-without-children moved from copy constructor to a named method #31492

Merged
merged 2 commits into from Sep 22, 2020

Conversation

jan-kaspar
Copy link
Contributor

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.

dirsim_cmp
reco_cmp

@cmsbuild
Copy link
Contributor

The code-checks are being triggered in jenkins.

@jan-kaspar
Copy link
Contributor Author

FYI @forthommel @ghugo83

@cmsbuild
Copy link
Contributor

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-31492/18428

@cmsbuild
Copy link
Contributor

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.
@forthommel, @fabiocos 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

virtual ~DetGeomDesc();

DetGeomDesc* makeCopyWithoutChildren() const;
Copy link
Contributor

@makortel makortel Sep 17, 2020

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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

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.

Copy link
Contributor

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);

Copy link
Contributor

Choose a reason for hiding this comment

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

@Dr15Jones Yes exactly
+10000

Copy link
Contributor Author

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;
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

Make it private?

Copy link
Contributor

@ghugo83 ghugo83 Sep 17, 2020

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 {
Copy link
Contributor

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

@cmsbuild
Copy link
Contributor

The code-checks are being triggered in jenkins.

@jan-kaspar
Copy link
Contributor Author

4e4ac6d implements Dr15Jones 's suggestion #31492 (comment)

@cmsbuild
Copy link
Contributor

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-31492/18455

@cmsbuild
Copy link
Contributor

Pull request #31492 was updated. @civanch, @Dr15Jones, @makortel, @cvuosalo, @ianna, @mdhildreth, @cmsbuild can you please check and sign again.

@civanch
Copy link
Contributor

civanch commented Sep 18, 2020

please test

@cmsbuild
Copy link
Contributor

cmsbuild commented Sep 18, 2020

The tests are being triggered in jenkins.

@cmsbuild
Copy link
Contributor

+1
Tested at: 4e4ac6d
https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-f53611/9421/summary.html
CMSSW: CMSSW_11_2_X_2020-09-17-2300
SCRAM_ARCH: slc7_amd64_gcc820

@cmsbuild
Copy link
Contributor

Comparison job queued.

@cmsbuild
Copy link
Contributor

Comparison is ready
https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-f53611/9421/summary.html

Comparison Summary:

  • No significant changes to the logs found
  • Reco comparison results: 0 differences found in the comparisons
  • DQMHistoTests: Total files compared: 35
  • DQMHistoTests: Total histograms compared: 2540471
  • DQMHistoTests: Total failures: 1
  • DQMHistoTests: Total nulls: 0
  • DQMHistoTests: Total successes: 2540448
  • DQMHistoTests: Total skipped: 22
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: 0.0 KiB( 34 files compared)
  • Checked 149 log files, 22 edm output root files, 35 DQM output files

@cvuosalo
Copy link
Contributor

+1

@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 Sep 22, 2020

+1

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

8 participants