Пример #1
0
def TileJetMonitoringConfig(flags, **kwargs):
    ''' Function to configure TileJetMonitorAlgorithm algorithm in the monitoring system.'''

    # Define one top-level monitoring algorithm. The new configuration
    # framework uses a component accumulator.
    from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
    result = ComponentAccumulator()

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

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

    from TileConditions.TileCablingSvcConfig import TileCablingSvcCfg
    result.merge(TileCablingSvcCfg(flags))

    from TileConditions.TileBadChannelsConfig import TileBadChanToolCfg
    badChanTool = result.popToolsAndMerge(TileBadChanToolCfg(flags))

    # The following class will make a sequence, configure algorithms, and link
    # them to GenericMonitoringTools
    from AthenaMonitoring import AthMonitorCfgHelper
    helper = AthMonitorCfgHelper(flags, 'TileMonitoring')

    # Adding an TileJetMonitorAlgorithm algorithm to the helper
    from AthenaConfiguration.ComponentFactory import CompFactory
    tileJetMonAlg = helper.addAlgorithm(CompFactory.TileJetMonitorAlgorithm,
                                        'TileJetMonAlg')

    tileJetMonAlg.TileBadChanTool = badChanTool
    tileJetMonAlg.TriggerChain = ''

    for k, v in kwargs.items():
        setattr(tileJetMonAlg, k, v)

    DoEnergyProfiles = kwargs.get(
        'DoEnergyProfiles',
        tileJetMonAlg._descriptors['DoEnergyProfiles'].default)

    Do1DHistograms = kwargs.get(
        'Do1DHistograms', tileJetMonAlg._descriptors['Do1DHistograms'].default)
    DoEnergyDiffHistograms = kwargs.get(
        'DoEnergyDiffHistograms',
        tileJetMonAlg._descriptors['DoEnergyDiffHistograms'].default)

    if flags.DQ.DataType not in ('heavyioncollisions', 'cosmics'):

        jvtTool = CompFactory.JetVertexTaggerTool()
        jetContainer = kwargs.get(
            'JetContainer', tileJetMonAlg._descriptors['JetContainer'].default)
        jvtTool.JetContainer = jetContainer
        tileJetMonAlg.JVT = jvtTool

        jetCleaningTool = CompFactory.JetCleaningTool()
        jetCleaningTool.CutLevel = "LooseBad"
        jetCleaningTool.DoUgly = False

        tileJetMonAlg.JetCleaningTool = jetCleaningTool
        result.addPublicTool(jetCleaningTool)

        jetPtMin = 20000
        jetTrackingEtaLimit = 2.4
        eventCleaningTool = CompFactory.ECUtils.EventCleaningTool()
        eventCleaningTool.JetCleaningTool = jetCleaningTool
        eventCleaningTool.PtCut = jetPtMin
        eventCleaningTool.EtaCut = jetTrackingEtaLimit
        eventCleaningTool.JvtDecorator = "passJvt"
        eventCleaningTool.OrDecorator = "passOR"
        eventCleaningTool.CleaningLevel = jetCleaningTool.CutLevel

        tileJetMonAlg.EventCleaningTool = eventCleaningTool
        tileJetMonAlg.JetTrackingEtaLimit = jetTrackingEtaLimit
        tileJetMonAlg.JetPtMin = jetPtMin

        tileJetMonAlg.DoEventCleaning = True
        tileJetMonAlg.DoJetCleaning = True

    else:

        tileJetMonAlg.DoEventCleaning = False
        tileJetMonAlg.DoJetCleaning = False

    # 1) Configure histogram with TileJetMonAlg algorithm execution time
    executeTimeGroup = helper.addGroup(tileJetMonAlg, 'TileJetMonExecuteTime',
                                       'Tile/')
    executeTimeGroup.defineHistogram(
        'TIME_execute',
        path='Jet',
        type='TH1F',
        title='Time for execute TileJetMonAlg algorithm;time [#mus]',
        xbins=300,
        xmin=0,
        xmax=300000)

    from TileMonitoring.TileMonitoringCfgHelper import addValueVsModuleAndChannelMaps, getPartitionName
    runNumber = flags.Input.RunNumber[0]

    # 2) Configure 2D histograms (profiles/maps) with Tile channel time vs module and channel per partion (DQ summary)
    channelTimeDQGroup = helper.addGroup(tileJetMonAlg, 'TileJetChanTimeDQ',
                                         'Tile/Jet/')
    addValueVsModuleAndChannelMaps(channelTimeDQGroup,
                                   name='tileJetChanTime',
                                   title='Average time with jets',
                                   path='DQ',
                                   type='TProfile2D',
                                   value='time',
                                   run=str(runNumber))

    gains = ['LG', 'HG']
    partitions = ['LBA', 'LBC', 'EBA', 'EBC']

    # 3a) Configure 1D histograms with Tile channel time per partition
    channelTimeGroup = helper.addGroup(tileJetMonAlg, 'TileJetChanTime',
                                       'Tile/Jet/ChanTime/')
    for partition in partitions:
        title = 'Partition ' + partition + ': Tile Channel Time;time [ns];N'
        name = 'channelTime' + partition
        path = partition
        channelTimeGroup.defineHistogram(name,
                                         title=title,
                                         path=path,
                                         type='TH1F',
                                         xbins=600,
                                         xmin=-30.0,
                                         xmax=30.0)

    # 3b) Configure 1D histograms with Tile channel time per partition for extended barrels without scintillators
    for partition in ['EBA', 'EBC']:
        title = 'Partition ' + partition + ': Tile Channel Time (without scintillators);time [ns];N'
        name = 'channelTime' + partition + '_NoScint'
        path = partition
        channelTimeGroup.defineHistogram(name,
                                         title=title,
                                         path=path,
                                         type='TH1F',
                                         xbins=600,
                                         xmin=-30.0,
                                         xmax=30.0)

    # Energy upper limits of the cell-time histograms
    energiesHG = [
        500, 1000, 2000, 4000, 6000, 8000, 10000, 13000, 16000, 20000
    ]
    energiesLG = [25000, 30000, 40000, 50000, 65000, 80000]
    energiesALL = {'LG': energiesLG, 'HG': energiesHG}
    tileJetMonAlg.CellEnergyUpperLimitsHG = energiesHG
    tileJetMonAlg.CellEnergyUpperLimitsLG = energiesLG

    # 4) Configure histograms with Tile cell time in energy slices per partition and gain
    cellTimeGroup = helper.addGroup(tileJetMonAlg, 'TileJetCellTime',
                                    'Tile/Jet/CellTime/')
    for partition in partitions:
        for gain in gains:
            index = 0
            energies = energiesALL[gain]
            for index in range(0, len(energies) + 1):
                toEnergy = energies[index] if index < len(energies) else None
                fromEnergy = energies[index - 1] if index > 0 else None
                name = 'Cell_time_' + partition + '_' + gain + '_slice_' + str(
                    index)
                title = 'Partition ' + partition + ': ' + gain + ' Tile Cell time in energy range'
                if not toEnergy:
                    title += ' > ' + str(fromEnergy) + ' MeV; time [ns]'
                elif not fromEnergy:
                    title += ' < ' + str(toEnergy) + ' MeV; time [ns]'
                else:
                    title += ' [' + str(fromEnergy) + ' .. ' + str(
                        toEnergy) + ') MeV; time [ns]'
                cellTimeGroup.defineHistogram(name,
                                              title=title,
                                              path=partition,
                                              type='TH1F',
                                              xbins=600,
                                              xmin=-30.0,
                                              xmax=30.0)

    if DoEnergyProfiles:

        # 5) Configure 1D histograms (profiles) with Tile cell energy profile in energy slices per partition and gain
        cellEnergyProfileGroup = helper.addGroup(tileJetMonAlg,
                                                 'TileJetCellEnergyProfile',
                                                 'Tile/Jet/CellTime/')
        for partition in partitions:
            for gain in gains:
                name = 'index_' + partition + '_' + gain
                name += ',energy_' + partition + '_' + gain
                name += ';Cell_ene_' + partition + '_' + gain + '_prof'
                title = 'Partition ' + partition + ': ' + gain + ' Tile Cell energy profile;Slice;Energy [MeV]'
                xmax = len(energiesALL[gain]) + 0.5
                nbins = len(energiesALL[gain]) + 1
                cellEnergyProfileGroup.defineHistogram(name,
                                                       title=title,
                                                       path=partition,
                                                       type='TProfile',
                                                       xbins=nbins,
                                                       xmin=-0.5,
                                                       xmax=xmax)

    else:

        # 6) Configure 1D histograms with Tile cell energy in energy slices per partition, gain and slice
        cellEnergyGroup = helper.addGroup(tileJetMonAlg, 'TileJetCellEnergy',
                                          'Tile/Jet/CellTime/')
        for partition in partitions:
            for gain in gains:
                energies = energiesALL[gain]
                for index in range(0, len(energies) + 1):
                    toEnergy = energies[index] if index < len(
                        energies) else 2 * energies[index - 1]
                    fromEnergy = energies[index - 1] if index > 0 else -1000
                    name = 'Cell_ene_' + partition + '_' + gain + '_slice_' + str(
                        index)
                    title = 'Partition ' + partition + ': ' + gain + ' Tile Cell Energy'
                    title += ' in energy range [' + str(
                        fromEnergy) + ' .. ' + str(
                            toEnergy) + ') MeV;Energy [MeV]'
                    cellEnergyGroup.defineHistogram(name,
                                                    title=title,
                                                    path=partition,
                                                    type='TH1F',
                                                    xbins=100,
                                                    xmin=fromEnergy,
                                                    xmax=toEnergy)

    from TileCalibBlobObjs.Classes import TileCalibUtils as Tile

    if Do1DHistograms:

        # 7) Configure 1D histograms with Tile channel time per channel
        channelTime1DGroup = helper.addGroup(tileJetMonAlg,
                                             'TileJetChanTime1D',
                                             'Tile/Jet/ChanTime/')

        for ros in range(1, Tile.MAX_ROS):
            for module in range(0, Tile.MAX_DRAWER):
                for channel in range(0, Tile.MAX_CHAN):
                    moduleName = Tile.getDrawerString(ros, module)
                    title = 'Time in ' + moduleName + ' channel ' + str(
                        channel) + ';time [ns];N'
                    name = moduleName + '_ch_' + str(channel) + '_1d'
                    path = getPartitionName(ros) + '/' + moduleName
                    channelTime1DGroup.defineHistogram(name,
                                                       title=title,
                                                       path=path,
                                                       type='TH1F',
                                                       xbins=600,
                                                       xmin=-30.0,
                                                       xmax=30.0)

    if DoEnergyDiffHistograms:

        # 7) Configure 1D histograms with Tile cell relative energy difference between two channels per even channel
        energyDiffGroup = helper.addGroup(tileJetMonAlg, 'TileJetEnergyDiff',
                                          'Tile/Jet/EnergyDiff/')

        for ros in range(1, Tile.MAX_ROS):
            for module in range(0, Tile.MAX_DRAWER):
                for channel in range(0, Tile.MAX_CHAN):
                    if not channel % 2:
                        for gain in gains:
                            moduleName = Tile.getDrawerString(ros, module)
                            title = 'Tile Cell Energy difference in ' + moduleName + ' channel ' + str(
                                channel) + ' ' + gain
                            title += ';#frac{ene1 - ene2}{ene1 + ene2}'
                            name = moduleName + '_enediff_' + gain + '_ch1_' + str(
                                channel)
                            path = getPartitionName(ros) + '/' + moduleName
                            energyDiffGroup.defineHistogram(name,
                                                            title=title,
                                                            path=path,
                                                            type='TH1F',
                                                            xbins=100,
                                                            xmin=-1.0,
                                                            xmax=1.0)

    accumalator = helper.result()
    result.merge(accumalator)
    return result
