// Special numeric integrator that can handle integrals over open domains.
// To this end the range is cut in up three pieces: [-inf,-1],[-1,+1] and [+1,inf]
// and the outer two pieces, if required are calculated using a 1/x transform
// END_HTML
#include "RooFit.h"
#include "RooImproperIntegrator1D.h"
#include "RooImproperIntegrator1D.h"
#include "RooIntegrator1D.h"
#include "RooInvTransform.h"
#include "RooNumber.h"
#include "RooNumIntFactory.h"
#include "RooArgSet.h"
#include "RooMsgService.h"
#include "Riostream.h"
#include <math.h>
#include "TClass.h"
ClassImp(RooImproperIntegrator1D)
;
void RooImproperIntegrator1D::registerIntegrator(RooNumIntFactory& fact)
{
RooImproperIntegrator1D* proto = new RooImproperIntegrator1D() ;
fact.storeProtoIntegrator(proto,RooArgSet(),RooIntegrator1D::Class()->GetName()) ;
}
RooImproperIntegrator1D::RooImproperIntegrator1D() :
_function(0), _integrator1(0), _integrator2(0), _integrator3(0)
{
}
RooImproperIntegrator1D::RooImproperIntegrator1D(const RooAbsFunc& function) :
RooAbsIntegrator(function),
_useIntegrandLimits(kTRUE),
_origFunc((RooAbsFunc*)&function),
_function(0),
_integrator1(0),
_integrator2(0),
_integrator3(0)
{
initialize(&function) ;
}
RooImproperIntegrator1D::RooImproperIntegrator1D(const RooAbsFunc& function, const RooNumIntConfig& config) :
RooAbsIntegrator(function),
_useIntegrandLimits(kTRUE),
_origFunc((RooAbsFunc*)&function),
_function(0),
_config(config),
_integrator1(0),
_integrator2(0),
_integrator3(0)
{
initialize(&function) ;
}
RooImproperIntegrator1D::RooImproperIntegrator1D(const RooAbsFunc& function, Double_t xmin, Double_t xmax, const RooNumIntConfig& config) :
RooAbsIntegrator(function),
_xmin(xmin),
_xmax(xmax),
_useIntegrandLimits(kFALSE),
_origFunc((RooAbsFunc*)&function),
_function(0),
_config(config),
_integrator1(0),
_integrator2(0),
_integrator3(0)
{
initialize(&function) ;
}
RooAbsIntegrator* RooImproperIntegrator1D::clone(const RooAbsFunc& function, const RooNumIntConfig& config) const
{
return new RooImproperIntegrator1D(function,config) ;
}
void RooImproperIntegrator1D::initialize(const RooAbsFunc* function)
{
if(!isValid()) {
oocoutE((TObject*)0,Integration) << "RooImproperIntegrator: cannot integrate invalid function" << endl;
return;
}
if (function) {
_function= new RooInvTransform(*function);
} else {
function = _origFunc ;
if (_integrator1) {
delete _integrator1 ;
_integrator1 = 0 ;
}
if (_integrator2) {
delete _integrator2 ;
_integrator2 = 0 ;
}
if (_integrator3) {
delete _integrator3 ;
_integrator3 = 0 ;
}
}
switch(_case= limitsCase()) {
case ClosedBothEnds:
_integrator1= new RooIntegrator1D(*function,_xmin,_xmax,_config);
break;
case OpenBothEnds:
_integrator1= new RooIntegrator1D(*function,-1,+1,RooIntegrator1D::Trapezoid);
_integrator2= new RooIntegrator1D(*_function,-1,0,RooIntegrator1D::Midpoint);
_integrator3= new RooIntegrator1D(*_function,0,+1,RooIntegrator1D::Midpoint);
break;
case OpenBelowSpansZero:
_integrator1= new RooIntegrator1D(*_function,-1,0,RooIntegrator1D::Midpoint);
_integrator2= new RooIntegrator1D(*function,-1,_xmax,RooIntegrator1D::Trapezoid);
break;
case OpenBelow:
_integrator1= new RooIntegrator1D(*_function,1/_xmax,0,RooIntegrator1D::Midpoint);
break;
case OpenAboveSpansZero:
_integrator1= new RooIntegrator1D(*_function,0,+1,RooIntegrator1D::Midpoint);
_integrator2= new RooIntegrator1D(*function,_xmin,+1,RooIntegrator1D::Trapezoid);
break;
case OpenAbove:
_integrator1= new RooIntegrator1D(*_function,0,1/_xmin,RooIntegrator1D::Midpoint);
break;
case Invalid:
default:
_valid= kFALSE;
}
}
RooImproperIntegrator1D::~RooImproperIntegrator1D()
{
if(0 != _integrator1) delete _integrator1;
if(0 != _integrator2) delete _integrator2;
if(0 != _integrator3) delete _integrator3;
if(0 != _function) delete _function;
}
Bool_t RooImproperIntegrator1D::setLimits(Double_t *xmin, Double_t *xmax)
{
if(_useIntegrandLimits) {
oocoutE((TObject*)0,Integration) << "RooIntegrator1D::setLimits: cannot override integrand's limits" << endl;
return kFALSE;
}
_xmin= *xmin;
_xmax= *xmax;
return checkLimits();
}
Bool_t RooImproperIntegrator1D::checkLimits() const
{
if (_useIntegrandLimits) {
if(_xmin == integrand()->getMinLimit(0) &&
_xmax == integrand()->getMaxLimit(0)) return kTRUE;
}
if(limitsCase() != _case) {
const_cast<RooImproperIntegrator1D*>(this)->initialize() ;
return kTRUE ;
}
switch(_case) {
case ClosedBothEnds:
_integrator1->setLimits(_xmin,_xmax);
break;
case OpenBothEnds:
break;
case OpenBelowSpansZero:
_integrator2->setLimits(-1,_xmax);
break;
case OpenBelow:
_integrator1->setLimits(1/_xmax,0);
break;
case OpenAboveSpansZero:
_integrator2->setLimits(_xmin,+1);
break;
case OpenAbove:
_integrator1->setLimits(0,1/_xmin);
break;
case Invalid:
default:
return kFALSE;
}
return kTRUE;
}
RooImproperIntegrator1D::LimitsCase RooImproperIntegrator1D::limitsCase() const
{
if(0 == integrand() || !integrand()->isValid()) return Invalid;
if (_useIntegrandLimits) {
_xmin= integrand()->getMinLimit(0);
_xmax= integrand()->getMaxLimit(0);
}
Bool_t inf1= RooNumber::isInfinite(_xmin);
Bool_t inf2= RooNumber::isInfinite(_xmax);
if(!inf1 && !inf2) {
return ClosedBothEnds;
}
else if(inf1 && inf2) {
return OpenBothEnds;
}
else if(inf1) {
if(_xmax >= 0) {
return OpenBelowSpansZero;
}
else {
return OpenBelow;
}
}
else {
if(_xmin <= 0) {
return OpenAboveSpansZero;
}
else {
return OpenAbove;
}
}
}
Double_t RooImproperIntegrator1D::integral(const Double_t* yvec)
{
Double_t result(0);
if(0 != _integrator1) result+= _integrator1->integral(yvec);
if(0 != _integrator2) result+= _integrator2->integral(yvec);
if(0 != _integrator3) result+= _integrator3->integral(yvec);
return result;
}
RooImproperIntegrator1D.cxx:1 RooImproperIntegrator1D.cxx:2 RooImproperIntegrator1D.cxx:3 RooImproperIntegrator1D.cxx:4 RooImproperIntegrator1D.cxx:5 RooImproperIntegrator1D.cxx:6 RooImproperIntegrator1D.cxx:7 RooImproperIntegrator1D.cxx:8 RooImproperIntegrator1D.cxx:9 RooImproperIntegrator1D.cxx:10 RooImproperIntegrator1D.cxx:11 RooImproperIntegrator1D.cxx:12 RooImproperIntegrator1D.cxx:13 RooImproperIntegrator1D.cxx:14 RooImproperIntegrator1D.cxx:15 RooImproperIntegrator1D.cxx:16 RooImproperIntegrator1D.cxx:17 RooImproperIntegrator1D.cxx:18 RooImproperIntegrator1D.cxx:19 RooImproperIntegrator1D.cxx:20 RooImproperIntegrator1D.cxx:21 RooImproperIntegrator1D.cxx:22 RooImproperIntegrator1D.cxx:23 RooImproperIntegrator1D.cxx:24 RooImproperIntegrator1D.cxx:25 RooImproperIntegrator1D.cxx:26 RooImproperIntegrator1D.cxx:27 RooImproperIntegrator1D.cxx:28 RooImproperIntegrator1D.cxx:29 RooImproperIntegrator1D.cxx:30 RooImproperIntegrator1D.cxx:31 RooImproperIntegrator1D.cxx:32 RooImproperIntegrator1D.cxx:33 RooImproperIntegrator1D.cxx:34 RooImproperIntegrator1D.cxx:35 RooImproperIntegrator1D.cxx:36 RooImproperIntegrator1D.cxx:37 RooImproperIntegrator1D.cxx:38 RooImproperIntegrator1D.cxx:39 RooImproperIntegrator1D.cxx:40 RooImproperIntegrator1D.cxx:41 RooImproperIntegrator1D.cxx:42 RooImproperIntegrator1D.cxx:43 RooImproperIntegrator1D.cxx:44 RooImproperIntegrator1D.cxx:45 RooImproperIntegrator1D.cxx:46 RooImproperIntegrator1D.cxx:47 RooImproperIntegrator1D.cxx:48 RooImproperIntegrator1D.cxx:49 RooImproperIntegrator1D.cxx:50 RooImproperIntegrator1D.cxx:51 RooImproperIntegrator1D.cxx:52 RooImproperIntegrator1D.cxx:53 RooImproperIntegrator1D.cxx:54 RooImproperIntegrator1D.cxx:55 RooImproperIntegrator1D.cxx:56 RooImproperIntegrator1D.cxx:57 RooImproperIntegrator1D.cxx:58 RooImproperIntegrator1D.cxx:59 RooImproperIntegrator1D.cxx:60 RooImproperIntegrator1D.cxx:61 RooImproperIntegrator1D.cxx:62 RooImproperIntegrator1D.cxx:63 RooImproperIntegrator1D.cxx:64 RooImproperIntegrator1D.cxx:65 RooImproperIntegrator1D.cxx:66 RooImproperIntegrator1D.cxx:67 RooImproperIntegrator1D.cxx:68 RooImproperIntegrator1D.cxx:69 RooImproperIntegrator1D.cxx:70 RooImproperIntegrator1D.cxx:71 RooImproperIntegrator1D.cxx:72 RooImproperIntegrator1D.cxx:73 RooImproperIntegrator1D.cxx:74 RooImproperIntegrator1D.cxx:75 RooImproperIntegrator1D.cxx:76 RooImproperIntegrator1D.cxx:77 RooImproperIntegrator1D.cxx:78 RooImproperIntegrator1D.cxx:79 RooImproperIntegrator1D.cxx:80 RooImproperIntegrator1D.cxx:81 RooImproperIntegrator1D.cxx:82 RooImproperIntegrator1D.cxx:83 RooImproperIntegrator1D.cxx:84 RooImproperIntegrator1D.cxx:85 RooImproperIntegrator1D.cxx:86 RooImproperIntegrator1D.cxx:87 RooImproperIntegrator1D.cxx:88 RooImproperIntegrator1D.cxx:89 RooImproperIntegrator1D.cxx:90 RooImproperIntegrator1D.cxx:91 RooImproperIntegrator1D.cxx:92 RooImproperIntegrator1D.cxx:93 RooImproperIntegrator1D.cxx:94 RooImproperIntegrator1D.cxx:95 RooImproperIntegrator1D.cxx:96 RooImproperIntegrator1D.cxx:97 RooImproperIntegrator1D.cxx:98 RooImproperIntegrator1D.cxx:99 RooImproperIntegrator1D.cxx:100 RooImproperIntegrator1D.cxx:101 RooImproperIntegrator1D.cxx:102 RooImproperIntegrator1D.cxx:103 RooImproperIntegrator1D.cxx:104 RooImproperIntegrator1D.cxx:105 RooImproperIntegrator1D.cxx:106 RooImproperIntegrator1D.cxx:107 RooImproperIntegrator1D.cxx:108 RooImproperIntegrator1D.cxx:109 RooImproperIntegrator1D.cxx:110 RooImproperIntegrator1D.cxx:111 RooImproperIntegrator1D.cxx:112 RooImproperIntegrator1D.cxx:113 RooImproperIntegrator1D.cxx:114 RooImproperIntegrator1D.cxx:115 RooImproperIntegrator1D.cxx:116 RooImproperIntegrator1D.cxx:117 RooImproperIntegrator1D.cxx:118 RooImproperIntegrator1D.cxx:119 RooImproperIntegrator1D.cxx:120 RooImproperIntegrator1D.cxx:121 RooImproperIntegrator1D.cxx:122 RooImproperIntegrator1D.cxx:123 RooImproperIntegrator1D.cxx:124 RooImproperIntegrator1D.cxx:125 RooImproperIntegrator1D.cxx:126 RooImproperIntegrator1D.cxx:127 RooImproperIntegrator1D.cxx:128 RooImproperIntegrator1D.cxx:129 RooImproperIntegrator1D.cxx:130 RooImproperIntegrator1D.cxx:131 RooImproperIntegrator1D.cxx:132 RooImproperIntegrator1D.cxx:133 RooImproperIntegrator1D.cxx:134 RooImproperIntegrator1D.cxx:135 RooImproperIntegrator1D.cxx:136 RooImproperIntegrator1D.cxx:137 RooImproperIntegrator1D.cxx:138 RooImproperIntegrator1D.cxx:139 RooImproperIntegrator1D.cxx:140 RooImproperIntegrator1D.cxx:141 RooImproperIntegrator1D.cxx:142 RooImproperIntegrator1D.cxx:143 RooImproperIntegrator1D.cxx:144 RooImproperIntegrator1D.cxx:145 RooImproperIntegrator1D.cxx:146 RooImproperIntegrator1D.cxx:147 RooImproperIntegrator1D.cxx:148 RooImproperIntegrator1D.cxx:149 RooImproperIntegrator1D.cxx:150 RooImproperIntegrator1D.cxx:151 RooImproperIntegrator1D.cxx:152 RooImproperIntegrator1D.cxx:153 RooImproperIntegrator1D.cxx:154 RooImproperIntegrator1D.cxx:155 RooImproperIntegrator1D.cxx:156 RooImproperIntegrator1D.cxx:157 RooImproperIntegrator1D.cxx:158 RooImproperIntegrator1D.cxx:159 RooImproperIntegrator1D.cxx:160 RooImproperIntegrator1D.cxx:161 RooImproperIntegrator1D.cxx:162 RooImproperIntegrator1D.cxx:163 RooImproperIntegrator1D.cxx:164 RooImproperIntegrator1D.cxx:165 RooImproperIntegrator1D.cxx:166 RooImproperIntegrator1D.cxx:167 RooImproperIntegrator1D.cxx:168 RooImproperIntegrator1D.cxx:169 RooImproperIntegrator1D.cxx:170 RooImproperIntegrator1D.cxx:171 RooImproperIntegrator1D.cxx:172 RooImproperIntegrator1D.cxx:173 RooImproperIntegrator1D.cxx:174 RooImproperIntegrator1D.cxx:175 RooImproperIntegrator1D.cxx:176 RooImproperIntegrator1D.cxx:177 RooImproperIntegrator1D.cxx:178 RooImproperIntegrator1D.cxx:179 RooImproperIntegrator1D.cxx:180 RooImproperIntegrator1D.cxx:181 RooImproperIntegrator1D.cxx:182 RooImproperIntegrator1D.cxx:183 RooImproperIntegrator1D.cxx:184 RooImproperIntegrator1D.cxx:185 RooImproperIntegrator1D.cxx:186 RooImproperIntegrator1D.cxx:187 RooImproperIntegrator1D.cxx:188 RooImproperIntegrator1D.cxx:189 RooImproperIntegrator1D.cxx:190 RooImproperIntegrator1D.cxx:191 RooImproperIntegrator1D.cxx:192 RooImproperIntegrator1D.cxx:193 RooImproperIntegrator1D.cxx:194 RooImproperIntegrator1D.cxx:195 RooImproperIntegrator1D.cxx:196 RooImproperIntegrator1D.cxx:197 RooImproperIntegrator1D.cxx:198 RooImproperIntegrator1D.cxx:199 RooImproperIntegrator1D.cxx:200 RooImproperIntegrator1D.cxx:201 RooImproperIntegrator1D.cxx:202 RooImproperIntegrator1D.cxx:203 RooImproperIntegrator1D.cxx:204 RooImproperIntegrator1D.cxx:205 RooImproperIntegrator1D.cxx:206 RooImproperIntegrator1D.cxx:207 RooImproperIntegrator1D.cxx:208 RooImproperIntegrator1D.cxx:209 RooImproperIntegrator1D.cxx:210 RooImproperIntegrator1D.cxx:211 RooImproperIntegrator1D.cxx:212 RooImproperIntegrator1D.cxx:213 RooImproperIntegrator1D.cxx:214 RooImproperIntegrator1D.cxx:215 RooImproperIntegrator1D.cxx:216 RooImproperIntegrator1D.cxx:217 RooImproperIntegrator1D.cxx:218 RooImproperIntegrator1D.cxx:219 RooImproperIntegrator1D.cxx:220 RooImproperIntegrator1D.cxx:221 RooImproperIntegrator1D.cxx:222 RooImproperIntegrator1D.cxx:223 RooImproperIntegrator1D.cxx:224 RooImproperIntegrator1D.cxx:225 RooImproperIntegrator1D.cxx:226 RooImproperIntegrator1D.cxx:227 RooImproperIntegrator1D.cxx:228 RooImproperIntegrator1D.cxx:229 RooImproperIntegrator1D.cxx:230 RooImproperIntegrator1D.cxx:231 RooImproperIntegrator1D.cxx:232 RooImproperIntegrator1D.cxx:233 RooImproperIntegrator1D.cxx:234 RooImproperIntegrator1D.cxx:235 RooImproperIntegrator1D.cxx:236 RooImproperIntegrator1D.cxx:237 RooImproperIntegrator1D.cxx:238 RooImproperIntegrator1D.cxx:239 RooImproperIntegrator1D.cxx:240 RooImproperIntegrator1D.cxx:241 RooImproperIntegrator1D.cxx:242 RooImproperIntegrator1D.cxx:243 RooImproperIntegrator1D.cxx:244 RooImproperIntegrator1D.cxx:245 RooImproperIntegrator1D.cxx:246 RooImproperIntegrator1D.cxx:247 RooImproperIntegrator1D.cxx:248 RooImproperIntegrator1D.cxx:249 RooImproperIntegrator1D.cxx:250 RooImproperIntegrator1D.cxx:251 RooImproperIntegrator1D.cxx:252 RooImproperIntegrator1D.cxx:253 RooImproperIntegrator1D.cxx:254 RooImproperIntegrator1D.cxx:255 RooImproperIntegrator1D.cxx:256 RooImproperIntegrator1D.cxx:257 RooImproperIntegrator1D.cxx:258 RooImproperIntegrator1D.cxx:259 RooImproperIntegrator1D.cxx:260 RooImproperIntegrator1D.cxx:261 RooImproperIntegrator1D.cxx:262 RooImproperIntegrator1D.cxx:263 RooImproperIntegrator1D.cxx:264 RooImproperIntegrator1D.cxx:265 RooImproperIntegrator1D.cxx:266 RooImproperIntegrator1D.cxx:267 RooImproperIntegrator1D.cxx:268 RooImproperIntegrator1D.cxx:269 RooImproperIntegrator1D.cxx:270 RooImproperIntegrator1D.cxx:271 RooImproperIntegrator1D.cxx:272 RooImproperIntegrator1D.cxx:273 RooImproperIntegrator1D.cxx:274 RooImproperIntegrator1D.cxx:275 RooImproperIntegrator1D.cxx:276 RooImproperIntegrator1D.cxx:277 RooImproperIntegrator1D.cxx:278 RooImproperIntegrator1D.cxx:279 RooImproperIntegrator1D.cxx:280 RooImproperIntegrator1D.cxx:281 RooImproperIntegrator1D.cxx:282 RooImproperIntegrator1D.cxx:283 RooImproperIntegrator1D.cxx:284 RooImproperIntegrator1D.cxx:285 RooImproperIntegrator1D.cxx:286 RooImproperIntegrator1D.cxx:287 RooImproperIntegrator1D.cxx:288 RooImproperIntegrator1D.cxx:289 RooImproperIntegrator1D.cxx:290 RooImproperIntegrator1D.cxx:291 RooImproperIntegrator1D.cxx:292 RooImproperIntegrator1D.cxx:293 RooImproperIntegrator1D.cxx:294 RooImproperIntegrator1D.cxx:295 RooImproperIntegrator1D.cxx:296 RooImproperIntegrator1D.cxx:297 RooImproperIntegrator1D.cxx:298 RooImproperIntegrator1D.cxx:299 RooImproperIntegrator1D.cxx:300 RooImproperIntegrator1D.cxx:301 RooImproperIntegrator1D.cxx:302 RooImproperIntegrator1D.cxx:303 RooImproperIntegrator1D.cxx:304 RooImproperIntegrator1D.cxx:305 RooImproperIntegrator1D.cxx:306 RooImproperIntegrator1D.cxx:307 RooImproperIntegrator1D.cxx:308 RooImproperIntegrator1D.cxx:309 RooImproperIntegrator1D.cxx:310 RooImproperIntegrator1D.cxx:311 RooImproperIntegrator1D.cxx:312 RooImproperIntegrator1D.cxx:313 RooImproperIntegrator1D.cxx:314 RooImproperIntegrator1D.cxx:315 RooImproperIntegrator1D.cxx:316 RooImproperIntegrator1D.cxx:317 RooImproperIntegrator1D.cxx:318 RooImproperIntegrator1D.cxx:319 RooImproperIntegrator1D.cxx:320 RooImproperIntegrator1D.cxx:321 RooImproperIntegrator1D.cxx:322 RooImproperIntegrator1D.cxx:323 RooImproperIntegrator1D.cxx:324 RooImproperIntegrator1D.cxx:325 RooImproperIntegrator1D.cxx:326 RooImproperIntegrator1D.cxx:327 RooImproperIntegrator1D.cxx:328 RooImproperIntegrator1D.cxx:329 RooImproperIntegrator1D.cxx:330 RooImproperIntegrator1D.cxx:331 RooImproperIntegrator1D.cxx:332