コード例 #1
0
def AddIteration(seed_container, shape_name, **kwargs):

    out_shape_name = shape_name
    if 'suffix' in kwargs.keys(): out_shape_name += '_%s' % kwargs['suffix']
    mod_shape_key = out_shape_name + '_Modulate'
    remodulate = True
    if 'remodulate' in kwargs.keys():
        if not kwargs['remodulate']:
            mod_tool = GetNullModulator()
            remodulate = False

    if remodulate:
        if 'modulator' in kwargs.keys(): mod_tool = kwargs['modulator']
        else:
            #mod_shape_name=BuildHarmonicName(out_shape_name,**kwargs)
            mod_tool = MakeModulatorTool(mod_shape_key, **kwargs)

    if 'map_tool' in kwargs.keys(): map_tool = kwargs['map_tool']
    else:
        from HIEventUtils.HIEventUtilsConf import HIEventShapeMapTool
        map_tool = HIEventShapeMapTool()

    assoc_name = jtm.HIJetDRAssociation.AssociationName
    HIEventShapeJetIteration = CompFactory.HIEventShapeJetIteration
    iter_tool = HIEventShapeJetIteration('HIJetIteration_%s' % out_shape_name)

    iter_tool.InputEventShapeKey = shape_name
    iter_tool.OutputEventShapeKey = out_shape_name
    iter_tool.AssociationKey = assoc_name
    iter_tool.CaloJetSeedContainerKey = seed_container
    iter_tool.Subtractor = GetSubtractorTool(**kwargs)
    iter_tool.ModulationScheme = HIJetFlags.ModulationScheme()
    iter_tool.RemodulateUE = HIJetFlags.Remodulate()
    iter_tool.Modulator = mod_tool
    iter_tool.ShallowCopy = False
    iter_tool.ModulationEventShapeKey = mod_shape_key
    iter_tool.EventShapeMapTool = map_tool

    if 'track_jet_seeds' in kwargs.keys():
        iter_tool.TrackJetSeedContainerKey = kwargs['track_jet_seeds']
    jtm.add(iter_tool)
    jtm.jetrecs += [iter_tool]
    jtm.HIJetRecs += [iter_tool]
    return iter_tool
コード例 #2
0
    def configure(self):
        from CaloRec.CaloRecConf import CaloCellMaker
        cellMaker = CaloCellMaker("HICaloCellCopier",CaloCellsOutputName="SubtractedCells",OwnPolicy = 0)
        from CaloRec.CaloRecConf import CaloCellFastCopyTool
        cellCopyTool = CaloCellFastCopyTool("HICellCopyTool")
        cellCopyTool.InputName ="AllCalo"
        cellCopyTool.IncludeSamplings = [ "PreSamplerB", "EMB1", "EMB2", "EMB3",
                                          "PreSamplerE", "EME1", "EME2", "EME3",
                                          "HEC0", "HEC1", "HEC2", "HEC3",
                                          "TileBar0", "TileBar1", "TileBar2",
                                          "TileGap1", "TileGap2", "TileGap3",
                                          "TileExt0", "TileExt1", "TileExt2",
                                          "FCal1", "FCal2", "FCal3" ]

        from AthenaCommon.AppMgr import ToolSvc
        ToolSvc += cellCopyTool

        from HIJetRec.HIJetRecConf import HISubtractedCellMakerTool
        cellSubtrTool=HISubtractedCellMakerTool()
        from HIJetRec.HIJetRecFlags import HIJetFlags
        cellSubtrTool.EventShapeKey=HIJetFlags.IteratedEventShapeKey()
        from HIJetRec.HIJetRecTools import jtm
        cellSubtrTool.Modulator=jtm.modulator
        from HIEventUtils.HIEventUtilsConf import HIEventShapeMapTool
        theMapTool=HIEventShapeMapTool()
        cellSubtrTool.EventShapeMapTool=theMapTool
        ToolSvc += cellSubtrTool

        from CaloRec.CaloRecConf import CaloCellContainerFinalizerTool
        cellFinalizerTool = CaloCellContainerFinalizerTool("HICaloCellFinalizerTool")
        ToolSvc += cellFinalizerTool

        cellMaker.CaloCellMakerToolNames = [cellCopyTool,cellSubtrTool,cellFinalizerTool]
        from AthenaCommon.AlgSequence import AlgSequence
        topSequence = AlgSequence()
        topSequence+=cellMaker
        
        return True
