Exemple #1
0
def JetHypoExerciserCompareCfg(label, fn_frag, mult_string, event_generator):

    test_conditions = FastReductionLabeledCompTests(label, fn_frag,
                                                    mult_string)

    print(test_conditions.__dict__)

    ht0, ht1 = test_conditions.make_helper_tools()

    # print('ht0 = ', ht0)
    # print('ht1 = ', ht1)

    jetHypoExerciserAlg = JetHypoExerciserCompareAlg("JetHypoCompareExerciser")
    jetHypoExerciserAlg.JetHypoHelperTool0 = ht0  # run ufn first
    # jetHypoExerciserAlg.JetHypoHelperTool1 = ht0
    jetHypoExerciserAlg.JetHypoHelperTool1 = ht1  # then tree

    jetHypoExerciserAlg.event_generator = event_generator

    jetHypoExerciserAlg.visit_debug = True  #  more evebt debug if True

    jetHypoExerciserAlg.logname = test_conditions.logname

    print(jetHypoExerciserAlg)

    result = ComponentAccumulator()
    result.addEventAlgo(jetHypoExerciserAlg)
    return result
Exemple #2
0
def RpcOverlayAlgCfg(flags, name="RpcOverlay", **kwargs):
    """Return a ComponentAccumulator for RPCOverlay algorithm"""
    acc = ComponentAccumulator()

    kwargs.setdefault("BkgInputKey", flags.Overlay.BkgPrefix + "RPC_DIGITS")
    kwargs.setdefault("SignalInputKey", flags.Overlay.SigPrefix + "RPC_DIGITS")
    kwargs.setdefault("OutputKey", "RPC_DIGITS")

    # Do RPC overlay
    RpcOverlay = CompFactory.RpcOverlay
    alg = RpcOverlay(name, **kwargs)
    acc.addEventAlgo(alg)

    # Setup output
    if flags.Output.doWriteRDO:
        from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
        acc.merge(
            OutputStreamCfg(flags, "RDO", ItemList=["RpcPadContainer#RPCPAD"]))

    if flags.Output.doWriteRDO_SGNL:
        from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
        acc.merge(
            OutputStreamCfg(flags,
                            "RDO_SGNL",
                            ItemList=[
                                "RpcPadContainer#" + flags.Overlay.SigPrefix +
                                "RPCPAD"
                            ]))

    return acc
Exemple #3
0
def TileMuonFitterCfg(flags, **kwargs):

    acc = ComponentAccumulator()

    kwargs.setdefault('DoHoughTransform', True)
    kwargs.setdefault('EThreshold', 250.0)
    kwargs.setdefault('BeamType', flags.Beam.Type)
    kwargs.setdefault('CaloCellContainer', 'AllCalo')

    if kwargs['DoHoughTransform']:
        kwargs.setdefault('name', 'TileMuonFitter')
        kwargs.setdefault('ComTimeKey', 'ComTimeTileMuon')
        kwargs.setdefault('TileCosmicMuonKey', 'TileCosmicMuonHT')
    else:
        kwargs.setdefault('name', 'TileMuonFitterMF')
        kwargs.setdefault('ComTimeKey', 'ComTimeTileMuonMF')
        kwargs.setdefault('TileCosmicMuonKey', 'TileCosmicMuonMF')

    from TileGeoModel.TileGMConfig import TileGMCfg
    acc.merge(TileGMCfg(flags))

    from LArGeoAlgsNV.LArGMConfig import LArGMCfg
    acc.merge(LArGMCfg(flags))

    TileMuonFitter = CompFactory.TileMuonFitter
    acc.addEventAlgo(TileMuonFitter(**kwargs), primary=True)

    return acc
