Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:11:22

0001 /*****************************************************************************
0002  * Project: RooFit                                                           *
0003  * Package: RooFitCore                                                       *
0004  *    File: $Id: RooGlobalFunc.h,v 1.14 2007/07/16 21:04:28 wouter Exp $
0005  * Authors:                                                                  *
0006  *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
0007  *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
0008  *                                                                           *
0009  * Copyright (c) 2000-2005, Regents of the University of California          *
0010  *                          and Stanford University. All rights reserved.    *
0011  *                                                                           *
0012  * Redistribution and use in source and binary forms,                        *
0013  * with or without modification, are permitted according to the terms        *
0014  * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
0015  *****************************************************************************/
0016 #ifndef ROO_GLOBAL_FUNC
0017 #define ROO_GLOBAL_FUNC
0018 
0019 #include "RooCmdArg.h"
0020 #include "RooLinkedList.h"
0021 #include "RooArgSet.h"
0022 
0023 #include "ROOT/RConfig.hxx"
0024 
0025 #include <map>
0026 #include <string>
0027 
0028 class RooDataHist ;
0029 class RooDataSet ;
0030 class RooFitResult ;
0031 class RooAbsPdf ;
0032 class RooAbsRealLValue ;
0033 class RooRealConstant ;
0034 class RooMsgService ;
0035 class RooFormulaVar ;
0036 class RooAbsData ;
0037 class RooCategory ;
0038 class RooAbsReal ;
0039 class RooAbsBinning ;
0040 class RooAbsCollection ;
0041 class RooAbsPdf ;
0042 class RooConstVar ;
0043 class RooRealVar ;
0044 class RooAbsCategory ;
0045 class RooNumIntConfig ;
0046 class TH1 ;
0047 class TTree ;
0048 
0049 /*! \namespace RooFit
0050 The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs
0051 (or other types of arguments).
0052 
0053 These switches are documented with the relevant functions, e.g. RooAbsPdf::fitTo().
0054 For an introduction to RooFit (not the namespace), check the [user's guides](https://root.cern/root-user-guides-and-manuals),
0055 [courses](https://root.cern/courses) or [the RooFit chapter of the Manual](https://root.cern/manual/roofit/).
0056 */
0057 namespace RooFit {
0058 
0059 /// Verbosity level for RooMsgService::StreamConfig in RooMsgService
0060 enum MsgLevel { DEBUG=0, INFO=1, PROGRESS=2, WARNING=3, ERROR=4, FATAL=5 } ;
0061 /// Topics for a RooMsgService::StreamConfig in RooMsgService
0062 enum MsgTopic { Generation=1, Minimization=2, Plotting=4, Fitting=8, Integration=16, LinkStateMgmt=32,
0063     Eval=64, Caching=128, Optimization=256, ObjectHandling=512, InputArguments=1024, Tracing=2048,
0064     Contents=4096, DataHandling=8192, NumIntegration=16384, FastEvaluations=1<<15, HistFactory=1<<16, IO=1<<17 };
0065 enum MPSplit { BulkPartition=0, Interleave=1, SimComponents=2, Hybrid=3 } ;
0066 
0067 /// For setting the offset mode with the Offset() command argument to
0068 /// RooAbsPdf::fitTo()
0069 enum class OffsetMode { None, Initial, Bin };
0070 
0071 namespace Experimental {
0072 
0073 /// Configuration options for parallel minimization with multiprocessing library
0074 RooCmdArg ParallelGradientOptions(bool enable=true, int orderStrategy=0, int chainFactor=1) ;
0075 RooCmdArg ParallelDescentOptions(bool enable=false, int splitStrategy=0, int numSplits=4) ;
0076 
0077 } // Experimental
0078 
0079 /**
0080  * \defgroup CmdArgs RooFit command arguments
0081  * These arguments can be passed to functions of RooFit objects.
0082  * \ingroup Roofitmain
0083  * @{
0084  */
0085 
0086 /**
0087  * \defgroup Plotting Arguments for plotOn functions
0088  * @{
0089  */
0090 RooCmdArg DrawOption(const char* opt) ;
0091 RooCmdArg Normalization(double scaleFactor) ;
0092 RooCmdArg Slice(const RooArgSet& sliceSet) ;
0093 RooCmdArg Slice(RooCategory& cat, const char* label) ;
0094 RooCmdArg Slice(std::map<RooCategory*, std::string> const&) ;
0095 RooCmdArg Project(const RooArgSet& projSet) ;
0096 RooCmdArg ProjWData(const RooAbsData& projData, bool binData=false) ;
0097 RooCmdArg ProjWData(const RooArgSet& projSet, const RooAbsData& projData, bool binData=false) ;
0098 RooCmdArg Asymmetry(const RooCategory& cat) ;
0099 RooCmdArg Precision(double prec) ;
0100 RooCmdArg ShiftToZero() ;
0101 RooCmdArg Range(const char* rangeName, bool adjustNorm=true) ;
0102 RooCmdArg Range(double lo, double hi, bool adjustNorm=true) ;
0103 RooCmdArg NormRange(const char* rangeNameList) ;
0104 RooCmdArg VLines() ;
0105 RooCmdArg LineColor(Color_t color) ;
0106 RooCmdArg LineStyle(Style_t style) ;
0107 RooCmdArg LineWidth(Width_t width) ;
0108 RooCmdArg FillColor(Color_t color) ;
0109 RooCmdArg FillStyle(Style_t style) ;
0110 RooCmdArg ProjectionRange(const char* rangeName) ;
0111 RooCmdArg Name(const char* name) ;
0112 RooCmdArg Invisible(bool inv=true) ;
0113 RooCmdArg AddTo(const char* name, double wgtSel=1.0, double wgtOther=1.0) ;
0114 RooCmdArg EvalErrorValue(double value) ;
0115 RooCmdArg MoveToBack()  ;
0116 RooCmdArg VisualizeError(const RooDataSet& paramData, double Z=1) ;
0117 RooCmdArg VisualizeError(const RooFitResult& fitres, double Z=1, bool linearMethod=true) ;
0118 RooCmdArg VisualizeError(const RooFitResult& fitres, const RooArgSet& param, double Z=1, bool linearMethod=true) ;
0119 RooCmdArg ShowProgress() ;
0120 
0121 // RooAbsPdf::plotOn arguments
0122 RooCmdArg Normalization(double scaleFactor, Int_t scaleType) ;
0123 template<class... Args_t>
0124 RooCmdArg Components(Args_t &&... argsOrArgSet) {
0125   RooCmdArg out{"SelectCompSet",0};
0126   out.setSet(0, RooArgSet{std::forward<Args_t>(argsOrArgSet)...});
0127   return out;
0128 }
0129 RooCmdArg Components(const char* compSpec) ;
0130 
0131 // RooAbsData::plotOn arguments
0132 RooCmdArg Cut(const char* cutSpec) ;
0133 RooCmdArg Cut(const RooFormulaVar& cutVar) ;
0134 RooCmdArg Binning(const RooAbsBinning& binning) ;
0135 RooCmdArg Binning(const char* binningName) ;
0136 RooCmdArg Binning(int nBins, double xlo=0.0, double xhi=0.0) ;
0137 RooCmdArg MarkerStyle(Style_t style) ;
0138 RooCmdArg MarkerSize(Size_t size) ;
0139 RooCmdArg MarkerColor(Color_t color) ;
0140 RooCmdArg CutRange(const char* rangeName) ;
0141 RooCmdArg XErrorSize(double width) ;
0142 RooCmdArg RefreshNorm() ;
0143 RooCmdArg Efficiency(const RooCategory& cat) ;
0144 RooCmdArg Rescale(double factor) ;
0145 
0146 /** @} */
0147 
0148 /**
0149  * \defgroup ConstructorArgs Arguments for various constructors
0150  * @{
0151  */
0152 // RooDataHist::ctor arguments
0153 RooCmdArg Weight(double wgt) ;
0154 RooCmdArg Index(RooCategory& icat) ;
0155 RooCmdArg Import(const char* state, TH1& histo) ;
0156 RooCmdArg Import(const std::map<std::string,TH1*>&) ;
0157 RooCmdArg Import(const char* state, RooDataHist& dhist) ;
0158 RooCmdArg Import(const std::map<std::string,RooDataHist*>&) ;
0159 RooCmdArg Import(TH1& histo, bool importDensity=false) ;
0160 
0161 // RooDataSet::ctor arguments
0162 RooCmdArg WeightVar(const char* name="weight", bool reinterpretAsWeight=false) ;
0163 RooCmdArg WeightVar(const RooRealVar& arg, bool reinterpretAsWeight=false) ;
0164 RooCmdArg Import(const char* state, RooAbsData& data) ;
0165 RooCmdArg Import(const std::map<std::string,RooDataSet*>& ) ;
0166 template<class DataPtr_t>
0167 RooCmdArg Import(std::map<std::string,DataPtr_t> const& map) {
0168     RooCmdArg container("ImportDataSliceMany",0,0,0,0,nullptr,nullptr,nullptr,nullptr) ;
0169     for (auto const& item : map) {
0170       container.addArg(Import(item.first.c_str(), *item.second)) ;
0171     }
0172     container.setProcessRecArgs(true,false) ;
0173     return container ;
0174 }
0175 
0176 RooCmdArg Link(const char* state, RooAbsData& data) ;
0177 RooCmdArg Link(const std::map<std::string,RooAbsData*>&) ;
0178 RooCmdArg Import(RooAbsData& data) ;
0179 RooCmdArg Import(TTree& tree) ;
0180 RooCmdArg ImportFromFile(const char* fname, const char* tname) ;
0181 RooCmdArg StoreError(const RooArgSet& aset) ;
0182 RooCmdArg StoreAsymError(const RooArgSet& aset) ;
0183 RooCmdArg OwnLinked() ;
0184 
0185 /** @} */
0186 
0187 // RooAbsPdf::printLatex arguments
0188 RooCmdArg Columns(Int_t ncol) ;
0189 RooCmdArg OutputFile(const char* fileName) ;
0190 RooCmdArg Format(const char* what, const RooCmdArg& arg1={}, const RooCmdArg& arg2={},
0191                  const RooCmdArg& arg3={},const RooCmdArg& arg4={},
0192                  const RooCmdArg& arg5={},const RooCmdArg& arg6={},
0193                  const RooCmdArg& arg7={},const RooCmdArg& arg8={}) ;
0194 RooCmdArg Sibling(const RooAbsCollection& sibling) ;
0195 
0196 // RooAbsRealLValue::frame arguments
0197 RooCmdArg Title(const char* name) ;
0198 RooCmdArg Bins(Int_t nbin) ;
0199 RooCmdArg AutoSymRange(const RooAbsData& data, double marginFactor=0.1) ;
0200 RooCmdArg AutoRange(const RooAbsData& data, double marginFactor=0.1) ;
0201 
0202 // RooAbsData::createHistogram arguments
0203 RooCmdArg AutoSymBinning(Int_t nbins=100, double marginFactor=0.1) ;
0204 RooCmdArg AutoBinning(Int_t nbins=100, double marginFactor=0.1) ;
0205 
0206 // RooAbsReal::fillHistogram arguments
0207 RooCmdArg IntegratedObservables(const RooArgSet& intObs) ;
0208 
0209 // RooAbsData::reduce arguments
0210 RooCmdArg SelectVars(const RooArgSet& vars) ;
0211 RooCmdArg EventRange(Int_t nStart, Int_t nStop) ;
0212 
0213 
0214 /**
0215  * \defgroup Fitting Arguments for fitting
0216  * @{
0217  */
0218 // RooChi2Var::ctor / RooNLLVar arguments
0219 RooCmdArg Extended(bool flag=true) ;
0220 RooCmdArg DataError(Int_t) ;
0221 RooCmdArg NumCPU(Int_t nCPU, Int_t interleave=0) ;
0222 RooCmdArg Parallelize(int nWorkers) ;
0223 RooCmdArg ModularL(bool flag=false) ;
0224 RooCmdArg TimingAnalysis(bool timingAnalysis) ;
0225 
0226 //RooCmdArg BatchMode(std::string const& batchMode="cpu");
0227 //// The const char * overload is necessary, otherwise the compiler will cast a
0228 //// C-Style string to a bool and choose the BatchMode(bool) overload if one
0229 //// calls for example BatchMode("off").
0230 //inline RooCmdArg BatchMode(const char * batchMode) { return BatchMode(std::string(batchMode)); }
0231 //inline RooCmdArg BatchMode(bool batchModeOn) { return BatchMode(batchModeOn ? "cpu" : "off"); }
0232 
0233 RooCmdArg IntegrateBins(double precision);
0234 
0235 // RooAbsPdf::fitTo arguments
0236 RooCmdArg PrefitDataFraction(double data_ratio = 0.0) ;
0237 RooCmdArg Optimize(Int_t flag=2) ;
0238 
0239 class EvalBackend : public RooCmdArg {
0240 public:
0241    enum class Value { Legacy, Cpu, Cuda, Codegen, CodegenNoGrad };
0242 
0243    EvalBackend(Value value);
0244 
0245    EvalBackend(std::string const &name);
0246 
0247    static EvalBackend Legacy();
0248    static EvalBackend Cpu();
0249    static EvalBackend Cuda();
0250    static EvalBackend Codegen();
0251    static EvalBackend CodegenNoGrad();
0252 
0253    Value value() const { return static_cast<Value>(getInt(0)); }
0254 
0255    bool operator==(EvalBackend const &other) const { return value() == other.value(); }
0256 
0257    bool operator!=(EvalBackend const &other) const { return value() != other.value(); }
0258 
0259    std::string name() const;
0260 
0261    static Value &defaultValue();
0262 private:
0263    static Value toValue(std::string const& name);
0264    static std::string toName(Value value);
0265 };
0266 
0267 ////////////////////////////////////////////////////////////////////////////////
0268 /// Create a RooCmdArg to declare conditional observables.
0269 /// \param[in] argsOrArgSet Can either be one or more RooRealVar with the
0270 //                          observables or a single RooArgSet containing them.
0271 template<class... Args_t>
0272 RooCmdArg ConditionalObservables(Args_t &&... argsOrArgSet) {
0273   RooCmdArg out{"ProjectedObservables",0};
0274   out.setSet(0, RooArgSet{std::forward<Args_t>(argsOrArgSet)...});
0275   return out;
0276 }
0277 
0278 // obsolete, for backward compatibility
0279 template<class... Args_t>
0280 RooCmdArg ProjectedObservables(Args_t &&... argsOrArgSet) {
0281   return ConditionalObservables(std::forward<Args_t>(argsOrArgSet)...);
0282 }
0283 
0284 RooCmdArg Verbose(bool flag=true) ;
0285 RooCmdArg Save(bool flag=true) ;
0286 RooCmdArg Timer(bool flag=true) ;
0287 RooCmdArg PrintLevel(Int_t code) ;
0288 RooCmdArg Warnings(bool flag=true) ;
0289 RooCmdArg Strategy(Int_t code) ;
0290 RooCmdArg InitialHesse(bool flag=true) ;
0291 RooCmdArg Hesse(bool flag=true) ;
0292 RooCmdArg Minos(bool flag=true) ;
0293 RooCmdArg Minos(const RooArgSet& minosArgs) ;
0294 RooCmdArg SplitRange(bool flag=true) ;
0295 RooCmdArg SumCoefRange(const char* rangeName) ;
0296 RooCmdArg Constrain(const RooArgSet& params) ;
0297 RooCmdArg MaxCalls(int n) ;
0298 
0299 template<class... Args_t>
0300 RooCmdArg GlobalObservables(Args_t &&... argsOrArgSet) {
0301   RooCmdArg out{"GlobalObservables",0};
0302   out.setSet(0, RooArgSet{std::forward<Args_t>(argsOrArgSet)...});
0303   return out;
0304 }
0305 RooCmdArg GlobalObservablesSource(const char* sourceName);
0306 RooCmdArg GlobalObservablesTag(const char* tagName) ;
0307 RooCmdArg ExternalConstraints(const RooArgSet& constraintPdfs) ;
0308 RooCmdArg PrintEvalErrors(Int_t numErrors) ;
0309 RooCmdArg EvalErrorWall(bool flag) ;
0310 RooCmdArg SumW2Error(bool flag) ;
0311 RooCmdArg AsymptoticError(bool flag) ;
0312 RooCmdArg CloneData(bool flag) ;
0313 RooCmdArg Integrate(bool flag) ;
0314 RooCmdArg Minimizer(const char* type, const char* alg=nullptr) ;
0315 RooCmdArg Offset(std::string const& mode);
0316 // The const char * overload is necessary, otherwise the compiler will cast a
0317 // C-Style string to a bool and choose the Offset(bool) overload if one
0318 // calls for example Offset("off").
0319 inline RooCmdArg Offset(const char * mode) { return Offset(std::string(mode)); }
0320 // For backwards compatibility
0321 inline RooCmdArg Offset(bool flag=true) { return flag ? Offset("initial") : Offset("off"); }
0322 RooCmdArg RecoverFromUndefinedRegions(double strength);
0323 /** @} */
0324 
0325 // RooAbsPdf::paramOn arguments
0326 RooCmdArg Label(const char* str) ;
0327 RooCmdArg Layout(double xmin, double xmax=0.99, double ymin=0.95) ;
0328 RooCmdArg Parameters(const RooArgSet& params) ;
0329 RooCmdArg ShowConstants(bool flag=true) ;
0330 
0331 // RooTreeData::statOn arguments
0332 RooCmdArg What(const char* str) ;
0333 
0334 // RooProdPdf::ctor arguments
0335 RooCmdArg Conditional(const RooArgSet& pdfSet, const RooArgSet& depSet, bool depsAreCond=false) ;
0336 
0337 /**
0338  * \defgroup Generating Arguments for generating data
0339  * @{
0340  */
0341 // RooAbsPdf::generate arguments
0342 RooCmdArg ProtoData(const RooDataSet& protoData, bool randomizeOrder=false, bool resample=false) ;
0343 RooCmdArg NumEvents(Int_t numEvents) ;
0344 RooCmdArg NumEvents(double numEvents) ;
0345 RooCmdArg AutoBinned(bool flag=true) ;
0346 RooCmdArg GenBinned(const char* tag) ;
0347 RooCmdArg AllBinned() ;
0348 RooCmdArg ExpectedData(bool flag=true) ;
0349 RooCmdArg Asimov(bool flag=true) ;
0350 
0351 /** @} */
0352 
0353 // RooAbsRealLValue::createHistogram arguments
0354 RooCmdArg YVar(const RooAbsRealLValue& var, const RooCmdArg& arg={}) ;
0355 RooCmdArg ZVar(const RooAbsRealLValue& var, const RooCmdArg& arg={}) ;
0356 RooCmdArg AxisLabel(const char* name) ;
0357 RooCmdArg Scaling(bool flag) ;
0358 
0359 
0360 // RooAbsReal::createHistogram arguments
0361 RooCmdArg IntrinsicBinning(bool flag=true) ;
0362 
0363 // RooAbsReal::createIntegral arguments
0364 template<class... Args_t>
0365 RooCmdArg NormSet(Args_t &&... argsOrArgSet) {
0366   RooCmdArg out{"NormSet",0};
0367   out.setSet(0, RooArgSet{std::forward<Args_t>(argsOrArgSet)...});
0368   return out;
0369 }
0370 RooCmdArg NumIntConfig(const RooNumIntConfig& cfg) ;
0371 
0372 // RooMCStudy::ctor arguments
0373 RooCmdArg Silence(bool flag=true) ;
0374 RooCmdArg FitModel(RooAbsPdf& pdf) ;
0375 RooCmdArg FitOptions(const RooCmdArg& arg1                ,const RooCmdArg& arg2={},
0376                      const RooCmdArg& arg3={},const RooCmdArg& arg4={},
0377                      const RooCmdArg& arg5={},const RooCmdArg& arg6={}) ;
0378 RooCmdArg Binned(bool flag=true) ;
0379 
0380 // RooMCStudy::plot* arguments
0381 RooCmdArg Frame(const RooCmdArg& arg1                ,const RooCmdArg& arg2={},
0382                 const RooCmdArg& arg3={},const RooCmdArg& arg4={},
0383                 const RooCmdArg& arg5={},const RooCmdArg& arg6={}) ;
0384 RooCmdArg FrameBins(Int_t nbins) ;
0385 RooCmdArg FrameRange(double xlo, double xhi) ;
0386 RooCmdArg FitGauss(bool flag=true) ;
0387 
0388 // RooRealVar::format arguments
0389 RooCmdArg AutoPrecision(Int_t ndigit=2) ;
0390 RooCmdArg FixedPrecision(Int_t ndigit=2) ;
0391 RooCmdArg TLatexStyle(bool flag=true) ;
0392 RooCmdArg LatexStyle(bool flag=true) ;
0393 RooCmdArg LatexTableStyle(bool flag=true) ;
0394 RooCmdArg VerbatimName(bool flag=true) ;
0395 
0396 // RooMsgService::addReportingStream arguments
0397 RooCmdArg Topic(Int_t topic) ;
0398 RooCmdArg ObjectName(const char* name) ;
0399 RooCmdArg ClassName(const char* name) ;
0400 RooCmdArg BaseClassName(const char* name) ;
0401 RooCmdArg TagName(const char* name) ;
0402 RooCmdArg OutputStream(std::ostream& os) ;
0403 RooCmdArg Prefix(bool flag) ;
0404 RooCmdArg Color(Color_t color) ;
0405 
0406 // RooWorkspace::import() arguments
0407 RooCmdArg RenameConflictNodes(const char* suffix, bool renameOrigNodes=false) ;
0408 RooCmdArg RenameAllNodes(const char* suffix) ;
0409 RooCmdArg RenameAllVariables(const char* suffix) ;
0410 RooCmdArg RenameAllVariablesExcept(const char* suffix,const char* exceptionList) ;
0411 RooCmdArg RenameVariable(const char* inputName, const char* outputName) ;
0412 RooCmdArg Rename(const char* suffix) ;
0413 RooCmdArg RecycleConflictNodes(bool flag=true) ;
0414 RooCmdArg Embedded(bool flag=true) ;
0415 RooCmdArg NoRecursion(bool flag=true) ;
0416 
0417 // RooSimCloneTool::build() arguments
0418 RooCmdArg SplitParam(const char* varname, const char* catname) ;
0419 RooCmdArg SplitParam(const RooRealVar& var, const RooAbsCategory& cat) ;
0420 RooCmdArg SplitParamConstrained(const char* varname, const char* catname, const char* rsname) ;
0421 RooCmdArg SplitParamConstrained(const RooRealVar& var, const RooAbsCategory& cat, const char* rsname) ;
0422 RooCmdArg Restrict(const char* catName, const char* stateNameList) ;
0423 
0424 // RooAbsPdf::createCdf() arguments
0425 RooCmdArg SupNormSet(const RooArgSet& nset) ;
0426 RooCmdArg ScanParameters(Int_t nbins,Int_t intOrder) ;
0427 RooCmdArg ScanNumCdf() ;
0428 RooCmdArg ScanAllCdf() ;
0429 RooCmdArg ScanNoCdf() ;
0430 
0431 // Generic container arguments (to be able to supply more command line arguments)
0432 RooCmdArg MultiArg(const RooCmdArg& arg1, const RooCmdArg& arg2,
0433          const RooCmdArg& arg3={},const RooCmdArg& arg4={},
0434          const RooCmdArg& arg5={},const RooCmdArg& arg6={},
0435          const RooCmdArg& arg7={},const RooCmdArg& arg8={}) ;
0436 
0437 RooConstVar& RooConst(double val) ;
0438 
0439 // End group CmdArgs:
0440 /**
0441  * @}
0442  */
0443 
0444 namespace Detail {
0445 
0446 // Function to pack an arbitrary number of RooCmdArgs into a RooLinkedList. Implementation detail of many high-level RooFit functions.
0447 template <typename... Args>
0448 inline std::unique_ptr<RooLinkedList> createCmdList(RooCmdArg const* arg1, Args &&...args)
0449 {
0450    auto cmdList = std::make_unique<RooLinkedList>();
0451    for (auto &arg : {arg1, static_cast<RooCmdArg const *>(args)...}) {
0452       cmdList->Add(const_cast<RooCmdArg *>(arg));
0453    }
0454    return cmdList;
0455 }
0456 
0457 inline std::unique_ptr<RooLinkedList> createCmdList()
0458 {
0459    return std::make_unique<RooLinkedList>();
0460 }
0461 
0462 inline std::unique_ptr<RooLinkedList> createCmdList(RooLinkedList const *cmdList)
0463 {
0464    auto cmdListCopy = std::make_unique<RooLinkedList>();
0465    for (auto *arg : *cmdList) {
0466       cmdListCopy->Add(arg);
0467    }
0468    return cmdListCopy;
0469 }
0470 
0471 // RooFit-internal helper struct to build a map object that only uses
0472 // std::vector, which can be implicitly converted to std::map in C++. Used to
0473 // avoid std::map in pythonizations.
0474 template <class Key_t, class Val_t>
0475 struct FlatMap {
0476    std::vector<Key_t> keys;
0477    std::vector<Val_t> vals;
0478 };
0479 
0480 template <class Key_t, class Val_t>
0481 auto flatMapToStdMap(FlatMap<Key_t, Val_t> const& flatMap) {
0482    std::map<Key_t, Val_t> out;
0483    for (std::size_t i = 0; i < flatMap.keys.size(); ++i) {
0484       out[flatMap.keys[i]] = flatMap.vals[i];
0485    }
0486    return out;
0487 }
0488 
0489 // Internal variant of Slice(), Import(), and Link(), that take flat maps instad of std::map.
0490 RooCmdArg SliceFlatMap(FlatMap<RooCategory *, std::string> const &args);
0491 RooCmdArg ImportFlatMap(FlatMap<std::string, RooDataHist *> const &args);
0492 RooCmdArg ImportFlatMap(FlatMap<std::string, TH1 *> const &args);
0493 RooCmdArg ImportFlatMap(FlatMap<std::string, RooDataSet *> const &args);
0494 RooCmdArg LinkFlatMap(FlatMap<std::string, RooAbsData *> const &args);
0495 
0496 } // namespace Detail
0497 
0498 } // namespace RooFit
0499 
0500 namespace RooFitShortHand {
0501 
0502 RooConstVar& C(double value);
0503 
0504 } // namespace RooFitShortHand
0505 
0506 #endif