Пример #1
0
    def configure(self):
        mlog = logging.getLogger('topoEgammaGetter.py::configure:')
        mlog.info('entering')

        # the egammaRecBuilder
        from egammaAlgs.egammaRecBuilder import egammaRecBuilder
        try:
            self._egammaRecBuilder = egammaRecBuilder(
                doTrackMatching=DetFlags.detdescr.ID_on(),
                doConversions=doConversions())
        except Exception:
            mlog.error("could not get handle to egammaRecBuilder")
            import traceback
            traceback.print_exc()
            return False

        # the supercluster builders
        from egammaAlgs.egammaSuperClusterBuilder import \
            electronSuperClusterBuilder, photonSuperClusterBuilder
        try:
            self._electronSuperClusterBuilder = electronSuperClusterBuilder(
                doTrackMatching=DetFlags.detdescr.ID_on())
            self._photonSuperClusterBuilder = photonSuperClusterBuilder(
                doConversions=doConversions())
        except Exception:
            mlog.error("could not get handle to supcluster builders")
            import traceback
            traceback.print_exc()
            return False

        # the topoEgammaBuilder (the part that puts everything together
        from egammaAlgs.topoEgammaBuilder import topoEgammaBuilder
        try:
            self._topoEgammaBuilder = topoEgammaBuilder(
                EMClusterTool=EMClusterTool,
                EMShowerTool=EMShowerBuilder,
                ObjectQualityTool=egammaOQFlagsBuilder,
                # Decoration tools
                egammaTools=FcnWrapper(egammaDecorationTools),
                ElectronTools=FcnWrapper(electronDecorationTools),
                PhotonTools=FcnWrapper(photonDecorationTools))
        except Exception:
            mlog.error("could not get handle to topoEgammaBuilder")
            import traceback
            traceback.print_exc()
            return False

        # the egammaLargeClusterMaker
        # (Which chooses the cells to store in the AOD)
        from egammaAlgs.egammaLargeClusterMakerAlg import (
            egammaLargeClusterMakerAlg)
        try:
            self._egammaLargeClusterMaker = egammaLargeClusterMakerAlg()
        except Exception:
            mlog.error("could not get handle to egammaLargeClusterMaker")
            import traceback
            traceback.print_exc()
            return False

        return True
Пример #2
0
def TrigTopoEgammaElectronCfg(name='topoEgammaBuilder_TrigElectrons'):
    from AthenaMonitoringKernel.GenericMonitoringTool import GenericMonitoringTool, defineHistogram
    monTool = GenericMonitoringTool("MonTool_topoEgammaBuilder")
    monTool.Histograms = [ defineHistogram('EldeltaEta',type='TH1F', title='#Delta#eta',    path='EXPERT',xbins=80, xmin=-0.01,xmax=0.01),
                           defineHistogram('EldeltaPhi',type='TH1F', title='#Delta#phi',    path='EXPERT',xbins=80, xmin=-0.01, xmax=0.01),
                           defineHistogram('EleT',      type='TH1F', title='p#_{T} [GeV]',  path='EXPERT',xbins=80, xmin=0., xmax=100)]
    
    mlog = logging.getLogger("TrigElectronFactories")
    mlog.info('Starting configuration')
    TrigTopoEgammaElectron = AlgFactory( egammaAlgsConf.topoEgammaBuilder, name = name,
            SuperElectronRecCollectionName = TrigEgammaKeys.SuperElectronRecCollectionName,
            SuperPhotonRecCollectionName = TrigEgammaKeys.SuperPhotonRecCollectionName,
            ElectronOutputName = TrigEgammaKeys.outputElectronKey,
            PhotonOutputName = TrigEgammaKeys.outputPhotonKey,  
            AmbiguityTool = EGammaAmbiguityTool,
            EMClusterTool = TrigEMClusterTool,
            EMShowerTool=TrigEMShowerBuilder,
            egammaTools = FcnWrapper(TrigEgammaDecorationTools),
            doAdd = False,
            doPhotons = False,
            doElectrons = True,
            #MonTool = monTool
            )
    return TrigTopoEgammaElectron()