コード例 #3
0
def MakeSubtractionTool(shapeKey, moment_name='', momentOnly=False, **kwargs):
    HIJetConstituentSubtractionTool = CompFactory.HIJetConstituentSubtractionTool
    suffix = shapeKey
    if momentOnly: suffix += '_' + moment_name

    if 'modulator' in kwargs.keys(): mod_tool = kwargs['modulator']
    else: mod_tool = GetNullModulator()

    if 'map_tool' in kwargs.keys(): map_tool = kwargs['map_tool']
    else:
        from HIEventUtils.HIEventUtilsConf import HIEventShapeMapTool
        map_tool = HIEventShapeMapTool()

    subtr = HIJetConstituentSubtractionTool("HICS_" + suffix)
    subtr.EventShapeKey = shapeKey
    subtr.Modulator = mod_tool
    subtr.MomentName = 'JetSubtractedScale%sMomentum' % moment_name
    subtr.SetMomentOnly = momentOnly
    subtr.ApplyOriginCorrection = HIJetFlags.ApplyOriginCorrection()
    subtr.Subtractor = GetSubtractorTool(**kwargs)
    subtr.EventShapeMapTool = map_tool

    jtm.add(subtr)
    return subtr
コード例 #4
0
def _getHIJetBuildTool(merge_param,
                       ptmin=20000.,
                       ptminFilter=20000.,
                       jet_calib='jes',
                       cluster_calib='EM',
                       hicluster_name='HICluster',
                       name=''):

    global jtm

    msg = 'Naming convention breaks with merge param %d' % merge_param
    int_merge_param = int(10 * merge_param)
    assert 10 * merge_param == int_merge_param, msg
    assert merge_param > 0.

    if not name:
        name = 'TrigAntiKt%dHIJets' % int_merge_param

    EventShapeKey = "HLT_xAOD__HIEventShapeContainer_TrigHIEventShape"
    ClusterKey = hicluster_name

    # Plug in directly tools from HIJetTools.py e.g. to avoid PseudoJetGetter which is different at HLT and for other reasons
    # -------------------------------------------------------------------------------------------------------------------------

    #jet filters
    from JetRec.JetRecConf import JetFilterTool
    jetfil5 = JetFilterTool("HLT_a" + str(int_merge_param) + "jetfil5",
                            PtMin=5000)
    jtm.add(jetfil5)
    jetfil8 = JetFilterTool("HLT_a" + str(int_merge_param) + "jetfil8",
                            PtMin=8000)
    jtm.add(jetfil8)
    jetfil20 = JetFilterTool("HLT_a" + str(int_merge_param) + "jetfil20",
                             PtMin=20000)
    jtm.add(jetfil20)

    #DR association- form element links for all clusters w/in DR of each jet
    #    DR=HIJetFlags.ClusterDRAssociation()
    #    from HIJetRec.HIJetRecConf import HIJetDRAssociationTool
    #    assoc=HIJetDRAssociationTool("HLT_a"+str(int_merge_param)+"HIJetDRAssociation")
    #    assoc.ContainerKey=ClusterKey
    #    assoc.DeltaR=DR
    #    #assoc.AssociationName="%s_DR%dAssoc" % (ClusterKey,int(10*DR))
    #    assoc.AssociationName="HLT_a"+str(int_merge_param)+"HIClDR%dAssoc" % (int(10*DR))
    #    #assoc.AssociationName="GhostTrack"
    #    jtm.add(assoc)
    #
    #    assoc_name=assoc.AssociationName

    #calculate discriminants as moments
    from HIJetRec.HIJetRecConf import HIJetMaxOverMeanTool
    max_over_mean = HIJetMaxOverMeanTool("HLT_a" + str(int_merge_param) +
                                         "HIJetMaxOverMean")
    jtm.add(max_over_mean)

    #discriminants for jet filtering
    from HIJetRec.HIJetRecConf import HIJetDiscriminatorTool
    discrim = HIJetDiscriminatorTool("HLT_a" + str(int_merge_param) +
                                     "HIJetDiscriminator")
    discrim.MaxOverMeanCut = HIJetFlags.DCutMaxOverMean()
    discrim.MinimumETMaxCut = HIJetFlags.DCutMax()
    jtm.add(discrim)
    #jtm.trigjetrecs += [discr]

    #null modulator
    #tname="HLT_a"+str(int_merge_param)+"NullUEModulator"
    #if hasattr(jtm,tname) : return getattr(jtm,tname)
    from HIJetRec.HIJetRecConf import HIUEModulatorTool
    mod_tool = HIUEModulatorTool("HLT_a" + str(int_merge_param) +
                                 "NullUEModulator")
    mod_tool.EventShapeKey = 'NULL'
    for n in [2, 3, 4]:
        setattr(mod_tool, 'DoV%d' % n, False)
    jtm.add(mod_tool)

    # subtraction
    from HIJetRec.HIJetRecConf import HIJetCellSubtractorTool
    cell_subtr = HIJetCellSubtractorTool("HLT_a" + str(int_merge_param) +
                                         "HIJetSubtractor")
    jtm.add(cell_subtr)

    # calibration
    from JetCalibTools.JetCalibToolsConf import JetCalibrationTool
    #calib_tool=JetCalibrationTool("HLT_a"+str(int_merge_param)+"HICalibTool",JetCollection="AntiKt4TopoEM",ConfigFile="JES_Full2012dataset_Preliminary_Jan13.config",CalibSequence="AbsoluteEtaJES")
    #calib_tool=JetCalibrationTool("HLT_a"+str(int_merge_param)+"HICalibTool",JetCollection="AntiKt4EMTopo",ConfigFile="JES_Full2012dataset_May2014.config",CalibSequence="JetArea_Residual_Origin_EtaJES_GSC",IsData=False)
    #calib_tool=JetCalibrationTool("HLT_a"+str(int_merge_param)+"HICalibTool",JetCollection="AntiKt4EMTopo",ConfigFile="JES_MC15Prerecommendation_April2015.config",CalibSequence="EtaJES", IsData=False)
    calib_tool = JetCalibrationTool(
        "HLT_a" + str(int_merge_param) + "HICalibTool",
        JetCollection="AntiKt4EMTopo",
        ConfigFile="JES_Full2012dataset_Preliminary_Jan13.config",
        CalibSequence="AbsoluteEtaJES",
        IsData=False)

    jtm.add(calib_tool)

    from TrigHLTJetRec.TrigHLTJetRecConfig import _getTriggerPseudoJetGetter

    # -------------------------------------------------------------------------------------------------

    a2_unsubtracted_name = "TrigAntiKt2HIJets_Unsubtracted_a" + str(
        int_merge_param)
    seed_finder = jtm.addJetFinder(
        a2_unsubtracted_name,
        "AntiKt",
        0.2,
        gettersin=[_getTriggerPseudoJetGetter(cluster_calib)],
        #modifiersin=[assoc,max_over_mean,jetfil5], # jtm.modifiersMap['HI_Unsubtr'],	# may think about TrigHI_Unsubtracted with just max_over_mean
        modifiersin=[
            max_over_mean, jetfil5
        ],  # jtm.modifiersMap['HI_Unsubtr'],	# may think about TrigHI_Unsubtracted with just max_over_mean
        #modifiersin=[assoc,max_over_mean,jetfil5,discrim], # jtm.modifiersMap['HI_Unsubtr'],	# may think about TrigHI_Unsubtracted with just max_over_mean
        ghostArea=0.0,
        isTrigger=True,
        ptmin=5000,
        ptminFilter=5000)

    seeds0_name = "TrigAntiKt2HIJets_seeds0_a" + str(int_merge_param)
    seeds0 = jtm.addJetCopier(seeds0_name,
                              a2_unsubtracted_name, [discrim],
                              isTrigger=True,
                              shallow=False)
    #seeds0 = seed_finder

    #from HIJetRec.HIJetRecConf import HIEventShapeJetIterationHLT
    from TrigHIRec.TrigHIRecConf import TrigHIEventShapeJetIteration
    iter0_name = "a" + str(int_merge_param) + "iter0"
    iter0 = TrigHIEventShapeJetIteration(iter0_name)
    iter0.InputEventShapeKey = EventShapeKey
    iter0.OutputEventShapeKey = EventShapeKey + "_" + iter0_name
    #iter0.AssociationKey=assoc_name
    iter0.InputClustersKey = ClusterKey
    #iter0.SeedContainerKeys=[seeds0.OutputContainer]
    iter0.SeedContainerKey = seeds0.OutputContainer
    #if not hasattr(jtm,"HLT_a"+str(int_merge_param)+"HIJetSubtractor") :
    #    from HIJetRec.HIJetRecConf import HIJetCellSubtractorTool
    #    cell_subtr=HIJetCellSubtractorTool("HLT_a"+str(int_merge_param)+"HIJetSubtractor")
    #    jtm.add(cell_subtr)
    #iter0.Subtractor=jtm.HIJetSubtractor
    iter0.Subtractor = cell_subtr
    from HIEventUtils.HIEventUtilsConf import HIEventShapeMapTool
    iter0.EventShapeMapTool = HIEventShapeMapTool()
    jtm.add(iter0)
    jtm.jetrecs += [iter0]

    #subtr1=MakeSubtractionTool(iter0.OutputEventShapeKey,moment_name="subtr1")
    from HIJetRec.HIJetRecConf import HIJetConstituentSubtractionTool
    subtr1 = HIJetConstituentSubtractionTool("HIConstituentSubtractor_%s" %
                                             iter0.OutputEventShapeKey)
    subtr1.EventShapeKey = iter0.OutputEventShapeKey
    subtr1.SetMomentOnly = False
    subtr1.MomentName = "JetSubtractedScaleMomentum"  #"subtr1"
    #subtr1.Subtractor=jtm.HIJetSubtractor
    subtr1.Subtractor = cell_subtr
    subtr1.Modulator = mod_tool
    jtm.add(subtr1)

    seeds1_name = "TrigAntiKt2HIJets_seeds1_a" + str(int_merge_param)
    seeds1 = jtm.addJetCopier(seeds1_name,
                              a2_unsubtracted_name,
                              [subtr1, calib_tool, jetfil8],
                              isTrigger=True,
                              shallow=False)  #add calib tool

    iter1_name = "a" + str(int_merge_param) + "iter1"
    iter1 = TrigHIEventShapeJetIteration(iter1_name)
    iter1.InputEventShapeKey = EventShapeKey
    iter1.OutputEventShapeKey = EventShapeKey + "_" + iter1_name
    #iter1.AssociationKey=assoc_name
    iter1.InputClustersKey = ClusterKey
    #iter1.SeedContainerKeys=[seeds1.OutputContainer]
    iter1.SeedContainerKey = seeds1.OutputContainer
    #iter1.Subtractor=jtm.HIJetSubtractor
    iter1.Subtractor = cell_subtr
    #iter1.ModulationScheme=1;
    #iter1.RemodulateUE=remodulate
    #iter1.Modulator=mod_tool
    #iter1.ModulationEventShapeKey=mod_tool.EventShapeKey
    jtm.add(iter1)
    jtm.jetrecs += [iter1]

    #subtr2=MakeSubtractionTool(iter1.OutputEventShapeKey,moment_name="subtr2")
    from HIJetRec.HIJetRecConf import HIJetConstituentSubtractionTool
    subtr2 = HIJetConstituentSubtractionTool("HIConstituentSubtractor_%s" %
                                             iter1.OutputEventShapeKey)
    subtr2.EventShapeKey = iter1.OutputEventShapeKey
    subtr2.MomentName = "JetSubtractedScaleMomentum"
    subtr2.SetMomentOnly = False
    #subtr2.Subtractor=jtm.HIJetSubtractor
    subtr2.Subtractor = cell_subtr
    subtr2.Modulator = mod_tool
    jtm.add(subtr2)

    finder = jtm.addJetFinder(
        name + "_finder",
        "AntiKt",
        merge_param,
        gettersin=[_getTriggerPseudoJetGetter(cluster_calib)],
        modifiersin=[subtr2, calib_tool],
        ghostArea=0.0,
        rndseed=0,
        isTrigger=True,
        ptmin=ptmin,
        ptminFilter=ptminFilter)

    exe_tools = [seed_finder, seeds0, iter0, seeds1, iter1, finder]
    from JetRec.JetRecConf import JetToolRunner
    runner = JetToolRunner("jetrunHI_a" + str(int_merge_param),
                           Tools=exe_tools)
    jtm.add(runner)

    builder = jtm.addJetCopier(name,
                               name + "_finder", [],
                               isTrigger=True,
                               shallow=False)
    builder.unlock()
    builder.InputTool = runner
    builder.lock()

    jetBuildTool = builder

    ## we could also add to hi_modifiers the calibration as defined below:

    #_is_calibration_supported(int_merge_param, jet_calib, cluster_calib)

    # # tell the offline code which calibration is requested
    #calib_str = {'jes': 'calib:j:triggerNoPileup:HLTKt4',
    #             'subjes': 'calib:aj:trigger:HLTKt4',
    #             'sub': 'calib:a:trigger:HLTKt4'}.get(jet_calib, '')

    #myMods = [calib_str] if calib_str else []

    return jetBuildTool
