RooFracRemainder.cxx

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Project: RooFit                                                           *
00003  * Package: RooFitCore                                                       *
00004  * @(#)root/roofitcore:$Id: RooFracRemainder.cxx 24278 2008-06-15 15:21:16Z 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 //
00021 // RooFracRemainder calculates the remainder fraction of a sum of RooAbsReal
00022 // fraction, i.e (1 - sum_i a_i). This class is used by RooSimWSTool to
00023 // as specialization of the remainder fraction term of a parameter with
00024 // a constrained split
00025 // END_HTML
00026 //
00027 
00028 
00029 #include "RooFit.h"
00030 
00031 #include "Riostream.h"
00032 #include "Riostream.h"
00033 #include <math.h>
00034 
00035 #include "RooFracRemainder.h"
00036 #include "RooAbsReal.h"
00037 #include "RooAbsPdf.h"
00038 #include "RooErrorHandler.h"
00039 #include "RooArgSet.h"
00040 #include "RooMsgService.h"
00041 
00042 ClassImp(RooFracRemainder)
00043 ;
00044 
00045 
00046 //_____________________________________________________________________________
00047 RooFracRemainder::RooFracRemainder()
00048 {
00049   // Default constructor
00050 
00051   _setIter1 = _set1.createIterator() ;
00052 }
00053 
00054 
00055 
00056 //_____________________________________________________________________________
00057 RooFracRemainder::RooFracRemainder(const char* name, const char* title, const RooArgSet& sumSet) :
00058   RooAbsReal(name, title),
00059   _set1("set1","First set of components",this)
00060 {
00061   // Constructor with given set of input fractions. All arguments in sumSet must be of type RooAbsReal.
00062 
00063   _setIter1 = _set1.createIterator() ;
00064 
00065   TIterator* inputIter = sumSet.createIterator() ;
00066   RooAbsArg* comp ;
00067   while((comp = (RooAbsArg*)inputIter->Next())) {
00068     if (!dynamic_cast<RooAbsReal*>(comp)) {
00069       coutE(InputArguments) << "RooFracRemainder::ctor(" << GetName() << ") ERROR: component " << comp->GetName() 
00070                             << " is not of type RooAbsReal" << endl ;
00071       RooErrorHandler::softAbort() ;
00072     }
00073     _set1.add(*comp) ;
00074   }
00075 
00076   delete inputIter ;
00077 }
00078 
00079 
00080 
00081 
00082 //_____________________________________________________________________________
00083 RooFracRemainder::RooFracRemainder(const RooFracRemainder& other, const char* name) :
00084   RooAbsReal(other, name), 
00085   _set1("set1",this,other._set1)
00086 {
00087   // Copy constructor
00088 
00089   _setIter1 = _set1.createIterator() ;
00090   
00091   // Member _ownedList is intentionally not copy-constructed -- ownership is not transferred
00092 }
00093 
00094 
00095 
00096 //_____________________________________________________________________________
00097 RooFracRemainder::~RooFracRemainder() 
00098 {
00099   // Destructor
00100 
00101   if (_setIter1) delete _setIter1 ;
00102 }
00103 
00104 
00105 
00106 //_____________________________________________________________________________
00107 Double_t RooFracRemainder::evaluate() const 
00108 {
00109   // Calculate value
00110 
00111   Double_t sum(1);
00112   RooAbsReal* comp ;
00113   const RooArgSet* nset = _set1.nset() ;
00114 
00115   _setIter1->Reset() ;
00116 
00117   while((comp=(RooAbsReal*)_setIter1->Next())) {
00118     sum -= comp->getVal(nset) ;
00119   }
00120     
00121   return sum ;
00122 }
00123 

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