58#if (__GNUC__==3&&__GNUC_MINOR__==2&&__GNUC_PATCHLEVEL__==3)
73 _sizeThresholdForMapSearch(100)
88 _sizeThresholdForMapSearch(100)
106 _allRRV(other._allRRV),
107 _sizeThresholdForMapSearch(100)
114 for (
auto item : other.
_list) {
143 if (
_list.size() > 1) {
144 std::vector<RooAbsArg*> tmp;
145 tmp.reserve(
_list.size());
148 for (
auto arg :
_list) {
150 if (!arg->dependsOn(*
this, arg)) tmp.push_back(arg);
154 std::sort(tmp.begin(), tmp.end());
156 tmp.erase(std::unique(tmp.begin(), tmp.end()), tmp.end());
158 auto newEnd =
_list.end();
159 for (
auto item : tmp) {
160 newEnd = std::remove(
_list.begin(), newEnd, item);
164 }
while (!tmp.empty() &&
_list.size() > 1);
167 if (
_list.size() > 1) {
169 <<
") WARNING: unable to delete following elements in client-server order " ;
175 for (
auto item :
_list) {
204 snapName.
Append(
"Snapshot of ") ;
238 for (
auto orig :
_list) {
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);
256 coutE(
ObjectHandling) <<
"RooAbsCollection::snapshot(): Errors occurred in deep clone process, snapshot not created" << endl ;
265 var->redirectServers(
output,deepCopy);
288 for (
const auto server : var.
servers()) {
310 if (&other==
this)
return *this ;
312 for (
auto elem :
_list) {
313 auto theirs = other.
find(*elem);
314 if(!theirs)
continue;
316 elem->copyCache(theirs) ;
317 elem->setAttribute(
"Constant",theirs->isConstant()) ;
330 if (&other==
this)
return *this ;
339 for (
auto elem :
_list) {
340 auto theirs = other.
find(*elem);
341 if(!theirs)
continue;
343 elem->copyCache(theirs,
kTRUE) ;
356 if (&other==
this) return ;
359 auto iter2 = other.
_list.begin();
360 for (
auto iter1 =
_list.begin();
361 iter1 !=
_list.end() && iter2 != other.
_list.end();
368 auto theirs =
static_cast<RooRealVar*
>(*iter2);
371 (*iter2)->syncCache() ;
372 (*iter1)->copyCache(*iter2,
kTRUE,setValDirty) ;
460 for (
auto item : list.
_list) {
461 result |=
add(*item,silent);
478 for (
auto item : list.
_list) {
495 for (
auto item : list.
_list) {
510 coutE(
ObjectHandling) <<
"RooAbsCollection: cannot replace variables in a copied list" << endl;
515 for (
const auto * arg : other.
_list) {
517 auto found =
find(*arg);
518 if (found)
replace(*found,*arg);
535 coutE(
ObjectHandling) <<
"RooAbsCollection: cannot replace variables in a copied list" << endl;
541 auto var1It = std::find(
_list.begin(),
_list.end(), &var1);
543 if (var1It ==
_list.end()) {
545 <<
" and cannot be replaced" << endl;
553 if(other != 0 && other != &var1) {
555 <<
"\" with already existing \"" << var2.
GetName() <<
"\"" << endl;
585 const auto sizeBefore =
_list.size();
587 if (matchByNameOnly) {
590 return elm->GetName() ==
name;
592 std::set<RooAbsArg*> toBeDeleted;
596 if (nameMatch(elm)) {
597 toBeDeleted.insert(elm);
604 for (
auto arg : toBeDeleted)
607 _list.erase(std::remove(_list.begin(), _list.end(), &var), _list.end());
610 if (_nameToItemMap && sizeBefore != _list.size()) {
611 _nameToItemMap->erase(var.namePtr());
614 return sizeBefore != _list.size();
626 auto oldSize =
_list.size();
627 for (
auto item : list.
_list) {
628 remove(*item, silent, matchByNameOnly);
631 return oldSize !=
_list.size();
662 for (
auto arg :
_list) {
663 arg->setAttribute(
name, value);
678 selName.
Append(
"_selection") ;
682 for (
auto arg :
_list) {
683 if (arg->getAttribute(
name)==value)
702 selName.
Append(
"_selection") ;
706 for (
auto arg :
_list) {
707 if (refColl.
find(*arg))
725 selName.
Append(
"_selection") ;
728 const size_t bufSize = strlen(nameList) + 1;
729 char* buf =
new char[bufSize] ;
730 strlcpy(buf,nameList,bufSize) ;
731 char* wcExpr = strtok(buf,
",") ;
740 while((arg=iter.
next())) {
748 wcExpr = strtok(0,
",") ;
768 return left->
namePtr() == right->namePtr();
771 return std::is_permutation(
_list.begin(),
_list.end(),
772 otherColl.
_list.begin(),
784 for (
auto arg :
_list) {
785 if (otherColl.
find(*arg)) {
795template<
class Collection_t>
796RooAbsArg* findUsingNamePointer(
const Collection_t& coll,
const TNamed* ptr) {
797 auto findByNamePtr = [ptr](
const RooAbsArg* elm) {
798 return ptr == elm->namePtr();
801 auto item = std::find_if(coll.begin(), coll.end(), findByNamePtr);
803 return item != coll.end() ? *item :
nullptr;
818 if (!nptr)
return nullptr;
822 return item ? item : findUsingNamePointer(
_list, nptr);
832 const auto nptr = arg.
namePtr();
835 return item ? item : findUsingNamePointer(
_list, nptr);
842 const std::string theName(
name);
844 return elm->GetName() == theName;
846 return item !=
_list.end() ? item -
_list.begin() : -1;
996 return ras->getVal() ;
1017 ras->setVal(newVal);
1027 for (
auto arg :
_list) {
1028 retVal += arg->GetName();
1032 retVal.erase(retVal.end()-1);
1064 os << IsA()->GetName() ;
1077 if (opt &&
TString(opt)==
"I") {
1080 if (opt &&
TString(opt).Contains(
"v")) {
1098 for (
auto arg :
_list) {
1107 os << arg->GetName();
1129 Int_t maxNameLen(1) ;
1131 if (nameFieldLengthSaved==0) {
1132 for (
auto next :
_list) {
1133 Int_t len = strlen(next->GetName()) ;
1134 if (len>maxNameLen) maxNameLen = len ;
1139 unsigned int idx = 0;
1140 for (
auto next :
_list) {
1141 os <<
indent << std::setw(3) << ++idx <<
") ";
1156 for (
auto arg :
_list) {
1157 cout << arg <<
" " << arg->IsA()->GetName() <<
"::" << arg->GetName() <<
" (" << arg->GetTitle() <<
")" << endl ;
1205 pc.defineInt(
"ncol",
"Columns",0,1) ;
1206 pc.defineString(
"outputFile",
"OutputFile",0,
"") ;
1207 pc.defineString(
"format",
"Format",0,
"NEYVU") ;
1208 pc.defineInt(
"sigDigit",
"Format",0,1) ;
1209 pc.defineObject(
"siblings",
"Sibling",0,0,
kTRUE) ;
1210 pc.defineInt(
"dummy",
"FormatArgs",0,0) ;
1211 pc.defineMutex(
"Format",
"FormatArgs") ;
1221 pc.process(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
1226 const char* outFile =
pc.getString(
"outputFile") ;
1227 if (outFile && strlen(outFile)) {
1228 std::ofstream ofs(outFile) ;
1229 if (
pc.hasProcessed(
"FormatArgs")) {
1232 printLatex(ofs,
pc.getInt(
"ncol"),0,0,
pc.getObjectList(
"siblings"),formatCmd) ;
1234 printLatex(ofs,
pc.getInt(
"ncol"),
pc.getString(
"format"),
pc.getInt(
"sigDigit"),
pc.getObjectList(
"siblings")) ;
1237 if (
pc.hasProcessed(
"FormatArgs")) {
1240 printLatex(cout,
pc.getInt(
"ncol"),0,0,
pc.getObjectList(
"siblings"),formatCmd) ;
1242 printLatex(cout,
pc.getInt(
"ncol"),
pc.getString(
"format"),
pc.getInt(
"sigDigit"),
pc.getObjectList(
"siblings")) ;
1263 sibOption = option ;
1267 sibFormatCmd = *formatCmd ;
1271 static char buf[100] ;
1272 strlcpy(buf,tmp.
Data(),100) ;
1273 sibFormatCmd.
_s[0] = buf ;
1295 while((arg=iter.
next())) {
1301 coutW(
InputArguments) <<
"RooAbsCollection::printLatex: can only print RooRealVar in LateX, skipping non-RooRealVar object named "
1305 coutW(
InputArguments) <<
"RooAbsCollection::printLatex: WARNING: naming and/or ordering of sibling list is different" << endl ;
1308 listListRRV.
Add(list) ;
1310 coutW(
InputArguments) <<
"RooAbsCollection::printLatex: ERROR: sibling list(s) must have same length as self" << endl ;
1321 for (k=0 ; k<nlist ; k++) subheader +=
"c" ;
1323 TString header =
"\\begin{tabular}{" ;
1324 for (j=0 ; j<ncol ; j++) {
1325 if (j>0) header +=
"|" ;
1326 header += subheader ;
1329 ofs << header << endl ;
1333 for (i=0 ; i<nrow ; i++) {
1334 for (j=0 ; j<ncol ; j++) {
1335 for (k=0 ; k<nlist ; k++) {
1343 TString* tmp = par->
format((k==0)?*formatCmd:sibFormatCmd) ;
1348 if (!(j==ncol-1 && k==nlist-1)) {
1353 ofs <<
"\\\\" << endl ;
1356 ofs <<
"\\end{tabular}" << endl ;
1369 if (!rangeSpec)
return kTRUE ;
1372 vector<string> cutVec ;
1373 if (rangeSpec && strlen(rangeSpec)>0) {
1374 if (strchr(rangeSpec,
',')==0) {
1375 cutVec.push_back(rangeSpec) ;
1377 const size_t bufSize = strlen(rangeSpec)+1;
1378 char* buf =
new char[bufSize] ;
1379 strlcpy(buf,rangeSpec,bufSize) ;
1380 const char* oneRange = strtok(buf,
",") ;
1382 cutVec.push_back(oneRange) ;
1383 oneRange = strtok(0,
",") ;
1391 for (
auto arg :
_list) {
1394 for (icut=0 ; icut<cutVec.size() ; icut++) {
1395 if (arg->inRange(cutVec[icut].c_str())) {
1396 selectThisArg =
kTRUE ;
1400 if (!selectThisArg) {
1406 return selectByRange ;
1442 return strcmp(
l->GetName(),
r->
GetName()) > 0;
1445 std::sort(
_list.begin(),
_list.end(), cmpReverse);
1449 return strcmp(
l->GetName(),
r->
GetName()) < 0;
1461 ccoutE(
DataHandling) <<
"The legacy RooFit collection iterators don't support reverse iterations, any more. "
1462 <<
"Use begin() and end()" << endl;
1463 return std::make_unique<LegacyIterator_t>(
_list);
1470 _list.push_back(item);
1477 (*_nameToItemMap)[item->
namePtr()] = item;
1490 _nameToItemMap.reset(
new std::unordered_map<const TNamed*, Storage_t::value_type>());
1491 for (
const auto item :
_list) {
1492 (*_nameToItemMap)[item->namePtr()] = item;
1517 if (item->second->namePtr() == item->first) {
1518 return item->second;
1522 if (
auto arg = findUsingNamePointer(
_list, namePtr)) {
1523 (*_nameToItemMap)[arg->namePtr()] = arg;
static void indent(ostringstream &buf, int indent_level)
TString operator+(const TString &s1, const TString &s2)
Use the special concatenation constructor.
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
const TNamed * namePtr() const
virtual TObject * Clone(const char *newname=0) const
Make a clone of an object using the Streamer facility.
virtual void copyCache(const RooAbsArg *source, Bool_t valueOnly=kFALSE, Bool_t setValDirty=kTRUE)=0
void setAttribute(const Text_t *name, Bool_t value=kTRUE)
Set (default) or clear a named boolean attribute of this object.
const RefCountList_t & servers() const
List of all servers of this object.
virtual void syncCache(const RooArgSet *nset=0)=0
RooAbsCategoryLValue is the common abstract base class for objects that represent a discrete value th...
virtual bool setIndex(value_type index, bool printError=true)=0
Change category state by specifying the index code of the desired state.
virtual bool setLabel(const char *label, Bool_t printError=kTRUE)=0
Change category state by specifying a state name.
RooAbsCategory is the base class for objects that represent a discrete value with a finite number of ...
virtual value_type getCurrentIndex() const
Return index number of current state.
virtual const char * getCurrentLabel() const
Return label string of current state.
RooAbsCollection is an abstract container object that can hold multiple RooAbsArg objects.
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
RooAbsCollection * selectCommon(const RooAbsCollection &refColl) const
Create a subset of the current collection, consisting only of those elements that are contained as we...
Bool_t setCatLabel(const char *name, const char *newVal="", Bool_t verbose=kFALSE)
Set state name of a RooAbsCategoryLValue stored in set with given name to newVal.
virtual TObject * create(const char *newname) const =0
Bool_t setCatIndex(const char *name, Int_t newVal=0, Bool_t verbose=kFALSE)
Set index value of a RooAbsCategoryLValue stored in set with given name to newVal.
Int_t getCatIndex(const char *name, Int_t defVal=0, Bool_t verbose=kFALSE) const
Get index value of a RooAbsCategory stored in set with given name.
RooAbsCollection()
Default constructor.
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.
virtual Bool_t replace(const RooAbsArg &var1, const RooAbsArg &var2)
Replace var1 with var2 and return kTRUE for success.
const char * getCatLabel(const char *name, const char *defVal="", Bool_t verbose=kFALSE) const
Get state name of a RooAbsCategory stored in set with given name.
RooAbsArg * tryFastFind(const TNamed *namePtr) const
Perform a search in a hash map.
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.
void sort(Bool_t reverse=false)
Sort collection using std::sort and name comparison.
Bool_t addServerClonesToList(const RooAbsArg &var)
Add clones of servers of given argument to end of list.
virtual void printName(std::ostream &os) const
Return collection name.
RooAbsCollection * snapshot(Bool_t deepCopy=kTRUE) const
Take a snap shot of current collection contents.
virtual Bool_t addOwned(RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
virtual RooAbsArg * addClone(const RooAbsArg &var, Bool_t silent=kFALSE)
Add a clone of the specified argument to list.
Int_t index(const RooAbsArg *arg) const
Returns index of given arg, or -1 if arg is not in the collection.
RooFIter fwdIterator() const
One-time forward iterator.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
Bool_t setStringValue(const char *name, const char *newVal="", Bool_t verbose=kFALSE)
Set string value of a RooStringVar stored in set with given name to newVal.
Double_t getRealValue(const char *name, Double_t defVal=0, Bool_t verbose=kFALSE) const
Get value of a RooAbsReal stored in set with given name.
virtual ~RooAbsCollection()
Destructor.
Bool_t setRealValue(const char *name, Double_t newVal=0, Bool_t verbose=kFALSE)
Set value of a RooAbsRealLValye stored in set with given name to newVal No error messages are printed...
RooAbsArg * first() const
void assignFast(const RooAbsCollection &other, Bool_t setValDirty=kTRUE)
Functional equivalent of operator=() but assumes this and other collection have same layout.
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 ...
Bool_t overlaps(const RooAbsCollection &otherColl) const
Check if this and other collection have common entries.
Bool_t allInRange(const char *rangeSpec) const
Return true if all contained object report to have their value inside the specified range.
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 ...
virtual void Print(Option_t *options=0) const
This method must be overridden when a class wants to print itself.
std::unique_ptr< LegacyIterator_t > makeLegacyIterator(bool forward=true) const
Factory for legacy iterators.
std::size_t _sizeThresholdForMapSearch
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...
std::unique_ptr< std::unordered_map< const TNamed *, Storage_t::value_type > > _nameToItemMap
void dump() const
Base contents dumper for debugging purposes.
virtual void printTitle(std::ostream &os) const
Return collection title.
Bool_t equals(const RooAbsCollection &otherColl) const
Check if this and other collection have identically-named contents.
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...
void useHashMapForFind(bool flag) const
Install an internal hash map for fast finding of elements by name.
const char * getStringValue(const char *name, const char *defVal="", Bool_t verbose=kFALSE) const
Get string value of a RooStringVar stored in set with given name.
const char * GetName() const
Returns name of object.
virtual void printClassName(std::ostream &os) const
Return collection class name.
std::string contentsString() const
Return comma separated list of contained object names as STL string.
void setName(const char *name)
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 safeDeleteList()
Examine client server dependencies in list and delete contents in safe order: any client is deleted b...
virtual void RecursiveRemove(TObject *obj)
If one of the TObject we have a referenced to is deleted, remove the reference.
virtual Bool_t remove(const RooAbsArg &var, Bool_t silent=kFALSE, Bool_t matchByNameOnly=kFALSE)
Remove the specified argument from our list.
void makeTypedStructureTag()
void insert(RooAbsArg *)
Insert an element into the owned collections.
RooAbsArg * find(const char *name) const
Find object with given name in list.
virtual void printValue(std::ostream &os) const
Print value of collection, i.e.
virtual Int_t defaultPrintContents(Option_t *opt) const
Define default RooPrinable print options for given Print() flag string For inline printing only show ...
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
virtual void setVal(Double_t value)=0
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooCmdArg is a named container for two doubles, two integers two object points and three string point...
void addArg(const RooCmdArg &arg)
Utility function to add nested RooCmdArg to payload of this RooCmdArg.
Class RooCmdConfig is a configurable parser for RooCmdArg named arguments.
A one-time forward iterator working on RooLinkedList or RooAbsCollection.
RooAbsArg * next()
Return next element or nullptr if at end.
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
TObject * FindObject(const char *name) const
Return pointer to obejct with given name.
RooFIter fwdIterator() const
Create a one-time-use forward iterator for this list.
TObject * At(Int_t index) const
Return object stored in sequential position given by index.
void Delete(Option_t *o=0)
Remove all elements in collection and delete all elements NB: Collection does not own elements,...
virtual void Add(TObject *arg)
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)...
RooPlotable is a 'mix-in' base class that define the standard RooFit plotting and printing methods.
static void nameFieldLength(Int_t newLen)
Set length of field reserved from printing name of RooAbsArgs in multi-line collection printing to gi...
RooRealVar represents a variable that can be changed from the outside.
TString * format(const RooCmdArg &formatArg) const
Format contents of RooRealVar for pretty printing on RooPlot parameter boxes.
void copyCacheFast(const RooRealVar &other, Bool_t setValDirty=kTRUE)
std::size_t size() const
Number of contained objects (neglecting the ref count).
RooStringVar is a RooAbsArg implementing string values.
static void create(const TObject *obj)
Register creation of object 'obj'.
The TNamed class is the base class for all named ROOT classes.
virtual const char * GetName() const
Returns name of object.
Mother of all ROOT objects.
virtual const char * GetName() const
Returns name of object.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
virtual const char * GetTitle() const
Returns title of object.
Regular expression class.
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
TString & Append(const char *cs)
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
RooCmdArg LatexTableStyle(Bool_t flag=kTRUE)
static constexpr double pc
void forward(const LAYERDATA &prevLayerData, LAYERDATA &currLayerData)
apply the weights (and functions) in forward direction of the DNN
static void output(int code)