Пример #3
0
    def configure(self):
        "This method will be called when object is initialized"

        mlog = logging.getLogger( 'CaloRingerAlgorithmBuilder::configure:%s:' \
            % self.__class__.__name__.replace( ".", '_' )  )
        mlog.info('entering')
        try:

            # Instantiate the main algorithm:
            MainCaloRingerAlgorithm = AlgFactory(
                CaloRingerAlgsConf.Ringer__CaloRingerAlgorithm,
                name="MainCaloRingerAlgorithm",
                inputReaderTools=FcnWrapper(getCaloRingerInputReaderTools))

            self._caloRingerAlg = MainCaloRingerAlgorithm()

            if caloRingerFlags.buildCaloRingsOn():
                # Egamma locker not being used anymore.
                #postponeEgammaLock(self._caloRingerAlg)
                pass

            # Check if CaloRingerAlgorithm has readers:
            if not self._caloRingerAlg.inputReaderTools:
                raise RuntimeError(("Cannot instantiate CaloRingerAlgorithm "
                                    "without readers."))

            if caloRingerFlags.buildCaloRingsOn():
                self._eventOutputs = { outputCaloRingsType() : \
            getCaloRingerOutputs(self._caloRingerAlg.inputReaderTools,addRingSetsContainers=False), \
                                       outputRingSetType() : \
            getCaloRingerOutputs(self._caloRingerAlg.inputReaderTools,addCaloRingsContainers=False) \
                                     }
                self._output.update(self._eventOutputs)

            # Check for existing output:
            self.checkExistingOutput()

            if not self.ignoreExistingDataObject()                                                     \
               and ( (  caloRingerFlags.buildElectronCaloRings()                                   and \
                  ( inputAvailable(outputCaloRingsType(), outputElectronCaloRingsKey())            or  \
                         inputAvailable(outputCaloRingsType(), outputElectronCaloAsymRingsKey()) ) or  \
                  ( inputAvailable(outputRingSetType(),   outputElectronRingSetsKey())             or  \
                         inputAvailable(outputRingSetType(), outputElectronAsymRingSetsKey()) ) )      \
               or  ( caloRingerFlags.buildPhotonCaloRings()                                        and \
                  ( inputAvailable(outputCaloRingsType(), outputPhotonCaloRingsKey())              or  \
                         inputAvailable(outputCaloRingsType(), outputPhotonCaloAsymRingsKey()) )   or  \
                  ( inputAvailable(outputRingSetType(),   outputPhotonRingSetsKey())               or  \
                         inputAvailable(outputRingSetType(), outputPhotonAsymRingSetsKey()) ) ) ):
                raise RuntimeError((
                    "Already existing input will be overwriten and not set Ringer flag "
                    "ignoreExistingDataObject."))

        except Exception:
            removeFromTopSequence(self._caloRingerAlg)
            caloRingerFlags.Enabled = False
            self._disabled = True
            treatException(("Could not get handle to CaloRingerAlgorithm."
                            " Reason:\n%s") % traceback.format_exc())
            return False

        return True
