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

Fix usage of deprecated methods returning TIterator (replace with range loops or begin/end) #43373

Merged
merged 2 commits into from
Nov 27, 2023

Conversation

iarspider
Copy link
Contributor

PR description:

This PR fixes warnings observed in ROOT6_X IBs:1, 2:

/data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/69cb71416398349c2ccc9f39dc38e469/opt/cmssw/el8_amd64_gcc12/cms/cmssw/CMSSW_14_0_ROOT6_X_2023-11-22-2300/src/PhysicsTools/TagAndProbe/src/TagProbeFitter.cc: In member function 'std::string TagProbeFitter::calculateEfficiency(std::string, const std::vector<std::__cxx11::basic_string<char> >&, const std::vector<std::__cxx11::basic_string<char> >&, std::vector<std::__cxx11::basic_string<char> >&, std::map<std::__cxx11::basic_string<char>, std::vector<double> >&, std::map<std::__cxx11::basic_string<char>, std::vector<std::__cxx11::basic_string<char> > >&, std::vector<std::__cxx11::basic_string<char> >&)':
  /data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/69cb71416398349c2ccc9f39dc38e469/opt/cmssw/el8_amd64_gcc12/cms/cmssw/CMSSW_14_0_ROOT6_X_2023-11-22-2300/src/PhysicsTools/TagAndProbe/src/TagProbeFitter.cc:332:46: warning: 'TIterator* RooAbsCollection::createIterator(bool) const' is deprecated: will be removed in ROOT v6.34: begin(), end() and range-based for loops. [-Wdeprecated-declarations]
   332 |     TIterator* iter = dataVars.createIterator();
      |                       ~~~~~~~~~~~~~~~~~~~~~~~^~
In file included from /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/lcg/root/6.31.01-00fbbfcc467ea63cb3d71a5375f62eb9/include/RooArgSet.h:19,
                 from /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/lcg/root/6.31.01-00fbbfcc467ea63cb3d71a5375f62eb9/include/RooWorkspace.h:20,
                 from /data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/69cb71416398349c2ccc9f39dc38e469/opt/cmssw/el8_amd64_gcc12/cms/cmssw/CMSSW_14_0_ROOT6_X_2023-11-22-2300/src/PhysicsTools/TagAndProbe/interface/TagProbeFitter.h:7,
                 from /data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/69cb71416398349c2ccc9f39dc38e469/opt/cmssw/el8_amd64_gcc12/cms/cmssw/CMSSW_14_0_ROOT6_X_2023-11-22-2300/src/PhysicsTools/TagAndProbe/src/TagProbeFitter.cc:1:
/data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/lcg/root/6.31.01-00fbbfcc467ea63cb3d71a5375f62eb9/include/RooAbsCollection.h:227:21: note: declared here
  227 |   inline TIterator* createIterator(bool dir = kIterForward) const
      |                     ^~~~~~~~~~~~~~
  /data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/69cb71416398349c2ccc9f39dc38e469/opt/cmssw/el8_amd64_gcc12/cms/cmssw/CMSSW_14_0_ROOT6_X_2023-11-22-2300/src/PhysicsTools/TagAndProbe/src/TagProbeFitter.cc:483:55: warning: 'RooLinkedListIter RooAbsCollection::iterator(bool) const' is deprecated: will be removed in ROOT v6.34: begin(), end() and range-based for loops. [-Wdeprecated-declarations]
   483 |       RooLinkedListIter vit = binnedVariables.iterator();
      |                               ~~~~~~~~~~~~~~~~~~~~~~~~^~
/data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/lcg/root/6.31.01-00fbbfcc467ea63cb3d71a5375f62eb9/include/RooAbsCollection.h:235:21: note: declared here
  235 |   RooLinkedListIter iterator(bool dir = kIterForward) const
      |                     ^~~~~~~~