Exemple #4
0
def CopyCaloCalibrationHitContainersCfg(flags, **kwargs):
    """Return overlay configuration for the CopyCalibrationHitContainer algorithms"""

    acc = ComponentAccumulator()

    allowedContainers = [
        "LArCalibrationHitActive",
        "LArCalibrationHitDeadMaterial",
        "LArCalibrationHitInactive"
        "TileCalibrationCellHitCnt",
        "TileCalibrationDMHitCnt",
        "TileCalibHitActiveCell",
        "TileCalibHitInactiveCell",
        "TileCalibHitDeadMaterial",
    ]
    availableContainers = []

    # Detect the list of calibration hit containers
    for container in allowedContainers:
        if (flags.Overlay.DataOverlay and container in flags.Input.Collections) \
            or (not flags.Overlay.DataOverlay and container in flags.Input.SecondaryCollections):
            availableContainers.append(container)

    for container in availableContainers:
        acc.merge(
            CopyCaloCalibrationHitContainerAlgCfg(flags, container, **kwargs))
        acc.merge(
            CopyCaloCalibrationHitContainerOutputCfg(flags, container,
                                                     **kwargs))

    return acc
Exemple #5
0
def CopyCaloCalibrationHitContainerAlgCfg(
        flags,
        collectionName,
        name="CopyCaloCalibrationHitContainer",
        **kwargs):
    """Return a ComponentAccumulator for the CaloCalibrationHitContainer copying"""
    acc = ComponentAccumulator()

    kwargs.setdefault("collectionName", collectionName)
    kwargs.setdefault("SignalInputKey",
                      flags.Overlay.SigPrefix + collectionName)
    kwargs.setdefault("OutputKey", collectionName)

    # Copy CaloCalibrationHitContainer
    CopyCaloCalibrationHitContainer = CompFactory.CopyCaloCalibrationHitContainer
    alg = CopyCaloCalibrationHitContainer(name + collectionName, **kwargs)
    acc.addEventAlgo(alg)

    # Re-map signal address
    from SGComps.AddressRemappingConfig import AddressRemappingCfg
    acc.merge(
        AddressRemappingCfg([
            "CaloCalibrationHitContainer#" + collectionName + "->" +
            flags.Overlay.SigPrefix + collectionName
        ]))

    return acc
Exemple #6
0
def AthenaStackingActionToolCfg(ConfigFlags,
                                name='G4UA::AthenaStackingActionTool',
                                **kwargs):

    result = ComponentAccumulator()
    ## Killing neutrinos
    if "ATLAS" in ConfigFlags.Sim.Layout:
        kwargs.setdefault('KillAllNeutrinos', True)
    ## Neutron Russian Roulette
    #need to check if it exists?
    #if ConfigFlags.hasFlag('Sim.NRRThreshold') and ConfigFlags.hasFlag('Sim.NRRWeight'):
    if ConfigFlags.Sim.NRRThreshold and ConfigFlags.Sim.NRRWeight:
        if ConfigFlags.Sim.CalibrationRun != 'Off':
            raise NotImplementedError(
                "Neutron Russian Roulette should not be used in Calibration Runs."
            )
        kwargs.setdefault('NRRThreshold', ConfigFlags.Sim.NRRThreshold)
        kwargs.setdefault('NRRWeight', ConfigFlags.Sim.NRRWeight)
    ## Photon Russian Roulette
    if ConfigFlags.Sim.PRRThreshold and ConfigFlags.Sim.PRRWeight:
        if ConfigFlags.Sim.CalibrationRun != 'Off':
            raise NotImplementedError(
                "Photon Russian Roulette should not be used in Calibration Runs."
            )
        kwargs.setdefault('PRRThreshold', ConfigFlags.Sim.PRRThreshold)
        kwargs.setdefault('PRRWeight', ConfigFlags.Sim.PRRWeight)
    kwargs.setdefault('IsISFJob', ConfigFlags.Sim.ISFRun)

    result.setPrivateTools(
        CompFactory.G4UA.AthenaStackingActionTool(name, **kwargs))
    return result
Exemple #7
0
def CopyTimingsAlgCfg(flags, name="CopyTimings", **kwargs):
    """Return a ComponentAccumulator for the CopyTimings algorithm"""
    acc = ComponentAccumulator()

    # Disable background copying
    kwargs.setdefault("BkgInputKey", "")

    kwargs.setdefault("SignalInputKey",
                      flags.Overlay.SigPrefix + "EVNTtoHITS_timings")
    kwargs.setdefault("OutputKey", "EVNTtoHITS_timings")

    # Copy RecoTimingObj
    CopyTimings = CompFactory.CopyTimings
    alg = CopyTimings(name, **kwargs)
    acc.addEventAlgo(alg)

    # Re-map signal address
    from SGComps.AddressRemappingConfig import AddressRemappingCfg
    acc.merge(
        AddressRemappingCfg([
            "RecoTimingObj#EVNTtoHITS_timings->" + flags.Overlay.SigPrefix +
            "EVNTtoHITS_timings"
        ]))

    return acc