コード例 #5
0
theSubtrTool = jtm.HIJetClusterSubtractor
theSubtrTool.unlock()
theSubtrTool.UseSamplings = False
theSubtrTool.lock()

if is_mc_or_overlay:
    for theCalibTool in jtm.HICalibMap.values():
        theCalibTool.unlock()
        theCalibTool.IsData = False
        theCalibTool.CalibSequence = 'EtaJES'
        theCalibTool.lock()

#Import the map tool - it will have to harvest configuration along the path
from HIEventUtils.HIEventUtilsConf import HIEventShapeMapTool
theMapTool = HIEventShapeMapTool()

if not HIJetFlags.DoCellBasedSubtraction():
    #Make new event shape at tower level
    from HIGlobal.HIGlobalConf import HIEventShapeMaker
    from HIGlobal.HIGlobalConf import HIEventShapeFillerTool
    #EventShapeKey set to point to weighted container, can remove code on L16
    EventShapeKey = jobproperties.HIGlobalFlags.EventShapeKey() + 'Weighted'

    ESAlg_W = HIEventShapeMaker("ESAlg_W")
    ESAlg_W.OutputContainerKey = EventShapeKey
    ESAlg_W.UseCaloCell = False
    ESAlg_W.InputTowerKey = "HIClusters"

    #Hack needed because ES algorithm requires a summary tool, this disables it
    from HIEventUtils.HIEventUtilsConf import HIEventShapeSummaryTool
