Creating and running our steering macro

Last update: 23 Jan 2020 [History] [Edit]

To actually run this Athena algorithm we need a configuration file describing how to use it, a so called job options file. While this isn’t exactly what happens (see main Athena tutorial), it is often quite helpful to think of this as a simple python file in which you create and configure all the C++ algorithms and tools that you will be using.

tip This is only needed when working in Athena, inside EventLoop this will not be used. As such if you know that you will never work in Athena you can leave this out (or add it later).

Create a new file called MyAnalysis/share/ You can really put this anywhere, but it is probably a good idea to keep it in your source area (which is in version control), probably even in your package. Fill this new file, MyAnalysis/share/, with the following:

#See: for more details about anything here

testFile = os.getenv("ALRB_TutorialData") + '/r9315/mc16_13TeV.410501.PowhegPythia8EvtGen_A14_ttbar_hdamp258p75_nonallhad.merge.AOD.e5458_s3126_r9364_r9315/AOD.11182705._000001.pool.root.1'

#override next line on command line with: --filesInput=XXX
jps.AthenaCommonFlags.FilesInput = [testFile] 

#Specify AccessMode (read mode) ... ClassAccess is good default for xAOD
jps.AthenaCommonFlags.AccessMode = "ClassAccess" 

# Create the algorithm's configuration.
from AnaAlgorithm.DualUseConfig import createAlgorithm
alg = createAlgorithm ( 'MyxAODAnalysis', 'AnalysisAlg' )

# later on we'll add some configuration options for our algorithm that go here

# Add our algorithm to the main alg sequence
athAlgSeq += alg

# limit the number of events (for testing purposes)
theApp.EvtMax = 500

# optional include for reducing printout from athena

Read over the comments carefully to understand what is happening. Notice that we will only run over the first 500 events (for testing purposes). Obviously if you were doing a real analysis you would want to remove that statement to run over all events in a sample.

tip The way of creating an algorithm we are showing you above is the dual-use way, i.e. it is the same in EventLoop and Athena. The traditional Athens-only way of creating the algorithm is to use:

alg = CfgMgr.MyxAODAnalysis('AnalysisAlg')

To make sure that the newly used file gets installed and can be found we need to recompile (we need to call cmake explicitly as we did create a new file):

cd ../build/
cmake ../source/

OK, now the big moment has come. Within your run directory execute your job options with athena:

cd ../run
athena MyAnalysis/


If your algorithm does not run, make sure that you have defined the environment variable ALRB_TutorialData, as explained here.

tip You can specify the number of events your job processes with the --evtMax option (-1, the default, means process all events):

athena MyAnalysis/ --evtMax=-1 

tip You can override the input files used with –filesInput option:

athena MyAnalysis/ --filesInput=another.file.root