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