From 90869af8300683dcc8eedf909fe908c4a182789c Mon Sep 17 00:00:00 2001
From: Lorenzo Moneta <Lorenzo.Moneta@cern.ch>
Date: Tue, 24 Apr 2012 16:41:46 +0000
Subject: [PATCH] use noRounding for the Poisson of the sidebands since the
 noff value can be in some cause non-integer (i.e. be interpreted as a Gamma
 constraint)

git-svn-id: http://root.cern.ch/svn/root/trunk@43932 27541ba8-7e3a-0410-8455-c3a389f83636
---
 roofit/roostats/src/NumberCountingPdfFactory.cxx | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/roofit/roostats/src/NumberCountingPdfFactory.cxx b/roofit/roostats/src/NumberCountingPdfFactory.cxx
index a4214272113..462682ba584 100644
--- a/roofit/roostats/src/NumberCountingPdfFactory.cxx
+++ b/roofit/roostats/src/NumberCountingPdfFactory.cxx
@@ -133,8 +133,10 @@ void NumberCountingPdfFactory::AddModel(Double_t* sig,
 
       RooPoisson* sigRegion = 
          new RooPoisson(("sigRegion"+str.str()).c_str(),("sigRegion"+str.str()).c_str(), *x,*splusb);
+
+      //LM:  need to set noRounding since y can take non integer values
       RooPoisson* sideband = 
-         new RooPoisson(("sideband"+str.str()).c_str(),("sideband"+str.str()).c_str(), *y,*bTau);
+         new RooPoisson(("sideband"+str.str()).c_str(),("sideband"+str.str()).c_str(), *y,*bTau,true);
 
       likelihoodFactors.Add(sigRegion);
       likelihoodFactors.Add(sideband);
@@ -245,7 +247,11 @@ void NumberCountingPdfFactory::AddData(Double_t* mainMeas,
       std::stringstream str;
       str<<"_"<<i;
 
-      Double_t _tau = 1./back[i]/back_syst[i]/back_syst[i];
+      //Double_t _tau = 1./back[i]/back_syst[i]/back_syst[i];
+      // LM: compute tau correctly for the Gamma distribution : mode = tau*b  and variance is (tau*b+1)
+      Double_t err = back_syst[i]; 
+      Double_t _tau = (1.0 + sqrt(1 + 4 * err * err))/ (2. * err * err)/ back[i];
+
       RooRealVar*  tau = SafeObservableCreation(ws,  ("tau"+str.str()).c_str(), _tau );
 
       oocoutW(ws,ObjectHandling) << "NumberCountingPdfFactory: changed value of " << tau->GetName() << " to " << tau->getVal() << 
-- 
GitLab