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.
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
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/ATestRun_jobOptions.py, with the following:
#See: https://twiki.cern.ch/twiki/bin/viewauth/AtlasComputing/SoftwareTutorialxAODAnalysisInCMake 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 include("AthAnalysisBaseComps/SuppressLogging.py")
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.
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/ make
OK, now the big moment has come. Within your
run directory execute
your job options with athena:
cd ../run athena MyAnalysis/ATestRun_jobOptions.py
If your algorithm does not run, make sure that you have defined the environment variable
ALRB_TutorialData, as explained here.
You can specify the number of events your job processes with the
--evtMaxoption (-1, the default, means process all events):
athena MyAnalysis/ATestRun_jobOptions.py --evtMax=-1
You can override the input files used with –filesInput option:
athena MyAnalysis/ATestRun_jobOptions.py --filesInput=another.file.root