def configure(self): from AthenaCommon.Logging import logging mlog = logging.getLogger('TileGapSelectionGetter::configure:') mlog.info('entering') import traceback try: from RecExConfig.ObjKeyStore import objKeyStore cellsname = resolveSGKey('CaloCellContainer', self._cellsSGKey) alg = egammaD3PDAnalysis.TileGapSelectionAlg \ ('TileGapSelection', Getter = SGObjGetterTool ('TileGapSelectionGetter', SGKey = cellsname, TypeName = 'CaloCellContainer'), OutputCellContainerName = self.outputKey()) self.seq += alg # register output in objKeyStore objKeyStore.addTransient(self.outputType(), self.outputKey()) self._handle = alg except: mlog.error("Error configuring TileGapSelectionAlg.") traceback.print_exc() return True
def _electronRawClusterAssocHook(c, prefix, sgkey, typeName, *args, **kw): assoc = getattr(c, c.name() + '_D3PD__egammaRawClusterAssociationTool', None) if assoc: assoc.Associator.AssocGetter.SGKey = \ (resolveSGKey(typeName, sgkey) + D3PDMakerFlags.RawClustersAssocSGKeySuffix()) return
def _fixJetTiming(c, **kw): # Check version number of the input data. # If no version is found, assume old. rlist = release_version() if rlist: if rlist[0] >= 16: return if rlist[0] == 15 and rlist[1] >= 7: return if rlist[0] == 15 and rlist[1] == 6 and rlist[2] >= 8: return sgkey_in = c.Getter.SGKey sgkey_in = resolveSGKey('JetCollection', sgkey_in) sgkey_out = sgkey_in + '_timing' seq = AlgSequence(D3PDMakerFlags.PreD3PDAlgSeqName()) if not hasattr(seq, sgkey_out): tools = [] caloqual_kw = { 'doCellBasedVariables': True, 'doConstituentBasedVariables': True, 'doSamplingBasedVariables': True, 'cutOnTile': 254, 'cutOnLAr': 4000, 'doTileQuality': True, 'doLArQuality': True } if hasattr(JetRecToolsConf, 'JetTimeQualityTool'): # rel 15 setup tool1 = JetRecToolsConf.JetTimeQualityTool(sgkey_out + 'TimeTool', DoTime=False, DoQuality=False, UseCells=False) if rec.readESD() or rec.readRDO(): tool1.DoTime = True tool1.DoQuality = True tool1.UseCells = True if rec.readAOD() and (sgkey_in.find('H1Topo') >= 0 or sgkey_in.find('LCTopo') >= 0): tool1.DoTime = True tools.append(tool1) else: # rel 16 caloqual_kw['doTiming'] = True tool2 = JetCaloQualityTool(sgkey_out + 'QualTool', **caloqual_kw) tools.append(tool2) alg = JetD3PDMaker.JetFixupAlg(sgkey_out, InputKey=sgkey_in, OutputKey=sgkey_out, Tools=tools) for t in tools: alg += t seq += alg c.Getter.SGKey = sgkey_out return
def JetMomentCalcConfig (sgkey, moments, seq): """Configure algorithms to recalculate jet moments. SGKEY is the StoreGate key for the jet collection to process. It is expended with resolveSGKey. MOMENTS is the list of moments to calculate. It can be either: None: To do the `recommended' set of moments. 'all': To do all moments. A list: Calculate the moments given in the list. SEQ is the sequence to which the algorithm should be added. """ # Skip this in releases for which it's not supported. try: from JetMomentTools import JetMomentsConfigHelpers except ImportError: return recommendedAreaAndJVFMoments = JetMomentsConfigHelpers.recommendedAreaAndJVFMoments addStandardMoments = getattr (JetMomentsConfigHelpers, 'addStandardMoments', None) if not addStandardMoments: addStandardMoments = JetMomentsConfigHelpers.specialMoment # Always turn this on if we're making jets --- it changes jvf results. from JetRec.JetRecFlags import jetFlags jetFlags.jetPerformanceJob = True key = resolveSGKey ('JetCollection', sgkey) # Don't do this if it isn't a known jet type. goodtypes = ['LCTopo','Topo', 'Truth'] if not sum([key.find(k) > 0 for k in goodtypes]): return False # Further protection. from JetMomentTools.GhostAssociation import interpretJetName if interpretJetName(key) == None: return # Crash otherwise if type(moments) == type([]) and 'origin' in moments: if not hasattr (JetMomentsConfigHelpers,'setupSpecialMomentTools'): # This isn't in devval... log = logging.getLogger ('JetMomentCalcConfig') log.warn ('OriginCorrection moments not available; skipping.') moments = moments[:] moments.remove ('origin') if moments == None: alg = recommendedAreaAndJVFMoments(key, seq=seq) elif moments == 'all': alg = addStandardMoments(key, seq=seq) else: addStandardMoments(key, moments=moments, seq=seq) return
def makeCorrectionTools(self): corrargs = self._corrargs.copy() if not self._corrargs.has_key('cells_name'): cells = resolveSGKey('CaloCellContainer', 'AODCellContainer,AllCalo') corrargs['cells_name'] = cells return make_CaloSwCorrections(self._clusterKey, suffix=self._suffix, version=self._corrversion, **corrargs)
def _get_purity(args, hookargs): from AthenaCommon.AppMgr import ToolSvc from InDetRecExample.InDetKeys import InDetKeys from InDetRecExample.InDetJobProperties import InDetFlags # this tool is only needed for D3PD writing and hence it is configured here from TrkVertexFitterValidationUtils.TrkVertexFitterValidationUtilsConf import Trk__TrkPriVxPurityTool mckey = resolveSGKey('McEventCollection', D3PDMakerFlags.TruthSGKey()) TrkPriVxPurityTool = Trk__TrkPriVxPurityTool(MonteCarloCollection=mckey) ToolSvc += TrkPriVxPurityTool if InDetFlags.doPrintConfigurables(): print TrkPriVxPurityTool return
def egammaTimeCorrConfig \ (seq = AlgSequence(D3PDMakerFlags.PreD3PDAlgSeqName()), prefix = '', sgkey = D3PDMakerFlags.ElectronSGKey(), typeName = 'DataVector<xAOD::Electron_v1>', allowMissing = False): """Configure egammaTimeCorrAlg for D3PD making. SEQ is the Gaudi sequence to which the algorithm should be added. Default is that given by PreD3PDAlgSeqName. PREFIX is a prefix to add to the name of the algorithm scheduled. SGKEY/TYPENAME is the StoreGate key of the input electron container and the name of its type. If ALLOWMISSING is true, don't fail if the SG key doesn't exist. """ if (not D3PDMakerFlags.MakeEgammaUserData() or D3PDMakerFlags.HaveEgammaUserData()): return DVGetter = D3PDMakerCoreComps.SGDataVectorGetterTool resolved_sgkey = resolveSGKey (typeName, sgkey) auxprefix = (D3PDMakerFlags.EgammaUserDataPrefix() + '_' + resolved_sgkey + '_') algName = 'egammaTimeCorrAlg' + resolved_sgkey if not hasattr (seq, algName): from IOVDbSvc.CondDB import conddb conddb.addFolder("LAR_OFL","/LAR/TimeCorrectionOfl/NonRunCon <tag>LARTimeCorrectionOflNonRunCon-00</tag>",force=True) conddb.addFolder("LAR_OFL","/LAR/TimeCorrectionOfl/RunCon <tag>LARTimeCorrectionOflRunCon-00</tag>",force=True) from CaloClusterCorrection.CaloClusterTimeTool import GetCaloClusterTimeTool myCaloClusterTimeTool=GetCaloClusterTimeTool("caloClusterTimeTool", "/LAR/TimeCorrectionOfl/NonRunCon","/LAR/TimeCorrectionOfl/RunCon") seq += egammaD3PDAnalysis.egammaTimeCorrAlg \ (algName, Getter = DVGetter (prefix + 'egammaTimeCorrGetter', TypeName = typeName, SGKey = sgkey), AllowMissing = allowMissing, AuxPrefix = auxprefix, CaloClusterTimeTool = myCaloClusterTimeTool, ) return
def makeClusterFilter( InputName = "CaloCalTopoCluster", OutputName = "SelectedClusters", ptCut=5000., etaCut=5 ) : from CaloD3PDMaker.CaloD3PDMakerConf import ClusterFilter clusterFilter = ClusterFilter(OutputName) clusterFilter.InputName = resolveSGKey ('CaloClusterContainer', InputName) clusterFilter.OutputName = OutputName clusterFilter.ptCut = ptCut clusterFilter.etaCut = etaCut return clusterFilter
def PhotonTruthConfig \ (seq = AlgSequence(D3PDMakerFlags.PreD3PDAlgSeqName()), prefix = '', sgkey = D3PDMakerFlags.ElectronSGKey(), typeName = 'ElectronContainer', allowMissing = False): """Configure PhotonTruthAlg for D3PD making. SEQ is the Gaudi sequence to which the algorithm should be added. Default is that given by PreD3PDAlgSeqName. PREFIX is a prefix to add to the name of the algorithm scheduled. SGKEY/TYPENAME is the StoreGate key of the input electron container and the name of its type. If ALLOWMISSING is true, don't fail if the SG key doesn't exist. """ if not rec.doTruth(): return if (not D3PDMakerFlags.MakeEgammaUserData() or D3PDMakerFlags.HaveEgammaUserData()): return DVGetter = D3PDMakerCoreComps.SGDataVectorGetterTool resolved_sgkey = resolveSGKey (typeName, sgkey) auxprefix = (D3PDMakerFlags.EgammaUserDataPrefix() + '_' + resolved_sgkey + '_') from TruthD3PDMaker.MCTruthClassifierConfig \ import D3PDMCTruthClassifier ptaname = 'PhotonTruthAlg_' + resolved_sgkey if not hasattr (seq, ptaname): seq += egammaD3PDAnalysis.PhotonTruthAlg \ (ptaname, PhotonGetter = DVGetter (prefix + 'PhotonTruthAlgGetter', TypeName = typeName, SGKey = sgkey), AllowMissing = allowMissing, AuxPrefix = auxprefix, TruthTool = egammaD3PDAnalysis.PhotonTruthTool ('D3PD__PhotonTruthTool', Classifier = D3PDMCTruthClassifier)) return
def TileGapConfig \ (seq = AlgSequence(D3PDMakerFlags.PreD3PDAlgSeqName()), prefix = '', sgkey = 'egClusterCollection', typeName = 'DataVector<xAOD::CaloCluster_v1>', allowMissing = False): """Configure egammaMaxECellAlg for D3PD making. SEQ is the Gaudi sequence to which the algorithm should be added. Default is that given by PreD3PDAlgSeqName. PREFIX is a prefix to add to the name of the algorithm scheduled. SGKEY/TYPENAME is the StoreGate key of the input electron container and the name of its type. If ALLOWMISSING is true, don't fail if the SG key doesn't exist. """ if (not D3PDMakerFlags.MakeEgammaUserData() or D3PDMakerFlags.HaveEgammaUserData()): return DVGetter = D3PDMakerCoreComps.SGDataVectorGetterTool resolved_sgkey = resolveSGKey (typeName, sgkey) auxprefix = (D3PDMakerFlags.EgammaUserDataPrefix() + '_' + resolved_sgkey + '_') algName = 'TileGapSumAlg' + resolved_sgkey if not hasattr (seq, algName): gapsel = TileGapSelectionGetter (seq) myAlg = egammaD3PDAnalysis.TileGapSumAlg \ (algName, ClusterGetter = DVGetter (prefix + 'TileGapAlgGetter', TypeName = typeName, SGKey = sgkey), CellGetter = SGDataVectorGetterTool (prefix + 'TileGapAlgCellGetter', SGKey = gapsel.outputKey(), TypeName = gapsel.outputType()), AllowMissing = allowMissing, AuxPrefix = auxprefix,) seq += myAlg return
def egammaDeltaEmax2Config \ (seq = AlgSequence(D3PDMakerFlags.PreD3PDAlgSeqName()), prefix = '', sgkey = D3PDMakerFlags.ElectronSGKey(), typeName = 'DataVector<xAOD::Electron_v1>', allowMissing = False): """Configure egammaDeltaEmax2Alg for D3PD making. SEQ is the Gaudi sequence to which the algorithm should be added. Default is that given by PreD3PDAlgSeqName. PREFIX is a prefix to add to the name of the algorithm scheduled. SGKEY/TYPENAME is the StoreGate key of the input electron container and the name of its type. If ALLOWMISSING is true, don't fail if the SG key doesn't exist. """ if (not D3PDMakerFlags.MakeEgammaUserData() or D3PDMakerFlags.HaveEgammaUserData()): return DVGetter = D3PDMakerCoreComps.SGDataVectorGetterTool resolved_sgkey = resolveSGKey (typeName, sgkey) auxprefix = (D3PDMakerFlags.EgammaUserDataPrefix() + '_' + resolved_sgkey + '_') emax2name = 'DeltaEmax2Alg_' + resolved_sgkey if not hasattr (seq, emax2name): highlum = False if typeName == 'ElectronContainer': from AthenaCommon.BeamFlags import jobproperties if jobproperties.Beam.numberOfCollisions() >= 20 : highlum = True seq += egammaD3PDAnalysis.egammaDeltaEmax2Alg \ (emax2name, Getter = DVGetter (prefix + 'DeltaEmax2Getter', TypeName = typeName, SGKey = sgkey), AllowMissing = allowMissing, HighLum = highlum, AuxPrefix = auxprefix) return
def egammaCalcOQConfig \ (seq = AlgSequence(D3PDMakerFlags.PreD3PDAlgSeqName()), prefix = '', sgkey = D3PDMakerFlags.ElectronSGKey(), typeName = 'ElectronContainer', allowMissing = False): """Configure egammaTopoIsoAlg for D3PD making. SEQ is the Gaudi sequence to which the algorithm should be added. Default is that given by PreD3PDAlgSeqName. PREFIX is a prefix to add to the name of the algorithm scheduled. SGKEY/TYPENAME is the StoreGate key of the input electron container and the name of its type. If ALLOWMISSING is true, don't fail if the SG key doesn't exist. """ if (not D3PDMakerFlags.MakeEgammaUserData() or D3PDMakerFlags.HaveEgammaUserData()): return DVGetter = D3PDMakerCoreComps.SGDataVectorGetterTool resolved_sgkey = resolveSGKey (typeName, sgkey) udprefix = (D3PDMakerFlags.EgammaUserDataPrefix() + '_' + resolved_sgkey + '_') oqname = 'egammaCalcOQAlg_' + resolved_sgkey if not hasattr (seq, oqname): from AthenaCommon.AppMgr import ToolSvc ToolSvc += egammaOQFlagsBuilderBase() seq += egammaD3PDAnalysis.egammaCalcOQAlg \ (oqname, egammaOQFlagsBuilder = egammaOQFlagsBuilderBase(), Getter = DVGetter (prefix + 'egammaCalcOQGetter', TypeName = typeName, SGKey = sgkey), AllowMissing = allowMissing, UDPrefix = udprefix ) return
def egammaNbCellsGainAlgConfig \ (seq = AlgSequence(D3PDMakerFlags.PreD3PDAlgSeqName()), prefix = '', sgkey = D3PDMakerFlags.ElectronSGKey(), typeName = 'ElectronContainer', allowMissing = False): """Configure egammaNbCellsGainAlg for D3PD making. SEQ is the Gaudi sequence to which the algorithm should be added. Default is that given by PreD3PDAlgSeqName. PREFIX is a prefix to add to the name of the algorithm scheduled. SGKEY/TYPENAME is the StoreGate key of the input electron container and the name of its type. If ALLOWMISSING is true, don't fail if the SG key doesn't exist. """ if (not D3PDMakerFlags.MakeEgammaUserData() or D3PDMakerFlags.HaveEgammaUserData()): return DVGetter = D3PDMakerCoreComps.SGDataVectorGetterTool resolved_sgkey = resolveSGKey (typeName, sgkey) auxprefix = (D3PDMakerFlags.EgammaUserDataPrefix() + '_' + resolved_sgkey + '_') algName = 'egammaNbCellsGainAlg' + resolved_sgkey if not hasattr (seq, algName): myAlg = egammaD3PDAnalysis.egammaNbCellsGainAlg \ (algName, Getter = DVGetter (prefix + 'egammaNbCellsGainAlgGetter', TypeName = typeName, SGKey = sgkey), AllowMissing = allowMissing, AuxPrefix = auxprefix,) seq += myAlg return
def JetVertexFractionConfig \ (seq = AlgSequence(D3PDMakerFlags.PreD3PDAlgSeqName()), prefix = '', sgkey = D3PDMakerFlags.JetSGKey(), typeName = 'JetCollection'): """Configure algorithms required to fill JVF information into UserData. SEQ is the Gaudi sequence to which the algorithms should be added. Default is that given by PreD3PDAlgSeqName. PREFIX is a prefix to add to the names of the algorithms scheduled. SGKEY/TYPENAME is the StoreGate key of the input jet container and the name of its type. """ DVGetter = D3PDMakerCoreComps.SGDataVectorGetterTool if (not D3PDMakerFlags.MakeJetUserData() or D3PDMakerFlags.HaveJetUserData()): return resolved_sgkey = resolveSGKey (typeName, sgkey) jvfname = 'JetVertexFractionAlg_' + resolved_sgkey if not hasattr (seq, jvfname): # Need to rebuild track associations... from JetD3PDAnalysis.JetMomentCalcConfig import JetMomentCalcConfig JetMomentCalcConfig (resolved_sgkey, None, seq=seq) from JetMomentTools.SetupJetMomentTools\ import getJetVertexAssociationTool seq += JetD3PDAnalysis.JetVertexFractionAlg \ (jvfname, Getter = DVGetter (prefix + 'JetVertexFractionGetter', TypeName = typeName, SGKey = sgkey), JetVertexAssociationTool = # Parameters are irrelevant; these will work for any jets. getJetVertexAssociationTool ('AntiKt', 0.4, 'Topo'), UDPrefix = D3PDMakerFlags.JetUserDataPrefix())
# $Id$ # # @file TruthD3PDMaker/python/MCTruthClassifierConfig.py # @author scott snyder <*****@*****.**> # @date Jan, 2010 # @brief Import this to configure the MCTruthClassifier tool for D3PD making. # # Create the classifier tool, and set the MC collection name to match # what's in D3PDMakerFlags. from D3PDMakerCoreComps.resolveSGKey import resolveSGKey from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags from AthenaCommon.Constants import ERROR mckey = resolveSGKey('DataVector<xAOD::TruthParticle_v1>', D3PDMakerFlags.TruthSGKey()) from TruthD3PDAnalysis import D3PDMCTruthClassifier D3PDMCTruthClassifier = D3PDMCTruthClassifier( name='D3PDMCTruthClassifier', xAODTruthParticleContainerName=mckey, pTNeutralPartCut=1e-3, OutputLevel=ERROR, partExtrConePhi=0.6, #0.4 partExtrConeEta=0.2, #0.2 ROICone=True) try: D3PDMCTruthClassifier.forceNotUseBremRefitTrk = True except AttributeError: pass
def PhotonUserDataConfig \ (seq = AlgSequence(D3PDMakerFlags.PreD3PDAlgSeqName()), prefix = '', sgkey = D3PDMakerFlags.PhotonSGKey(), typeName = 'PhotonContainer'): """Configure algorithms required for D3PD making for photons. SEQ is the Gaudi sequence to which the algorithms should be added. Default is that given by PreD3PDAlgSeqName. PREFIX is a prefix to add to the names of the algorithms scheduled. SGKEY/TYPENAME is the StoreGate key of the input electron container and the name of its type. """ DVGetter = D3PDMakerCoreComps.SGDataVectorGetterTool if (not D3PDMakerFlags.MakeEgammaUserData() or D3PDMakerFlags.HaveEgammaUserData()): return #not use MCTruthClassifier to avoid crash # if rec.doTruth(): # ptaname = prefix + 'PhotonTruthAlg' # if not hasattr (seq, ptaname): # seq += egammaD3PDAnalysis.PhotonTruthAlg \ # (ptaname, # PhotonGetter = DVGetter # (prefix + 'PhotonTruthAlgGetter', # TypeName = typeName, # SGKey = sgkey), # UDPrefix = D3PDMakerFlags.EgammaUserDataPrefix()) # ptianame = prefix + 'PhotonTopoIsoAlg' if not hasattr (seq, ptianame): seq += egammaD3PDAnalysis.PhotonTopoIsoAlg \ (ptianame, PhotonGetter = DVGetter (prefix +'PhotonTopoIsoAlgPhotonGetter', TypeName = typeName, SGKey = sgkey), ClusterGetter = DVGetter (prefix + 'PhotonTopoIsoAlgClusterGetter', TypeName = 'CaloClusterContainer', SGKey = D3PDMakerFlags.ClusterSGKey()), UDPrefix = D3PDMakerFlags.EgammaUserDataPrefix()) emax2gamname = prefix + 'DeltaEmax2GamAlg' if not hasattr (seq, emax2gamname): seq += egammaD3PDAnalysis.egammaDeltaEmax2Alg \ (emax2gamname, Getter = DVGetter (prefix + 'DeltaEmax2GamGetter', TypeName = typeName, SGKey = sgkey), UDPrefix = D3PDMakerFlags.EgammaUserDataPrefix()) resname = resolveSGKey (typeName, sgkey) gamrawclustname = 'GamRawClusterAlg_' + resname if not hasattr (seq, gamrawclustname): seq += egammaD3PDAnalysis.RawClusterAlg \ (gamrawclustname, Getter = DVGetter (prefix + 'GamRawClusterAlgGetter', TypeName = typeName, SGKey = sgkey), RawClustersName = resname + D3PDMakerFlags.RawClustersSGKeySuffix(), RawClustersAssocName = resname + D3PDMakerFlags.RawClustersAssocSGKeySuffix(), ClusterCorrectionTool = egammaSwToolNone()) isoname = prefix + 'egammaIsIsoAlg' if not hasattr (seq, isoname): from egammaPIDTools.egammaIsolationMVATopToolBase \ import egammaIsolationMVATopToolBase egammaIsolationMVATopToolBase ("egammaIsolationMVATopTool") seq += egammaD3PDAnalysis.egammaIsIsoAlg \ (isoname, Getter = DVGetter (prefix + 'egammaIsIsoGetter', TypeName = typeName, SGKey = sgkey), UDPrefix = D3PDMakerFlags.EgammaUserDataPrefix(), IsoTypes = [egammaIsolationType.iso99, egammaIsolationType.iso98, egammaIsolationType.iso95, egammaIsolationType.iso90, egammaIsolationType.caloIso99, egammaIsolationType.caloIso98, egammaIsolationType.caloIso95, egammaIsolationType.caloIso90, egammaIsolationType.caloIso80, egammaIsolationType.trackIso99, egammaIsolationType.trackIso98, egammaIsolationType.trackIso95, egammaIsolationType.likelihoodIso95, egammaIsolationType.likelihoodIso90, egammaIsolationType.likelihoodIso80, ])