Пример #4
0
    def configure(self):
        mlog = logging.getLogger ('egammaGetter.py::configure:')
        mlog.info('entering')        

        if doSuperclusters() : 
          egammaBuilder = AlgFactory(egammaRecConf.topoEgammaBuilder, name = 'egamma',
                                     # Keys
                                     ElectronOutputName = egammaKeys.outputElectronKey(),
                                     PhotonOutputName = egammaKeys.outputPhotonKey(),                                     
                                     #Super Cluster Tools
                                     TopoClusterCopier = egammaTopoClusterCopier,
                                     electronSuperClusterBuilder = electronSuperClusterBuilder,
                                     photonSuperClusterBuilder = photonSuperClusterBuilder,
                                     InputTopoClusterContainerName = egammaRecFlags.egammaTopoClusterCollection(),                                           
                                     # Builder tools
                                     BremCollectionBuilderTool = EMBremCollectionBuilder,
                                     TrackMatchBuilderTool = EMTrackMatchBuilder,
                                     VertexBuilder = EMVertexBuilder if doConversions() else None,
                                     ConversionBuilderTool = EMConversionBuilder if doConversions() else None,
                                     AmbiguityTool = EGammaAmbiguityTool,                                     
                                     # Decoration tools
                                     egammaTools = FcnWrapper(egammaDecorationTools),
                                     ElectronTools = FcnWrapper(electronDecorationTools),
                                     PhotonTools = FcnWrapper(photonDecorationTools),                                     
                                     # Flags and other properties
                                     # Track matching depending if ID is on/off
                                     doTrackMatching = DetFlags.detdescr.ID_on(),
                                     # conversions building/matching depending if ID is on/off
                                     doVertexCollection=doConversions(),
                                     doConversions = doConversions()
                                     )
        else : 
          egammaBuilder = AlgFactory(egammaRecConf.egammaBuilder, name = 'egamma',
                                     # Keys
                                     ElectronOutputName = egammaKeys.outputElectronKey(),
                                     PhotonOutputName = egammaKeys.outputPhotonKey(),
                                     TopoSeededClusterContainerName = getTopoSeededCollectionName(),                                     
                                     # Builder tools
                                     BremCollectionBuilderTool = EMBremCollectionBuilder,
                                     TrackMatchBuilderTool = EMTrackMatchBuilder,
                                     VertexBuilder = EMVertexBuilder if doConversions() else None,
                                     ConversionBuilderTool = EMConversionBuilder if doConversions() else None,
                                     AmbiguityTool = EGammaAmbiguityTool,                                     
                                     # Decoration tools
                                     egammaTools = FcnWrapper(egammaDecorationTools),
                                     ElectronTools = FcnWrapper(electronDecorationTools),
                                     PhotonTools = FcnWrapper(photonDecorationTools),                                     
                                     # Flags and other properties
                                     # Track matching depending if ID is on/off
                                     doTrackMatching = DetFlags.detdescr.ID_on(),
                                     # conversions building/matching depending if ID is on/off
                                     doVertexCollection=doConversions(),
                                     doConversions = doConversions(),
                                     #
                                     clusterEnergyCut = 10*MeV,
                                     doTopoSeededPhotons = egammaRecFlags.doTopoCaloSeeded()
                                     )          

        # configure egamma here:
        try:
            self._egammaBuilderHandle = egammaBuilder()
        except Exception:
            mlog.error("could not get handle to egamma")
            import traceback
            print traceback.format_exc()
            return False
        
        print self._egammaBuilderHandle
        return True
Пример #5
0
def getCaloRingerPhotonSelectorsBuilder():
    "Return the Photon Selectors"
    #if caloRingerFlags.doPhotonIdentification:
    #  from CaloRingerTools.CaloRingerSelectorsBuilders import CaloRingerPhotonSelectorsBuilder
    #  return CaloRingerPhotonSelectorBuilder().getAllSelectorHandles()
    #else:
    return PublicToolHandleArray([])


from CaloRingerAlgs.CaloRingerAlgorithmBuilder import checkBuildElectronCaloRings
from CaloRingerAlgs.CaloRingerAlgorithmBuilder import checkDoElectronIdentification
CaloRingerElectronsReaderTool = ToolFactory(
    CaloRingerToolsConf.Ringer__CaloRingerElectronsReader,
    name="CaloRingerElectronsReaderTool",
    inputKey=CaloRingerKeys.inputElectronKey(),
    crBuilder=FcnWrapper(getElectronCaloRingsBuilder),
    builderAvailable=FcnWrapper(checkBuildElectronCaloRings),
    ElectronSelectors=FcnWrapper(getCaloRingerElectronSelectorsBuilder),
    selectorsAvailable=FcnWrapper(checkDoElectronIdentification),
)