Exemple #8
0
def TileRawChannelNoiseFilterCfg(flags, **kwargs):
    """Return component accumulator with configured private Tile raw channel noise filter tool

    Arguments:
        flags  -- Athena configuration flags (ConfigFlags)
    """

    acc = ComponentAccumulator()

    from TileRecUtils.TileDQstatusConfig import TileDQstatusAlgCfg
    acc.merge(TileDQstatusAlgCfg(flags))

    from TileConditions.TileInfoLoaderConfig import TileInfoLoaderCfg
    acc.merge(TileInfoLoaderCfg(flags))

    if 'TileCondToolEmscale' not in kwargs:
        from TileConditions.TileEMScaleConfig import TileCondToolEmscaleCfg
        emScaleTool = acc.popToolsAndMerge(TileCondToolEmscaleCfg(flags))
        kwargs['TileCondToolEmscale'] = emScaleTool

    if 'TileCondToolNoiseSample' not in kwargs:
        from TileConditions.TileSampleNoiseConfig import TileCondToolNoiseSampleCfg
        sampleNoiseTool = acc.popToolsAndMerge(
            TileCondToolNoiseSampleCfg(flags))
        kwargs['TileCondToolNoiseSample'] = sampleNoiseTool

    if 'TileBadChanTool' not in kwargs:
        from TileConditions.TileBadChannelsConfig import TileBadChanToolCfg
        badChanTool = acc.popToolsAndMerge(TileBadChanToolCfg(flags))
        kwargs['TileBadChanTool'] = badChanTool

    TileRawChannelNoiseFilter = CompFactory.TileRawChannelNoiseFilter
    acc.setPrivateTools(TileRawChannelNoiseFilter(**kwargs))

    return acc
Exemple #9
0
def TrigLiveFractionCondAlgCfg(configFlags):
    name = 'TrigLiveFractionCondAlg'
    result = ComponentAccumulator()

    kwargs = {}
    if configFlags.IOVDb.DatabaseInstance == 'COMP200':
        folder = '/TRIGGER/LUMI/PerBcidDeadtime'

        # Mistakenly created as multi-version folder, must specify HEAD
        result.merge(
            addFolders(configFlags,
                       folder,
                       'TRIGGER',
                       tag='HEAD',
                       className='AthenaAttributeList'))

        kwargs['DeadtimeFolderInputKey'] = folder
        kwargs['LuminosityInputKey'] = 'LuminosityCondData'

        from LumiBlockComps.LuminosityCondAlgConfig import LuminosityCondAlgCfg
        result.merge(LuminosityCondAlgCfg(configFlags))

    else:
        kwargs['DeadtimeFolderInputKey'] = ''
        kwargs['LuminosityInputKey'] = ''

    TrigLiveFractionCondAlg = CompFactory.TrigLiveFractionCondAlg
    alg = TrigLiveFractionCondAlg(
        name, TrigLiveFractionOutputKey='TrigLiveFractionCondData', **kwargs)
    result.addCondAlgo(alg)
    return result
Exemple #10
0
def testCfg(configFlags):
    result = ComponentAccumulator()

    tool1 = CompFactory.CaloUtils.ToolWithConstantsTestTool \
            ('tool1',
             prefix = 'test.',
             cf1 = 2.5,
             ci1 = 10,
             cb1 = False,
             ca1 = "[3, 4.5, 6]",
             ca2 = "[[4, 5], [6, 7], [9, 8]]")
    result.addPublicTool(tool1)

    tool2 = CompFactory.CaloUtils.ToolWithConstantsTestTool \
            ('tool2',
             CondKey = 'test2Cond',
             DBHandleKey = 'test2Cond',
             prefix = 'test.',
             cf1 = 2.5,
             ci1 = 10,
             ca1 = "[3, 4.5, 6]")
    result.addPublicTool(tool2)

    result.addEventAlgo(TestAlg('TestAlg'))
    return result
