Logo ROOT  
Reference Guide
RooRecursiveFraction.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 RooRecursiveFraction.cxx
19\class RooRecursiveFraction
20\ingroup Roofitcore
21
22Class RooRecursiveFraction is a RooAbsReal implementation that
23calculates the plain fraction of sum of RooAddPdf components
24from a set of recursive fractions: for a given set of input fractions
25\f$ {a_i} \f$, it returns \f$ a_n * \prod_{i=0}^{n-1} (1 - a_i) \f$.
26**/
27
28#include "Riostream.h"
29#include <math.h>
30
32#include "RooAbsReal.h"
33#include "RooAbsPdf.h"
34#include "RooErrorHandler.h"
35#include "RooArgSet.h"
36#include "RooNLLVar.h"
37#include "RooChi2Var.h"
38#include "RooMsgService.h"
39
40using namespace std;
41
43
44
45
46////////////////////////////////////////////////////////////////////////////////
47/// Default constructor
48
50{
51
52}
53
54
55
56////////////////////////////////////////////////////////////////////////////////
57/// Constructor of plain RooAddPdf fraction from list of recursive fractions
58
59RooRecursiveFraction::RooRecursiveFraction(const char* name, const char* title, const RooArgList& fracList) :
60 RooAbsReal(name, title),
61 _list("list","First set of components",this)
62{
63 for (Int_t ifrac=fracList.getSize()-1 ; ifrac>=0 ; ifrac--) {
64 RooAbsArg* comp = fracList.at(ifrac) ;
65 if (!dynamic_cast<RooAbsReal*>(comp)) {
66 std::stringstream errorMsg;
67 errorMsg << "RooRecursiveFraction::ctor(" << GetName() << ") ERROR: component " << comp->GetName()
68 << " is not of type RooAbsReal" << endl ;
69 coutE(InputArguments) << errorMsg.str();
70 throw std::invalid_argument(errorMsg.str());
71 }
72
73 _list.add(*comp) ;
74 }
75}
76
77
78
79////////////////////////////////////////////////////////////////////////////////
80/// Copy constructor
81
83 RooAbsReal(other, name),
84 _list("list",this,other._list)
85{
86
87}
88
89
90
91////////////////////////////////////////////////////////////////////////////////
92/// Destructor
93
95{
96
97}
98
99
100
101////////////////////////////////////////////////////////////////////////////////
102/// Calculate and return value of \f$ a_n * \prod_{i=0}^{n-1} (1 - a_i) \f$.
104{
105 const RooArgSet* nset = _list.nset() ;
106
107 // Note that input coefficients are saved in reverse in this list.
108 Double_t prod = static_cast<RooAbsReal&>(_list[0]).getVal(nset);
109
110 for (unsigned int i=1; i < _list.size(); ++i) {
111 prod *= (1 - static_cast<RooAbsReal&>(_list[i]).getVal(nset));
112 }
113
114 return prod ;
115}
116
#define coutE(a)
Definition: RooMsgService.h:33
#define ClassImp(name)
Definition: Rtypes.h:375
char name[80]
Definition: TGX11.cxx:110
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition: RooAbsArg.h:78
Int_t getSize() const
Return the number of elements in the collection.
Storage_t::size_type size() const
const RooArgSet * nset() const
Definition: RooAbsProxy.h:45
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:63
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition: RooAbsReal.h:93
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgList.h:22
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
Definition: RooArgList.h:110
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:57
bool add(const RooAbsArg &var, bool valueServer, bool shapeServer, bool silent)
Overloaded RooCollection_t::add() method insert object into set and registers object as server to own...
Class RooRecursiveFraction is a RooAbsReal implementation that calculates the plain fraction of sum o...
~RooRecursiveFraction() override
Destructor.
Double_t evaluate() const override
Calculate and return value of .
RooRecursiveFraction()
Default constructor.
const char * GetName() const override
Returns name of object.
Definition: TNamed.h:47
@ InputArguments
Definition: RooGlobalFunc.h:64