Overcorrection in first and last bins
Hello.
I have been encountering strange overcorrections in the first and last bins when I try to unfold my data using RooUnfold
.To illustrate this problem, I've managed to reproduce the behavior in your provided Python example. Also, in order to rule out any version-specific quirks, I tested multiple versions of RooUnfold, and it appears that this problem persists across the different versions.
Here is my reproducer script:roounfold_example_test.py. You can run it, for example, on lxplus
after doing a source like this: source /cvmfs/sft.cern.ch/lcg/views/LCG_103/x86_64-centos7-gcc12-opt/setup.sh; python3 roounfold_example_test.py
I want to highlight that I made just three specific changes to your example. Firstly, I increased the width of the training and testing distributions I sampled from. Secondly, I increased the number of sampled events. Thirdly, I adjusted the smear function to ensure it achieves high efficiency while minimizing smearing, effectively creating a response matrix that closely resembles a diagonal.
Here is the diff
comparing your example to my reproducer:
--- RooUnfoldExample.py 2023-10-03 14:58:07.878721571 +0100
+++ roounfold_example_test.py 2023-10-03 14:56:02.657470768 +0100
@@ -28,10 +28,10 @@
# ==============================================================================
def smear(xt):
- xeff= 0.3 + (1.0-0.3)/20*(xt+10.0); # efficiency
+ xeff= 0.95; # efficiency
x= gRandom.Rndm();
if x>xeff: return None;
- xsmear= gRandom.Gaus(-2.5,0.2); # bias and smear
+ xsmear= gRandom.Gaus(0.0,0.5); # bias and smear
return xt+xsmear;
# ==============================================================================
@@ -41,8 +41,8 @@
response= ROOT.RooUnfoldResponse (40, -10.0, 10.0);
# Train with a Breit-Wigner, mean 0.3 and width 2.5.
-for i in range(100000):
- xt= gRandom.BreitWigner (0.3, 2.5);
+for i in range(1000000):
+ xt= gRandom.BreitWigner (0.3, 19.0);
x= smear (xt);
if x!=None:
response.Fill (x, xt);
@@ -52,8 +52,8 @@
hTrue= TH1D ("true", "Test Truth", 40, -10.0, 10.0);
hMeas= TH1D ("meas", "Test Measured", 40, -10.0, 10.0);
# Test with a Gaussian, mean 0 and width 2.
-for i in range(10000):
- xt= gRandom.Gaus (0.0, 2.0)
+for i in range(100000):
+ xt= gRandom.Gaus (0.0, 20.0)
x= smear (xt);
hTrue.Fill(xt);
if x!=None: hMeas.Fill(x);
I end up getting this result where you can clearly see the overcorrection in the first and last bin:
I get a similar behaviour when using RooUnfoldSvd
for example, and the problem, as expected, disappears when using RooUnfoldBinByBin
.
Can you please comment on whether this could be a bug or just a fundamental misunderstanding on my end? Many thanks.