Exemple #11
0
def TileRawChannelCorrectionAlgCfg(flags, **kwargs):
    """Return component accumulator with configured Tile raw channel correction algorithm

    Arguments:
        flags  -- Athena configuration flags (ConfigFlags)

    Keyword arguments:
        InputRawChannelContainer -- input Tile raw channel container. Defaults to TileRawChannelCnt.
        OutputRawChannelContainer -- output Tile raw channel container. Defaults to TileRawChannelCntCorrected.
    """

    acc = ComponentAccumulator()

    kwargs.setdefault('InputRawChannelContainer', 'TileRawChannelCnt')
    kwargs.setdefault('OutputRawChannelContainer',
                      'TileRawChannelCntCorrected')

    if 'NoiseFilterTools' not in kwargs:
        kwargs['NoiseFilterTools'] = acc.popToolsAndMerge(
            TileRawChannelCorrectionToolsCfg(flags))

    TileRawChannelCorrectionAlg = CompFactory.TileRawChannelCorrectionAlg
    acc.addEventAlgo(TileRawChannelCorrectionAlg(**kwargs), primary=True)

    return acc
Exemple #12
0
def _larCablingCfg(configFlags, algo, folder):
    result = ComponentAccumulator()

    result.merge(IOVDbSvcCfg(configFlags))

    #MC folder-tag hack (See also ATCONDDB-49)
    tagsperFolder = {
        "/LAR/Identifier/OnOffIdMap": "LARIdentifierOnOffIdMap-012",
        "/LAR/Identifier/FebRodMap": "LARIdentifierFebRodMap-005",
        "/LAR/Identifier/CalibIdMap": "LARIdentifierCalibIdMap-012",
        "/LAR/IdentifierOfl/OnOffIdMap_SC": "LARIdentifierOflOnOffIdMap_SC-000"
    }

    if configFlags.Input.isMC:
        db = 'LAR_OFL'
        if folder in tagsperFolder:
            ft = tagsperFolder[folder]
            folderwithtag = folder + "<tag>" + ft + "</tag>"
    else:
        db = 'LAR_ONL'
        folderwithtag = folder

    result.addCondAlgo(algo(ReadKey=folder), primary=True)
    result.merge(
        addFolders(configFlags,
                   folderwithtag,
                   className="AthenaAttributeList",
                   detDb=db))
    #print (result)
    return result
Exemple #13
0
def L1TriggerByteStreamDecoderCfg(flags):
    from AthenaCommon.Configurable import Configurable
    cb = Configurable.configurableRun3Behavior
    Configurable.configurableRun3Behavior += 1

    decoderTools = []
    if flags.Trigger.enableL1CaloLegacy or not flags.Trigger.enableL1Phase1:
        roibResultTool = RoIBResultByteStreamToolCfg(
            name="RoIBResultBSDecoderTool", writeBS=False)
        decoderTools += [roibResultTool]

    if flags.Trigger.enableL1Phase1:
        # Placeholder for real decoder tools - now it's just an example
        exampleTool = ExampleL1TriggerByteStreamToolCfg(
            name="L1MuonBSDecoderTool", writeBS=False)
        decoderTools += [exampleTool]

    decoderAlg = CompFactory.L1TriggerByteStreamDecoderAlg(
        name="L1TriggerByteStreamDecoder", DecoderTools=decoderTools)

    acc = ComponentAccumulator()
    acc.addEventAlgo(decoderAlg, primary=True)

    Configurable.configurableRun3Behavior = cb
    return acc
Exemple #14
0
def Q5FwdG4FieldSvcCfg(ConfigFlags, name='Q5FwdG4FieldSvc', **kwargs):
    result = ComponentAccumulator()
    result.addService(MagField__ForwardRegionFieldSvc(
        "Q5", Magnet=6))  # FIXME find a better way to do this.
    kwargs.setdefault("MagneticFieldSvc", result.getService("Q5"))
    result.merge(ForwardFieldSvcCfg(ConfigFlags, name, **kwargs))
    return result