/data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/69cb71416398349c2ccc9f39dc38e469/opt/cmssw/el8_amd64_gcc12/cms/cmssw/CMSSW_14_0_ROOT6_X_2023-11-22-2300/src/PhysicsTools/TagAndProbe/src/TagProbeFitter.cc: In member function 'void TagProbeFitter::saveFitPlot(RooWorkspace*)':
  /data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/69cb71416398349c2ccc9f39dc38e469/opt/cmssw/el8_amd64_gcc12/cms/cmssw/CMSSW_14_0_ROOT6_X_2023-11-22-2300/src/PhysicsTools/TagAndProbe/src/TagProbeFitter.cc:791:39: warning: 'RooLinkedListIter RooAbsCollection::iterator(bool) const' is deprecated: will be removed in ROOT v6.34: begin(), end() and range-based for loops. [-Wdeprecated-declarations]
   791 |   RooLinkedListIter it = obs->iterator();
      |                          ~~~~~~~~~~~~~^~
/data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/lcg/root/6.31.01-00fbbfcc467ea63cb3d71a5375f62eb9/include/RooAbsCollection.h:235:21: note: declared here
  235 |   RooLinkedListIter iterator(bool dir = kIterForward) const
      |                     ^~~~~~~~
/data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/69cb71416398349c2ccc9f39dc38e469/opt/cmssw/el8_amd64_gcc12/cms/cmssw/CMSSW_14_0_ROOT6_X_2023-11-22-2300/src/PhysicsTools/TagAndProbe/src/TagProbeFitter.cc: In member function 'void TagProbeFitter::saveDistributionsPlot(RooWorkspace*)':
  /data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/69cb71416398349c2ccc9f39dc38e469/opt/cmssw/el8_amd64_gcc12/cms/cmssw/CMSSW_14_0_ROOT6_X_2023-11-22-2300/src/PhysicsTools/TagAndProbe/src/TagProbeFitter.cc:870:40: warning: 'RooLinkedListIter RooAbsCollection::iterator(bool) const' is deprecated: will be removed in ROOT v6.34: begin(), end() and range-based for loops. [-Wdeprecated-declarations]
   870 |   RooLinkedListIter it = vars->iterator();
      |                          ~~~~~~~~~~~~~~^~
/data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/lcg/root/6.31.01-00fbbfcc467ea63cb3d71a5375f62eb9/include/RooAbsCollection.h:235:21: note: declared here
  235 |   RooLinkedListIter iterator(bool dir = kIterForward) const
      |                     ^~~~~~~~
/data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/69cb71416398349c2ccc9f39dc38e469/opt/cmssw/el8_amd64_gcc12/cms/cmssw/CMSSW_14_0_ROOT6_X_2023-11-22-2300/src/PhysicsTools/TagAndProbe/src/TagProbeFitter.cc: In member function 'void TagProbeFitter::saveEfficiencyPlots(RooDataSet&, const TString&, RooArgSet&, RooArgSet&)':
  /data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/69cb71416398349c2ccc9f39dc38e469/opt/cmssw/el8_amd64_gcc12/cms/cmssw/CMSSW_14_0_ROOT6_X_2023-11-22-2300/src/PhysicsTools/TagAndProbe/src/TagProbeFitter.cc:912:52: warning: 'RooLinkedListIter RooAbsCollection::iterator(bool) const' is deprecated: will be removed in ROOT v6.34: begin(), end() and range-based for loops. [-Wdeprecated-declarations]
   912 |   RooLinkedListIter v1it = binnedVariables.iterator();
      |                            ~~~~~~~~~~~~~~~~~~~~~~~~^~
/data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/lcg/root/6.31.01-00fbbfcc467ea63cb3d71a5375f62eb9/include/RooAbsCollection.h:235:21: note: declared here
  235 |   RooLinkedListIter iterator(bool dir = kIterForward) const
      |                     ^~~~~~~~
  /data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/69cb71416398349c2ccc9f39dc38e469/opt/cmssw/el8_amd64_gcc12/cms/cmssw/CMSSW_14_0_ROOT6_X_2023-11-22-2300/src/PhysicsTools/TagAndProbe/src/TagProbeFitter.cc:919:54: warning: 'RooLinkedListIter RooAbsCollection::iterator(bool) const' is deprecated: will be removed in ROOT v6.34: begin(), end() and range-based for loops. [-Wdeprecated-declarations]
   919 |     RooLinkedListIter v2it = binnedVariables.iterator();
      |                              ~~~~~~~~~~~~~~~~~~~~~~~~^~