Пример #2
0
def METMonitoringConfig(inputFlags):
    # '''Function to configures some algorithms in the monitoring system.'''

    #    from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
    #    result = ComponentAccumulator()

    from AthenaMonitoring import AthMonitorCfgHelper
    #    helper = AthMonitorCfgHelper(inputFlags,'AthMonitorCfg')
    helper = AthMonitorCfgHelper(inputFlags, 'METMonitor')

    from AthenaConfiguration.ComponentFactory import CompFactory
    METRefFinal_MonAlg = helper.addAlgorithm(CompFactory.METMonitoringAlg,
                                             'METRefFinal_MonAlg')
    #    anotherExampleMonAlg = helper.addAlgorithm(METMonitoringExampleAlg,'AnotherExampleMonAlg')
    met_types = [
        "MET_RefFinal", "MET_RefJet", "MET_Muon", "MET_RefEle", "MET_RefGamma",
        "MET_RefTau", "MET_PVSoftTrk"
    ]

    METRefFinal_MonAlg.METContainer = "MET_Reference_AntiKt4EMTopo"
    METRefFinal_MonAlg.metKeys = met_types
    METRefFinal_MonAlg.alltrigger = True
    group = helper.addGroup(METRefFinal_MonAlg, "METMonitor",
                            "MissingEt/AllTriggers/MET_AntiKt4EMTopo/")

    for mets in met_types:
        defineHistograms(METRefFinal_MonAlg, group, helper, mets)

    if inputFlags.DQ.DataType != 'cosmics':
        METPflow_MonAlg = helper.addAlgorithm(CompFactory.METMonitoringAlg,
                                              'METPflow_MonAlg')
        pfmet_types = [
            "MET_PFlow", "MET_PFlow_RefJet", "MET_PFlow_Muon",
            "MET_PFlow_RefEle", "MET_PFlow_RefGamma", "MET_PFlow_RefTau",
            "MET_PFlow_PVSoftTrk"
        ]
        METPflow_MonAlg.METContainer = "MET_Reference_AntiKt4EMPFlow"
        METPflow_MonAlg.metKeys = pfmet_types
        METPflow_MonAlg.alltrigger = True

        group = helper.addGroup(METPflow_MonAlg, "METMonitor",
                                "MissingEt/AllTriggers/MET_AntiKt4EMPFlow/")
        for mets in pfmet_types:
            defineHistograms(METPflow_MonAlg, group, helper, mets)

    METEMTopo_MonAlg = helper.addAlgorithm(CompFactory.METMonitoringAlg,
                                           'METEMTopo_MonAlg')
    emtopomet_types = ["MET_Topo"]
    METEMTopo_MonAlg.METContainer = "MET_EMTopo"
    METEMTopo_MonAlg.metKeys = emtopomet_types
    METEMTopo_MonAlg.alltrigger = True

    group = helper.addGroup(METEMTopo_MonAlg, "METMonitor",
                            "MissingEt/AllTriggers/MET_Calo/EMTopo")
    for mets in emtopomet_types:
        defineHistograms(METEMTopo_MonAlg, group, helper, mets)

    METCalo_MonAlg = helper.addAlgorithm(CompFactory.METMonitoringAlg,
                                         'METCalo_MonAlg')
    metcalo_types = ["PEMB", "EMB", "PEME", "EME", "TILE", "HEC", "FCAL"]
    METCalo_MonAlg.METContainer = "MET_Calo"
    METCalo_MonAlg.METCaloKeys = metcalo_types
    METCalo_MonAlg.alltrigger = True

    group = helper.addGroup(METCalo_MonAlg, "METMonitor",
                            "MissingEt/AllTriggers/MET_Calo/MET_Cell")
    for mets in metcalo_types:
        defineHistogramsCalo(METCalo_MonAlg, group, helper, mets)