コード例 #6
0
def ApplySubtractionToClusters(**kwargs):
    if 'event_shape_key' in kwargs.keys():
        event_shape_key = kwargs['event_shape_key']
    else:
        from HIGlobal.HIGlobalFlags import jobproperties
        event_shape_key = jobproperties.HIGlobalFlags.EventShapeKey()

    if 'cluster_key' in kwargs.keys(): cluster_key = kwargs['cluster_key']
    else: cluster_key = HIJetFlags.HIClusterKey()

    if 'output_cluster_key' in kwargs.keys():
        output_cluster_key = kwargs['output_cluster_key']
    else:
        cluster_key = cluster_key + ".deepCopy"

    if 'modulator' in kwargs.keys(): mod_tool = kwargs['modulator']
    else: mod_tool = GetNullModulator()

    if 'map_tool' in kwargs.keys(): map_tool = kwargs['map_tool']
    else:
        from HIEventUtils.HIEventUtilsConf import HIEventShapeMapTool
        map_tool = HIEventShapeMapTool()

    if 'update_only' in kwargs.keys(): update_only = kwargs['update_only']
    else: update_only = False

    if 'apply_origin_correction' in kwargs.keys():
        apply_origin_correction = kwargs['apply_origin_correction']
    else:
        apply_origin_correction = HIJetFlags.ApplyOriginCorrection()

    do_cluster_moments = False
    if 'CalculateMoments' in kwargs.keys():
        do_cluster_moments = kwargs['CalculateMoments']

    HIClusterSubtraction = CompFactory.HIClusterSubtraction
    toolName = 'HIClusterSubtraction'
    if 'name' in kwargs.keys(): toolName = kwargs['name']

    theAlg = HIClusterSubtraction(toolName)
    theAlg.ClusterKey = cluster_key
    theAlg.OutClusterKey = output_cluster_key
    theAlg.EventShapeKey = event_shape_key
    theAlg.Subtractor = GetSubtractorTool(**kwargs)
    theAlg.Modulator = mod_tool
    theAlg.UpdateOnly = update_only
    theAlg.SetMoments = do_cluster_moments
    theAlg.ApplyOriginCorrection = apply_origin_correction
    theAlg.EventShapeMapTool = map_tool

    if do_cluster_moments:
        CaloClusterMomentsMaker = CompFactory.CaloClusterMomentsMaker
        from CaloTools.CaloNoiseToolDefault import CaloNoiseToolDefault
        theCaloNoiseTool = CaloNoiseToolDefault()
        from AthenaCommon.AppMgr import ToolSvc
        ToolSvc += theCaloNoiseTool

        HIClusterMoments = CaloClusterMomentsMaker("HIClusterMoments")
        #HIClusterMoments.MaxAxisAngle = 20*deg
        #HIClusterMoments.CaloNoiseTool = theCaloNoiseTool
        #HIClusterMoments.UsePileUpNoise = False
        HIClusterMoments.MinBadLArQuality = 4000
        HIClusterMoments.MomentsNames = [
            "CENTER_MAG", "LONGITUDINAL", "FIRST_ENG_DENS", "SECOND_ENG_DENS",
            "ENG_FRAC_EM", "ENG_FRAC_MAX", "ENG_FRAC_CORE", "ENG_BAD_CELLS",
            "N_BAD_CELLS", "N_BAD_CELLS_CORR", "BAD_CELLS_CORR_E",
            "BADLARQ_FRAC", "ENG_POS", "SIGNIFICANCE", "CELL_SIGNIFICANCE",
            "CELL_SIG_SAMPLING", "AVG_LAR_Q", "AVG_TILE_Q"
        ]

        from IOVDbSvc.CondDB import conddb
        if not conddb.isOnline:
            #            from LArRecUtils.LArHVScaleRetrieverDefault import LArHVScaleRetrieverDefault
            #            HIClusterMoments.LArHVScaleRetriever=LArHVScaleRetrieverDefault()
            HIClusterMoments.MomentsNames += [
                "ENG_BAD_HV_CELLS", "N_BAD_HV_CELLS"
            ]

        theAlg.ClusterCorrectionTools = [HIClusterMoments]

    jtm.add(theAlg)
    jtm.jetrecs += [theAlg]
    jtm.HIJetRecs += [theAlg]