/data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/lcg/root/6.31.01-00fbbfcc467ea63cb3d71a5375f62eb9/include/RooAbsCollection.h:235:21: note: declared here
  235 |   RooLinkedListIter iterator(bool dir = kIterForward) const
      |                     ^~~~~~~~
  /data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/69cb71416398349c2ccc9f39dc38e469/opt/cmssw/el8_amd64_gcc12/cms/cmssw/CMSSW_14_0_ROOT6_X_2023-11-22-2300/src/PhysicsTools/TagAndProbe/src/TagProbeFitter.cc:929:56: warning: 'RooLinkedListIter RooAbsCollection::iterator(bool) const' is deprecated: will be removed in ROOT v6.34: begin(), end() and range-based for loops. [-Wdeprecated-declarations]
   929 |       RooLinkedListIter v3it = binnedVariables.iterator();
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~^~
/data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/lcg/root/6.31.01-00fbbfcc467ea63cb3d71a5375f62eb9/include/RooAbsCollection.h:235:21: note: declared here
  235 |   RooLinkedListIter iterator(bool dir = kIterForward) const
      |                     ^~~~~~~~
/data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/69cb71416398349c2ccc9f39dc38e469/opt/cmssw/el8_amd64_gcc12/cms/cmssw/CMSSW_14_0_ROOT6_X_2023-11-22-2300/src/PhysicsTools/Utilities/src/SideBandSubtraction.cc: In member function 'int SideBandSubtract::doSubtraction(RooRealVar*, Double_t, Int_t)':
  /data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/69cb71416398349c2ccc9f39dc38e469/opt/cmssw/el8_amd64_gcc12/cms/cmssw/CMSSW_14_0_ROOT6_X_2023-11-22-2300/src/PhysicsTools/Utilities/src/SideBandSubtraction.cc:101:60: warning: 'TIterator* RooAbsCollection::createIterator(bool) const' is deprecated: will be removed in ROOT v6.34: begin(), end() and range-based for loops. [-Wdeprecated-declarations]
   101 |   TIterator* iter = (TIterator*)Data->get()->createIterator();
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
In file included from /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/lcg/root/6.31.01-00fbbfcc467ea63cb3d71a5375f62eb9/include/RooArgSet.h:19,
                 from /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/lcg/root/6.31.01-00fbbfcc467ea63cb3d71a5375f62eb9/include/RooAbsReal.h:22,
                 from /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/lcg/root/6.31.01-00fbbfcc467ea63cb3d71a5375f62eb9/include/RooAbsRealLValue.h:24,
                 from /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/lcg/root/6.31.01-00fbbfcc467ea63cb3d71a5375f62eb9/include/RooRealVar.h:19,
                 from /data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/69cb71416398349c2ccc9f39dc38e469/opt/cmssw/el8_amd64_gcc12/cms/cmssw/CMSSW_14_0_ROOT6_X_2023-11-22-2300/src/PhysicsTools/Utilities/interface/SideBandSubtraction.h:5,
                 from /data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/69cb71416398349c2ccc9f39dc38e469/opt/cmssw/el8_amd64_gcc12/cms/cmssw/CMSSW_14_0_ROOT6_X_2023-11-22-2300/src/PhysicsTools/Utilities/src/SideBandSubtraction.cc:13:
/data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/lcg/root/6.31.01-00fbbfcc467ea63cb3d71a5375f62eb9/include/RooAbsCollection.h:227:21: note: declared here
  227 |   inline TIterator* createIterator(bool dir = kIterForward) const
      |                     ^~~~~~~~~~~~~~