#trigger
    METRefFinal_XE30_MonAlg = helper.addAlgorithm(CompFactory.METMonitoringAlg,
                                                  'METRefFinal_XE30_MonAlg')
    METRefFinal_XE30_MonAlg.METContainer = "MET_Reference_AntiKt4EMTopo"
    METRefFinal_XE30_MonAlg.metTotalKey = "FinalTrk"
    METRefFinal_XE30_MonAlg.metKeys = met_types
    METRefFinal_XE30_MonAlg.dotrigger = True
    group = helper.addGroup(METRefFinal_XE30_MonAlg, "METMonitor",
                            "MissingEt/TrigXE30/MET_AntiKt4EMTopo/")
    for mets in met_types:
        defineHistograms(METRefFinal_XE30_MonAlg, group, helper, mets)

    if inputFlags.DQ.DataType != 'cosmics':
        METPflow_XE30_MonAlg = helper.addAlgorithm(
            CompFactory.METMonitoringAlg, 'METPflow_XE30_MonAlg')
        METPflow_XE30_MonAlg.METContainer = "MET_Reference_AntiKt4EMPFlow"
        METPflow_XE30_MonAlg.metTotalKey = "FinalTrk"
        METPflow_XE30_MonAlg.metKeys = pfmet_types
        METPflow_XE30_MonAlg.dotrigger = True
        group = helper.addGroup(METPflow_XE30_MonAlg, "METMonitor",
                                "MissingEt/TrigXE30/MET_AntiKt4EMPflow/")
        for mets in pfmet_types:
            defineHistograms(METPflow_XE30_MonAlg, group, helper, mets)

    METCalo_XE30_MonAlg = helper.addAlgorithm(CompFactory.METMonitoringAlg,
                                              'METCalo_XE30_MonAlg')
    METCalo_XE30_MonAlg.METCaloContainer = "MET_Calo"
    METCalo_XE30_MonAlg.METCaloKeys = metcalo_types
    METCalo_XE30_MonAlg.dotrigger = True
    group = helper.addGroup(METCalo_XE30_MonAlg, "METMonitor",
                            "MissingEt/TrigXE30/MET_Calo/MET_Cell")
    for mets in metcalo_types:
        defineHistogramsCalo(METCalo_XE30_MonAlg, group, helper, mets)

    METEMTopo_XE30_MonAlg = helper.addAlgorithm(CompFactory.METMonitoringAlg,
                                                'METEMTopo_XE30_MonAlg')
    METEMTopo_XE30_MonAlg.METContainer = "MET_EMTopo"
    METEMTopo_XE30_MonAlg.METAntiKt4EMTopoContainer = "MET_Reference_AntiKt4EMTopo"
    emtopomet_types = ["MET_Topo"]
    METEMTopo_XE30_MonAlg.metKeys = emtopomet_types
    METEMTopo_XE30_MonAlg.dotrigger = True
    METEMTopo_XE30_group = helper.addGroup(
        METEMTopo_XE30_MonAlg, "METMonitor",
        "MissingEt/TrigXE30/MET_Calo/EMTopo")
    for mets in emtopomet_types:
        defineHistograms(METEMTopo_XE30_MonAlg, METEMTopo_XE30_group, helper,
                         mets)