Exemple #15
0
def egammaTruthAssociationCfg(flags, name='egammaTruthAssociation', **kwargs):

    mlog = logging.getLogger(name)
    mlog.info('Start configuration')

    acc = ComponentAccumulator()

    if "MCTruthClassifier" not in kwargs:
        mctruth = MCTruthClassifierCaloTruthMatchCfg(flags)
        kwargs["MCTruthClassifier"] = mctruth.popPrivateTools()
        acc.merge(mctruth)

    kwargs.setdefault("ClusterContainerName",
                      flags.Egamma.Keys.Output.CaloClusters)
    kwargs.setdefault("ElectronContainerName",
                      flags.Egamma.Keys.Output.Electrons)
    kwargs.setdefault("PhotonContainerName", flags.Egamma.Keys.Output.Photons)
    kwargs.setdefault("FwdElectronContainerName",
                      flags.Egamma.Keys.Output.ForwardElectrons)
    kwargs.setdefault("TruthEventContainerName",
                      flags.Egamma.Keys.Input.TruthEvents)
    kwargs.setdefault("TruthParticleContainerName",
                      flags.Egamma.Keys.Input.TruthParticles)
    kwargs.setdefault("EgammaTruthContainerName",
                      flags.Egamma.Keys.Output.TruthParticles)
    kwargs.setdefault("MatchForwardElectrons", flags.Egamma.doForwardSeeded)
    kwargs.setdefault("SimBarcodeOffset", flags.Sim.SimBarcodeOffset)

    egtruthAlg = egammaTruthAssociationAlg(name, **kwargs)

    acc.addEventAlgo(egtruthAlg)
    return acc
Exemple #16
0
def MetaDataSvcCfg(flags, toolNames=[]):
    # should cover most use cases (POOL, RAW) when called with appropriate toolNames argument
    from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
    from AthenaConfiguration.ComponentFactory import CompFactory
    from six import string_types

    result = ComponentAccumulator()

    result.addService(CompFactory.StoreGateSvc("MetaDataStore"))
    result.addService(CompFactory.StoreGateSvc("InputMetaDataStore"))

    svc = CompFactory.MetaDataSvc("MetaDataSvc")
    svc.MetaDataContainer = "MetaDataHdr"
    result.addService(svc)
    result.addService(
        CompFactory.ProxyProviderSvc(ProviderNames=["MetaDataSvc"]))

    for name in toolNames:
        if not isinstance(name, string_types):
            from AthenaCommon.Logging import logging
            log = logging.getLogger("MetaDataSvcConfig")
            log.error(
                'Attempted to pass a non-string argument as a metadata tool name'
            )
            continue
        thistool = CompFactory.getComps(name)[0]()
        result.addPublicTool(thistool)
        svc.MetaDataTools += [thistool]

    return result
Exemple #17
0
def ToolConstantsCondAlgCfg(flags, key, DetStoreKey='', COOLFolder=''):
    """Configure a conditions algorithm to convert inline COOL data or detector store data to ToolConstants.
    KEY is also the key of the output conditions object.
    For reading from COOL inline data, COOLFOLDER gives the name
    of the COOL folder; the dta are given by KEY within the folder.
    The caller should register the folder with IOVDbSvc.
    For copying a ToolConstants object from the detector store,
    set DETSTOREKEY to the key of the object to copy."""

    if ((DetStoreKey == '' and COOLFolder == '')
            or (DetStoreKey != '' and COOLFolder != '')):
        raise RuntimeError(
            "ToolConstantsCondAlgCfg: For key " + key +
            ", exactly one of DetStoreKey or COOLFolder must be specified")

    result = ComponentAccumulator()

    name = 'ToolConstantsCondAlg_' + key

    ToolConstantsCondAlg = CompFactory.ToolConstantsCondAlg  # CaloRec
    alg = ToolConstantsCondAlg(name,
                               COOLFolderKey=COOLFolder,
                               ToolConstantsKey=key,
                               DetStoreKey=DetStoreKey)
    result.addCondAlgo(alg)

    return result
Exemple #18
0
def Ranecu(seed, name="AtRndmGenSvc"):
    """Return a ComponentAccumulator containing an AtRndmGenSvc with seed"""
    acc = ComponentAccumulator()
    service = AtRndmGenSvc(name)
    service.Seeds.append(seed)
    acc.addService(service)
    return acc
