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
00030
00031
00032
00033
00034
00035
00036
00037 #include "RooFit.h"
00038 #include "Riostream.h"
00039
00040 #include "RooGenericPdf.h"
00041 #include "RooGenericPdf.h"
00042 #include "RooStreamParser.h"
00043 #include "RooMsgService.h"
00044 #include "RooArgList.h"
00045
00046
00047
00048 ClassImp(RooGenericPdf)
00049
00050
00051
00052
00053 RooGenericPdf::RooGenericPdf(const char *name, const char *title, const RooArgList& dependents) :
00054 RooAbsPdf(name,title),
00055 _actualVars("actualVars","Variables used by PDF expression",this),
00056 _formula(0),
00057 _formExpr(title)
00058 {
00059
00060 _actualVars.add(dependents) ;
00061
00062 if (_actualVars.getSize()==0) _value = traceEval(0) ;
00063 }
00064
00065
00066
00067
00068 RooGenericPdf::RooGenericPdf(const char *name, const char *title,
00069 const char* inFormula, const RooArgList& dependents) :
00070 RooAbsPdf(name,title),
00071 _actualVars("actualVars","Variables used by PDF expression",this),
00072 _formula(0),
00073 _formExpr(inFormula)
00074 {
00075
00076
00077 _actualVars.add(dependents) ;
00078
00079 if (_actualVars.getSize()==0) _value = traceEval(0) ;
00080 }
00081
00082
00083
00084
00085 RooGenericPdf::RooGenericPdf(const RooGenericPdf& other, const char* name) :
00086 RooAbsPdf(other, name),
00087 _actualVars("actualVars",this,other._actualVars),
00088 _formula(0),
00089 _formExpr(other._formExpr)
00090 {
00091
00092 }
00093
00094
00095
00096
00097 RooGenericPdf::~RooGenericPdf()
00098 {
00099
00100 if (_formula) delete _formula ;
00101 }
00102
00103
00104
00105
00106 RooFormula& RooGenericPdf::formula() const
00107 {
00108 if (!_formula) {
00109 _formula = new RooFormula(GetName(),_formExpr.Data(),_actualVars) ;
00110 }
00111 return *_formula ;
00112 }
00113
00114
00115
00116
00117 Double_t RooGenericPdf::evaluate() const
00118 {
00119
00120
00121 return formula().eval(_normSet) ;
00122 }
00123
00124
00125
00126
00127 Bool_t RooGenericPdf::setFormula(const char* inFormula)
00128 {
00129
00130
00131 if (formula().reCompile(inFormula)) return kTRUE ;
00132
00133 _formExpr = inFormula ;
00134 setValueDirty() ;
00135 return kFALSE ;
00136 }
00137
00138
00139
00140
00141 Bool_t RooGenericPdf::isValidReal(Double_t , Bool_t ) const
00142 {
00143
00144 return kTRUE ;
00145 }
00146
00147
00148
00149
00150 Bool_t RooGenericPdf::redirectServersHook(const RooAbsCollection& newServerList, Bool_t mustReplaceAll, Bool_t nameChange, Bool_t )
00151 {
00152
00153
00154 if (_formula) {
00155 return _formula->changeDependents(newServerList,mustReplaceAll,nameChange) ;
00156 } else {
00157 return kTRUE ;
00158 }
00159 }
00160
00161
00162
00163
00164 void RooGenericPdf::printMultiline(ostream& os, Int_t content, Bool_t verbose, TString indent) const
00165 {
00166
00167
00168 RooAbsPdf::printMultiline(os,content,verbose,indent);
00169 if (verbose) {
00170 os << " --- RooGenericPdf --- " << endl ;
00171 indent.Append(" ");
00172 os << indent ;
00173 formula().printMultiline(os,content,verbose,indent);
00174 }
00175 }
00176
00177
00178
00179
00180 void RooGenericPdf::printMetaArgs(ostream& os) const
00181 {
00182
00183 os << "formula=\"" << _formExpr << "\" " ;
00184 }
00185
00186
00187
00188
00189 Bool_t RooGenericPdf::readFromStream(istream& is, Bool_t compact, Bool_t )
00190 {
00191
00192
00193 if (compact) {
00194 coutE(InputArguments) << "RooGenericPdf::readFromStream(" << GetName() << "): can't read in compact mode" << endl ;
00195 return kTRUE ;
00196 } else {
00197 RooStreamParser parser(is) ;
00198 return setFormula(parser.readLine()) ;
00199 }
00200 }
00201
00202
00203
00204 void RooGenericPdf::writeToStream(ostream& os, Bool_t compact) const
00205 {
00206
00207
00208 if (compact) {
00209 os << getVal() << endl ;
00210 } else {
00211 os << GetTitle() ;
00212 }
00213 }
00214
00215
00216