Matrix element is got from recHits_energy branch scaled with largest recHits energy:
scale = max(event.recHits_energy)
matrix[dEta,dPhi,channel] = event.recHits_energy[iHit]/scale
Since the hits image is coarser than recHits,
matrix[dEta,dPhi,channel] += event.recHits_energy[iHit]
And the scale should be done after whole matrix have been filled and separated by channel . Maybe Luca could comment on details on scaling.