diff --git a/README/ReleaseNotes/v628/index.md b/README/ReleaseNotes/v628/index.md index 46248e826c773..7289e1b77d7c7 100644 --- a/README/ReleaseNotes/v628/index.md +++ b/README/ReleaseNotes/v628/index.md @@ -53,6 +53,7 @@ Please use their non-experimental counterparts `ROOT::TBufferMerger` and `ROOT:: intended. Related to it was the `RooDataHist::cacheValidEntries()` function, which is removed as well. The preferred way to reduce RooFit datasets to subranges is [RooAbsData::reduce()](https://root.cern.ch/doc/v628/classRooAbsData.html#acfa7b31e5cd751eec1bc4e95d2796390). - The longtime-deprecated `RooStats::HistFactory::EstimateSummary` class is removed, including the functions that use it. The information that it was meant to store is managed by the `RooStats::HistFactory::Measurement` object since many years. +- The `RooSuperCategory::MakeIterator()` function that was deprecated since 6.22 is now removed. Please use range-based loops to iterate over the category states. ## Core Libraries diff --git a/roofit/roofitcore/CMakeLists.txt b/roofit/roofitcore/CMakeLists.txt index f6d772b7ccd0a..bd18cce28d280 100644 --- a/roofit/roofitcore/CMakeLists.txt +++ b/roofit/roofitcore/CMakeLists.txt @@ -461,7 +461,6 @@ ROOT_STANDARD_LIBRARY_PACKAGE(RooFitCore src/RooBinWidthFunction.cxx src/RooFitLegacy/RooCatTypeLegacy.cxx src/RooFitLegacy/RooMinuit.cxx - src/RooFitLegacy/RooMultiCatIter.cxx src/RunContext.cxx src/TestStatistics/ConstantTermsOptimizer.cxx src/TestStatistics/LikelihoodGradientWrapper.cxx diff --git a/roofit/roofitcore/inc/RooSuperCategory.h b/roofit/roofitcore/inc/RooSuperCategory.h index 05c795547e045..756dc7bf133f2 100644 --- a/roofit/roofitcore/inc/RooSuperCategory.h +++ b/roofit/roofitcore/inc/RooSuperCategory.h @@ -41,8 +41,6 @@ class RooSuperCategory : public RooAbsCategoryLValue { // Printing interface (human readable) void printMultiline(std::ostream& os, Int_t content, bool verbose=false, TString indent="") const override; - /// \deprecated Use begin(), end() or range-based for loops to iterate through state names. - TIterator* MakeIterator() const ; const RooArgSet& inputCatList() const { return _multiCat->inputCatList(); } bool inRange(const char* rangeName) const override; diff --git a/roofit/roofitcore/src/RooFitLegacy/RooMultiCatIter.cxx b/roofit/roofitcore/src/RooFitLegacy/RooMultiCatIter.cxx deleted file mode 100644 index 11639b34e9a30..0000000000000 --- a/roofit/roofitcore/src/RooFitLegacy/RooMultiCatIter.cxx +++ /dev/null @@ -1,237 +0,0 @@ -/***************************************************************************** - * Project: RooFit * - * Package: RooFitCore * - * @(#)root/roofitcore:$Id$ - * Authors: * - * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu * - * DK, David Kirkby, UC Irvine, dkirkby@uci.edu * - * * - * Copyright (c) 2000-2005, Regents of the University of California * - * and Stanford University. All rights reserved. * - * * - * Redistribution and use in source and binary forms, * - * with or without modification, are permitted according to the terms * - * listed in LICENSE (http://roofit.sourceforge.net/license.txt) * - *****************************************************************************/ - -/** -\class RooMultiCatIter -\ingroup Roofitlegacy - -\deprecated RooMultiCatIter is unnecessary, since all multi category classes know how to generate -their own states. Use begin() / end() and range-based for loops on instances of these classes. - -RooMultiCatIter iterates over all state permutations of a list of categories. -It serves as the state iterator for a RooSuperCategory or a RooMultiCategory. -Since this iterator only constructs state labels and does not change the value -of its input categories, it is not required that its inputs are LValues. -For cases where all inputs are LValues (such as for RooSuperCategory) the -values of the input can be changes by assigning the super category the -string label generated by this iterator -**/ - -#include "RooMultiCatIter.h" - -#include "RooAbsCategoryLValue.h" -#include "RooFitLegacy/RooCatTypeLegacy.h" - - -using namespace std; - - -//////////////////////////////////////////////////////////////////////////////// -/// Construct iterator over all permutations of states of categories in catList. -/// If rangeName is not null, iteration is restricted to states that are selected -/// in the given range name - -RooMultiCatIter::RooMultiCatIter(const RooArgSet& catList, const char* rangeName) : _catList("catList") -{ - if (rangeName) { - _rangeName = rangeName ; - } - initialize(catList) ; -} - - - -//////////////////////////////////////////////////////////////////////////////// -/// Copy constructor - -RooMultiCatIter::RooMultiCatIter(const RooMultiCatIter& other) : TIterator(other), _catList("catList") -{ - initialize(other._catList) ; -} - - - -//////////////////////////////////////////////////////////////////////////////// -/// Build iterator array for given catList - -void RooMultiCatIter::initialize(const RooArgSet& catList) -{ - // Copy RooCategory list into internal argset - for(TObject * obj : catList) { - _catList.add((RooAbsArg&)*obj) ; - } - - // Allocate storage for component iterators - _nIter = catList.getSize() ; - _iterList = new pTIterator[_nIter] ; - _catPtrList = new pRooCategory[_nIter] ; - _curTypeList = new RooCatType[_nIter] ; - - // Construct component iterators - _curIter = 0 ; - _curItem = 0 ; - for(auto * cat : static_range_cast(_catList)) { - _catPtrList[_curIter] = cat ; - _iterList[_curIter] = cat->typeIterator() ; - _iterList[_curIter]->Next() ; -// _curTypeList[_curIter] = *first ; -// _curTypeList[_curIter].SetName(first->GetName()) ; -// cout << "init: _curTypeList[" << _curIter << "] set to " << first->GetName() << endl ; -// _iterList[_curIter]->Reset() ; - _curIter++ ; - } - - Reset() ; -} - - - -//////////////////////////////////////////////////////////////////////////////// -/// Destructor - -RooMultiCatIter::~RooMultiCatIter() -{ - for (_curIter=0 ; _curIter<_nIter ; _curIter++) { - delete _iterList[_curIter] ; - } - delete[] _iterList ; - delete[] _catPtrList ; - delete[] _curTypeList ; -} - - - -//////////////////////////////////////////////////////////////////////////////// -/// Dummy implementation, always returns zero - -const TCollection* RooMultiCatIter::GetCollection() const -{ - //return &_catList.getCollection() ; - return 0 ; -} - - - -//////////////////////////////////////////////////////////////////////////////// -/// Construct string with composite object -/// label corresponding to the state name -/// of a RooMultiCategory or RooSuperCategory -/// constructed from this set of input categories - -TObjString* RooMultiCatIter::compositeLabel() -{ - TString& str = _compositeLabel.String() ; - - str = "{" ; - Int_t i ; - for (i=0 ; i<_nIter ; i++) { - if (i>0) str.Append(";") ; - str.Append(_curTypeList[i].GetName()) ; - } - str.Append("}") ; - - return &_compositeLabel ; -} - - - -//////////////////////////////////////////////////////////////////////////////// -/// Iterator increment operator - -TObject* RooMultiCatIter::Next() -{ - // Check for end - if (_curIter==_nIter) { - _curItem = 0; - return 0 ; - } - - RooCatType* next = (RooCatType*) _iterList[_curIter]->Next() ; - if (next) { - - // Increment current iterator - _curTypeList[_curIter] = *next ; - _curTypeList[_curIter].SetName(next->GetName()) ; - - // If higher order increment was successful, reset master iterator - if (_curIter>0) _curIter=0 ; - - _curItem = compositeLabel() ; - return _curItem ; - } else { - - // Reset current iterator - _iterList[_curIter]->Reset() ; - next = (RooCatType*) _iterList[_curIter]->Next() ; - if (next) { - _curTypeList[_curIter] = *next ; - _curTypeList[_curIter].SetName(next->GetName()) ; - } - //if (next) _catPtrList[_curIter]->setIndex(next->getVal()) ; - - // Increment next iterator - _curIter++ ; - _curItem = Next() ; - return _curItem ; - } -} - - - -//////////////////////////////////////////////////////////////////////////////// -/// Rewind master iterator - -void RooMultiCatIter::Reset() -{ - for (_curIter=0 ; _curIter<_nIter ; _curIter++) { - TIterator* cIter = _iterList[_curIter] ; - cIter->Reset() ; - RooCatType* first = (RooCatType*) cIter->Next() ; - if (first) { - if (_curIter==0) cIter->Reset() ; - _curTypeList[_curIter] = *first ; - _curTypeList[_curIter].SetName(first->GetName()) ; - } - } - _curIter=0 ; -} - - -//////////////////////////////////////////////////////////////////////////////// -/// Return current item (dummy) - -TObject *RooMultiCatIter::operator*() const -{ - return _curItem ; -} - - -//////////////////////////////////////////////////////////////////////////////// -/// Comparison operator to other iterator -/// Returns true if both iterator iterate over the -/// same set of input categories and are not at the -/// same sequential position - -bool RooMultiCatIter::operator!=(const TIterator &aIter) const -{ - auto otherMCIt = dynamic_cast(&aIter); - if (!otherMCIt) - return true; - - return (_curItem != otherMCIt->_curItem); - -} - diff --git a/roofit/roofitcore/src/RooFitLegacy/RooMultiCatIter.h b/roofit/roofitcore/src/RooFitLegacy/RooMultiCatIter.h deleted file mode 100644 index facec010e8946..0000000000000 --- a/roofit/roofitcore/src/RooFitLegacy/RooMultiCatIter.h +++ /dev/null @@ -1,63 +0,0 @@ -/***************************************************************************** - * Project: RooFit * - * Package: RooFitCore * - * File: $Id: RooMultiCatIter.h,v 1.14 2007/05/11 09:11:30 verkerke Exp $ - * Authors: * - * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu * - * DK, David Kirkby, UC Irvine, dkirkby@uci.edu * - * * - * Copyright (c) 2000-2005, Regents of the University of California * - * and Stanford University. All rights reserved. * - * * - * Redistribution and use in source and binary forms, * - * with or without modification, are permitted according to the terms * - * listed in LICENSE (http://roofit.sourceforge.net/license.txt) * - *****************************************************************************/ -#ifndef ROO_MULTI_CAT_ITER -#define ROO_MULTI_CAT_ITER - -#include "TIterator.h" -#include "RooArgSet.h" -#include "TObjString.h" -class RooCategory ; -class RooCatType ; -class RooAbsCategoryLValue ; - -typedef TIterator* pTIterator ; -typedef RooAbsCategoryLValue* pRooCategory ; - -class RooMultiCatIter : public TIterator { -public: - // Constructors, assignment etc. - RooMultiCatIter(const RooArgSet& catList, const char* rangeName=nullptr) ; - RooMultiCatIter(const RooMultiCatIter& other) ; - ~RooMultiCatIter() override ; - - // Iterator implementation - const TCollection* GetCollection() const override ; - TObject* Next() override ; - void Reset() override ; - bool operator!=(const TIterator &aIter) const override ; - TObject *operator*() const override ; - -protected: - - TIterator& operator=(const TIterator&) override { return *this ; } // forbidden for now - - void initialize(const RooArgSet& catList) ; - TObjString* compositeLabel() ; - - RooArgSet _catList ; // Set of categories iterated over - pTIterator* _iterList ; // Array of category type iterators - pRooCategory* _catPtrList ; // Array of pointers to original categories - RooCatType* _curTypeList ; // List of current types - Int_t _nIter ; // Number of categories/iterators in use - Int_t _curIter ; // Current location of master iterator - TObjString _compositeLabel ; // - TString _rangeName ; // Range name (optional) - TObject* _curItem; // Current item returned by Next() - -// ClassDefOverride(RooMultiCatIter,0) // Iterator over all state permutations of a list of categories -}; - -#endif diff --git a/roofit/roofitcore/src/RooMultiCategory.cxx b/roofit/roofitcore/src/RooMultiCategory.cxx index 90b792e02e83b..16417dbb3ea9d 100644 --- a/roofit/roofitcore/src/RooMultiCategory.cxx +++ b/roofit/roofitcore/src/RooMultiCategory.cxx @@ -108,26 +108,6 @@ std::string RooMultiCategory::createLabel() const } -#ifndef NDEBUG - -#include "RooFitLegacy/RooMultiCatIter.h" -namespace { -/// Check that root-6.22 redesign of category interfaces yields same labels -std::string computeLabelOldStyle(const RooArgSet& catSet, unsigned int index) { - RooMultiCatIter iter(catSet) ; - TObjString* obj ; - for (unsigned int i=0; (obj=(TObjString*)iter.Next()); ++i) { - if (i == index) { - return obj->String().Data(); - } - } - - return {}; -} -} -#endif - - //////////////////////////////////////////////////////////////////////////////// /// Calculate the current value. /// This enumerates the states of each serving category, and calculates a unique @@ -148,12 +128,6 @@ RooAbsCategory::value_type RooMultiCategory::evaluate() const multiplier *= cat->size(); } -#ifndef NDEBUG - assert(hasIndex(computedStateIndex)); - _currentIndex = computedStateIndex; - assert(createLabel() == computeLabelOldStyle(_catSet, computedStateIndex)); -#endif - return computedStateIndex; } diff --git a/roofit/roofitcore/src/RooSuperCategory.cxx b/roofit/roofitcore/src/RooSuperCategory.cxx index 8c779759cf673..9db1b89a2f4fa 100644 --- a/roofit/roofitcore/src/RooSuperCategory.cxx +++ b/roofit/roofitcore/src/RooSuperCategory.cxx @@ -34,7 +34,6 @@ supercategory will propagate to its input categories. #include "Riostream.h" #include "RooStreamParser.h" #include "RooArgSet.h" -#include "RooFitLegacy/RooMultiCatIter.h" #include "RooAbsCategoryLValue.h" #include "RooMsgService.h" @@ -85,16 +84,6 @@ RooSuperCategory::RooSuperCategory(const RooSuperCategory& other, const char *na } -//////////////////////////////////////////////////////////////////////////////// -/// Make an iterator over all state permutations of -/// the input categories of this supercategory. -/// The iterator just generates state names, it does not set them. -TIterator* RooSuperCategory::MakeIterator() const -{ - return new RooMultiCatIter(_multiCat->inputCatList()); -} - - //////////////////////////////////////////////////////////////////////////////// /// Set the value of the super category to the specified index. /// This will propagate to the sub-categories, and set their state accordingly.