-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Properly use Copy(TObject &)
methods in hist
classes
#10942
Conversation
One should explicitly specify which method is used
They should not be used at all
Use nullptr, remove dummy ";"
It is always dangerous because of potential linking problems
Starting build on |
Build failed on ROOT-ubuntu18.04/nortcxxmod. Failing tests: |
Build failed on ROOT-performance-centos8-multicore/cxx17. Failing tests: |
Build failed on ROOT-ubuntu2004/python3. Failing tests: |
Build failed on windows10/cxx14. Failing tests: |
Build failed on ROOT-debian10-i386/soversion. Failing tests: |
Build failed on mac1015/cxx17. Failing tests: |
Build failed on mac11/cxx14. Failing tests: |
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 am not sure if the use of non-virtual Copy in the copy constructor of the histogram class is correct.
This PR will make a copy a TProfile to a TH1D possible which can have some side effects.
Example:
TProfile p("p","p",10,0,10);
p.Fill(0.5,10); p.Fill(0.5,20);
TH1D & h1 = p;
TH1D h2 = h1;
h2.Draw();
h1.SetLineColor(kRed);
h1.Draw("SAME");
This code works silently with this PR producing an histogram from a Profile but with wrong information (e.g. the bin error).
I don't see then the benefits of not using the virtual Copy in the copy constructor and assignment operator in the case of the histograms.
If one want to keep usage of virtual In my mind, current implementation of copy constructors with using of virtual |
Are you referring about a check that the final type of the source is the same final type pf the target, i.e. in this code below:
if |
Such check must be introduced in all Copy methods in all classes. |
I agree if one is able to call copy constructors only for the final classes and not for base ones. In the ROOT histogram design this is not the case, since we have classes as TProfile deriving from TH1D and not TH1. |
When calling virtual |
These classes are base for TProfile[,2D,3D] and copy constructor should not be used together with such classes. This is check if TProfile::Copy() method.
Starting build on |
Build failed on ROOT-ubuntu18.04/nortcxxmod. Failing tests: |
Build failed on ROOT-ubuntu2004/python3. Failing tests: |
Build failed on ROOT-performance-centos8-multicore/cxx17. Failing tests: |
Build failed on windows10/cxx14. Failing tests: |
Build failed on ROOT-debian10-i386/soversion. Failing tests: |
Build failed on mac11/cxx14. Failing tests: |
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.
Thank you Sergei for the improvement and the change in TH1,2,3,D classes.
It looks fine to me now.
I think there is a reference file that needs to be update in the roottest repo for avoiding the failure seen in the CI, after the change to use nullptr
.
I already prepare PR for root-test: I will merge it shortly after merging this PR |
Build failed on mac1015/cxx17. Errors:
|
This is virtual method and can be overriden in derived classes.
Therefore when such method used in copy constructor or assignment
operator, one have to explicitly specify class which used.
Fixes #10919