from CaloRingerAlgs.CaloRingerAlgorithmBuilder import checkBuildPhotonCaloRings
from CaloRingerAlgs.CaloRingerAlgorithmBuilder import checkDoPhotonIdentification
CaloRingerPhotonsReaderTool = ToolFactory(
    CaloRingerToolsConf.Ringer__CaloRingerPhotonsReader,
    name="CaloRingerPhotonsReaderTool",
    inputKey=CaloRingerKeys.inputPhotonKey(),
    crBuilder=FcnWrapper(getPhotonCaloRingsBuilder),
    builderAvailable=FcnWrapper(checkBuildPhotonCaloRings),
    PhotonSelectors=FcnWrapper(getCaloRingerPhotonSelectorsBuilder),
    #selectorsAvailable = FcnWrapper(checkDoPhotonIdentification)
Пример #6
0
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration

__doc__ = """ToolFactory to instantiate egammaLargeClusterMaker
with default configuration"""
__author__ = "Jovan Mitrevski"

from egammaTools.egammaToolsFactories import egammaLargeClusterMakerTool
from CaloRec import CaloRecConf
from egammaRec.Factories import AlgFactory, FcnWrapper
from egammaRec import egammaKeys
from CaloClusterCorrection.CaloSwCorrections import make_CaloSwCorrections


def clusMakerTools():
    return [egammaLargeClusterMakerTool()]


egammaLargeClusterMakerAlg = AlgFactory(
    CaloRecConf.CaloClusterMaker,
    name="egammaLargeClusterMaker",
    SaveUncalibratedSignalState=False,
    ClustersOutputName=egammaKeys.EgammaLargeClustersKey(),
    ClusterMakerTools=FcnWrapper(clusMakerTools),
    ClusterCorrectionTools=make_CaloSwCorrections("ele7_11",
                                                  suffix="Nocorr",
                                                  version="none",
                                                  cells_name=egammaKeys.caloCellKey()))
Пример #7
0

egammaForwardBuilder = AlgFactory(
    egammaAlgsConf.egammaForwardBuilder,
    name='egammaForward',
    # Keys
    ElectronOutputName=egammaKeys.outputFwdElectronKey(),
    TopoClusterName="CaloCalTopoClusters",
    ClusterContainerName=egammaKeys.outputFwdClusterKey(),
    # Tools
    ObjectQualityTool=egammaOQFlagsBuilder,
    FourMomBuilderTool=EMFourMomBuilder,
    # Flags and other properties
    EtCut=5 * GeV,
    EtaCut=2.5,
    forwardelectronIsEMselectors=FcnWrapper(forwardSelectorTools),
    forwardelectronIsEMselectorResultNames=["Loose", "Medium", "Tight"])


class egammaForwardGetter(Configured):
    def configure(self):
        mlog = logging.getLogger('egammaForwardGetter.py::configure:')
        mlog.info('entering')

        # configure egammaForward here:
        try:
            self._egammaFwdBuilderHandle = egammaForwardBuilder()
        except Exception:
            mlog.error("could not get handle to egammaForward")
            traceback.print_exc()
            return False
Пример #8
0
def getSimBarcodeOffset1():
    "Return the simulation barcode offset for G4 particles from metadata + 1"
    return getSimBarcodeOffset() + 1


EMClassifierParticleCaloExtensionTool = ToolFactory(
    CfgMgr.Trk__ParticleCaloExtensionTool,
    name="EMClassifierParticleCaloExtensionTool",
    Extrapolator=egammaCaloExtrapolator)

EMMCTruthClassifier = ToolFactory(
    MCTruthClassifierConf.MCTruthClassifier,
    name='EMMCTruthClassifier',
    ParticleCaloExtensionTool=EMClassifierParticleCaloExtensionTool,
    barcodeG4Shift=FcnWrapper(getSimBarcodeOffset1))

egammaTruthAssociationAlg = AlgFactory(
    egammaAlgsConf.egammaTruthAssociationAlg,
    ClusterContainerName=egammaKeys.outputClusterKey(),
    ElectronContainerName=egammaKeys.outputElectronKey(),
    PhotonContainerName=egammaKeys.outputPhotonKey(),
    FwdElectronContainerName=egammaKeys.outputFwdElectronKey(),
    TruthEventContainerName=egammaKeys.truthEventKey(),
    TruthParticleContainerName=egammaKeys.truthParticleKey(),
    EgammaTruthContainerName=egammaKeys.outputTruthKey(),
    MCTruthClassifier=EMMCTruthClassifier,
    MatchForwardElectrons=egammaRecFlags.doEgammaForwardSeeded(),
    MatchClusters=False,
    SimBarcodeOffset=FcnWrapper(getSimBarcodeOffset))
Пример #9
0
#Factory for photon SC builder
TrigPhotonSuperClusterBuilder = AlgFactory( egammaAlgsConf.photonSuperClusterBuilder,
        name = 'TrigPhotonSuperClusterBuilder',
        InputEgammaRecContainerName=TrigEgammaKeys.EgammaRecKey,
        SuperPhotonRecCollectionName=TrigEgammaKeys.SuperPhotonRecCollectionName,
        ClusterCorrectionTool=egammaSwSuperClusterTool,
        MVACalibSvc= egammaMVASvc,
        doConversions = False,
        AddClustrsMatchingVtxTracks = False,
        ConversionBuilderTool = None,
        doAdd = False
        )

#Factory for photons
TrigTopoEgammaPhotons = AlgFactory( egammaAlgsConf.topoEgammaBuilder, 
        name = 'TrigTopoEgammaPhotons',
        SuperElectronRecCollectionName = TrigEgammaKeys.SuperElectronRecCollectionName,
        SuperPhotonRecCollectionName = TrigEgammaKeys.SuperPhotonRecCollectionName,
        ElectronOutputName = TrigEgammaKeys.outputElectronKey,
        PhotonOutputName = TrigEgammaKeys.outputPhotonKey,  
        AmbiguityTool = EGammaAmbiguityTool,
        EMClusterTool = TrigEMClusterTool,
        EMShowerTool=TrigEMShowerBuilder,
        egammaTools = FcnWrapper(TrigEgammaDecorationTools),
        PhotonTools = FcnWrapper(TrigPhotonDecorationTools),
        doAdd = False,
        doPhotons = True,
        doElectrons = False,
        )

Пример #10
0
        # 2017 (v11)
        LooseLHSelector.ConfigFile = "ElectronPhotonSelectorTools/offline/mc15_20160512/ElectronLikelihoodLooseOfflineConfig2016_CutBL_Smooth.conf"
        MediumLHSelector.ConfigFile = "ElectronPhotonSelectorTools/offline/mc15_20160512/ElectronLikelihoodMediumOfflineConfig2016_Smooth.conf"
        TightLHSelector.ConfigFile = "ElectronPhotonSelectorTools/offline/mc15_20160512/ElectronLikelihoodTightOfflineConfig2016_Smooth.conf"
        VeryLooseLHSelector.ConfigFile = "ElectronPhotonSelectorTools/offline/mc15_20160512/ElectronLikelihoodVeryLooseOfflineConfig2016_Smooth.conf"
    else:
        print('Wrong run flag configuration')


# The main algorithm
# Add triggerlist tools to ToolHandleArray
TrigEgammaAnalysisAlg = AlgFactory(
    TrigEgammaAnalysisToolsConf.TrigEgammaAnalysisAlg,
    name='TrigEgammaAnalysisAlg',
    Tools=FcnWrapper(getAllTools),
)


# This function will be used to collect events from Zee,JF17 and PhysicsMain samples.
# Use this if you really know. (for experts)
def getEventSelectionTool(runFlag):

    from TrigEgammaEmulationTool.TrigEgammaEmulationPidToolsConfig import getEgammaIsEMSelectorCaloOnly, \
                                                                          getElectronIsEMSelector,\
                                                                          getEgammaLikelihoodSelectorCaloOnly, \
                                                                          getElectronLikelihoodSelector2015,\
                                                                          getElectronLikelihoodSelectorNoD0
    from AthenaCommon import CfgMgr
    from AthenaCommon.AppMgr import ToolSvc
    # create all selector list. Here, the order is matter. Please check the