mana-core-athenarootcomps / python /

Full commit
# @file AthenaRootComps/python/
# @purpose make the Athena framework read a set of ROOT files to emulate the
#          usual TTree event loop
# @author Sebastien Binet <>
# Original code from Tadashi Maeno (AANTEventSelector)

def _configure():
    """Install the Athena-based TTree event selector and correctly configure
    a few other services.
    from AthenaCommon import CfgMgr
    from AthenaCommon.AppMgr import theApp
    from AthenaCommon.AppMgr import ServiceMgr as svcMgr
    from AthenaCommon.Logging import logging
    msg = logging.getLogger( 'ReadAthenaRoot' )
    msg.debug("Configuring Athena for reading ROOT files (via TChain)...")

    if not hasattr(svcMgr, 'THistSvc'):
        svcMgr += CfgMgr.THistSvc()

    if hasattr(svcMgr, 'EventSelector'):
        err = "svcMgr already configured with another EventSelector: [%s]"%\
        msg.error( err )
        raise RuntimeError( err )

    # Load ProxyProviderSvc
    if not hasattr (svcMgr, 'ProxyProviderSvc'):
        svcMgr += CfgMgr.ProxyProviderSvc()

    # from Configurables import Athena__RootNtupleEventSelector
    evtsel = CfgMgr.Athena__RootNtupleEventSelector( "EventSelector" )
    svcMgr += evtsel
    theApp.ExtSvc += [ evtsel.getFullName() ]
    theApp.EvtSel = "EventSelector"
    svcMgr.ProxyProviderSvc.ProviderNames += [evtsel.getFullName()]
    del evtsel
    # configure the cnvsvc
    svcMgr += CfgMgr.Athena__NtupleCnvSvc()
    if not hasattr(svcMgr, 'EventPersistencySvc'):
        svcMgr += CfgMgr.EvtPersistencySvc( "EventPersistencySvc" )
    svcMgr.EventPersistencySvc.CnvServices += [ "Athena::NtupleCnvSvc" ]
    msg.debug("Configuring Athena for reading ROOT files (via TChain)... [OK]")

# execute at module import

# clean-up namespace
del _configure