Configure Your Analysis Algorithms

Last update: 01 Jul 2022 [History] [Edit]

Create a python directory in your area mkdir MyAnalysis/python, this will hold your scripts where you define the algorithms you wish to set up for your analysis.

Next we can make our sequence and configure our muons. Create a file in your python directory called MyMuonAnalysisAlgorithms.py. Create an empty algorithm sequence by adding the following:

from AnaAlgorithm.AlgSequence import AlgSequence
from AnaAlgorithm.DualUseConfig import createService

def makeSequence (dataType) :

    algSeq = AlgSequence()

    return algSeq

Every job with CP algorithms needs to have an algorithm loaded at the beginning of the sequence to handle the systematics loading/handling.

Add this algorithm just below where you created algSeq:

    # Set up the systematics loader/handler service:
    sysService = createService( 'CP::SystematicsSvc', 'SystematicsSvc', sequence = algSeq )
    sysService.sigmaRecommended = 1

This takes care of registering all the systematics to run on, so that subsequent algorithms can just pick it up (and don’t have to be configured for it one-by-one). Note that even if you have a large number of algorithms for various object types with a lot of different systematics, you will only ever need/have a single SystematicsSvc. The individual algorithms are smart enough that they will only run for systematics that actually affect them.

Now to add the muon analysis algorithm sequence. For this example we will be using a Medium working point for our muons. Under where you added the sysService

    # Include, and then set up the muon analysis algorithm sequence:
    from MuonAnalysisAlgorithms.MuonAnalysisSequence import makeMuonAnalysisSequence
    muonSequenceMedium = makeMuonAnalysisSequence( dataType, deepCopyOutput = True, shallowViewOutput = False,
                                                   workingPoint = 'Medium.NonIso', postfix = 'medium' )
    muonSequenceMedium.configure( inputName = 'Muons',
                                  outputName = 'AnalysisMuons_%SYS%' )

    # Add the sequence to the job:
    algSeq += muonSequenceMedium

While some details may still change at some point, this interface has been stable for a long time, and we don’t expect any big or frequent changes anymore. Essentially there are three parts to this:

  • The first two lines create the sequence of muon algorithms that we want to run. This contains the entire sequence as one block to make it easy for users to pick up just the basic processing of muons if they don’t have any special needs. At this point we haven’t decided yet how best to allow users to modify their sequence if they have special needs, but there are several options.

  • The next line is a special post-configuration step that applies some special post-processing for all algorithms working with one object type. Essentially this takes care of setting all the properties you can only set if you look at the entire algorithm sequence instead of just one algorithm at a time. Note in particular that this line defines the name of our output muon collection.

  • In the end there should be a for loop that adds the individual algorithms to the job we are running. We will set this up in the next part.

Don’t forget to add your python directory to your MyAnalysis/CMakeLists.txt so your job can find the modules

# Install files from the package:
atlas_install_python_modules( python/*.py ) # <------
atlas_install_joboptions( share/*_jobOptions.py )
atlas_install_scripts( share/*_eljob.py )

And finally, create a file MyAnalysis/python/__init__.py containing the following

# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration

__version__ = '1.0.0'