# metcut
    METRefFinal_METCut_MonAlg = helper.addAlgorithm(
        CompFactory.METMonitoringAlg, 'METRefFinal_METCut_MonAlg')
    METRefFinal_METCut_MonAlg.METContainer = "MET_Reference_AntiKt4EMTopo"
    METRefFinal_METCut_MonAlg.metTotalKey = "FinalTrk"
    METRefFinal_METCut_MonAlg.metKeys = met_types
    METRefFinal_METCut_MonAlg.dometcut = True
    METRefFinal_METCut_MonAlg.metcut = 80
    group = helper.addGroup(METRefFinal_METCut_MonAlg, "METMonitor",
                            "MissingEt/CutMet80/MET_AntiKt4EMTopo/")
    for mets in met_types:
        defineHistograms(METRefFinal_METCut_MonAlg, group, helper, mets)

    if inputFlags.DQ.DataType != 'cosmics':
        METPflow_METCut_MonAlg = helper.addAlgorithm(
            CompFactory.METMonitoringAlg, 'METPflow_METCut_MonAlg')
        METPflow_METCut_MonAlg.METContainer = "MET_Reference_AntiKt4EMPFlow"
        METPflow_METCut_MonAlg.metKeys = pfmet_types
        METPflow_METCut_MonAlg.dometcut = True
        METPflow_METCut_MonAlg.metcut = 80
        group = helper.addGroup(METPflow_METCut_MonAlg, "METMonitor",
                                "MissingEt/CutMet80/MET_AntiKt4EMPflow/")
        for mets in pfmet_types:
            defineHistograms(METPflow_METCut_MonAlg, group, helper, mets)

    METCalo_METCut_MonAlg = helper.addAlgorithm(CompFactory.METMonitoringAlg,
                                                'METCalo_METCut_MonAlg')
    metcalo_types = ["PEMB", "EMB", "PEME", "EME", "TILE", "HEC", "FCAL"]
    METCalo_METCut_MonAlg.METCaloContainer = "MET_Calo"
    METCalo_METCut_MonAlg.METCaloKeys = metcalo_types
    METCalo_METCut_MonAlg.dometcut = True
    METCalo_METCut_MonAlg.metcut = 80
    METCalo_METCut_group = helper.addGroup(
        METCalo_METCut_MonAlg, "METMonitor",
        "MissingEt/CutMet80/MET_Calo/MET_Cell")
    for mets in metcalo_types:
        defineHistogramsCalo(METCalo_METCut_MonAlg, METCalo_METCut_group,
                             helper, mets)

    METEMTopo_METCut_MonAlg = helper.addAlgorithm(CompFactory.METMonitoringAlg,
                                                  'METEMTopo_METCut_MonAlg')
    METEMTopo_METCut_MonAlg.METContainer = "MET_EMTopo"
    METEMTopo_METCut_MonAlg.METAntiKt4EMTopoContainer = "MET_Reference_AntiKt4EMTopo"
    emtopomet_types = ["MET_Topo"]
    METEMTopo_METCut_MonAlg.metKeys = emtopomet_types
    METEMTopo_METCut_MonAlg.dometcut = True
    METEMTopo_METCut_MonAlg.metcut = 80
    METEMTopo_METCut_group = helper.addGroup(
        METEMTopo_METCut_MonAlg, "METMonitor",
        "MissingEt/CutMet80/MET_Calo/EMTopo")
    for mets in emtopomet_types:
        defineHistograms(METEMTopo_METCut_MonAlg, METEMTopo_METCut_group,
                         helper, mets)
