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
25a_i it returns a_0 * Prod_i (1 - a_i).
26**/
27
28
29#include "RooFit.h"
30
31#include "Riostream.h"
32#include "Riostream.h"
33#include <math.h>
34
36#include "RooAbsReal.h"
37#include "RooAbsPdf.h"
38#include "RooErrorHandler.h"
39#include "RooArgSet.h"
40#include "RooNLLVar.h"
41#include "RooChi2Var.h"
42#include "RooMsgService.h"
43
44using namespace std;
45
47;
48
49
50////////////////////////////////////////////////////////////////////////////////
51/// Default constructor
52
54{
56}
57
58
59
60////////////////////////////////////////////////////////////////////////////////
61/// Constructor of plain RooAddPdf fraction from list of recursive fractions
62
63RooRecursiveFraction::RooRecursiveFraction(const char* name, const char* title, const RooArgList& fracList) :
64 RooAbsReal(name, title),
65 _list("list","First set of components",this)
66{
68
69 for (Int_t ifrac=fracList.getSize()-1 ; ifrac>=0 ; ifrac--) {
70 RooAbsArg* comp = fracList.at(ifrac) ;
71 if (!dynamic_cast<RooAbsReal*>(comp)) {
72 coutE(InputArguments) << "RooRecursiveFraction::ctor(" << GetName() << ") ERROR: component " << comp->GetName()
73 << " is not of type RooAbsReal" << endl ;
75 }
76 _list.add(*comp) ;
77 }
78}
79
80
81
82////////////////////////////////////////////////////////////////////////////////
83/// Copy constructor
84
86 RooAbsReal(other, name),
87 _list("list",this,other._list)
88{
90}
91
92
93
94////////////////////////////////////////////////////////////////////////////////
95/// Destructor
96
98{
99 if (_listIter) delete _listIter ;
100}
101
102
103
104////////////////////////////////////////////////////////////////////////////////
105/// Calculate and return value of 1 - prod_i (1 - f_i )
106
108{
109 RooAbsReal* comp ;
110 const RooArgSet* nset = _list.nset() ;
111
112 _listIter->Reset() ;
113 comp=(RooAbsReal*)_listIter->Next() ;
114 Double_t prod = comp->getVal(nset) ;
115
116 while((comp=(RooAbsReal*)_listIter->Next())) {
117 prod *= (1-comp->getVal(nset)) ;
118 }
119
120 return prod ;
121}
122
#define coutE(a)
Definition: RooMsgService.h:34
int Int_t
Definition: RtypesCore.h:41
double Double_t
Definition: RtypesCore.h:55
#define ClassImp(name)
Definition: Rtypes.h:365
char name[80]
Definition: TGX11.cxx:109
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:71
Int_t getSize() const
TIterator * createIterator(Bool_t dir=kIterForward) const R__SUGGEST_ALTERNATIVE("begin()
TIterator-style iteration over contained elements.
const RooArgSet * nset() const
Definition: RooAbsProxy.h:46
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:59
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition: RooAbsReal.h:87
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgList.h:21
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
Definition: RooArgList.h:74
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:28
static void softAbort()
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Reimplementation of standard RooArgList::add()
Class RooRecursiveFraction is a RooAbsReal implementation that calculates the plain fraction of sum o...
virtual ~RooRecursiveFraction()
Destructor.
Double_t evaluate() const
do not persist
RooRecursiveFraction()
Default constructor.
virtual void Reset()=0
virtual TObject * Next()=0
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
@ InputArguments
Definition: RooGlobalFunc.h:68