Logo ROOT   6.10/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 \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 a_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 
35 #include "RooRecursiveFraction.h"
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 
44 using namespace std;
45 
47 ;
48 
49 
50 ////////////////////////////////////////////////////////////////////////////////
51 /// Default constructor
52 
54 {
55  _listIter = _list.createIterator() ;
56 }
57 
58 
59 
60 ////////////////////////////////////////////////////////////////////////////////
61 /// Constructor of plain RooAddPdf fraction from list of recursive fractions
62 
63 RooRecursiveFraction::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 
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
TIterator * createIterator(Bool_t dir=kIterForward) const
#define coutE(a)
Definition: RooMsgService.h:34
static void softAbort()
virtual void Reset()=0
RooRecursiveFraction()
Default constructor.
Double_t getVal(const RooArgSet *set=0) const
Definition: RooAbsReal.h:64
int Int_t
Definition: RtypesCore.h:41
STL namespace.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Reimplementation of standard RooArgList::add()
virtual ~RooRecursiveFraction()
Destructor.
const RooArgSet * nset() const
Definition: RooAbsProxy.h:46
Int_t getSize() const
RooAbsArg * at(Int_t idx) const
Definition: RooArgList.h:84
#define ClassImp(name)
Definition: Rtypes.h:336
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
Double_t evaluate() const
do not persist
Class RooRecursiveFraction is a RooAbsReal implementation that calculates the plain fraction of sum o...
virtual TObject * Next()=0
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:66