Exemple #19
0
def IPDetailedTrackGradeFactoryCfg(name='IPDetailedTrackGradeFactory',
                                   useBTagFlagsDefaults=True,
                                   **options):
    """Sets up a IPDetailedTrackGradeFactory tool and returns it.

    The following options have BTaggingFlags defaults:

    useSharedHitInfo                    default: True
    useDetailSharedHitInfo              default: True
    useRun2TrackGrading                 default: False
    hitBLayerGrade                      default: True

    input:             name: The name of the tool (should be unique).
          useBTagFlagsDefaults : Whether to use BTaggingFlags defaults for options that are not specified.
                  **options: Python dictionary with options for the tool.
    output: The actual tool."""
    acc = ComponentAccumulator()
    #btagrun1 was used to check old config, not sure we need it for Run3
    btagrun1 = False

    if useBTagFlagsDefaults:
        defaults = {
            'useSharedHitInfo': True,
            'useDetailSharedHitInfo': True,
            'useRun2TrackGrading': (btagrun1 is False),
            'useInnerLayers0HitInfo': (btagrun1 is False),
            'useDetailSplitHitInfo': (btagrun1 is False),
            'hitBLayerGrade': True
        }
        for option in defaults:
            options.setdefault(option, defaults[option])
    options['name'] = name
    acc.setPrivateTools(Analysis__DetailedTrackGradeFactory(**options))

    return acc
Exemple #20
0
def RNG(engine="dSFMT", name="AthRNGSvc"):
    """Return a ComponentAccumulator containing an AthRNGSvc"""
    acc = ComponentAccumulator()
    service = AthRNGSvc(name)
    service.EngineType = engine
    acc.addService(service)
    return acc
Exemple #21
0
def CopyTrackRecordCollectionAlgCfg(flags,
                                    collectionName,
                                    name="CopyTrackRecordCollection",
                                    **kwargs):
    """Return a ComponentAccumulator for the TrackRecordCollection copying"""
    acc = ComponentAccumulator()

    kwargs.setdefault("collectionName", collectionName)
    kwargs.setdefault("SignalInputKey",
                      flags.Overlay.SigPrefix + collectionName)
    kwargs.setdefault("OutputKey", collectionName)

    # Copy TrackRecordCollection
    CopyTrackRecordCollection = CompFactory.CopyTrackRecordCollection
    alg = CopyTrackRecordCollection(name + collectionName, **kwargs)
    acc.addEventAlgo(alg)

    # Re-map signal address
    from SGComps.AddressRemappingConfig import AddressRemappingCfg
    acc.merge(
        AddressRemappingCfg([
            "TrackRecordCollection#" + collectionName + "->" +
            flags.Overlay.SigPrefix + collectionName
        ]))

    return acc
Exemple #22
0
def JetGroomAlgCfg(ConfigFlags, buildjetsname, groomjetsname):
    groomcfg = ComponentAccumulator()

    # Create a sequence that holds a set of algorithms
    # -- mainly for understanding how chunks of the job
    #    relate to each other
    sequencename = "JetGroomSeq"
    groomcfg.addSequence(CompFactory.AthSequencer(sequencename))

    # Create the JetGroomer, provide it with a JetTrimmer
    jtrim = CompFactory.JetTrimming("trimSmallR2Frac5", RClus=0.2, PtFrac=0.05)
    jtrim.UngroomedJets = buildjetsname
    jtrim.ParentPseudoJets = "PseudoJetMerged_" + buildjetsname

    # Create the JetRecAlg, configure it to use the builder
    # using constructor syntax instead
    # (equivalent to setting properties with "=")
    jra = CompFactory.JetRecAlg(
        "JRA_trim",
        Provider=jtrim,  # Single ToolHandle
        Modifiers=[],  # ToolHandleArray
        OutputContainer=groomjetsname)

    # Add the alg to the ComponentAccumulator in the named sequence
    groomcfg.addEventAlgo(jra, sequencename)
    return groomcfg
