Consider this example:
#! /usr/bin/env python
import ROOT
dictio = {}
N = 3
for ind in range(0, N):
key = ROOT.TString("key_{}".format(ind))
H = ROOT.TH1F(key.Data(), "h", 4, 0.0, 3.0)
r = ROOT.TRandom(0)
H.FillRandom("gaus", r.Integer(600))
dictio[key] = H
print "key %s id %s integral %f" % (key, hex(id(dictio[key])), H.Integral())
print "*****"
for key in dictio:
print "key %s id %s integral %f" % (key, hex(id(dictio[key])), H.Integral())
The output is:
key key_0 id 0x7f2da76fa530 integral 228.000000
key key_1 id 0x7f2da76fa830 integral 116.000000
key key_2 id 0x7f2da76fa8f0 integral 7.000000
*****
key key_2 id 0x7f2da76fa8f0 integral 7.000000
key key_0 id 0x7f2da76fa530 integral 7.000000
key key_1 id 0x7f2da76fa830 integral 7.000000
Why is the integral of all histograms in the dictionary equal to the integral of the last histogram inserted?
Please read tips for efficient and successful posting and posting code
ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided