ksamdev/bsm_analyze — Issue #41: Problem when using TFractionFitter python 2.6
Author: baites
Created: 2012-03-08 21:57:39+00:00
State: open

There is a problem when reading the results from TFractionFitter when using python 2.6. The error is as follow

---
File "./main.py", line 20, in main
app.run(argv[1:])
File "/uscms_data/d2/baites/BSM/bsm_analyze/python/template/templates.py", line 89, in run
self.__process()
File "/uscms_data/d2/baites/BSM/bsm_analyze/python/template/templates.py", line 96, in __process
self.__fraction_fitter()
File "/uscms/home/baites/nobackup/BSM/bsm_analyze/python/util/timer.py", line 77, in wrapper
return self(instance, *parg, **karg)
File "/uscms/home/baites/nobackup/BSM/bsm_analyze/python/util/timer.py", line 104, in __call__
result = self.__wrapped(*parg, **karg)
File "/uscms_data/d2/baites/BSM/bsm_analyze/python/template/templates.py", line 127, in __fraction_fitter
self.__run_fraction_fitter()
File "/uscms_data/d2/baites/BSM/bsm_analyze/python/template/templates.py", line 183, in __run_fraction_fitter
fitter.GetResult(0, fraction, fraction_error)
void TFractionFitter::GetResult(Int_t parm, Double_t& value, Double_t& error) =>
could not convert argument 2
---

I tested the following changes in the code and it seems fixing the problem, where the commented lines are the original ones.

python/template/templates.py
---
# fraction = numpy.zeros(1, dtype = float)
# fraction_error = numpy.zeros(1, dtype = float)

fraction = ROOT.Double(0.0)
fraction_error = ROOT.Double(0.0)

fitter.GetResult(0, fraction, fraction_error)
# self.fractions["mc"] = [fraction[0], fraction_error[0]]
self.fractions["mc"] = [float(fraction), float(fraction_error)]

fitter.GetResult(1, fraction, fraction_error)
# self.fractions["qcd"] = [fraction[0], fraction_error[0]]
self.fractions["qcd"] = [float(fraction), float(fraction_error)]

---

Cheers,
Victor