Exemple #23
0
def CopyMcEventCollectionAlgCfg(flags, name="CopyMcEventCollection", **kwargs):
    """Return a ComponentAccumulator for the CopyMcEventCollection algorithm"""
    acc = ComponentAccumulator()

    kwargs.setdefault("RemoveBkgHardScatterTruth", True)

    if flags.Overlay.DataOverlay:
        # Disable background for data overlay
        kwargs.setdefault("BkgInputKey", "")
    else:
        kwargs.setdefault("BkgInputKey",
                          flags.Overlay.BkgPrefix + "TruthEvent")
    kwargs.setdefault("SignalInputKey", flags.Overlay.SigPrefix + "TruthEvent")
    kwargs.setdefault("OutputKey", "TruthEvent")

    # Merge and copy McEventCollection
    CopyMcEventCollection = CompFactory.CopyMcEventCollection
    alg = CopyMcEventCollection(name, **kwargs)
    acc.addEventAlgo(alg)

    # Re-map signal address
    from SGComps.AddressRemappingConfig import AddressRemappingCfg
    acc.merge(
        AddressRemappingCfg([
            "McEventCollection#TruthEvent->" + flags.Overlay.SigPrefix +
            "TruthEvent"
        ]))

    return acc
Exemple #24
0
def JetCopyAlgCfg(ConfigFlags, buildjetsname, copyjetsname):
    copycfg = ComponentAccumulator()

    # Create a sequence that holds a set of algorithms
    # -- mainly for understanding how chunks of the job
    #    relate to each other
    sequencename = "JetCopySeq"
    copycfg.addSequence(CompFactory.AthSequencer(sequencename))

    # Create the JetCopier, set some standard options
    jcopy = CompFactory.JetCopier("copier")
    jcopy.InputJets = buildjetsname

    # Add a simple jet modifier to the JetRecAlg
    jclsmoms = CompFactory.JetClusterMomentsTool("clsmoms",
                                                 JetContainer=copyjetsname)

    # Create the JetRecAlg, configure it to use the copier
    # using constructor syntax instead
    # (equivalent to setting properties with "=")
    jra = CompFactory.JetRecAlg(
        "JRA_copy",
        Provider=jcopy,  # Single ToolHandle
        Modifiers=[jclsmoms],  # ToolHandleArray
        OutputContainer=copyjetsname)

    # Add the alg to the ComponentAccumulator in the named sequence
    copycfg.addEventAlgo(jra, sequencename)
    return copycfg
Exemple #25
0
def JetGroomCfg(groomdef, configFlags, jetnameprefix="",jetnamesuffix=""):
    jetsfullname = jetnameprefix+groomdef.basename+jetnamesuffix+"Jets"
    jetlog.info("Setting up to find {0}".format(jetsfullname))

    sequencename = jetsfullname

    components = ComponentAccumulator()
    from AthenaCommon.AlgSequence import AthSequencer
    components.addSequence( AthSequencer(sequencename) )

    # Check if the ungroomed jets exist in the input file.
    # If not, we need to configure their reconstruction.
    filecontents = configFlags.Input.Collections
    if groomdef.ungroomedname not in filecontents:
        from . import JetRecCfg
        components.merge(JetRecCfg(groomdef.ungroomeddef, configFlags,
                                   jetnameoverride=groomdef.ungroomedname))
    else:
        # FIXME: Need to schedule rebuilding of pseudojets
        pass

    # FIXME: Add calls to JetModConfig.getFinalModifierListAndPrereqs
    components.addEventAlgo(getJetGroomAlg(jetsfullname,groomdef,groomdef.modifiers))

    return components
Exemple #26
0
def BTagMuonToJetAssociatorCfg(flags,
                               name,
                               useBTagFlagsDefaults=True,
                               **options):
    """Sets up a BTagMuonToJetAssociator tool and returns it.

    The following options have BTaggingFlags defaults:

    trackCone                           default: 1.0 (for the time being... has to be studied)
    useVariableSizedTrackCone           default: False

    input:             name: The name of the tool (should be unique).
      useBTagFlagsDefaults : Whether to use BTaggingFlags defaults for options that are not specified.
                  **options: Python dictionary with options for the tool.
    output: The actual tool, which can then by added to ToolSvc via ToolSvc += output."""
    acc = ComponentAccumulator()

    if useBTagFlagsDefaults:
        defaults = {'trackCone': 1.0, 'useVariableSizedTrackCone': False}
        for option in defaults:
            options.setdefault(option, defaults[option])
    options['name'] = name
    acc.setPrivateTools(Analysis__ParticleToJetAssociator(**options))

    return acc
