Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
22A 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
29#include "RooAbsReal.h"
30#include "RooAbsPdf.h"
31#include "RooArgSet.h"
32#include "RooMsgService.h"
33
35
36#include <ostream>
37
38////////////////////////////////////////////////////////////////////////////////
39/// Constructor of plain RooAddPdf fraction from list of recursive fractions
40
41RooRecursiveFraction::RooRecursiveFraction(const char* name, const char* title, const RooArgList& fracList) :
42 RooAbsReal(name, title),
43 _list("list","First set of components",this)
44{
45 for (Int_t ifrac=fracList.size()-1 ; ifrac>=0 ; ifrac--) {
47 if (!dynamic_cast<RooAbsReal*>(comp)) {
48 std::stringstream errorMsg;
49 errorMsg << "RooRecursiveFraction::ctor(" << GetName() << ") ERROR: component " << comp->GetName()
50 << " is not of type RooAbsReal" << std::endl;
51 coutE(InputArguments) << errorMsg.str();
52 throw std::invalid_argument(errorMsg.str());
53 }
54
55 _list.add(*comp) ;
56 }
57}
58
59
60
61////////////////////////////////////////////////////////////////////////////////
62/// Copy constructor
63
66 _list("list",this,other._list)
67{
68
69}
70
71////////////////////////////////////////////////////////////////////////////////
72/// Calculate and return value of \f$ a_n * \prod_{i=0}^{n-1} (1 - a_i) \f$.
74{
75 const RooArgSet* nset = _list.nset() ;
76
77 // Note that input coefficients are saved in reverse in this list.
78 double prod = static_cast<RooAbsReal&>(_list[0]).getVal(nset);
79
80 for (unsigned int i=1; i < _list.size(); ++i) {
81 prod *= (1 - static_cast<RooAbsReal&>(_list[i]).getVal(nset));
82 }
83
84 return prod ;
85}
#define coutE(a)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
char name[80]
Definition TGX11.cxx:142
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Definition RooAbsArg.h:76
Storage_t::size_type size() const
const RooArgSet * nset() const
Definition RooAbsProxy.h:52
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:63
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition RooAbsReal.h:107
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition RooArgList.h:22
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:24
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...
A RooAbsReal implementation that calculates the plain fraction of sum of RooAddPdf components from a ...
double evaluate() const override
Calculate and return value of .
RooRecursiveFraction()=default
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49