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 
22 Class RooRecursiveFraction is a RooAbsReal implementation that
23 calculates the plain fraction of sum of RooAddPdf components
24 from 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 
29 #include "RooFit.h"
30 
31 #include "Riostream.h"
32 #include <math.h>
33 
34 #include "RooRecursiveFraction.h"
35 #include "RooAbsReal.h"
36 #include "RooAbsPdf.h"
37 #include "RooErrorHandler.h"
38 #include "RooArgSet.h"
39 #include "RooNLLVar.h"
40 #include "RooChi2Var.h"
41 #include "RooMsgService.h"
42 
43 using namespace std;
44 
46 
47 
48 
49 ////////////////////////////////////////////////////////////////////////////////
50 /// Default constructor
51 
53 {
54 
55 }
56 
57 
58 
59 ////////////////////////////////////////////////////////////////////////////////
60 /// Constructor of plain RooAddPdf fraction from list of recursive fractions
61 
62 RooRecursiveFraction::RooRecursiveFraction(const char* name, const char* title, const RooArgList& fracList) :
63  RooAbsReal(name, title),
64  _list("list","First set of components",this)
65 {
66  for (Int_t ifrac=fracList.getSize()-1 ; ifrac>=0 ; ifrac--) {
67  RooAbsArg* comp = fracList.at(ifrac) ;
68  if (!dynamic_cast<RooAbsReal*>(comp)) {
69  std::stringstream errorMsg;
70  errorMsg << "RooRecursiveFraction::ctor(" << GetName() << ") ERROR: component " << comp->GetName()
71  << " is not of type RooAbsReal" << endl ;
72  coutE(InputArguments) << errorMsg.str();
73  throw std::invalid_argument(errorMsg.str());
74  }
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 {
89 
90 }
91 
92 
93 
94 ////////////////////////////////////////////////////////////////////////////////
95 /// Destructor
96 
98 {
99 
100 }
101 
102 
103 
104 ////////////////////////////////////////////////////////////////////////////////
105 /// Calculate and return value of \f$ a_n * \prod_{i=0}^{n-1} (1 - a_i) \f$.
107 {
108  const RooArgSet* nset = _list.nset() ;
109 
110  // Note that input coefficients are saved in reverse in this list.
111  Double_t prod = static_cast<RooAbsReal&>(_list[0]).getVal(nset);
112 
113  for (unsigned int i=1; i < _list.size(); ++i) {
114  prod *= (1 - static_cast<RooAbsReal&>(_list[i]).getVal(nset));
115  }
116 
117  return prod ;
118 }
119 
RooRecursiveFraction::_list
RooListProxy _list
Definition: RooRecursiveFraction.h:37
RooAbsReal.h
RooMsgService.h
RooFit.h
RooFit::InputArguments
@ InputArguments
Definition: RooGlobalFunc.h:68
RooArgSet.h
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
coutE
#define coutE(a)
Definition: RooMsgService.h:33
RooArgList
Definition: RooArgList.h:21
RooAbsReal::getVal
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition: RooAbsReal.h:91
RooAbsReal
Definition: RooAbsReal.h:61
RooArgList::at
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
Definition: RooArgList.h:88
RooRecursiveFraction::RooRecursiveFraction
RooRecursiveFraction()
Default constructor.
Definition: RooRecursiveFraction.cxx:52
RooNLLVar.h
RooChi2Var.h
RooRecursiveFraction
Definition: RooRecursiveFraction.h:25
RooRecursiveFraction::evaluate
Double_t evaluate() const
Calculate and return value of .
Definition: RooRecursiveFraction.cxx:106
RooAbsPdf.h
RooRecursiveFraction.h
RooAbsCollection::size
Storage_t::size_type size() const
Definition: RooAbsCollection.h:154
RooListProxy::add
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Reimplementation of standard RooArgList::add()
Definition: RooListProxy.cxx:104
RooAbsProxy::nset
const RooArgSet * nset() const
Definition: RooAbsProxy.h:59
Double_t
double Double_t
Definition: RtypesCore.h:59
RooRecursiveFraction::~RooRecursiveFraction
virtual ~RooRecursiveFraction()
Destructor.
Definition: RooRecursiveFraction.cxx:97
name
char name[80]
Definition: TGX11.cxx:110
RooErrorHandler.h
RooAbsArg
Definition: RooAbsArg.h:73
TNamed::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:53
Riostream.h
RooAbsCollection::getSize
Int_t getSize() const
Definition: RooAbsCollection.h:171
RooArgSet
Definition: RooArgSet.h:28
int