File indexing completed on 2025-01-18 10:11:18
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef ROO_ARG_LIST
0017 #define ROO_ARG_LIST
0018
0019 #include "RooAbsCollection.h"
0020
0021
0022 class RooArgList : public RooAbsCollection {
0023 public:
0024
0025
0026 RooArgList();
0027 RooArgList(const RooAbsCollection& coll) ;
0028 explicit RooArgList(const TCollection& tcoll, const char* name="") ;
0029 explicit RooArgList(const char *name);
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042 template<typename... Args_t>
0043 RooArgList(RooAbsArg const& arg, Args_t &&... moreArgsOrName)
0044
0045 {
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055 processArgs(arg, std::forward<Args_t>(moreArgsOrName)...);
0056 }
0057
0058
0059
0060 template<typename... Args_t>
0061 RooArgList(RooAbsArg && arg, Args_t &&... moreArgsOrName)
0062 : RooArgList{arg, std::move(arg), std::forward<Args_t>(moreArgsOrName)...} {}
0063
0064 template<typename... Args_t>
0065 explicit RooArgList(double arg, Args_t &&... moreArgsOrName) {
0066 processArgs(arg, std::forward<Args_t>(moreArgsOrName)...);
0067 }
0068
0069
0070
0071
0072
0073
0074 template<typename Iterator_t,
0075 typename value_type = typename std::remove_pointer<typename std::iterator_traits<Iterator_t>::value_type>,
0076 typename = std::enable_if<std::is_convertible<const value_type*, const RooAbsArg*>::value> >
0077 RooArgList(Iterator_t beginIt, Iterator_t endIt, const char* name="") :
0078 RooArgList(name) {
0079 for (auto it = beginIt; it != endIt; ++it) {
0080 processArg(*it);
0081 }
0082 }
0083
0084
0085
0086
0087
0088
0089
0090 RooArgList(std::vector<RooAbsArgPtrOrDouble> const& vec) {
0091 for(auto const& arg : vec) {
0092 if(arg.hasPtr) processArg(arg.ptr);
0093 else processArg(arg.val);
0094 }
0095 }
0096
0097 ~RooArgList() override;
0098
0099
0100
0101 RooArgList(const RooArgList& other, const char *name="");
0102
0103 RooArgList(RooArgList && other) : RooAbsCollection(std::move(other)) {}
0104 TObject* clone(const char* newname) const override { return new RooArgList(*this,newname); }
0105 TObject* create(const char* newname) const override { return new RooArgList(newname); }
0106 RooArgList& operator=(const RooArgList& other) { RooAbsCollection::operator=(other) ; return *this ; }
0107
0108
0109
0110 inline RooAbsArg* at(Int_t idx) const {
0111
0112 if (idx >= static_cast<Int_t>(_list.size()))
0113 return nullptr;
0114
0115 return _list[idx];
0116 }
0117
0118
0119 virtual bool readFromStream(std::istream& is, bool compact, bool verbose=false);
0120 virtual void writeToStream(std::ostream& os, bool compact);
0121
0122
0123 RooAbsArg& operator[](Int_t idx) const {
0124 assert(0 <= idx && idx < static_cast<Int_t>(_list.size()));
0125 return *_list[idx];
0126 }
0127
0128 protected:
0129 bool canBeAdded(RooAbsArg const&, bool) const override { return true; }
0130
0131 private:
0132 template<typename... Args_t>
0133 void processArgs(Args_t &&... args) {
0134
0135 int dummy[] = { 0, (processArg(std::forward<Args_t>(args)), 0) ... };
0136 (void)dummy;
0137 }
0138 void processArg(const RooAbsArg& arg) { add(arg); }
0139 void processArg(const RooAbsArg* arg) { add(*arg); }
0140 void processArg(RooAbsArg* arg) { add(*arg); }
0141 template<class Arg_t>
0142 void processArg(Arg_t && arg) {
0143 assert_is_no_temporary(std::forward<Arg_t>(arg));
0144 add(arg);
0145 }
0146 void processArg(const char* name) { _name = name; }
0147 void processArg(double value);
0148
0149 ClassDefOverride(RooArgList,1)
0150 };
0151
0152
0153 namespace RooFitShortHand {
0154
0155 template<class... Args_t>
0156 RooArgList L(Args_t&&... args) {
0157 return {std::forward<Args_t>(args)...};
0158 }
0159
0160 }
0161
0162
0163 #endif