```/*****************************************************************************
* Project: RooFit                                                           *
* Package: RooFitCore                                                       *
* @(#)root/roofitcore:\$Id\$
* Authors:                                                                  *
*   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
*   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
*                                                                           *
* Copyright (c) 2000-2005, Regents of the University of California          *
*                                                                           *
* Redistribution and use in source and binary forms,                        *
* with or without modification, are permitted according to the terms        *
*****************************************************************************/

//////////////////////////////////////////////////////////////////////////////
//
// BEGIN_HTML
// Class RooRecursiveFraction is a RooAbsReal implementation that
// calculates the plain fraction of sum of RooAddPdf components
// from a set of recursive fractions: for a given set of input fractions
// a_i it returns a_0 * Prod_i (1 - a_i).
// END_HTML
//

#include "RooFit.h"

#include "Riostream.h"
#include "Riostream.h"
#include <math.h>

#include "RooRecursiveFraction.h"
#include "RooAbsReal.h"
#include "RooAbsPdf.h"
#include "RooErrorHandler.h"
#include "RooArgSet.h"
#include "RooNLLVar.h"
#include "RooChi2Var.h"
#include "RooMsgService.h"

using namespace std;

ClassImp(RooRecursiveFraction)
;

//_____________________________________________________________________________
RooRecursiveFraction::RooRecursiveFraction()
{
// Default constructor
_listIter = _list.createIterator() ;
}

//_____________________________________________________________________________
RooRecursiveFraction::RooRecursiveFraction(const char* name, const char* title, const RooArgList& fracList) :
RooAbsReal(name, title),
_list("list","First set of components",this)
{
// Constructor of plain RooAddPdf fraction from list of recursive fractions
_listIter = _list.createIterator() ;

for (Int_t ifrac=fracList.getSize()-1 ; ifrac>=0 ; ifrac--) {
RooAbsArg* comp = fracList.at(ifrac) ;
if (!dynamic_cast<RooAbsReal*>(comp)) {
coutE(InputArguments) << "RooRecursiveFraction::ctor(" << GetName() << ") ERROR: component " << comp->GetName()
<< " is not of type RooAbsReal" << endl ;
RooErrorHandler::softAbort() ;
}
}
}

//_____________________________________________________________________________
RooRecursiveFraction::RooRecursiveFraction(const RooRecursiveFraction& other, const char* name) :
RooAbsReal(other, name),
_list("list",this,other._list)
{
// Copy constructor

_listIter = _list.createIterator() ;
}

//_____________________________________________________________________________
RooRecursiveFraction::~RooRecursiveFraction()
{
// Destructor

if (_listIter) delete _listIter ;
}

//_____________________________________________________________________________
Double_t RooRecursiveFraction::evaluate() const
{
// Calculate and return value of 1 - prod_i (1 - f_i )

RooAbsReal* comp ;
const RooArgSet* nset = _list.nset() ;

_listIter->Reset() ;
comp=(RooAbsReal*)_listIter->Next() ;
Double_t prod = comp->getVal(nset) ;

while((comp=(RooAbsReal*)_listIter->Next())) {
prod *= (1-comp->getVal(nset)) ;
}

return prod ;
}

```
RooRecursiveFraction.cxx:1
RooRecursiveFraction.cxx:2
RooRecursiveFraction.cxx:3
RooRecursiveFraction.cxx:4
RooRecursiveFraction.cxx:5
RooRecursiveFraction.cxx:6
RooRecursiveFraction.cxx:7
RooRecursiveFraction.cxx:8
RooRecursiveFraction.cxx:9
RooRecursiveFraction.cxx:10
RooRecursiveFraction.cxx:11
RooRecursiveFraction.cxx:12
RooRecursiveFraction.cxx:13
RooRecursiveFraction.cxx:14
RooRecursiveFraction.cxx:15
RooRecursiveFraction.cxx:16
RooRecursiveFraction.cxx:17
RooRecursiveFraction.cxx:18
RooRecursiveFraction.cxx:19
RooRecursiveFraction.cxx:20
RooRecursiveFraction.cxx:21
RooRecursiveFraction.cxx:22
RooRecursiveFraction.cxx:23
RooRecursiveFraction.cxx:24
RooRecursiveFraction.cxx:25
RooRecursiveFraction.cxx:26
RooRecursiveFraction.cxx:27
RooRecursiveFraction.cxx:28
RooRecursiveFraction.cxx:29
RooRecursiveFraction.cxx:30
RooRecursiveFraction.cxx:31
RooRecursiveFraction.cxx:32
RooRecursiveFraction.cxx:33
RooRecursiveFraction.cxx:34
RooRecursiveFraction.cxx:35
RooRecursiveFraction.cxx:36
RooRecursiveFraction.cxx:37
RooRecursiveFraction.cxx:38
RooRecursiveFraction.cxx:39
RooRecursiveFraction.cxx:40
RooRecursiveFraction.cxx:41
RooRecursiveFraction.cxx:42
RooRecursiveFraction.cxx:43
RooRecursiveFraction.cxx:44
RooRecursiveFraction.cxx:45
RooRecursiveFraction.cxx:46
RooRecursiveFraction.cxx:47
RooRecursiveFraction.cxx:48
RooRecursiveFraction.cxx:49
RooRecursiveFraction.cxx:50
RooRecursiveFraction.cxx:51
RooRecursiveFraction.cxx:52
RooRecursiveFraction.cxx:53
RooRecursiveFraction.cxx:54
RooRecursiveFraction.cxx:55
RooRecursiveFraction.cxx:56
RooRecursiveFraction.cxx:57
RooRecursiveFraction.cxx:58
RooRecursiveFraction.cxx:59
RooRecursiveFraction.cxx:60
RooRecursiveFraction.cxx:61
RooRecursiveFraction.cxx:62
RooRecursiveFraction.cxx:63
RooRecursiveFraction.cxx:64
RooRecursiveFraction.cxx:65
RooRecursiveFraction.cxx:66
RooRecursiveFraction.cxx:67
RooRecursiveFraction.cxx:68
RooRecursiveFraction.cxx:69
RooRecursiveFraction.cxx:70
RooRecursiveFraction.cxx:71
RooRecursiveFraction.cxx:72
RooRecursiveFraction.cxx:73
RooRecursiveFraction.cxx:74
RooRecursiveFraction.cxx:75
RooRecursiveFraction.cxx:76
RooRecursiveFraction.cxx:77
RooRecursiveFraction.cxx:78
RooRecursiveFraction.cxx:79
RooRecursiveFraction.cxx:80
RooRecursiveFraction.cxx:81
RooRecursiveFraction.cxx:82
RooRecursiveFraction.cxx:83
RooRecursiveFraction.cxx:84
RooRecursiveFraction.cxx:85
RooRecursiveFraction.cxx:86
RooRecursiveFraction.cxx:87
RooRecursiveFraction.cxx:88
RooRecursiveFraction.cxx:89
RooRecursiveFraction.cxx:90
RooRecursiveFraction.cxx:91
RooRecursiveFraction.cxx:92
RooRecursiveFraction.cxx:93
RooRecursiveFraction.cxx:94
RooRecursiveFraction.cxx:95
RooRecursiveFraction.cxx:96
RooRecursiveFraction.cxx:97
RooRecursiveFraction.cxx:98
RooRecursiveFraction.cxx:99
RooRecursiveFraction.cxx:100
RooRecursiveFraction.cxx:101
RooRecursiveFraction.cxx:102
RooRecursiveFraction.cxx:103
RooRecursiveFraction.cxx:104
RooRecursiveFraction.cxx:105
RooRecursiveFraction.cxx:106
RooRecursiveFraction.cxx:107
RooRecursiveFraction.cxx:108
RooRecursiveFraction.cxx:109
RooRecursiveFraction.cxx:110
RooRecursiveFraction.cxx:111
RooRecursiveFraction.cxx:112
RooRecursiveFraction.cxx:113
RooRecursiveFraction.cxx:114
RooRecursiveFraction.cxx:115
RooRecursiveFraction.cxx:116
RooRecursiveFraction.cxx:117
RooRecursiveFraction.cxx:118
RooRecursiveFraction.cxx:119