Logo ROOT  
Reference Guide
RooAbsCollection.cxx
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitCore *
4  * @(#)root/roofitcore:$Id$
5  * Authors: *
6  * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7  * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8  * *
9  * Copyright (c) 2000-2005, Regents of the University of California *
10  * and Stanford University. All rights reserved. *
11  * *
12  * Redistribution and use in source and binary forms, *
13  * with or without modification, are permitted according to the terms *
14  * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15  *****************************************************************************/
16 
17 /**
18 \file RooAbsCollection.cxx
19 \class RooAbsCollection
20 \ingroup Roofitcore
21 
22 RooAbsCollection is an abstract container object that can hold
23 multiple RooAbsArg objects. Collections are ordered and can
24 contain multiple objects of the same name, (but a derived
25 implementation can enforce unique names). The storage of objects is
26 implemented using the container denoted by RooAbsCollection::Storage_t.
27 **/
28 
29 #include "RooAbsCollection.h"
30 
31 #include "TClass.h"
32 #include "TStopwatch.h"
33 #include "TRegexp.h"
34 #include "RooStreamParser.h"
35 #include "RooFormula.h"
36 #include "RooAbsRealLValue.h"
37 #include "RooAbsCategoryLValue.h"
38 #include "RooStringVar.h"
39 #include "RooTrace.h"
40 #include "RooArgList.h"
41 #include "RooLinkedListIter.h"
42 #include "RooCmdConfig.h"
43 #include "RooRealVar.h"
44 #include "RooGlobalFunc.h"
45 #include "RooMsgService.h"
46 #include <ROOT/RMakeUnique.hxx>
47 #include "strlcpy.h"
48 
49 #include <algorithm>
50 #include <iomanip>
51 #include <iostream>
52 #include <fstream>
53 
54 using std::endl;
55 using std::vector;
56 using std::string;
57 using std::ostream;
58 using std::cout;
59 
60 #if (__GNUC__==3&&__GNUC_MINOR__==2&&__GNUC_PATCHLEVEL__==3)
61 char* operator+( streampos&, char* );
62 #endif
63 
65  ;
66 
67 ////////////////////////////////////////////////////////////////////////////////
68 /// Default constructor
69 
71  _list(),
72  _ownCont(kFALSE),
73  _name(),
74  _allRRV(kTRUE),
75  _sizeThresholdForMapSearch(100)
76 {
77  _list.reserve(8);
78 }
79 
80 
81 
82 ////////////////////////////////////////////////////////////////////////////////
83 /// Empty collection constructor
84 
86  _list(),
87  _ownCont(kFALSE),
88  _name(name),
89  _allRRV(kTRUE),
90  _sizeThresholdForMapSearch(100)
91 {
92  _list.reserve(8);
93 }
94 
95 
96 
97 ////////////////////////////////////////////////////////////////////////////////
98 /// Copy constructor. Note that a copy of a collection is always non-owning,
99 /// even the source collection is owning. To create an owning copy of
100 /// a collection (owning or not), use the snapshot() method.
101 
103  TObject(other),
104  RooPrintable(other),
105  _list(),
106  _ownCont(kFALSE),
107  _name(name),
108  _allRRV(other._allRRV),
109  _sizeThresholdForMapSearch(100)
110 {
111  RooTrace::create(this) ;
112  if (!name) setName(other.GetName()) ;
113 
114  _list.reserve(other._list.size());
115 
116  for (auto item : other._list) {
117  insert(item);
118  }
119 }
120 
121 
122 ////////////////////////////////////////////////////////////////////////////////
123 /// Move constructor.
124 
126  TObject(other),
127  RooPrintable(other),
128  _list(std::move(other._list)),
129  _ownCont(other._ownCont),
130  _name(std::move(other._name)),
131  _allRRV(other._allRRV),
132  _sizeThresholdForMapSearch(other._sizeThresholdForMapSearch)
133 {
134 }
135 
136 
137 ////////////////////////////////////////////////////////////////////////////////
138 /// Destructor
139 
141 {
142  // Delete all variables in our list if we own them
143  if(_ownCont){
144  safeDeleteList() ;
145  }
146 }
147 
148 
149 ////////////////////////////////////////////////////////////////////////////////
150 /// Examine client server dependencies in list and
151 /// delete contents in safe order: any client
152 /// is deleted before a server is deleted
153 
155 {
156  _nameToItemMap = nullptr;
157 
158  // Handle trivial case here
159  if (_list.size() > 1) {
160  std::vector<RooAbsArg*> tmp;
161  tmp.reserve(_list.size());
162  do {
163  tmp.clear();
164  for (auto arg : _list) {
165  // Check if arg depends on remainder of list
166  if (!arg->dependsOn(*this, arg)) tmp.push_back(arg);
167  }
168 
169  // sort and uniquify, in case some elements occur more than once
170  std::sort(tmp.begin(), tmp.end());
171 
172  tmp.erase(std::unique(tmp.begin(), tmp.end()), tmp.end());
173  // okay, can remove and delete what's in tmp
174  auto newEnd = _list.end();
175  for (auto item : tmp) {
176  newEnd = std::remove(_list.begin(), newEnd, item);
177  delete item;
178  }
179  _list.erase(newEnd, _list.end());
180  } while (!tmp.empty() && _list.size() > 1);
181 
182  // Check if there are any remaining elements
183  if (_list.size() > 1) {
184  coutW(ObjectHandling) << "RooAbsCollection::safeDeleteList(" << GetName()
185  << ") WARNING: unable to delete following elements in client-server order " ;
186  Print("1") ;
187  }
188  }
189 
190  // Built-in delete remaining elements
191  for (auto item : _list) {
192  delete item;
193  }
194  _list.clear();
195 }
196 
197 
198 
199 ////////////////////////////////////////////////////////////////////////////////
200 /// Take a snap shot of current collection contents.
201 /// An owning collection is returned containing clones of
202 /// - Elements in this collection
203 /// - External dependents of all elements and recursively any dependents of those dependents
204 /// (if deepCopy flag is set)
205 ///
206 /// This is useful to save the values of variables or parameters. It doesn't require
207 /// deep copying if the parameters are direct members of the collection.
208 ///
209 /// If deepCopy is specified, the client-server links between the cloned
210 /// list elements and the cloned external dependents are reconnected to
211 /// each other, making the snapshot a completely self-contained entity.
212 ///
213 ///
214 
216 {
217  // First create empty list
218  TString snapName ;
219  if (TString(GetName()).Length()>0) {
220  snapName.Append("Snapshot of ") ;
221  snapName.Append(GetName()) ;
222  }
224 
225  Bool_t error = snapshot(*output,deepCopy) ;
226  if (error) {
227  delete output ;
228  return 0 ;
229  }
230 
231  return output ;
232 }
233 
234 
235 
236 ////////////////////////////////////////////////////////////////////////////////
237 /// Take a snap shot of current collection contents:
238 /// A collection that owns its elements is returned containing clones of
239 /// - Elements in this collection
240 /// - External dependents of those elements
241 /// and recursively any dependents of those dependents
242 /// (if deepCopy flag is set)
243 ///
244 /// If deepCopy is specified, the client-server links between the cloned
245 /// list elements and the cloned external dependents are reconnected to
246 /// each other, making the snapshot a completely self-contained entity.
247 ///
248 ///
249 
251 {
252  // Copy contents
253  output.reserve(_list.size());
254  for (auto orig : _list) {
255  RooAbsArg *copy= (RooAbsArg*)orig->Clone();
256  output.add(*copy);
257  }
258 
259  // Add external dependents
260  Bool_t error(kFALSE) ;
261  if (deepCopy) {
262  // Recursively add clones of all servers
263  // Can only do index access because collection might reallocate when growing
264  for (Storage_t::size_type i = 0; i < output._list.size(); ++i) {
265  const auto var = output._list[i];
266  error |= output.addServerClonesToList(*var);
267  }
268  }
269 
270  // Handle eventual error conditions
271  if (error) {
272  coutE(ObjectHandling) << "RooAbsCollection::snapshot(): Errors occurred in deep clone process, snapshot not created" << endl ;
273  output._ownCont = kTRUE ;
274  return kTRUE ;
275  }
276 
277 
278 
279  // Redirect all server connections to internal list members
280  for (auto var : output) {
281  var->redirectServers(output,deepCopy);
282  }
283 
284 
285  // Transfer ownership of contents to list
286  output._ownCont = kTRUE ;
287  return kFALSE ;
288 }
289 
290 
291 
292 ////////////////////////////////////////////////////////////////////////////////
293 /// Add clones of servers of given argument to end of list
294 
296 {
297  Bool_t ret(kFALSE) ;
298 
299  // This can be a very heavy operation if existing elements depend on many others,
300  // so make sure that we have the hash map available for faster finding.
301  if (var.servers().size() > 20 || _list.size() > 30)
302  useHashMapForFind(true);
303 
304  for (const auto server : var.servers()) {
305  RooAbsArg* tmp = find(*server) ;
306 
307  if (!tmp) {
308  RooAbsArg* serverClone = (RooAbsArg*)server->Clone() ;
309  serverClone->setAttribute("SnapShot_ExtRefClone") ;
310  insert(serverClone);
311  ret |= addServerClonesToList(*server) ;
312  }
313  }
314 
315  return ret ;
316 }
317 
318 
319 
320 ////////////////////////////////////////////////////////////////////////////////
321 /// The assignment operator sets the value of any argument in our set
322 /// that also appears in the other set.
323 
325 {
326  if (&other==this) return *this ;
327 
328  for (auto elem : _list) {
329  auto theirs = other.find(*elem);
330  if(!theirs) continue;
331  theirs->syncCache() ;
332  elem->copyCache(theirs) ;
333  elem->setAttribute("Constant",theirs->isConstant()) ;
334  }
335  return *this;
336 }
337 
338 
339 
340 ////////////////////////////////////////////////////////////////////////////////
341 /// The assignment operator sets the value of any argument in our set
342 /// that also appears in the other set.
343 
345 {
346  if (&other==this) return *this ;
347 
348  // Short cut for 1 element assignment
349  if (getSize()==1 && getSize()==other.getSize() && oneSafe) {
350  other.first()->syncCache() ;
351  first()->copyCache(other.first(),kTRUE) ;
352  return *this ;
353  }
354 
355  for (auto elem : _list) {
356  auto theirs = other.find(*elem);
357  if(!theirs) continue;
358  theirs->syncCache() ;
359  elem->copyCache(theirs,kTRUE) ;
360  }
361  return *this;
362 }
363 
364 
365 
366 ////////////////////////////////////////////////////////////////////////////////
367 /// Functional equivalent of operator=() but assumes this and other collection
368 /// have same layout. Also no attributes are copied
369 
370 void RooAbsCollection::assignFast(const RooAbsCollection& other, Bool_t setValDirty)
371 {
372  if (&other==this) return ;
373  assert(_list.size() == other._list.size());
374 
375  auto iter2 = other._list.begin();
376  for (auto iter1 = _list.begin();
377  iter1 != _list.end() && iter2 != other._list.end();
378  ++iter1, ++iter2) {
379  // Identical size of iterators is documented assumption of method
380 
381  if (_allRRV) {
382  // All contents are known to be RooRealVars - fast version of assignment
383  auto ours = static_cast<RooRealVar*>(*iter1);
384  auto theirs = static_cast<RooRealVar*>(*iter2);
385  ours->copyCacheFast(*theirs,setValDirty);
386  } else {
387  (*iter2)->syncCache() ;
388  (*iter1)->copyCache(*iter2,kTRUE,setValDirty) ;
389  }
390  }
391 
392 }
393 
394 
395 
396 ////////////////////////////////////////////////////////////////////////////////
397 /// Add the specified argument to list. Returns kTRUE if successful, or
398 /// else kFALSE if a variable of the same name is already in the list.
399 /// This method can only be called on a list that is flagged as owning
400 /// all of its contents, or else on an empty list (which will force the
401 /// list into that mode).
402 
404 {
405  if(!canBeAdded(var, silent)) return false;
406 
407  // check that we own our variables or else are empty
408  if(!_ownCont && (getSize() > 0) && !silent) {
409  coutE(ObjectHandling) << ClassName() << "::" << GetName() << "::addOwned: can only add to an owned list" << endl;
410  return kFALSE;
411  }
412  _ownCont= kTRUE;
413 
414  insert(&var);
415 
416  return kTRUE;
417 }
418 
419 
420 
421 ////////////////////////////////////////////////////////////////////////////////
422 /// Add a clone of the specified argument to list. Returns a pointer to
423 /// the clone if successful, or else zero if a variable of the same name
424 /// is already in the list or the list does *not* own its variables (in
425 /// this case, try add() instead.) Calling addClone() on an empty list
426 /// forces it to take ownership of all its subsequent variables.
427 
429 {
430  if(!canBeAdded(var, silent)) return nullptr;
431 
432  // check that we own our variables or else are empty
433  if(!_ownCont && (getSize() > 0) && !silent) {
434  coutE(ObjectHandling) << ClassName() << "::" << GetName() << "::addClone: can only add to an owned list" << endl;
435  return 0;
436  }
437  _ownCont= kTRUE;
438 
439  // add a pointer to a clone of this variable to our list (we now own it!)
440  auto clone2 = static_cast<RooAbsArg*>(var.Clone());
441  assert(clone2);
442 
443  insert(clone2);
444 
445  return clone2;
446 }
447 
448 
449 
450 ////////////////////////////////////////////////////////////////////////////////
451 /// Add the specified argument to list. Returns kTRUE if successful, or
452 /// else kFALSE if a variable of the same name is already in the list
453 /// or the list owns its variables (in this case, try addClone() or addOwned() instead).
454 
456 {
457  if(!canBeAdded(var, silent)) return false;
458 
459  // check that this isn't a copy of a list
460  if(_ownCont && !silent) {
461  coutE(ObjectHandling) << ClassName() << "::" << GetName() << "::add: cannot add to an owned list" << endl;
462  return kFALSE;
463  }
464 
465  // add a pointer to this variable to our list (we don't own it!)
466  insert(const_cast<RooAbsArg*>(&var)); //FIXME const_cast
467 
468  return kTRUE;
469 }
470 
471 
472 ////////////////////////////////////////////////////////////////////////////////
473 /// Add a collection of arguments to this collection by calling addOwned()
474 /// for each element in the source collection
475 
477 {
478  Bool_t result(false) ;
479  _list.reserve(_list.size() + list._list.size());
480 
481  for (auto item : list._list) {
482  result |= addOwned(*item, silent) ;
483  }
484 
485  return result;
486 }
487 
488 
489 
490 ////////////////////////////////////////////////////////////////////////////////
491 /// Add a collection of arguments to this collection by calling addOwned()
492 /// for each element in the source collection
493 
495 {
496  _list.reserve(_list.size() + list._list.size());
497 
498  for (auto item : list._list) {
499  addClone(*item, silent);
500  }
501 }
502 
503 
504 
505 ////////////////////////////////////////////////////////////////////////////////
506 /// Replace any args in our set with args of the same name from the other set
507 /// and return kTRUE for success. Fails if this list is a copy of another.
508 
510 {
511  // check that this isn't a copy of a list
512  if(_ownCont) {
513  coutE(ObjectHandling) << "RooAbsCollection: cannot replace variables in a copied list" << endl;
514  return kFALSE;
515  }
516 
517  // loop over elements in the other list
518  for (const auto * arg : other._list) {
519  // do we have an arg of the same name in our set?
520  auto found = find(*arg);
521  if (found) replace(*found,*arg);
522  }
523  return kTRUE;
524 }
525 
526 
527 
528 ////////////////////////////////////////////////////////////////////////////////
529 /// Replace var1 with var2 and return kTRUE for success. Fails if
530 /// this list is a copy of another, if var1 is not already in this set,
531 /// or if var2 is already in this set. var1 and var2 do not need to have
532 /// the same name.
533 
535 {
536  // check that this isn't a copy of a list
537  if(_ownCont) {
538  coutE(ObjectHandling) << "RooAbsCollection: cannot replace variables in a copied list" << endl;
539  return kFALSE;
540  }
541 
542  // is var1 already in this list?
543  const char *name= var1.GetName();
544  auto var1It = std::find(_list.begin(), _list.end(), &var1);
545 
546  if (var1It == _list.end()) {
547  coutE(ObjectHandling) << "RooAbsCollection: variable \"" << name << "\" is not in the list"
548  << " and cannot be replaced" << endl;
549  return kFALSE;
550  }
551 
552 
553  // is var2's name already in this list?
554  if (dynamic_cast<RooArgSet*>(this)) {
555  RooAbsArg *other = find(var2);
556  if(other != 0 && other != &var1) {
557  coutE(ObjectHandling) << "RooAbsCollection: cannot replace \"" << name
558  << "\" with already existing \"" << var2.GetName() << "\"" << endl;
559  return kFALSE;
560  }
561  }
562 
563  // replace var1 with var2
564  if (_nameToItemMap) {
565  _nameToItemMap->erase((*var1It)->namePtr());
566  (*_nameToItemMap)[var2.namePtr()] = const_cast<RooAbsArg*>(&var2);
567  }
568  *var1It = const_cast<RooAbsArg*>(&var2); //FIXME try to get rid of const_cast
569 
570  if (_allRRV && dynamic_cast<const RooRealVar*>(&var2)==0) {
571  _allRRV=kFALSE ;
572  }
573 
574  return kTRUE;
575 }
576 
577 
578 
579 ////////////////////////////////////////////////////////////////////////////////
580 /// Remove the specified argument from our list. Return kFALSE if
581 /// the specified argument is not found in our list. An exact pointer
582 /// match is required, not just a match by name.
583 /// If `matchByNameOnly` is set, items will be looked up by name. In this case, if
584 /// the collection also owns the item, it will delete it.
585 Bool_t RooAbsCollection::remove(const RooAbsArg& var, Bool_t , Bool_t matchByNameOnly)
586 {
587  // is var already in this list?
588  const auto sizeBefore = _list.size();
589 
590  if (matchByNameOnly) {
591  const std::string name(var.GetName());
592  auto nameMatch = [&name](const RooAbsArg* elm) {
593  return elm->GetName() == name;
594  };
595  std::set<RooAbsArg*> toBeDeleted;
596 
597  if (_ownCont) {
598  std::for_each(_list.begin(), _list.end(), [&toBeDeleted, nameMatch](RooAbsArg* elm){
599  if (nameMatch(elm)) {
600  toBeDeleted.insert(elm);
601  }
602  });
603  }
604 
605  _list.erase(std::remove_if(_list.begin(), _list.end(), nameMatch), _list.end());
606 
607  for (auto arg : toBeDeleted)
608  delete arg;
609  } else {
610  _list.erase(std::remove(_list.begin(), _list.end(), &var), _list.end());
611  }
612 
613  if (_nameToItemMap && sizeBefore != _list.size()) {
614  _nameToItemMap->erase(var.namePtr());
615  }
616 
617  return sizeBefore != _list.size();
618 }
619 
620 
621 
622 ////////////////////////////////////////////////////////////////////////////////
623 /// Remove each argument in the input list from our list using remove(const RooAbsArg&).
624 /// Return kFALSE in case of problems.
625 
626 Bool_t RooAbsCollection::remove(const RooAbsCollection& list, Bool_t silent, Bool_t matchByNameOnly)
627 {
628 
629  auto oldSize = _list.size();
630  for (auto item : list._list) {
631  remove(*item, silent, matchByNameOnly);
632  }
633 
634  return oldSize != _list.size();
635 }
636 
637 
638 
639 ////////////////////////////////////////////////////////////////////////////////
640 /// Remove all arguments from our set, deleting them if we own them.
641 /// This effectively restores our object to the state it would have
642 /// just after calling the RooAbsCollection(const char*) constructor.
643 
645 {
646  _nameToItemMap = nullptr;
647 
648  if(_ownCont) {
649  safeDeleteList() ;
650  _ownCont= kFALSE;
651  }
652  else {
653  _list.clear();
654  }
655 }
656 
657 
658 
659 ////////////////////////////////////////////////////////////////////////////////
660 /// Set given attribute in each element of the collection by
661 /// calling each elements setAttribute() function.
662 
664 {
665  for (auto arg : _list) {
666  arg->setAttribute(name, value);
667  }
668 }
669 
670 
671 
672 
673 ////////////////////////////////////////////////////////////////////////////////
674 /// Create a subset of the current collection, consisting only of those
675 /// elements with the specified attribute set. The caller is responsibe
676 /// for deleting the returned collection
677 
679 {
680  TString selName(GetName()) ;
681  selName.Append("_selection") ;
682  RooAbsCollection *sel = (RooAbsCollection*) create(selName.Data()) ;
683 
684  // Scan set contents for matching attribute
685  for (auto arg : _list) {
686  if (arg->getAttribute(name)==value)
687  sel->add(*arg) ;
688  }
689 
690  return sel ;
691 }
692 
693 
694 ////////////////////////////////////////////////////////////////////////////////
695 /// Create a subset of the current collection, consisting only of those
696 /// elements that are contained as well in the given reference collection.
697 /// Returns `true` only if something went wrong.
698 /// The complement of this function is getParameters().
699 /// \param[in] refColl The collection to check for common elements.
700 /// \param[out] outColl Output collection.
701 
703 {
704  outColl.clear();
705  outColl.setName((std::string(GetName()) + "_selection").c_str());
706 
707  // Scan set contents for matching attribute
708  for (auto arg : _list) {
709  if (refColl.find(*arg))
710  outColl.add(*arg) ;
711  }
712 
713  return false;
714 }
715 
716 
717 ////////////////////////////////////////////////////////////////////////////////
718 /// Create a subset of the current collection, consisting only of those
719 /// elements that are contained as well in the given reference collection.
720 /// The caller is responsible for deleting the returned collection
721 
723 {
724  auto sel = static_cast<RooAbsCollection*>(create("")) ;
725  selectCommon(refColl, *sel);
726  return sel ;
727 }
728 
729 
730 ////////////////////////////////////////////////////////////////////////////////
731 /// Create a subset of the current collection, consisting only of those
732 /// elements with names matching the wildcard expressions in nameList,
733 /// supplied as a comma separated list
734 
736 {
737  // Create output set
738  TString selName(GetName()) ;
739  selName.Append("_selection") ;
740  RooAbsCollection *sel = (RooAbsCollection*) create(selName.Data()) ;
741 
742  const size_t bufSize = strlen(nameList) + 1;
743  char* buf = new char[bufSize] ;
744  strlcpy(buf,nameList,bufSize) ;
745  char* wcExpr = strtok(buf,",") ;
746  while(wcExpr) {
747  TRegexp rexp(wcExpr,kTRUE) ;
748  if (verbose) {
749  cxcoutD(ObjectHandling) << "RooAbsCollection::selectByName(" << GetName() << ") processing expression '" << wcExpr << "'" << endl ;
750  }
751 
752  RooFIter iter = fwdIterator() ;
753  RooAbsArg* arg ;
754  while((arg=iter.next())) {
755  if (TString(arg->GetName()).Index(rexp)>=0) {
756  if (verbose) {
757  cxcoutD(ObjectHandling) << "RooAbsCollection::selectByName(" << GetName() << ") selected element " << arg->GetName() << endl ;
758  }
759  sel->add(*arg) ;
760  }
761  }
762  wcExpr = strtok(0,",") ;
763  }
764  delete[] buf ;
765 
766  return sel ;
767 }
768 
769 
770 
771 
772 ////////////////////////////////////////////////////////////////////////////////
773 /// Check if this and other collection have identically-named contents
774 
776 {
777  // First check equal length
778  if (getSize() != otherColl.getSize()) return kFALSE ;
779 
780  // Then check that each element of our list also occurs in the other list
781  auto compareByNamePtr = [](const RooAbsArg * left, const RooAbsArg * right) {
782  return left->namePtr() == right->namePtr();
783  };
784 
785  return std::is_permutation(_list.begin(), _list.end(),
786  otherColl._list.begin(),
787  compareByNamePtr);
788 }
789 
790 
791 namespace {
792 ////////////////////////////////////////////////////////////////////////////////
793 /// Linear search through list of stored objects.
794 template<class Collection_t>
795 RooAbsArg* findUsingNamePointer(const Collection_t& coll, const TNamed* ptr) {
796  auto findByNamePtr = [ptr](const RooAbsArg* elm) {
797  return ptr == elm->namePtr();
798  };
799 
800  auto item = std::find_if(coll.begin(), coll.end(), findByNamePtr);
801 
802  return item != coll.end() ? *item : nullptr;
803 }
804 }
805 
806 
807 ////////////////////////////////////////////////////////////////////////////////
808 /// Find object with given name in list. A null pointer
809 /// is returned if no object with the given name is found.
811 {
812  if (!name)
813  return nullptr;
814 
815  // If an object with such a name exists, its name has been registered.
816  const TNamed* nptr = RooNameReg::known(name);
817  if (!nptr) return nullptr;
818 
819  RooAbsArg* item = tryFastFind(nptr);
820 
821  return item ? item : findUsingNamePointer(_list, nptr);
822 }
823 
824 
825 
826 ////////////////////////////////////////////////////////////////////////////////
827 /// Find object with given name in list. A null pointer
828 /// is returned if no object with the given name is found.
830 {
831  const auto nptr = arg.namePtr();
832  RooAbsArg* item = tryFastFind(nptr);
833 
834  return item ? item : findUsingNamePointer(_list, nptr);
835 }
836 
837 
838 ////////////////////////////////////////////////////////////////////////////////
839 /// Return index of item with given name, or -1 in case it's not in the collection.
840 Int_t RooAbsCollection::index(const char* name) const {
841  const std::string theName(name);
842  auto item = std::find_if(_list.begin(), _list.end(), [&theName](const RooAbsArg * elm){
843  return elm->GetName() == theName;
844  });
845  return item != _list.end() ? item - _list.begin() : -1;
846 }
847 
848 
849 ////////////////////////////////////////////////////////////////////////////////
850 /// Get value of a RooAbsReal stored in set with given name. If none is found, value of defVal is returned.
851 /// No error messages are printed unless the verbose flag is set
852 
854 {
855  RooAbsArg* raa = find(name) ;
856  if (!raa) {
857  if (verbose) coutE(InputArguments) << "RooAbsCollection::getRealValue(" << GetName() << ") ERROR no object with name '" << name << "' found" << endl ;
858  return defVal ;
859  }
860  RooAbsReal* rar = dynamic_cast<RooAbsReal*>(raa) ;
861  if (!rar) {
862  if (verbose) coutE(InputArguments) << "RooAbsCollection::getRealValue(" << GetName() << ") ERROR object '" << name << "' is not of type RooAbsReal" << endl ;
863  return defVal ;
864  }
865  return rar->getVal() ;
866 }
867 
868 
869 
870 ////////////////////////////////////////////////////////////////////////////////
871 /// Set value of a RooAbsRealLValye stored in set with given name to newVal
872 /// No error messages are printed unless the verbose flag is set
873 
875 {
876  RooAbsArg* raa = find(name) ;
877  if (!raa) {
878  if (verbose) coutE(InputArguments) << "RooAbsCollection::setRealValue(" << GetName() << ") ERROR no object with name '" << name << "' found" << endl ;
879  return kTRUE ;
880  }
881  RooAbsRealLValue* rar = dynamic_cast<RooAbsRealLValue*>(raa) ;
882  if (!rar) {
883  if (verbose) coutE(InputArguments) << "RooAbsCollection::setRealValue(" << GetName() << ") ERROR object '" << name << "' is not of type RooAbsRealLValue" << endl ;
884  return kTRUE;
885  }
886  rar->setVal(newVal) ;
887  return kFALSE ;
888 }
889 
890 
891 
892 ////////////////////////////////////////////////////////////////////////////////
893 /// Get state name of a RooAbsCategory stored in set with given name. If none is found, value of defVal is returned.
894 /// No error messages are printed unless the verbose flag is set
895 
896 const char* RooAbsCollection::getCatLabel(const char* name, const char* defVal, Bool_t verbose) const
897 {
898  RooAbsArg* raa = find(name) ;
899  if (!raa) {
900  if (verbose) coutE(InputArguments) << "RooAbsCollection::getCatLabel(" << GetName() << ") ERROR no object with name '" << name << "' found" << endl ;
901  return defVal ;
902  }
903  RooAbsCategory* rac = dynamic_cast<RooAbsCategory*>(raa) ;
904  if (!rac) {
905  if (verbose) coutE(InputArguments) << "RooAbsCollection::getCatLabel(" << GetName() << ") ERROR object '" << name << "' is not of type RooAbsCategory" << endl ;
906  return defVal ;
907  }
908  return rac->getCurrentLabel() ;
909 }
910 
911 
912 
913 ////////////////////////////////////////////////////////////////////////////////
914 /// Set state name of a RooAbsCategoryLValue stored in set with given name to newVal.
915 /// No error messages are printed unless the verbose flag is set
916 
917 Bool_t RooAbsCollection::setCatLabel(const char* name, const char* newVal, Bool_t verbose)
918 {
919  RooAbsArg* raa = find(name) ;
920  if (!raa) {
921  if (verbose) coutE(InputArguments) << "RooAbsCollection::setCatLabel(" << GetName() << ") ERROR no object with name '" << name << "' found" << endl ;
922  return kTRUE ;
923  }
924  RooAbsCategoryLValue* rac = dynamic_cast<RooAbsCategoryLValue*>(raa) ;
925  if (!rac) {
926  if (verbose) coutE(InputArguments) << "RooAbsCollection::setCatLabel(" << GetName() << ") ERROR object '" << name << "' is not of type RooAbsCategory" << endl ;
927  return kTRUE ;
928  }
929  rac->setLabel(newVal) ;
930  return kFALSE ;
931 }
932 
933 
934 
935 ////////////////////////////////////////////////////////////////////////////////
936 /// Get index value of a RooAbsCategory stored in set with given name. If none is found, value of defVal is returned.
937 /// No error messages are printed unless the verbose flag is set
938 
940 {
941  RooAbsArg* raa = find(name) ;
942  if (!raa) {
943  if (verbose) coutE(InputArguments) << "RooAbsCollection::getCatLabel(" << GetName() << ") ERROR no object with name '" << name << "' found" << endl ;
944  return defVal ;
945  }
946  RooAbsCategory* rac = dynamic_cast<RooAbsCategory*>(raa) ;
947  if (!rac) {
948  if (verbose) coutE(InputArguments) << "RooAbsCollection::getCatLabel(" << GetName() << ") ERROR object '" << name << "' is not of type RooAbsCategory" << endl ;
949  return defVal ;
950  }
951  return rac->getCurrentIndex() ;
952 }
953 
954 
955 
956 ////////////////////////////////////////////////////////////////////////////////
957 /// Set index value of a RooAbsCategoryLValue stored in set with given name to newVal.
958 /// No error messages are printed unless the verbose flag is set
959 
961 {
962  RooAbsArg* raa = find(name) ;
963  if (!raa) {
964  if (verbose) coutE(InputArguments) << "RooAbsCollection::setCatLabel(" << GetName() << ") ERROR no object with name '" << name << "' found" << endl ;
965  return kTRUE ;
966  }
967  RooAbsCategoryLValue* rac = dynamic_cast<RooAbsCategoryLValue*>(raa) ;
968  if (!rac) {
969  if (verbose) coutE(InputArguments) << "RooAbsCollection::setCatLabel(" << GetName() << ") ERROR object '" << name << "' is not of type RooAbsCategory" << endl ;
970  return kTRUE ;
971  }
972  rac->setIndex(newVal) ;
973  return kFALSE ;
974 }
975 
976 
977 
978 ////////////////////////////////////////////////////////////////////////////////
979 /// Get string value of a RooStringVar stored in set with given name. If none is found, value of defVal is returned.
980 /// No error messages are printed unless the verbose flag is set
981 
982 const char* RooAbsCollection::getStringValue(const char* name, const char* defVal, Bool_t verbose) const
983 {
984  RooAbsArg* raa = find(name) ;
985  if (!raa) {
986  if (verbose) coutE(InputArguments) << "RooAbsCollection::getStringValue(" << GetName() << ") ERROR no object with name '" << name << "' found" << endl ;
987  return defVal ;
988  }
989  auto ras = dynamic_cast<const RooStringVar*>(raa) ;
990  if (!ras) {
991  if (verbose) coutE(InputArguments) << "RooAbsCollection::getStringValue(" << GetName() << ") ERROR object '" << name << "' is not of type RooStringVar" << endl ;
992  return defVal ;
993  }
994 
995  return ras->getVal() ;
996 }
997 
998 
999 
1000 ////////////////////////////////////////////////////////////////////////////////
1001 /// Set string value of a RooStringVar stored in set with given name to newVal.
1002 /// No error messages are printed unless the verbose flag is set
1003 
1004 Bool_t RooAbsCollection::setStringValue(const char* name, const char* newVal, Bool_t verbose)
1005 {
1006  RooAbsArg* raa = find(name) ;
1007  if (!raa) {
1008  if (verbose) coutE(InputArguments) << "RooAbsCollection::setStringValue(" << GetName() << ") ERROR no object with name '" << name << "' found" << endl ;
1009  return kTRUE ;
1010  }
1011  auto ras = dynamic_cast<RooStringVar*>(raa);
1012  if (!ras) {
1013  if (verbose) coutE(InputArguments) << "RooAbsCollection::setStringValue(" << GetName() << ") ERROR object '" << name << "' is not of type RooStringVar" << endl ;
1014  return kTRUE ;
1015  }
1016  ras->setVal(newVal);
1017 
1018  return false;
1019 }
1020 
1021 ////////////////////////////////////////////////////////////////////////////////
1022 /// Return comma separated list of contained object names as STL string
1024 {
1025  string retVal ;
1026  for (auto arg : _list) {
1027  retVal += arg->GetName();
1028  retVal += ",";
1029  }
1030 
1031  retVal.erase(retVal.end()-1);
1032 
1033  return retVal;
1034 }
1035 
1036 
1037 
1038 ////////////////////////////////////////////////////////////////////////////////
1039 /// Return collection name
1040 
1041 void RooAbsCollection::printName(ostream& os) const
1042 {
1043  os << GetName() ;
1044 }
1045 
1046 
1047 
1048 ////////////////////////////////////////////////////////////////////////////////
1049 /// Return collection title
1050 
1051 void RooAbsCollection::printTitle(ostream& os) const
1052 {
1053  os << GetTitle() ;
1054 }
1055 
1056 
1057 
1058 ////////////////////////////////////////////////////////////////////////////////
1059 /// Return collection class name
1060 
1061 void RooAbsCollection::printClassName(ostream& os) const
1062 {
1063  os << IsA()->GetName() ;
1064 }
1065 
1066 
1067 
1068 ////////////////////////////////////////////////////////////////////////////////
1069 /// Define default RooPrinable print options for given Print() flag string
1070 /// For inline printing only show value of objects, for default print show
1071 /// name,class name value and extras of each object. In verbose mode
1072 /// also add object adress, argument and title
1073 
1075 {
1076  if (opt && TString(opt)=="I") {
1077  return kValue ;
1078  }
1079  if (opt && TString(opt).Contains("v")) {
1081  }
1082  return kName|kClassName|kValue ;
1083 }
1084 
1085 
1086 
1087 
1088 
1089 ////////////////////////////////////////////////////////////////////////////////
1090 /// Print value of collection, i.e. a comma separated list of contained
1091 /// object names
1092 
1093 void RooAbsCollection::printValue(ostream& os) const
1094 {
1095  Bool_t first2(kTRUE) ;
1096  os << "(" ;
1097  for (auto arg : _list) {
1098  if (!first2) {
1099  os << "," ;
1100  } else {
1101  first2 = kFALSE ;
1102  }
1103  if (arg->IsA()->InheritsFrom(RooStringVar::Class())) {
1104  os << '\'' << ((RooStringVar *)arg)->getVal() << '\'';
1105  } else {
1106  os << arg->GetName();
1107  }
1108  }
1109  os << ")" ;
1110 }
1111 
1112 
1113 
1114 ////////////////////////////////////////////////////////////////////////////////
1115 /// Implement multiline printing of collection, one line for each contained object showing
1116 /// the requested content
1117 
1118 void RooAbsCollection::printMultiline(ostream&os, Int_t contents, Bool_t /*verbose*/, TString indent) const
1119 {
1120  if (TString(GetName()).Length()>0 && (contents&kCollectionHeader)) {
1121  os << indent << ClassName() << "::" << GetName() << ":" << (_ownCont?" (Owning contents)":"") << endl;
1122  }
1123 
1124  TString deeper(indent);
1125  deeper.Append(" ");
1126 
1127  // Adjust the width of the name field to fit the largest name, if requested
1128  Int_t maxNameLen(1) ;
1129  Int_t nameFieldLengthSaved = RooPrintable::_nameLength ;
1130  if (nameFieldLengthSaved==0) {
1131  for (auto next : _list) {
1132  Int_t len = strlen(next->GetName()) ;
1133  if (len>maxNameLen) maxNameLen = len ;
1134  }
1135  RooPrintable::nameFieldLength(maxNameLen+1) ;
1136  }
1137 
1138  unsigned int idx = 0;
1139  for (auto next : _list) {
1140  os << indent << std::setw(3) << ++idx << ") ";
1141  next->printStream(os,contents,kSingleLine,"");
1142  }
1143 
1144  // Reset name field length, if modified
1145  RooPrintable::nameFieldLength(nameFieldLengthSaved) ;
1146 }
1147 
1148 
1149 
1150 ////////////////////////////////////////////////////////////////////////////////
1151 /// Base contents dumper for debugging purposes
1152 
1154 {
1155  for (auto arg : _list) {
1156  cout << arg << " " << arg->IsA()->GetName() << "::" << arg->GetName() << " (" << arg->GetTitle() << ")" << endl ;
1157  }
1158 }
1159 
1160 
1161 
1162 ////////////////////////////////////////////////////////////////////////////////
1163 /// Output content of collection as LaTex table. By default a table with two columns is created: the left
1164 /// column contains the name of each variable, the right column the value.
1165 ///
1166 /// The following optional named arguments can be used to modify the default behavior
1167 /// <table>
1168 /// <tr><th> Argument <th> Effect
1169 /// <tr><td> `Columns(Int_t ncol)` <td> Fold table into multiple columns, i.e. ncol=3 will result in 3 x 2 = 6 total columns
1170 /// <tr><td> `Sibling(const RooAbsCollection& other)` <td> Define sibling list.
1171 /// The sibling list is assumed to have objects with the same
1172 /// name in the same order. If this is not the case warnings will be printed. If a single
1173 /// sibling list is specified, 3 columns will be output: the (common) name, the value of this
1174 /// list and the value in the sibling list. Multiple sibling lists can be specified by
1175 /// repeating the Sibling() command.
1176 /// <tr><td> `Format(const char* str)` <td> Classic format string, provided for backward compatibility
1177 /// <tr><td> `Format()` <td> Formatting arguments.
1178 /// <table>
1179 /// <tr><td> const char* what <td> Controls what is shown. "N" adds name, "E" adds error,
1180 /// "A" shows asymmetric error, "U" shows unit, "H" hides the value
1181 /// <tr><td> `FixedPrecision(int n)` <td> Controls precision, set fixed number of digits
1182 /// <tr><td> `AutoPrecision(int n)` <td> Controls precision. Number of shown digits is calculated from error
1183 /// and n specified additional digits (1 is sensible default)
1184 /// <tr><td> `VerbatimName(Bool_t flag)` <td> Put variable name in a \\verb+ + clause.
1185 /// </table>
1186 /// <tr><td> `OutputFile(const char* fname)` <td> Send output to file with given name rather than standard output
1187 ///
1188 /// </table>
1189 ///
1190 /// Example use:
1191 /// ```
1192 /// list.printLatex(Columns(2), Format("NEU",AutoPrecision(1),VerbatimName()) );
1193 /// ```
1194 
1195 void RooAbsCollection::printLatex(const RooCmdArg& arg1, const RooCmdArg& arg2,
1196  const RooCmdArg& arg3, const RooCmdArg& arg4,
1197  const RooCmdArg& arg5, const RooCmdArg& arg6,
1198  const RooCmdArg& arg7, const RooCmdArg& arg8) const
1199 {
1200 
1201 
1202  // Define configuration for this method
1203  RooCmdConfig pc("RooAbsCollection::printLatex()") ;
1204  pc.defineInt("ncol","Columns",0,1) ;
1205  pc.defineString("outputFile","OutputFile",0,"") ;
1206  pc.defineString("format","Format",0,"NEYVU") ;
1207  pc.defineInt("sigDigit","Format",0,1) ;
1208  pc.defineObject("siblings","Sibling",0,0,kTRUE) ;
1209  pc.defineInt("dummy","FormatArgs",0,0) ;
1210  pc.defineMutex("Format","FormatArgs") ;
1211 
1212  // Stuff all arguments in a list
1213  RooLinkedList cmdList;
1214  cmdList.Add(const_cast<RooCmdArg*>(&arg1)) ; cmdList.Add(const_cast<RooCmdArg*>(&arg2)) ;
1215  cmdList.Add(const_cast<RooCmdArg*>(&arg3)) ; cmdList.Add(const_cast<RooCmdArg*>(&arg4)) ;
1216  cmdList.Add(const_cast<RooCmdArg*>(&arg5)) ; cmdList.Add(const_cast<RooCmdArg*>(&arg6)) ;
1217  cmdList.Add(const_cast<RooCmdArg*>(&arg7)) ; cmdList.Add(const_cast<RooCmdArg*>(&arg8)) ;
1218 
1219  // Process & check varargs
1220  pc.process(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
1221  if (!pc.ok(kTRUE)) {
1222  return ;
1223  }
1224 
1225  const char* outFile = pc.getString("outputFile") ;
1226  if (outFile && strlen(outFile)) {
1227  std::ofstream ofs(outFile) ;
1228  if (pc.hasProcessed("FormatArgs")) {
1229  RooCmdArg* formatCmd = static_cast<RooCmdArg*>(cmdList.FindObject("FormatArgs")) ;
1230  formatCmd->addArg(RooFit::LatexTableStyle()) ;
1231  printLatex(ofs,pc.getInt("ncol"),0,0,pc.getObjectList("siblings"),formatCmd) ;
1232  } else {
1233  printLatex(ofs,pc.getInt("ncol"),pc.getString("format"),pc.getInt("sigDigit"),pc.getObjectList("siblings")) ;
1234  }
1235  } else {
1236  if (pc.hasProcessed("FormatArgs")) {
1237  RooCmdArg* formatCmd = static_cast<RooCmdArg*>(cmdList.FindObject("FormatArgs")) ;
1238  formatCmd->addArg(RooFit::LatexTableStyle()) ;
1239  printLatex(cout,pc.getInt("ncol"),0,0,pc.getObjectList("siblings"),formatCmd) ;
1240  } else {
1241  printLatex(cout,pc.getInt("ncol"),pc.getString("format"),pc.getInt("sigDigit"),pc.getObjectList("siblings")) ;
1242  }
1243  }
1244 }
1245 
1246 
1247 
1248 
1249 ////////////////////////////////////////////////////////////////////////////////
1250 /// Internal implementation function of printLatex
1251 
1252 void RooAbsCollection::printLatex(ostream& ofs, Int_t ncol, const char* option, Int_t sigDigit, const RooLinkedList& siblingList, const RooCmdArg* formatCmd) const
1253 {
1254  // Count number of rows to print
1255  Int_t nrow = (Int_t) (getSize() / ncol + 0.99) ;
1256  Int_t i,j,k ;
1257 
1258  // Sibling list do not need to print their name as it is supposed to be the same
1259  TString sibOption ;
1260  RooCmdArg sibFormatCmd ;
1261  if (option) {
1262  sibOption = option ;
1263  sibOption.ReplaceAll("N","") ;
1264  sibOption.ReplaceAll("n","") ;
1265  } else {
1266  sibFormatCmd = *formatCmd ;
1267  TString tmp = formatCmd->_s[0] ;
1268  tmp.ReplaceAll("N","") ;
1269  tmp.ReplaceAll("n","") ;
1270  static char buf[100] ;
1271  strlcpy(buf,tmp.Data(),100) ;
1272  sibFormatCmd._s[0] = buf ;
1273  }
1274 
1275 
1276  // Make list of lists ;
1277  RooLinkedList listList ;
1278  listList.Add((RooAbsArg*)this) ;
1279  RooFIter sIter = siblingList.fwdIterator() ;
1280  RooAbsCollection* col ;
1281  while((col=(RooAbsCollection*)sIter.next())) {
1282  listList.Add(col) ;
1283  }
1284 
1285  RooLinkedList listListRRV ;
1286 
1287  // Make list of RRV-only components
1288  RooFIter lIter = listList.fwdIterator() ;
1289  RooArgList* prevList = 0 ;
1290  while((col=(RooAbsCollection*)lIter.next())) {
1291  RooArgList* list = new RooArgList ;
1292  RooFIter iter = col->fwdIterator() ;
1293  RooAbsArg* arg ;
1294  while((arg=iter.next())) {
1295 
1296  RooRealVar* rrv = dynamic_cast<RooRealVar*>(arg) ;
1297  if (rrv) {
1298  list->add(*rrv) ;
1299  } else {
1300  coutW(InputArguments) << "RooAbsCollection::printLatex: can only print RooRealVar in LateX, skipping non-RooRealVar object named "
1301  << arg->GetName() << endl ;
1302  }
1303  if (prevList && TString(rrv->GetName()).CompareTo(prevList->at(list->getSize()-1)->GetName())) {
1304  coutW(InputArguments) << "RooAbsCollection::printLatex: WARNING: naming and/or ordering of sibling list is different" << endl ;
1305  }
1306  }
1307  listListRRV.Add(list) ;
1308  if (prevList && list->getSize() != prevList->getSize()) {
1309  coutW(InputArguments) << "RooAbsCollection::printLatex: ERROR: sibling list(s) must have same length as self" << endl ;
1310  delete list ;
1311  listListRRV.Delete() ;
1312  return ;
1313  }
1314  prevList = list ;
1315  }
1316 
1317  // Construct table header
1318  Int_t nlist = listListRRV.GetSize() ;
1319  TString subheader = "l" ;
1320  for (k=0 ; k<nlist ; k++) subheader += "c" ;
1321 
1322  TString header = "\\begin{tabular}{" ;
1323  for (j=0 ; j<ncol ; j++) {
1324  if (j>0) header += "|" ;
1325  header += subheader ;
1326  }
1327  header += "}" ;
1328  ofs << header << endl ;
1329 
1330 
1331  // Print contents, delegating actual printing to RooRealVar::format()
1332  for (i=0 ; i<nrow ; i++) {
1333  for (j=0 ; j<ncol ; j++) {
1334  for (k=0 ; k<nlist ; k++) {
1335  RooRealVar* par = (RooRealVar*) ((RooArgList*)listListRRV.At(k))->at(i+j*nrow) ;
1336  if (par) {
1337  if (option) {
1338  TString* tmp = par->format(sigDigit,(k==0)?option:sibOption.Data()) ;
1339  ofs << *tmp ;
1340  delete tmp ;
1341  } else {
1342  TString* tmp = par->format((k==0)?*formatCmd:sibFormatCmd) ;
1343  ofs << *tmp ;
1344  delete tmp ;
1345  }
1346  }
1347  if (!(j==ncol-1 && k==nlist-1)) {
1348  ofs << " & " ;
1349  }
1350  }
1351  }
1352  ofs << "\\\\" << endl ;
1353  }
1354 
1355  ofs << "\\end{tabular}" << endl ;
1356  listListRRV.Delete() ;
1357 }
1358 
1359 
1360 
1361 
1362 ////////////////////////////////////////////////////////////////////////////////
1363 /// Return true if all contained object report to have their
1364 /// value inside the specified range
1365 
1366 Bool_t RooAbsCollection::allInRange(const char* rangeSpec) const
1367 {
1368  if (!rangeSpec) return kTRUE ;
1369 
1370  // Parse rangeSpec specification
1371  vector<string> cutVec ;
1372  if (rangeSpec && strlen(rangeSpec)>0) {
1373  if (strchr(rangeSpec,',')==0) {
1374  cutVec.push_back(rangeSpec) ;
1375  } else {
1376  const size_t bufSize = strlen(rangeSpec)+1;
1377  char* buf = new char[bufSize] ;
1378  strlcpy(buf,rangeSpec,bufSize) ;
1379  const char* oneRange = strtok(buf,",") ;
1380  while(oneRange) {
1381  cutVec.push_back(oneRange) ;
1382  oneRange = strtok(0,",") ;
1383  }
1384  delete[] buf ;
1385  }
1386  }
1387 
1388  // Apply range based selection criteria
1389  Bool_t selectByRange = kTRUE ;
1390  for (auto arg : _list) {
1391  Bool_t selectThisArg = kFALSE ;
1392  UInt_t icut ;
1393  for (icut=0 ; icut<cutVec.size() ; icut++) {
1394  if (arg->inRange(cutVec[icut].c_str())) {
1395  selectThisArg = kTRUE ;
1396  break ;
1397  }
1398  }
1399  if (!selectThisArg) {
1400  selectByRange = kFALSE ;
1401  break ;
1402  }
1403  }
1404 
1405  return selectByRange ;
1406 }
1407 
1408 
1409 
1410 ////////////////////////////////////////////////////////////////////////////////
1411 
1413 {
1414 }
1415 
1416 
1417 ////////////////////////////////////////////////////////////////////////////////
1418 
1420 {
1421 }
1422 
1423 ////////////////////////////////////////////////////////////////////////////////
1424 /// If one of the TObject we have a referenced to is deleted, remove the
1425 /// reference.
1426 
1428 {
1429  if (obj && obj->InheritsFrom(RooAbsArg::Class())) remove(*(RooAbsArg*)obj,false,false);
1430 }
1431 
1432 ////////////////////////////////////////////////////////////////////////////////
1433 /// Sort collection using std::sort and name comparison
1434 
1436  //Windows seems to need an implementation where two different std::sorts are written
1437  //down in two different blocks. Switching between the two comparators using a ternary
1438  //operator does not compile on windows, although the signature is identical.
1439  if (reverse) {
1440  const auto cmpReverse = [](const RooAbsArg * l, const RooAbsArg * r) {
1441  return strcmp(l->GetName(), r->GetName()) > 0;
1442  };
1443 
1444  std::sort(_list.begin(), _list.end(), cmpReverse);
1445  }
1446  else {
1447  const auto cmp = [](const RooAbsArg * l, const RooAbsArg * r) {
1448  return strcmp(l->GetName(), r->GetName()) < 0;
1449  };
1450 
1451  std::sort(_list.begin(), _list.end(), cmp);
1452  }
1453 }
1454 
1455 ////////////////////////////////////////////////////////////////////////////////
1456 /// Factory for legacy iterators.
1457 
1458 std::unique_ptr<RooAbsCollection::LegacyIterator_t> RooAbsCollection::makeLegacyIterator (bool forward) const {
1459  if (!forward)
1460  ccoutE(DataHandling) << "The legacy RooFit collection iterators don't support reverse iterations, any more. "
1461  << "Use begin() and end()" << endl;
1462  return std::make_unique<LegacyIterator_t>(_list);
1463 }
1464 
1465 
1466 ////////////////////////////////////////////////////////////////////////////////
1467 /// Insert an element into the owned collections.
1469  _list.push_back(item);
1470 
1471  if (_allRRV && dynamic_cast<const RooRealVar*>(item)==0) {
1472  _allRRV= false;
1473  }
1474 
1475  if (_nameToItemMap) {
1476  (*_nameToItemMap)[item->namePtr()] = item;
1477  }
1478 }
1479 
1480 
1481 ////////////////////////////////////////////////////////////////////////////////
1482 /// Install an internal hash map for fast finding of elements by name.
1484  if (!flag && _nameToItemMap){
1485  _nameToItemMap = nullptr;
1486  }
1487 
1488  if (flag && !_nameToItemMap) {
1489  _nameToItemMap.reset(new std::unordered_map<const TNamed*, Storage_t::value_type>());
1490  for (const auto item : _list) {
1491  (*_nameToItemMap)[item->namePtr()] = item;
1492  }
1493  }
1494 }
1495 
1496 
1497 ////////////////////////////////////////////////////////////////////////////////
1498 /// Perform a search in a hash map.
1499 /// This only happens if this collection is larger than _sizeThresholdForMapSearch.
1500 /// This search is *not guaranteed* to find an existing
1501 /// element because elements can be renamed while
1502 /// being stored in the collection.
1504  if (_list.size() >= _sizeThresholdForMapSearch && !_nameToItemMap) {
1505  useHashMapForFind(true);
1506  assert(_nameToItemMap);
1507  }
1508 
1509  if (!_nameToItemMap) {
1510  return nullptr;
1511  }
1512 
1513  auto item = _nameToItemMap->find(namePtr);
1514  if (item != _nameToItemMap->end()) {
1515  // Have an element. Check that it didn't get renamed.
1516  if (item->second->namePtr() == item->first) {
1517  return item->second;
1518  } else {
1519  // Item has been renamed / replaced.
1520  _nameToItemMap->erase(item);
1521  if (auto arg = findUsingNamePointer(_list, namePtr)) {
1522  (*_nameToItemMap)[arg->namePtr()] = arg;
1523  return arg;
1524  }
1525  }
1526  }
1527 
1528  return nullptr;
1529 }
1530 
1531 
1532 ////////////////////////////////////////////////////////////////////////////////
1533 /// Check that all entries where the collections overlap have the same name.
1535  for (unsigned int i=0; i < std::min(_list.size(), other.size()); ++i) {
1536  if (_list[i]->namePtr() != other._list[i]->namePtr())
1537  return false;
1538  }
1539 
1540  return true;
1541 }
RooAbsArg::Clone
virtual TObject * Clone(const char *newname=0) const
Make a clone of an object using the Streamer facility.
Definition: RooAbsArg.h:84
RooStreamParser.h
RooPrintable::_nameLength
static Int_t _nameLength
Definition: RooPrintable.h:57
RooAbsCollection::RecursiveRemove
virtual void RecursiveRemove(TObject *obj)
If one of the TObject we have a referenced to is deleted, remove the reference.
Definition: RooAbsCollection.cxx:1427
l
auto * l
Definition: textangle.C:4
RooPrintable::nameFieldLength
static void nameFieldLength(Int_t newLen)
Set length of field reserved from printing name of RooAbsArgs in multi-line collection printing to gi...
Definition: RooPrintable.cxx:63
RooCmdArg
RooCmdArg is a named container for two doubles, two integers two object points and three string point...
Definition: RooCmdArg.h:27
RooAbsCollection::defaultPrintContents
virtual Int_t defaultPrintContents(Option_t *opt) const
Define default RooPrinable print options for given Print() flag string For inline printing only show ...
Definition: RooAbsCollection.cxx:1074
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:100
RooCmdConfig.h
RooStringVar.h
RooLinkedListIter.h
RooMsgService.h
RooAbsCollection::first
RooAbsArg * first() const
Definition: RooAbsCollection.h:236
RooSTLRefCountList::size
std::size_t size() const
Number of contained objects (neglecting the ref count).
Definition: RooSTLRefCountList.h:101
Option_t
const char Option_t
Definition: RtypesCore.h:66
RooAbsCategory::getCurrentIndex
virtual value_type getCurrentIndex() const
Return index number of current state.
Definition: RooAbsCategory.cxx:114
RooAbsCategoryLValue::setLabel
virtual bool setLabel(const char *label, Bool_t printError=kTRUE)=0
Change category state by specifying a state name.
RooAbsCollection::setStringValue
Bool_t setStringValue(const char *name, const char *newVal="", Bool_t verbose=kFALSE)
Set string value of a RooStringVar stored in set with given name to newVal.
Definition: RooAbsCollection.cxx:1004
RooFit::InputArguments
@ InputArguments
Definition: RooGlobalFunc.h:61
RooRealVar::format
TString * format(const RooCmdArg &formatArg) const
Format contents of RooRealVar for pretty printing on RooPlot parameter boxes.
Definition: RooRealVar.cxx:857
TString::Data
const char * Data() const
Definition: TString.h:369
RooAbsCollection::setCatLabel
Bool_t setCatLabel(const char *name, const char *newVal="", Bool_t verbose=kFALSE)
Set state name of a RooAbsCategoryLValue stored in set with given name to newVal.
Definition: RooAbsCollection.cxx:917
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
RooCmdArg::addArg
void addArg(const RooCmdArg &arg)
Utility function to add nested RooCmdArg to payload of this RooCmdArg.
Definition: RooCmdArg.cxx:196
RooLinkedList::GetSize
Int_t GetSize() const
Definition: RooLinkedList.h:62
RooAbsCollection::assignValueOnly
RooAbsCollection & assignValueOnly(const RooAbsCollection &other, Bool_t oneSafe=kFALSE)
The assignment operator sets the value of any argument in our set that also appears in the other set.
Definition: RooAbsCollection.cxx:344
r
ROOT::R::TRInterface & r
Definition: Object.C:4
RooAbsCollection::fwdIterator
RooFIter fwdIterator() const
One-time forward iterator.
Definition: RooAbsCollection.h:193
TStopwatch.h
RooAbsCollection::getCatIndex
Int_t getCatIndex(const char *name, Int_t defVal=0, Bool_t verbose=kFALSE) const
Get index value of a RooAbsCategory stored in set with given name.
Definition: RooAbsCollection.cxx:939
coutE
#define coutE(a)
Definition: RooMsgService.h:33
RooTrace::create
static void create(const TObject *obj)
Register creation of object 'obj'.
Definition: RooTrace.cxx:68
RooAbsArg::namePtr
const TNamed * namePtr() const
De-duplicated pointer to this object's name.
Definition: RooAbsArg.h:543
RooAbsCollection::tryFastFind
RooAbsArg * tryFastFind(const TNamed *namePtr) const
Perform a search in a hash map.
Definition: RooAbsCollection.cxx:1503
coutW
#define coutW(a)
Definition: RooMsgService.h:32
output
static void output(int code)
Definition: gifencode.c:226
RooArgList
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgList.h:21
RooAbsReal::getVal
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition: RooAbsReal.h:91
Int_t
int Int_t
Definition: RtypesCore.h:45
RooAbsCollection::setRealValue
Bool_t setRealValue(const char *name, Double_t newVal=0, Bool_t verbose=kFALSE)
Set value of a RooAbsRealLValye stored in set with given name to newVal No error messages are printed...
Definition: RooAbsCollection.cxx:874
RooAbsCollection::remove
virtual Bool_t remove(const RooAbsArg &var, Bool_t silent=kFALSE, Bool_t matchByNameOnly=kFALSE)
Remove the specified argument from our list.
Definition: RooAbsCollection.cxx:585
RooAbsCollection::find
RooAbsArg * find(const char *name) const
Find object with given name in list.
Definition: RooAbsCollection.cxx:810
RooAbsCollection::printClassName
virtual void printClassName(std::ostream &os) const
Return collection class name.
Definition: RooAbsCollection.cxx:1061
TGeant4Unit::pc
static constexpr double pc
Definition: TGeant4SystemOfUnits.h:130
TClass.h
indent
static void indent(ostringstream &buf, int indent_level)
Definition: TClingCallFunc.cxx:87
RooPrintable::kAddress
@ kAddress
Definition: RooPrintable.h:33
RooAbsCollection::printMultiline
virtual void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Implement multiline printing of collection, one line for each contained object showing the requested ...
Definition: RooAbsCollection.cxx:1118
RooFormula.h
RooAbsCollection::canBeAdded
virtual bool canBeAdded(const RooAbsArg &arg, bool silent) const =0
Determine whether it's possible to add a given RooAbsArg to the collection or not.
RooAbsReal
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:61
RooArgList::at
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
Definition: RooArgList.h:72
RooLinkedList::fwdIterator
RooFIter fwdIterator() const
Create a one-time-use forward iterator for this list.
Definition: RooLinkedList.cxx:750
RooAbsCollection::makeTypedStructureTag
void makeTypedStructureTag()
Definition: RooAbsCollection.cxx:1419
TObject::GetTitle
virtual const char * GetTitle() const
Returns title of object.
Definition: TObject.cxx:403
RooAbsCollection::addServerClonesToList
Bool_t addServerClonesToList(const RooAbsArg &var)
Add clones of servers of given argument to end of list.
Definition: RooAbsCollection.cxx:295
TString
Basic string class.
Definition: TString.h:136
RooLinkedList::FindObject
TObject * FindObject(const char *name) const
Return pointer to obejct with given name.
Definition: RooLinkedList.cxx:531
RooAbsCollection::GetName
const char * GetName() const
Returns name of object.
Definition: RooAbsCollection.h:286
RooPrintable
RooPlotable is a 'mix-in' base class that define the standard RooFit plotting and printing methods.
Definition: RooPrintable.h:25
RooAbsCategory::getCurrentLabel
virtual const char * getCurrentLabel() const
Return label string of current state.
Definition: RooAbsCategory.cxx:130
TObject::InheritsFrom
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:445
RooAbsCollection::useHashMapForFind
void useHashMapForFind(bool flag) const
Install an internal hash map for fast finding of elements by name.
Definition: RooAbsCollection.cxx:1483
RooAbsCollection::printTitle
virtual void printTitle(std::ostream &os) const
Return collection title.
Definition: RooAbsCollection.cxx:1051
RooAbsCollection::operator=
RooAbsCollection & operator=(const RooAbsCollection &other)
The assignment operator sets the value of any argument in our set that also appears in the other set.
Definition: RooAbsCollection.cxx:324
bool
operator+
TString operator+(const TString &s1, const TString &s2)
Use the special concatenation constructor.
Definition: TString.cxx:1496
TString::ReplaceAll
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:692
RooAbsCollection::_sizeThresholdForMapSearch
std::size_t _sizeThresholdForMapSearch
Definition: RooAbsCollection.h:338
RooAbsCategory
RooAbsCategory is the base class for objects that represent a discrete value with a finite number of ...
Definition: RooAbsCategory.h:37
RooCmdConfig
Class RooCmdConfig is a configurable parser for RooCmdArg named arguments.
Definition: RooCmdConfig.h:27
RooAbsCollection.h
RooAbsCollection::setName
void setName(const char *name)
Definition: RooAbsCollection.h:282
RooLinkedList::At
TObject * At(int index) const
Return object stored in sequential position given by index.
Definition: RooLinkedList.cxx:487
TObject::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:359
RooTrace.h
RooAbsCollection::selectByName
RooAbsCollection * selectByName(const char *nameList, Bool_t verbose=kFALSE) const
Create a subset of the current collection, consisting only of those elements with names matching the ...
Definition: RooAbsCollection.cxx:735
TRegexp.h
RooAbsCollection::_ownCont
Bool_t _ownCont
Definition: RooAbsCollection.h:312
RooFit::DataHandling
@ DataHandling
Definition: RooGlobalFunc.h:62
RooPrintable::kName
@ kName
Definition: RooPrintable.h:33
RooAbsCollection::hasSameLayout
bool hasSameLayout(const RooAbsCollection &other) const
Check that all entries where the collections overlap have the same name.
Definition: RooAbsCollection.cxx:1534
RooAbsCategoryLValue::setIndex
virtual bool setIndex(value_type index, bool printError=true)=0
Change category state by specifying the index code of the desired state.
RooAbsCollection::makeStructureTag
void makeStructureTag()
Definition: RooAbsCollection.cxx:1412
RooAbsCollection::setCatIndex
Bool_t setCatIndex(const char *name, Int_t newVal=0, Bool_t verbose=kFALSE)
Set index value of a RooAbsCategoryLValue stored in set with given name to newVal.
Definition: RooAbsCollection.cxx:960
RooAbsCollection::getRealValue
Double_t getRealValue(const char *name, Double_t defVal=0, Bool_t verbose=kFALSE) const
Get value of a RooAbsReal stored in set with given name.
Definition: RooAbsCollection.cxx:853
RooAbsCollection::create
virtual TObject * create(const char *newname) const =0
RooAbsCollection::RooAbsCollection
RooAbsCollection()
Default constructor.
Definition: RooAbsCollection.cxx:70
RooAbsArg::syncCache
virtual void syncCache(const RooArgSet *nset=0)=0
RooAbsCollection::dump
void dump() const
Base contents dumper for debugging purposes.
Definition: RooAbsCollection.cxx:1153
RooAbsCollection::addClone
virtual RooAbsArg * addClone(const RooAbsArg &var, Bool_t silent=kFALSE)
Add a clone of the specified argument to list.
Definition: RooAbsCollection.cxx:428
TNamed
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
RooFIter
A one-time forward iterator working on RooLinkedList or RooAbsCollection.
Definition: RooLinkedListIter.h:40
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:101
TString::Append
TString & Append(const char *cs)
Definition: TString.h:564
RooPrintable::kCollectionHeader
@ kCollectionHeader
Definition: RooPrintable.h:33
RooLinkedList
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
Definition: RooLinkedList.h:37
RooAbsCollection::replace
virtual Bool_t replace(const RooAbsArg &var1, const RooAbsArg &var2)
Replace var1 with var2 and return kTRUE for success.
Definition: RooAbsCollection.cxx:534
RooFIter::next
RooAbsArg * next()
Return next element or nullptr if at end.
Definition: RooLinkedListIter.h:49
RooPrintable::kArgs
@ kArgs
Definition: RooPrintable.h:33
RooAbsCollection
RooAbsCollection is an abstract container object that can hold multiple RooAbsArg objects.
Definition: RooAbsCollection.h:33
RooAbsCollection::add
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
Definition: RooAbsCollection.cxx:455
RooAbsCollection::printLatex
void printLatex(const RooCmdArg &arg1=RooCmdArg(), const RooCmdArg &arg2=RooCmdArg(), const RooCmdArg &arg3=RooCmdArg(), const RooCmdArg &arg4=RooCmdArg(), const RooCmdArg &arg5=RooCmdArg(), const RooCmdArg &arg6=RooCmdArg(), const RooCmdArg &arg7=RooCmdArg(), const RooCmdArg &arg8=RooCmdArg()) const
Output content of collection as LaTex table.
Definition: RooAbsCollection.cxx:1195
RooAbsCollection::_allRRV
Bool_t _allRRV
Definition: RooAbsCollection.h:314
RooAbsCollection::size
Storage_t::size_type size() const
Definition: RooAbsCollection.h:214
RooLinkedList::Add
virtual void Add(TObject *arg)
Definition: RooLinkedList.h:64
RooPrintable::kValue
@ kValue
Definition: RooPrintable.h:33
RooAbsCollection::printValue
virtual void printValue(std::ostream &os) const
Print value of collection, i.e.
Definition: RooAbsCollection.cxx:1093
RooFit::ObjectHandling
@ ObjectHandling
Definition: RooGlobalFunc.h:61
RooAbsCollection::getCatLabel
const char * getCatLabel(const char *name, const char *defVal="", Bool_t verbose=kFALSE) const
Get state name of a RooAbsCategory stored in set with given name.
Definition: RooAbsCollection.cxx:896
RooRealVar.h
RooAbsCollection::addOwned
virtual Bool_t addOwned(RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
Definition: RooAbsCollection.cxx:403
RooAbsArg::servers
const RefCountList_t & servers() const
List of all servers of this object.
Definition: RooAbsArg.h:199
RooAbsCollection::~RooAbsCollection
virtual ~RooAbsCollection()
Destructor.
Definition: RooAbsCollection.cxx:140
unsigned int
ccoutE
#define ccoutE(a)
Definition: RooMsgService.h:41
TRegexp
Regular expression class.
Definition: TRegexp.h:31
RooAbsCollection::selectCommon
bool selectCommon(const RooAbsCollection &refColl, RooAbsCollection &outColl) const
Create a subset of the current collection, consisting only of those elements that are contained as we...
Definition: RooAbsCollection.cxx:702
RooGlobalFunc.h
TString::Index
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:639
RooAbsArg::copyCache
virtual void copyCache(const RooAbsArg *source, Bool_t valueOnly=kFALSE, Bool_t setValDirty=kTRUE)=0
RooCmdArg::_s
std::string _s[3]
Definition: RooCmdArg.h:119
TString::CompareTo
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
Definition: TString.cxx:439
RooPrintable::kClassName
@ kClassName
Definition: RooPrintable.h:33
RooPrintable::kExtras
@ kExtras
Definition: RooPrintable.h:33
Double_t
double Double_t
Definition: RtypesCore.h:59
RooAbsCollection::getStringValue
const char * getStringValue(const char *name, const char *defVal="", Bool_t verbose=kFALSE) const
Get string value of a RooStringVar stored in set with given name.
Definition: RooAbsCollection.cxx:982
RooRealVar::copyCacheFast
void copyCacheFast(const RooRealVar &other, Bool_t setValDirty=kTRUE)
Definition: RooRealVar.h:133
RooStringVar
RooStringVar is a RooAbsArg implementing string values.
Definition: RooStringVar.h:23
RooAbsCollection::equals
Bool_t equals(const RooAbsCollection &otherColl) const
Check if this and other collection have identically-named contents.
Definition: RooAbsCollection.cxx:775
RooAbsCategoryLValue.h
TMVA::DNN::forward
void forward(const LAYERDATA &prevLayerData, LAYERDATA &currLayerData)
apply the weights (and functions) in forward direction of the DNN
Definition: NeuralNet.icc:546
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
RooAbsArg::setAttribute
void setAttribute(const Text_t *name, Bool_t value=kTRUE)
Set (default) or clear a named boolean attribute of this object.
Definition: RooAbsArg.cxx:291
name
char name[80]
Definition: TGX11.cxx:110
RooPrintable::kTitle
@ kTitle
Definition: RooPrintable.h:33
RooNameReg::known
static const TNamed * known(const char *stringPtr)
If the name is already known, return its TNamed pointer. Otherwise return 0 (don't register the name)...
Definition: RooNameReg.cxx:113
genreflex::verbose
bool verbose
Definition: rootcling_impl.cxx:133
RooAbsCollection::_nameToItemMap
std::unique_ptr< std::unordered_map< const TNamed *, Storage_t::value_type > > _nameToItemMap
Definition: RooAbsCollection.h:337
RooPrintable::kSingleLine
@ kSingleLine
Definition: RooPrintable.h:34
RooAbsArg
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition: RooAbsArg.h:72
RMakeUnique.hxx
RooAbsCollection::Print
virtual void Print(Option_t *options=0) const
This method must be overridden when a class wants to print itself.
Definition: RooAbsCollection.h:259
RooAbsCollection::safeDeleteList
void safeDeleteList()
Examine client server dependencies in list and delete contents in safe order: any client is deleted b...
Definition: RooAbsCollection.cxx:154
RooFit::LatexTableStyle
RooCmdArg LatexTableStyle(Bool_t flag=kTRUE)
Definition: RooGlobalFunc.cxx:330
TNamed::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
Text_t
char Text_t
Definition: RtypesCore.h:62
RooAbsCategoryLValue
RooAbsCategoryLValue is the common abstract base class for objects that represent a discrete value th...
Definition: RooAbsCategoryLValue.h:25
RooAbsCollection::allInRange
Bool_t allInRange(const char *rangeSpec) const
Return true if all contained object report to have their value inside the specified range.
Definition: RooAbsCollection.cxx:1366
Class
void Class()
Definition: Class.C:29
RooRealVar
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:39
RooAbsRealLValue::setVal
virtual void setVal(Double_t value)=0
Set the current value of the object. Needs to be overridden by implementations.
RooAbsCollection::removeAll
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
Definition: RooAbsCollection.cxx:644
RooAbsRealLValue
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
Definition: RooAbsRealLValue.h:31
RooArgList.h
TObject::ClassName
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:130
RooAbsRealLValue.h
RooAbsCollection::selectByAttrib
RooAbsCollection * selectByAttrib(const char *name, Bool_t value) const
Create a subset of the current collection, consisting only of those elements with the specified attri...
Definition: RooAbsCollection.cxx:678
RooAbsCollection::printName
virtual void printName(std::ostream &os) const
Return collection name.
Definition: RooAbsCollection.cxx:1041
RooAbsCollection::makeLegacyIterator
std::unique_ptr< LegacyIterator_t > makeLegacyIterator(bool forward=true) const
Factory for legacy iterators.
Definition: RooAbsCollection.cxx:1458
RooAbsCollection::sort
void sort(Bool_t reverse=false)
Sort collection using std::sort and name comparison.
Definition: RooAbsCollection.cxx:1435
RooLinkedList::Delete
void Delete(Option_t *o=0)
Remove all elements in collection and delete all elements NB: Collection does not own elements,...
Definition: RooLinkedList.cxx:575
RooAbsCollection::insert
void insert(RooAbsArg *)
Insert an element into the owned collections.
Definition: RooAbsCollection.cxx:1468
RooAbsCollection::getSize
Int_t getSize() const
Definition: RooAbsCollection.h:231
RooAbsCollection::_list
Storage_t _list
Definition: RooAbsCollection.h:309
RooArgSet
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:33
RooAbsCollection::index
Int_t index(const RooAbsArg *arg) const
Returns index of given arg, or -1 if arg is not in the collection.
Definition: RooAbsCollection.h:247
RooAbsCollection::assignFast
void assignFast(const RooAbsCollection &other, Bool_t setValDirty=kTRUE)
Functional equivalent of operator=() but assumes this and other collection have same layout.
Definition: RooAbsCollection.cxx:370
RooAbsCollection::snapshot
RooAbsCollection * snapshot(Bool_t deepCopy=kTRUE) const
Take a snap shot of current collection contents.
Definition: RooAbsCollection.cxx:215
cxcoutD
#define cxcoutD(a)
Definition: RooMsgService.h:81
RooAbsCollection::setAttribAll
void setAttribAll(const Text_t *name, Bool_t value=kTRUE)
Set given attribute in each element of the collection by calling each elements setAttribute() functio...
Definition: RooAbsCollection.cxx:663
int
RooAbsCollection::clear
void clear()
Clear contents. If the collection is owning, it will also delete the contents.
Definition: RooAbsCollection.h:227
RooAbsCollection::contentsString
std::string contentsString() const
Return comma separated list of contained object names as STL string.
Definition: RooAbsCollection.cxx:1023