Exemple #27
0
def egammaRecBuilderCfg(flags, name='egammaRecBuilder', **kwargs):

    mlog = logging.getLogger(name)
    mlog.debug('Start configuration')

    acc = ComponentAccumulator()
    if "TrackMatchBuilderTool" not in kwargs:
        emtrkmatch = EMTrackMatchBuilderCfg(flags)
        kwargs["TrackMatchBuilderTool"] = emtrkmatch.popPrivateTools()
        acc.merge(emtrkmatch)

    if "ConversionBuilderTool" not in kwargs:
        emcnv = EMConversionBuilderCfg(flags)
        kwargs["ConversionBuilderTool"] = emcnv.popPrivateTools()
        acc.merge(emcnv)

    kwargs.setdefault("egammaRecContainer",
                      flags.Egamma.Keys.Internal.EgammaRecs)
    kwargs.setdefault("InputTopoClusterContainerName",
                      flags.Egamma.Keys.Internal.EgammaTopoClusters)

    egrecAlg = egammaRecBuilder(name, **kwargs)

    acc.addEventAlgo(egrecAlg)
    return acc
Exemple #28
0
def MuonCorrectionsToolCfg(name='MuonCorrectionsTool', **options):
    """Sets up the CP MuonCorrection tool and returns it."""
    acc = ComponentAccumulator()
    options['name'] = name
    acc.setPrivateTools(CP__MuonCalibrationAndSmearingTool(**options))

    return acc
Exemple #29
0
def MuonChi2TrackFitterCfg(flags, name='MuonChi2TrackFitter', **kwargs):
    Trk__KalmanUpdator = CompFactory.Trk.KalmanUpdator
    Trk__GlobalChi2Fitter = CompFactory.Trk.GlobalChi2Fitter
    import MuonConfig.MuonRIO_OnTrackCreatorConfig  # Trying to avoid circular dependencies here

    result = ComponentAccumulator()

    extrapolator_CA = MuonExtrapolatorCfg(flags)
    extrapolator = extrapolator_CA.getPrimary()
    result.addPublicTool(extrapolator)  # TODO remove
    result.merge(extrapolator_CA)

    acc = MuonConfig.MuonRIO_OnTrackCreatorConfig.MuonRotCreatorCfg(flags)
    rotcreator = acc.getPrimary()
    result.merge(acc)

    measurement_updater = Trk__KalmanUpdator()
    result.addPublicTool(measurement_updater)  #FIXME

    kwargs.setdefault("ExtrapolationTool", extrapolator)
    kwargs.setdefault("RotCreatorTool", rotcreator)
    kwargs.setdefault("MeasurementUpdateTool", measurement_updater)
    kwargs.setdefault("StraightLine", False)
    kwargs.setdefault("OutlierCut", 3.0)
    kwargs.setdefault("GetMaterialFromTrack", False)
    kwargs.setdefault("RejectLargeNScat", True)

    # take propagator and navigator from the extrapolator
    kwargs.setdefault("PropagatorTool", extrapolator.Propagators[0])
    kwargs.setdefault("NavigatorTool", extrapolator.Navigator)

    fitter = Trk__GlobalChi2Fitter(name=name, **kwargs)
    result.setPrivateTools(fitter)
    # print fitter
    return result
Exemple #30
0
def FCAL3CalibCalculatorCfg(ConfigFlags, name="FCAL3CalibCalculator", **kwargs):
    result = ComponentAccumulator()
    kwargs.setdefault("FCALdeltaX",9.0*mm)
    kwargs.setdefault("FCALdeltaY",9.0*mm*math.sin(60*deg))
    kwargs.setdefault("FCALSampling",3)
    result.addService(LArG4__FCAL__LArFCALCalibCalculatorBase(name, **kwargs))
    return result