00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "RooFit.h"
00030
00031 #include "Riostream.h"
00032 #include "Riostream.h"
00033 #include <math.h>
00034
00035 #include "RooConstraintSum.h"
00036 #include "RooAbsReal.h"
00037 #include "RooAbsPdf.h"
00038 #include "RooErrorHandler.h"
00039 #include "RooArgSet.h"
00040 #include "RooNLLVar.h"
00041 #include "RooChi2Var.h"
00042 #include "RooMsgService.h"
00043
00044 ClassImp(RooConstraintSum)
00045 ;
00046
00047
00048
00049 RooConstraintSum::RooConstraintSum()
00050 {
00051
00052 _setIter1 = _set1.createIterator() ;
00053 }
00054
00055
00056
00057
00058 RooConstraintSum::RooConstraintSum(const char* name, const char* title, const RooArgSet& constraintSet, const RooArgSet& paramSet) :
00059 RooAbsReal(name, title),
00060 _set1("set1","First set of components",this),
00061 _paramSet("paramSet","Set of parameters",this)
00062 {
00063
00064
00065 _setIter1 = _set1.createIterator() ;
00066
00067 TIterator* inputIter = constraintSet.createIterator() ;
00068 RooAbsArg* comp ;
00069 while((comp = (RooAbsArg*)inputIter->Next())) {
00070 if (!dynamic_cast<RooAbsPdf*>(comp)) {
00071 coutE(InputArguments) << "RooConstraintSum::ctor(" << GetName() << ") ERROR: component " << comp->GetName()
00072 << " is not of type RooAbsPdf" << endl ;
00073 RooErrorHandler::softAbort() ;
00074 }
00075 _set1.add(*comp) ;
00076 }
00077
00078 _paramSet.add(paramSet) ;
00079
00080 delete inputIter ;
00081 }
00082
00083
00084
00085
00086
00087
00088 RooConstraintSum::RooConstraintSum(const RooConstraintSum& other, const char* name) :
00089 RooAbsReal(other, name),
00090 _set1("set1",this,other._set1),
00091 _paramSet("paramSet",this,other._paramSet)
00092 {
00093
00094
00095 _setIter1 = _set1.createIterator() ;
00096 }
00097
00098
00099
00100
00101 RooConstraintSum::~RooConstraintSum()
00102 {
00103
00104
00105 if (_setIter1) delete _setIter1 ;
00106 }
00107
00108
00109
00110
00111 Double_t RooConstraintSum::evaluate() const
00112 {
00113
00114
00115 Double_t sum(0);
00116 RooAbsReal* comp ;
00117 _setIter1->Reset() ;
00118
00119 while((comp=(RooAbsReal*)_setIter1->Next())) {
00120 sum -= ((RooAbsPdf*)comp)->getLogVal(&_paramSet) ;
00121 }
00122
00123 return sum ;
00124 }
00125