RooRecursiveFraction.cxx

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Project: RooFit                                                           *
00003  * Package: RooFitCore                                                       *
00004  * @(#)root/roofitcore:$Id: RooRecursiveFraction.cxx 25184 2008-08-20 13:59:55Z wouter $
00005  * Authors:                                                                  *
00006  *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
00007  *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
00008  *                                                                           *
00009  * Copyright (c) 2000-2005, Regents of the University of California          *
00010  *                          and Stanford University. All rights reserved.    *
00011  *                                                                           *
00012  * Redistribution and use in source and binary forms,                        *
00013  * with or without modification, are permitted according to the terms        *
00014  * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
00015  *****************************************************************************/
00016 
00017 //////////////////////////////////////////////////////////////////////////////
00018 //
00019 // BEGIN_HTML
00020 // Class RooRecursiveFraction is a RooAbsReal implementation that
00021 // calculates the plain fraction of sum of RooAddPdf components
00022 // from a set of recursive fractions: for a given set of input fractions
00023 // a_i it returns a_0 * Prod_i (1 - a_i). 
00024 // END_HTML
00025 //
00026 
00027 
00028 #include "RooFit.h"
00029 
00030 #include "Riostream.h"
00031 #include "Riostream.h"
00032 #include <math.h>
00033 
00034 #include "RooRecursiveFraction.h"
00035 #include "RooAbsReal.h"
00036 #include "RooAbsPdf.h"
00037 #include "RooErrorHandler.h"
00038 #include "RooArgSet.h"
00039 #include "RooNLLVar.h"
00040 #include "RooChi2Var.h"
00041 #include "RooMsgService.h"
00042 
00043 ClassImp(RooRecursiveFraction)
00044 ;
00045 
00046 
00047 //_____________________________________________________________________________
00048 RooRecursiveFraction::RooRecursiveFraction()
00049 {
00050   // Default constructor
00051   _listIter = _list.createIterator() ;
00052 }
00053 
00054 
00055 
00056 //_____________________________________________________________________________
00057 RooRecursiveFraction::RooRecursiveFraction(const char* name, const char* title, const RooArgList& fracList) :
00058   RooAbsReal(name, title),
00059   _list("list","First set of components",this)
00060 {
00061   // Constructor of plain RooAddPdf fraction from list of recursive fractions
00062   _listIter = _list.createIterator() ;
00063 
00064   for (Int_t ifrac=fracList.getSize()-1 ; ifrac>=0 ; ifrac--) {
00065     RooAbsArg* comp = fracList.at(ifrac) ;
00066     if (!dynamic_cast<RooAbsReal*>(comp)) {
00067       coutE(InputArguments) << "RooRecursiveFraction::ctor(" << GetName() << ") ERROR: component " << comp->GetName() 
00068                             << " is not of type RooAbsReal" << endl ;
00069       RooErrorHandler::softAbort() ;
00070     }
00071     _list.add(*comp) ;    
00072   }
00073 }
00074 
00075 
00076 
00077 //_____________________________________________________________________________
00078 RooRecursiveFraction::RooRecursiveFraction(const RooRecursiveFraction& other, const char* name) :
00079   RooAbsReal(other, name), 
00080   _list("list",this,other._list)
00081 {
00082   // Copy constructor
00083 
00084   _listIter = _list.createIterator() ;
00085 }
00086 
00087 
00088 
00089 //_____________________________________________________________________________
00090 RooRecursiveFraction::~RooRecursiveFraction() 
00091 {
00092   // Destructor
00093 
00094   if (_listIter) delete _listIter ;
00095 }
00096 
00097 
00098 
00099 //_____________________________________________________________________________
00100 Double_t RooRecursiveFraction::evaluate() const 
00101 {
00102   // Calculate and return value of 1 - prod_i (1 - f_i )
00103 
00104   RooAbsReal* comp ;
00105   const RooArgSet* nset = _list.nset() ;
00106 
00107   _listIter->Reset() ;
00108   comp=(RooAbsReal*)_listIter->Next() ;
00109   Double_t prod = comp->getVal(nset) ;
00110 
00111   while((comp=(RooAbsReal*)_listIter->Next())) {
00112     prod *= (1-comp->getVal(nset)) ;
00113   }
00114     
00115   return prod ;
00116 }
00117 

Generated on Tue Jul 5 15:07:28 2011 for ROOT_528-00b_version by  doxygen 1.5.1