backport new code which did not get merged into branch

backport new code which did not get merged into branch
Please merge into ROOT-6 branch.