ROOT  6.06/09
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 //
19 // BEGIN_HTML
20 // Class RooRecursiveFraction is a RooAbsReal implementation that
21 // calculates the plain fraction of sum of RooAddPdf components
22 // from a set of recursive fractions: for a given set of input fractions
23 // a_i it returns a_0 * Prod_i (1 - a_i).
24 // END_HTML
25 //
26 
27 
28 #include "RooFit.h"
29 
30 #include "Riostream.h"
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  _listIter = _list.createIterator() ;
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 {
67 
68  for (Int_t ifrac=fracList.getSize()-1 ; ifrac>=0 ; ifrac--) {
69  RooAbsArg* comp = fracList.at(ifrac) ;
70  if (!dynamic_cast<RooAbsReal*>(comp)) {
71  coutE(InputArguments) << "RooRecursiveFraction::ctor(" << GetName() << ") ERROR: component " << comp->GetName()
72  << " is not of type RooAbsReal" << endl ;
74  }
75  _list.add(*comp) ;
76  }
77 }
78 
79 
80 
81 ////////////////////////////////////////////////////////////////////////////////
82 /// Copy constructor
83 
85  RooAbsReal(other, name),
86  _list("list",this,other._list)
87 {
89 }
90 
91 
92 
93 ////////////////////////////////////////////////////////////////////////////////
94 /// Destructor
95 
97 {
98  if (_listIter) delete _listIter ;
99 }
100 
101 
102 
103 ////////////////////////////////////////////////////////////////////////////////
104 /// Calculate and return value of 1 - prod_i (1 - f_i )
105 
107 {
108  RooAbsReal* comp ;
109  const RooArgSet* nset = _list.nset() ;
110 
111  _listIter->Reset() ;
112  comp=(RooAbsReal*)_listIter->Next() ;
113  Double_t prod = comp->getVal(nset) ;
114 
115  while((comp=(RooAbsReal*)_listIter->Next())) {
116  prod *= (1-comp->getVal(nset)) ;
117  }
118 
119  return prod ;
120 }
121 
const RooArgSet * nset() const
Definition: RooAbsProxy.h:47
#define coutE(a)
Definition: RooMsgService.h:35
static void softAbort()
virtual void Reset()=0
RooRecursiveFraction()
Default constructor.
int Int_t
Definition: RtypesCore.h:41
STL namespace.
Double_t evaluate() const
do not persist
TIterator * createIterator(Bool_t dir=kIterForward) const
Double_t getVal(const RooArgSet *set=0) const
Definition: RooAbsReal.h:64
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Reimplementation of standard RooArgList::add()
virtual ~RooRecursiveFraction()
Destructor.
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
RooAbsArg * at(Int_t idx) const
Definition: RooArgList.h:84
double Double_t
Definition: RtypesCore.h:55
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:53
#define name(a, b)
Definition: linkTestLib0.cpp:5
virtual TObject * Next()=0
Int_t getSize() const
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:66
ClassImp(RooRecursiveFraction)