# Jet cleaning

    jetCleaningTool = CompFactory.JetCleaningTool()
    jetCleaningTool.CutLevel = "LooseBad"
    #    jetCleaningTool.CutLevel = "TightBad"
    jetCleaningTool.DoUgly = False

    JetCleaning_METMonAlg = helper.addAlgorithm(CompFactory.METMonitoringAlg,
                                                'JetCleaning_METMonAlg')
    JetCleaning_METMonAlg.metKeys = met_types
    JetCleaning_METMonAlg.DoJetCleaning = True
    JetCleaning_METMonAlg.JetCleaningTool = jetCleaningTool
    JetCleaningGroup = helper.addGroup(
        JetCleaning_METMonAlg, "METMonitor",
        "MissingEt/Jetcleaning/MET_AntiKt4EMTopo/")
    JetCleaning_METMonAlg.JetContainerName = "AntiKt4EMTopoJets"
    for mets in met_types:
        if mets == 'MET_PFlow_PVSoftTrk':
            JetCleaning_METMonAlg.JetContainerName = "AntiKt4EMPFlowJets"
        defineHistograms(JetCleaning_METMonAlg, JetCleaningGroup, helper, mets)

    if inputFlags.DQ.DataType != 'cosmics':
        PflowJetCleaning_METMonAlg = helper.addAlgorithm(
            CompFactory.METMonitoringAlg, 'PflowJetCleaning_METMonAlg')
        PflowJetCleaning_METMonAlg.METContainer = "MET_Reference_AntiKt4EMPFlow"
        PflowJetCleaning_METMonAlg.metKeys = pfmet_types
        PflowJetCleaning_METMonAlg.DoJetCleaning = True
        PflowJetCleaning_METMonAlg.JetCleaningTool = jetCleaningTool
        PflowJetCleaningGroup = helper.addGroup(
            PflowJetCleaning_METMonAlg, "METMonitor",
            "MissingEt/Jetcleaning/MET_AntiKt4EMPflow/")
        PflowJetCleaning_METMonAlg.JetContainerName = "AntiKt4EMPFlowJets"
        for mets in pfmet_types:
            defineHistograms(PflowJetCleaning_METMonAlg, PflowJetCleaningGroup,
                             helper, mets)

    METCaloJetCleaning_MonAlg = helper.addAlgorithm(
        CompFactory.METMonitoringAlg, 'METCaloJetCleaning_MonAlg')
    metcalo_types = ["PEMB", "EMB", "PEME", "EME", "TILE", "HEC", "FCAL"]
    METCaloJetCleaning_MonAlg.METCaloContainer = "MET_Calo"
    METCaloJetCleaning_MonAlg.METCaloKeys = metcalo_types
    METCaloJetCleaning_MonAlg.DoJetCleaning = True
    METCaloJetCleaning_MonAlg.JetCleaningTool = jetCleaningTool
    group = helper.addGroup(METCaloJetCleaning_MonAlg, "METMonitor",
                            "MissingEt/Jetcleaning/MET_Calo/MET_Cell")
    for mets in metcalo_types:
        defineHistogramsCalo(METCaloJetCleaning_MonAlg, group, helper, mets)

    METEMTopoJetCleaning_MonAlg = helper.addAlgorithm(
        CompFactory.METMonitoringAlg, 'METEMTopoJetCleaning_MonAlg')
    emtopomet_types = ["MET_Topo"]
    METEMTopoJetCleaning_MonAlg.METContainer = "MET_EMTopo"
    METEMTopoJetCleaning_MonAlg.metKeys = emtopomet_types
    METEMTopoJetCleaning_MonAlg.DoJetCleaning = True
    METEMTopoJetCleaning_MonAlg.JetCleaningTool = jetCleaningTool
    group = helper.addGroup(METEMTopoJetCleaning_MonAlg, "METMonitor",
                            "MissingEt/Jetcleaning/MET_Calo/EMTopo/")
    for mets in emtopomet_types:
        defineHistograms(METEMTopoJetCleaning_MonAlg, group, helper, mets)

    # Badjets

    jetCleaningTool.CutLevel = "LooseBad"
    #    jetCleaningTool.CutLevel = "TightBad"
    jetCleaningTool.DoUgly = False

    BadJets_METMonAlg = helper.addAlgorithm(CompFactory.METMonitoringAlg,
                                            'BadJets_METMonAlg')
    BadJets_METMonAlg.metKeys = met_types
    BadJets_METMonAlg.DoJetCleaning = True
    BadJets_METMonAlg.alltrigger = True
    BadJets_METMonAlg.DoBadJets = True
    BadJets_METMonAlg.JetCleaningTool = jetCleaningTool
    BadJets_METMonAlg.JetContainerName = "AntiKt4EMTopoJets"
    BadJetsGroup = helper.addGroup(
        BadJets_METMonAlg, "METMonitor",
        "MissingEt/AllTriggers/BadJets/MET_AntiKt4EMTopo")
    for mets in met_types:
        defineHistograms(BadJets_METMonAlg, BadJetsGroup, helper, mets)

    if inputFlags.DQ.DataType != 'cosmics':
        BadPFJets_METMonAlg = helper.addAlgorithm(CompFactory.METMonitoringAlg,
                                                  'BadPFJets_METMonAlg')
        BadPFJets_METMonAlg.METContainer = "MET_Reference_AntiKt4EMPFlow"
        BadPFJets_METMonAlg.metKeys = pfmet_types
        BadPFJets_METMonAlg.DoJetCleaning = True
        BadPFJets_METMonAlg.alltrigger = True
        BadPFJets_METMonAlg.DoBadJets = True
        BadPFJets_METMonAlg.JetCleaningTool = jetCleaningTool
        BadPFJets_METMonAlg.JetContainerName = "AntiKt4EMPFlowJets"
        BadPFJetsGroup = helper.addGroup(
            BadPFJets_METMonAlg, "METMonitor",
            "MissingEt/AllTriggers/BadJets/MET_AntiKt4EMPflow/")
        for mets in pfmet_types:
            defineHistograms(BadPFJets_METMonAlg, BadPFJetsGroup, helper, mets)

    BadJets_CaloMETMonAlg = helper.addAlgorithm(CompFactory.METMonitoringAlg,
                                                'BadJets_CaloMETMonAlg')
    metcalo_types = ["PEMB", "EMB", "PEME", "EME", "TILE", "HEC", "FCAL"]
    BadJets_CaloMETMonAlg.METCaloContainer = "MET_Calo"
    BadJets_CaloMETMonAlg.METCaloKeys = metcalo_types
    BadJets_CaloMETMonAlg.DoJetCleaning = True
    BadJets_CaloMETMonAlg.alltrigger = True
    BadJets_CaloMETMonAlg.DoBadJets = True
    BadJets_CaloMETMonAlg.JetContainerName = "AntiKt4EMTopoJets"
    BadJets_CaloMETMonAlg.JetCleaningTool = jetCleaningTool
    BadJetsGroup_CaloMETMonAlg = helper.addGroup(
        BadJets_CaloMETMonAlg, "METMonitor",
        "MissingEt/AllTriggers/BadJets/MET_Calo/MET_Cell")
    for mets in metcalo_types:
        defineHistogramsCalo(BadJets_CaloMETMonAlg, BadJetsGroup_CaloMETMonAlg,
                             helper, mets)

    BadJets_EMTopoMETMonAlg = helper.addAlgorithm(CompFactory.METMonitoringAlg,
                                                  'BadJets_EMTopoMETMonAlg')
    BadJets_EMTopoMETMonAlg.metKeys = emtopomet_types
    BadJets_EMTopoMETMonAlg.METContainer = "MET_EMTopo"
    BadJets_EMTopoMETMonAlg.DoJetCleaning = True
    BadJets_EMTopoMETMonAlg.alltrigger = True
    BadJets_EMTopoMETMonAlg.DoBadJets = True
    BadJets_EMTopoMETMonAlg.JetCleaningTool = jetCleaningTool
    BadJetsGroup = helper.addGroup(
        BadJets_EMTopoMETMonAlg, "METMonitor",
        "MissingEt/AllTriggers/BadJets/MET_Calo/EMTopo")
    for mets in emtopomet_types:
        defineHistograms(BadJets_EMTopoMETMonAlg, BadJetsGroup, helper, mets)
    return helper.result()