/data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/69cb71416398349c2ccc9f39dc38e469/opt/cmssw/el8_amd64_gcc12/cms/cmssw/CMSSW_14_0_ROOT6_X_2023-11-22-2300/src/PhysicsTools/Utilities/src/SideBandSubtraction.cc: In member function 'int SideBandSubtract::doGlobalFit()':
  /data/cmsbld/jenkins/workspace/build-any-ib/w/tmp/BUILDROOT/69cb71416398349c2ccc9f39dc38e469/opt/cmssw/el8_amd64_gcc12/cms/cmssw/CMSSW_14_0_ROOT6_X_2023-11-22-2300/src/PhysicsTools/Utilities/src/SideBandSubtraction.cc:434:60: warning: 'TIterator* RooAbsCollection::createIterator(bool) const' is deprecated: will be removed in ROOT v6.34: begin(), end() and range-based for loops. [-Wdeprecated-declarations]
   434 |   TIterator* iter = (TIterator*)Data->get()->createIterator();
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/lcg/root/6.31.01-00fbbfcc467ea63cb3d71a5375f62eb9/include/RooAbsCollection.h:227:21: note: declared here
  227 |   inline TIterator* createIterator(bool dir = kIterForward) const
      |                     ^~~~~~~~~~~~~~

PR validation:

Bot tests

@iarspider
Copy link
Contributor Author

please test for ROOT6_X

@cmsbuild
Copy link
Contributor

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-43373/37851

  • This PR adds an extra 32KB to repository

@cmsbuild
Copy link
Contributor

A new Pull Request was created by @iarspider for master.

It involves the following packages:

  • PhysicsTools/TagAndProbe (analysis)
  • PhysicsTools/Utilities (analysis)

@cmsbuild, @tvami can you please review it and eventually sign? Thanks.
@sextonkennedy, @rappoccio, @antoniovilela you are the release manager for this.

cms-bot commands are listed here

@iarspider
Copy link
Contributor Author

please test for ROOT6_X

@iarspider
Copy link
Contributor Author

please ping

@iarspider
Copy link
Contributor Author

please test

@iarspider
Copy link
Contributor Author

please test for CMSSW_14_0_ROOT6_X

@cmsbuild
Copy link
Contributor

+1

Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-928c2b/36035/summary.html
COMMIT: 0e1ee7a
CMSSW: CMSSW_14_0_X_2023-11-22-2300/el8_amd64_gcc12
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week0/cms-sw/cmssw/43373/36035/install.sh to create a dev area with all the needed externals and cmssw changes.

Comparison Summary

Summary:

  • You potentially added 394 lines to the logs
  • Reco comparison results: 11 differences found in the comparisons
  • DQMHistoTests: Total files compared: 50
  • DQMHistoTests: Total histograms compared: 3367918
  • DQMHistoTests: Total failures: 7
  • DQMHistoTests: Total nulls: 0
  • DQMHistoTests: Total successes: 3367889
  • DQMHistoTests: Total skipped: 22
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: 0.0 KiB( 49 files compared)
  • Checked 214 log files, 167 edm output root files, 50 DQM output files
  • TriggerResults: no differences found

@cmsbuild
Copy link
Contributor

+1

Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-928c2b/36036/summary.html
COMMIT: 0e1ee7a
CMSSW: CMSSW_14_0_ROOT6_X_2023-11-22-2300/el8_amd64_gcc12
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week0/cms-sw/cmssw/43373/36036/install.sh to create a dev area with all the needed externals and cmssw changes.

Comparison Summary

Summary:

@tvami
Copy link
Contributor

tvami commented Nov 24, 2023

@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. @rappoccio, @sextonkennedy, @antoniovilela (and backports should be raised in the release meeting by the corresponding L2)

@rappoccio
Copy link
Contributor

+1

TIterator* iter = dataVars.createIterator();
TObject* obj(nullptr);
while ((obj = iter->Next()))
for (TObject* obj : dataVars)
Copy link
Contributor

@guitargeek guitargeek Dec 5, 2023

Choose a reason for hiding this comment

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

Thanks for these changes! This even fixed a memory leak of the TIterator !

RooRealVar* sep_var = nullptr;
while ((var = (RooAbsArg*)iter->Next())) {
for (const auto& var : *Data->get()) {
Copy link
Contributor

@guitargeek guitargeek Dec 5, 2023

Choose a reason for hiding this comment

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

And this also fixed a memory leak 🙂

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.

5 participants