diff --git a/roofit/roofit/src/RooPoisson.cxx b/roofit/roofit/src/RooPoisson.cxx index b1fb8bb36ef47c46e77f850a5c120f7339306e84..5de81fcf26f503720794238313c86b2faf391898 100644 --- a/roofit/roofit/src/RooPoisson.cxx +++ b/roofit/roofit/src/RooPoisson.cxx @@ -87,26 +87,36 @@ Double_t RooPoisson::analyticalIntegral(Int_t code, const char* rangeName) const // Protect against negative lower boundaries if (xmin<0) xmin=0 ; - + Int_t ixmin = Int_t (xmin) ; Int_t ixmax = Int_t (xmax)+1 ; Double_t fracLoBin = 1-(xmin-ixmin) ; Double_t fracHiBin = 1-(ixmax-xmax) ; + if (!x.hasMax()) { + if (xmin<1e-6) { + return 1 ; + } else { + + // Return 1 minus integral from 0 to x.min() + + if(ixmin == 0){ // first bin + return TMath::Poisson(0, mean)*(xmin-0); + } + Double_t sum(0) ; + sum += TMath::Poisson(0,mean)*fracLoBin ; + sum+= ROOT::Math::poisson_cdf(ixmin-2, mean) - ROOT::Math::poisson_cdf(0,mean) ; + sum += TMath::Poisson(ixmin-1,mean)*fracHiBin ; + return 1-sum ; + } + } if(ixmin == ixmax-1){ // first bin return TMath::Poisson(ixmin, mean)*(xmax-xmin); - } - - + } Double_t sum(0) ; sum += TMath::Poisson(ixmin,mean)*fracLoBin ; - /* - for (int i=ixmin+1 ; i<ixmax-1 ; i++) { - sum += TMath::Poisson(i,mean) ; - } - */ sum+= ROOT::Math::poisson_cdf(ixmax-2, mean) - ROOT::Math::poisson_cdf(ixmin,mean) ; sum += TMath::Poisson(ixmax-1,mean)*fracHiBin ; diff --git a/roofit/roofitcore/inc/RooRealProxy.h b/roofit/roofitcore/inc/RooRealProxy.h index db0f2d5da8605331a94c731f33f1d45863981118..fc33e9d1cf6f8a600205e072e7ee67df5d390e38 100644 --- a/roofit/roofitcore/inc/RooRealProxy.h +++ b/roofit/roofitcore/inc/RooRealProxy.h @@ -50,6 +50,8 @@ public: RooRealProxy& operator=(const Double_t& value) { lvptr()->setVal(value) ; return *this ; } Double_t min(const char* rname=0) const { return lvptr()->getMin(rname) ; } Double_t max(const char* rname=0) const { return lvptr()->getMax(rname) ; } + Bool_t hasMin(const char* rname=0) const { return lvptr()->hasMin(rname) ; } + Bool_t hasMax(const char* rname=0) const { return lvptr()->hasMax(rname) ; } ClassDef(RooRealProxy,1) // Proxy for a RooAbsReal object diff --git a/roofit/roofitcore/src/RooRealVar.cxx b/roofit/roofitcore/src/RooRealVar.cxx index 73020f0d37a679084c23ba8df27ca497a261646b..937b7c835fc6d087f7fce7a92d057e168c574e0c 100644 --- a/roofit/roofitcore/src/RooRealVar.cxx +++ b/roofit/roofitcore/src/RooRealVar.cxx @@ -85,9 +85,25 @@ RooRealVar::RooRealVar(const char *name, const char *title, _binning = new RooUniformBinning(minValue,maxValue,100) ; - _value= 0.5*(minValue + maxValue); + if (RooNumber::isInfinite(minValue)) { + if (RooNumber::isInfinite(maxValue)) { + // [-inf,inf] + _value = 0 ; + } else { + // [-inf,X] + _value= maxValue ; + } + } else { + if (RooNumber::isInfinite(maxValue)) { + // [X,inf] + _value = minValue ; + } else { + // [X,X] + _value= 0.5*(minValue + maxValue); + } + } -// setPlotRange(minValue,maxValue) ; + // setPlotRange(minValue,maxValue) ; setRange(minValue,maxValue) ; }