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 #include "RooFit.h"
00027 #include "Riostream.h"
00028
00029 #include "RooNumIntConfig.h"
00030 #include "RooArgSet.h"
00031 #include "RooAbsIntegrator.h"
00032 #include "RooNumIntFactory.h"
00033 #include "RooMsgService.h"
00034
00035 #include "TClass.h"
00036
00037
00038
00039 ClassImp(RooNumIntConfig)
00040 ;
00041
00042 RooNumIntConfig* RooNumIntConfig::_default = 0 ;
00043
00044
00045
00046 void RooNumIntConfig::cleanup()
00047 {
00048
00049
00050 if (_default) {
00051 delete _default ;
00052 _default = 0 ;
00053 }
00054 }
00055
00056
00057
00058
00059 RooNumIntConfig& RooNumIntConfig::defaultConfig()
00060 {
00061
00062
00063
00064 if (_default==0) {
00065 _default = new RooNumIntConfig ;
00066 RooNumIntFactory::instance() ;
00067 }
00068 return *_default ;
00069 }
00070
00071
00072
00073
00074 RooNumIntConfig::RooNumIntConfig() :
00075 _epsAbs(1e-7),
00076 _epsRel(1e-7),
00077 _printEvalCounter(kFALSE),
00078 _method1D("method1D","1D integration method"),
00079 _method2D("method2D","2D integration method"),
00080 _methodND("methodND","ND integration method"),
00081 _method1DOpen("method1DOpen","1D integration method in open domain"),
00082 _method2DOpen("method2DOpen","2D integration method in open domain"),
00083 _methodNDOpen("methodNDOpen","ND integration method in open domain")
00084 {
00085
00086
00087
00088
00089
00090 _method1D.defineType("N/A",0) ;
00091 _method2D.defineType("N/A",0) ;
00092 _methodND.defineType("N/A",0) ;
00093 _method1DOpen.defineType("N/A",0) ;
00094 _method2DOpen.defineType("N/A",0) ;
00095 _methodNDOpen.defineType("N/A",0) ;
00096 }
00097
00098
00099
00100 RooNumIntConfig::~RooNumIntConfig()
00101 {
00102
00103
00104
00105 _configSets.Delete() ;
00106 }
00107
00108
00109
00110 RooNumIntConfig::RooNumIntConfig(const RooNumIntConfig& other) :
00111 TObject(other), RooPrintable(other),
00112 _epsAbs(other._epsAbs),
00113 _epsRel(other._epsRel),
00114 _printEvalCounter(other._printEvalCounter),
00115 _method1D(other._method1D),
00116 _method2D(other._method2D),
00117 _methodND(other._methodND),
00118 _method1DOpen(other._method1DOpen),
00119 _method2DOpen(other._method2DOpen),
00120 _methodNDOpen(other._methodNDOpen)
00121 {
00122
00123
00124
00125 TIterator* iter = other._configSets.MakeIterator() ;
00126 RooArgSet* set ;
00127 while((set=(RooArgSet*)iter->Next())) {
00128 RooArgSet* setCopy = (RooArgSet*) set->snapshot() ;
00129 setCopy->setName(set->GetName()) ;
00130 _configSets.Add(setCopy);
00131 }
00132 delete iter ;
00133 }
00134
00135
00136
00137 RooNumIntConfig& RooNumIntConfig::operator=(const RooNumIntConfig& other)
00138 {
00139
00140
00141
00142 if (&other==this) {
00143 return *this ;
00144 }
00145
00146
00147 _epsAbs = other._epsAbs ;
00148 _epsRel = other._epsRel ;
00149 _method1D.setIndex(other._method1D.getIndex()) ;
00150 _method2D.setIndex(other._method2D.getIndex()) ;
00151 _methodND.setIndex(other._methodND.getIndex()) ;
00152 _method1DOpen.setIndex(other._method1DOpen.getIndex()) ;
00153 _method2DOpen.setIndex(other._method2DOpen.getIndex()) ;
00154 _methodNDOpen.setIndex(other._methodNDOpen.getIndex()) ;
00155
00156
00157 _configSets.Delete() ;
00158
00159
00160 TIterator* iter = other._configSets.MakeIterator() ;
00161 RooArgSet* set ;
00162 while((set=(RooArgSet*)iter->Next())) {
00163 RooArgSet* setCopy = (RooArgSet*) set->snapshot() ;
00164 setCopy->setName(set->GetName()) ;
00165 _configSets.Add(setCopy);
00166 }
00167 delete iter ;
00168
00169 return *this ;
00170 }
00171
00172
00173
00174
00175 Bool_t RooNumIntConfig::addConfigSection(const RooAbsIntegrator* proto, const RooArgSet& inDefaultConfig)
00176 {
00177
00178
00179
00180
00181 TString name = proto->IsA()->GetName() ;
00182
00183
00184 if (proto->canIntegrate1D()) {
00185 _method1D.defineType(name) ;
00186 if (proto->canIntegrateOpenEnded()) {
00187 _method1DOpen.defineType(name) ;
00188 }
00189 }
00190
00191 if (proto->canIntegrate2D()) {
00192 _method2D.defineType(name) ;
00193 if (proto->canIntegrateOpenEnded()) {
00194 _method2DOpen.defineType(name) ;
00195 }
00196 }
00197
00198 if (proto->canIntegrateND()) {
00199 _methodND.defineType(name) ;
00200 if (proto->canIntegrateOpenEnded()) {
00201 _methodNDOpen.defineType(name) ;
00202 }
00203 }
00204
00205
00206 RooArgSet* config = (RooArgSet*) inDefaultConfig.snapshot() ;
00207 config->setName(name) ;
00208 _configSets.Add(config) ;
00209
00210 return kFALSE ;
00211 }
00212
00213
00214
00215
00216 RooArgSet& RooNumIntConfig::getConfigSection(const char* name)
00217 {
00218
00219
00220 return const_cast<RooArgSet&>((const_cast<const RooNumIntConfig*>(this)->getConfigSection(name))) ;
00221 }
00222
00223
00224
00225 const RooArgSet& RooNumIntConfig::getConfigSection(const char* name) const
00226 {
00227
00228
00229 static RooArgSet dummy ;
00230 RooArgSet* config = (RooArgSet*) _configSets.FindObject(name) ;
00231 if (!config) {
00232 oocoutE((TObject*)0,InputArguments) << "RooNumIntConfig::getIntegrator: ERROR: no configuration stored for integrator '" << name << "'" << endl ;
00233 return dummy ;
00234 }
00235 return *config ;
00236 }
00237
00238
00239
00240
00241 void RooNumIntConfig::setEpsAbs(Double_t newEpsAbs)
00242 {
00243
00244
00245 if (newEpsAbs<=0) {
00246 oocoutE((TObject*)0,InputArguments) << "RooNumIntConfig::setEpsAbs: ERROR: target absolute precision must be greater than zero" << endl ;
00247 return ;
00248 }
00249 _epsAbs = newEpsAbs ;
00250 }
00251
00252
00253 RooPrintable::StyleOption RooNumIntConfig::defaultPrintStyle(Option_t* opt) const
00254 {
00255 if (!opt) {
00256 return kStandard ;
00257 }
00258
00259 TString o(opt) ;
00260 o.ToLower() ;
00261
00262 if (o.Contains("v")) {
00263 return kVerbose ;
00264 }
00265 return kStandard ;
00266 }
00267
00268
00269
00270
00271 void RooNumIntConfig::setEpsRel(Double_t newEpsRel)
00272 {
00273
00274
00275 if (newEpsRel<=0) {
00276 oocoutE((TObject*)0,InputArguments) << "RooNumIntConfig::setEpsRel: ERROR: target absolute precision must be greater than zero" << endl ;
00277 return ;
00278 }
00279 _epsRel = newEpsRel ;
00280 }
00281
00282
00283
00284
00285 void RooNumIntConfig::printMultiline(ostream &os, Int_t , Bool_t verbose, TString indent) const
00286 {
00287
00288
00289 os << indent << "Requested precision: " << _epsAbs << " absolute, " << _epsRel << " relative" << endl << endl ;
00290 if (_printEvalCounter) {
00291 os << indent << "Printing of function evaluation counter for each integration enabled" << endl << endl ;
00292 }
00293
00294 os << indent << "1-D integration method: " << _method1D.getLabel() ;
00295 if (_method1DOpen.getIndex()!=_method1D.getIndex()) {
00296 os << " (" << _method1DOpen.getLabel() << " if open-ended)" << endl ;
00297 } else {
00298 os << endl ;
00299 }
00300 os << indent << "2-D integration method: " << _method2D.getLabel() ;
00301 if (_method2DOpen.getIndex()!=_method2D.getIndex()) {
00302 os << " (" << _method2DOpen.getLabel() << " if open-ended)" << endl ;
00303 } else {
00304 os << endl ;
00305 }
00306 os << indent << "N-D integration method: " << _methodND.getLabel() ;
00307 if (_methodNDOpen.getIndex()!=_methodND.getIndex()) {
00308 os << " (" << _methodNDOpen.getLabel() << " if open-ended)" << endl ;
00309 } else {
00310 os << endl ;
00311 }
00312
00313 if (verbose) {
00314
00315 os << endl << "Available integration methods:" << endl << endl ;
00316 TIterator* cIter = _configSets.MakeIterator() ;
00317 RooArgSet* configSet ;
00318 while ((configSet=(RooArgSet*)cIter->Next())) {
00319
00320 os << indent << "*** " << configSet->GetName() << " ***" << endl ;
00321 os << indent << "Capabilities: " ;
00322 const RooAbsIntegrator* proto = RooNumIntFactory::instance().getProtoIntegrator(configSet->GetName()) ;
00323 if (proto->canIntegrate1D()) os << "[1-D] " ;
00324 if (proto->canIntegrate2D()) os << "[2-D] " ;
00325 if (proto->canIntegrateND()) os << "[N-D] " ;
00326 if (proto->canIntegrateOpenEnded()) os << "[OpenEnded] " ;
00327 os << endl ;
00328
00329 os << "Configuration: " << endl ;
00330 configSet->printMultiline(os,kName|kValue) ;
00331
00332
00333 const char* depName = RooNumIntFactory::instance().getDepIntegratorName(configSet->GetName()) ;
00334 if (strlen(depName)>0) {
00335 os << indent << "(Depends on '" << depName << "')" << endl ;
00336 }
00337 os << endl ;
00338
00339 }
00340
00341 delete cIter ;
00342 }
00343 }