__doc__ = "JobOption fragment to add CaloRinger algorithm to run." from AthenaCommon.Logging import logging from CaloRingerAlgs.CaloRingerFlags import caloRingerFlags from CaloRingerAlgs.CaloRingerAlgorithmBuilder import CaloRingerAlgorithmBuilder mlog = logging.getLogger('CaloRinger_joboptions.py') mlog.info('Entering') ringerOutputLevel = caloRingerFlags.OutputLevel() # Check if we have our other algorithm dependencies enabled, otherwise disable # ringer: if caloRingerFlags.buildCaloRingsOn(): # Check egamma related objects: if not rec.doEgamma(): if caloRingerFlags.buildElectronCaloRings(): caloRingerFlags.buildElectronCaloRings.set_Value(False) caloRingerFlags.doElectronIdentification.set_Value(False) if not caloRingerFlags.buildElectronCaloRings(): mlog.info( 'No egamma builder available... disabling ElectronCaloRings reconstruction and electron selection.' ) if caloRingerFlags.buildPhotonCaloRings(): caloRingerFlags.buildPhotonCaloRings.set_Value(False) #caloRingerFlags.doPhotonIdentification.set_Value( False ) if not caloRingerFlags.buildPhotonCaloRings(): mlog.info( 'No egamma builder available... disabling PhotonCaloRings reconstruction and electron selection.' )
addOutputToList(caloRingerAODList, cType, cKey, auxOption) mlog.debug( "Added container with type/key %s/%s to StoreGateSvc", cType, cKey) break if rec.readESD() or rec.readAOD(): # In this case, we assume that the # joboption was added to add input file ringer containers # to the output file. # add the event store information: addRingerInputEventToList(caloRingerAODList, outputCaloRingsType()) addRingerInputEventToList(caloRingerAODList, outputCaloRingsAuxType()) addRingerInputEventToList(caloRingerAODList, outputRingSetType()) addRingerInputEventToList(caloRingerAODList, outputRingSetAuxType()) if CRMetaBuilder.usable() and caloRingerFlags.buildCaloRingsOn(): for cType, cKeys in CRMetaBuilder.output().items(): for cKey in cKeys: for dictKey, value in CaloRingerKeysDict.outputsMetaData.items( ): if value[0] == cType: auxOption = CaloRingerKeysDict.outputsMetaData[ dictKey][2] addOutputToList(caloRingerMetaDataList, cType, cKey, auxOption) mlog.debug( "Added container with type/key %s/%s to MetaDataStore", cType, cKey) break else: raise ValueError(
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
from RecExConfig.RecFlags import rec from AthenaCommon.AlgSequence import AlgSequence topSequence = AlgSequence() from CaloRingerAlgs.CaloRingerFlags import caloRingerFlags from CaloRingerAlgs.CaloRingerKeys import CaloRingerKeysDict # Get CaloRinger algorithm handles from CaloRingerAlgs.CaloRingerAlgorithmBuilder import CaloRingerAlgorithmBuilder CRAlgBuilder = CaloRingerAlgorithmBuilder() from CaloRingerAlgs.CaloRingerMetaDataBuilder import CaloRingerMetaDataBuilder CRMetaDataBuilder = CaloRingerMetaDataBuilder(disable=True) if rec.doESD() and caloRingerFlags.buildCaloRingsOn() and CRAlgBuilder.usable( ): LastCRWriter = CRMetaDataBuilder.getLastWriterHandle() CRMainAlg = CRAlgBuilder.getCaloRingerAlgHandle() CRMetaDataWriterAlg = CRMetaDataBuilder.getMetaDataWriterHandle() try: # FIXME: It seems that the python implementation takes a lot of memory # (https://its.cern.ch/jira/browse/ATLASRECTS-2769?filter=-1), # replace it as egamma is doing to use a C++ implementation pass # Make sure we add it before streams: for pos, alg in enumerate(topSequence): if LastCRWriter.getName() == alg.getName(): from CaloRingerAlgs.CaloRingerLocker import CaloRingerLocker CRLocker = CaloRingerLocker(name = "CaloRingerLocker", \ doElectron = caloRingerFlags.buildElectronCaloRings(), \