Logo ROOT  
Reference Guide
RooArgList.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitCore *
4  * File: $Id: RooArgList.h,v 1.14 2007/05/11 09:11:30 verkerke Exp $
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 #ifndef ROO_ARG_LIST
17 #define ROO_ARG_LIST
18 
19 #include "RooAbsCollection.h"
20 
21 class RooArgList : public RooAbsCollection {
22 public:
23 
24  // Constructors, assignment etc.
25  RooArgList();
26  RooArgList(const RooArgSet& set) ;
27  explicit RooArgList(const TCollection& tcoll, const char* name="") ;
28  explicit RooArgList(const char *name);
29  /// Construct a (non-owning) RooArgList from one or more
30  /// RooFit objects.
31  /// \param arg A RooFit object to be put in the set.
32  /// \param varsOrName Arbitrary number of
33  /// - RooFit objects deriving from RooAbsArg.
34  /// - A c-string to name the set.
35  template<typename... Arg_t>
36  RooArgList(const RooAbsArg& arg, const Arg_t&... argsOrName)
37  /*NB: Making this a delegating constructor led to linker errors with MSVC*/ {
38  processArg(arg);
39  // Expand parameter pack in C++ 11 way:
40  int dummy[] = { 0, (processArg(argsOrName), 0) ... };
41  (void)dummy;
42  };
43 
44  /// Construct from iterators.
45  /// \tparam Iterator_t An iterator pointing to RooFit objects or references thereof.
46  /// \param beginIt Iterator to first element to add.
47  /// \param end Iterator to end of range to be added.
48  /// \param name Optional name of the collection.
49  template<typename Iterator_t,
50  typename value_type = typename std::iterator_traits<Iterator_t>::value_type,
51  typename = std::enable_if<std::is_convertible<const value_type*, const RooAbsArg*>::value> >
52  RooArgList(Iterator_t beginIt, Iterator_t endIt, const char* name="") :
53  RooArgList(name) {
54  for (auto it = beginIt; it != endIt; ++it) {
55  add(*it);
56  }
57  }
58 
59  virtual ~RooArgList();
60  // Create a copy of an existing list. New variables cannot be added
61  // to a copied list. The variables in the copied list are independent
62  // of the original variables.
63  RooArgList(const RooArgList& other, const char *name="");
64  virtual TObject* clone(const char* newname) const { return new RooArgList(*this,newname); }
65  virtual TObject* create(const char* newname) const { return new RooArgList(newname); }
66  RooArgList& operator=(const RooArgList& other) { RooAbsCollection::operator=(other) ; return *this ; }
67 
68 
69  /// Return object at given index, or nullptr if index is out of range
70  inline RooAbsArg* at(Int_t idx) const {
71 
72  if (idx >= static_cast<Int_t>(_list.size()))
73  return nullptr;
74 
75  return _list[idx];
76  }
77 
78  // I/O streaming interface (machine readable)
79  virtual Bool_t readFromStream(std::istream& is, Bool_t compact, Bool_t verbose=kFALSE) ;
80  virtual void writeToStream(std::ostream& os, Bool_t compact) ;
81 
82  RooAbsArg& operator[](Int_t idx) const ;
83 
84 private:
85  void processArg(const RooAbsArg& arg) { add(arg); }
86  void processArg(const char* name) { _name = name; }
87 
88  ClassDef(RooArgList,1) // Ordered list of RooAbsArg objects
89 };
90 
91 #endif
RooArgList::processArg
void processArg(const char *name)
Definition: RooArgList.h:86
RooArgList::create
virtual TObject * create(const char *newname) const
Definition: RooArgList.h:65
RooArgList::operator[]
RooAbsArg & operator[](Int_t idx) const
Array operator.
Definition: RooArgList.cxx:146
RooArgList
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgList.h:21
RooArgList::operator=
RooArgList & operator=(const RooArgList &other)
Definition: RooArgList.h:66
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
RooArgList::RooArgList
RooArgList(Iterator_t beginIt, Iterator_t endIt, const char *name="")
Construct from iterators.
Definition: RooArgList.h:52
RooAbsCollection::_name
TString _name
Definition: RooAbsCollection.h:254
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
RooAbsCollection.h
RooArgList::processArg
void processArg(const RooAbsArg &arg)
Definition: RooArgList.h:85
RooArgList::RooArgList
RooArgList(const RooAbsArg &arg, const Arg_t &... argsOrName)
Construct a (non-owning) RooArgList from one or more RooFit objects.
Definition: RooArgList.h:36
RooArgList::RooArgList
RooArgList()
Default constructor.
Definition: RooArgList.cxx:59
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
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
void
typedef void((*Func_t)())
RooArgList::writeToStream
virtual void writeToStream(std::ostream &os, Bool_t compact)
Write the contents of the argset in ASCII form to given stream.
Definition: RooArgList.cxx:166
RooArgList::~RooArgList
virtual ~RooArgList()
Destructor.
Definition: RooArgList.cxx:129
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
name
char name[80]
Definition: TGX11.cxx:110
RooArgList::readFromStream
virtual Bool_t readFromStream(std::istream &is, Bool_t compact, Bool_t verbose=kFALSE)
Read the contents of the argset in ASCII form from given stream.
Definition: RooArgList.cxx:189
RooArgList::clone
virtual TObject * clone(const char *newname) const
Definition: RooArgList.h:64
genreflex::verbose
bool verbose
Definition: rootcling_impl.cxx:133
RooAbsArg
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition: RooAbsArg.h:72
TCollection
Collection abstract base class.
Definition: TCollection.h:63
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
int