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