Properties are handled with analysis algorithms in the same way in which they are handled in Athena/Gaudi.
declareProperty(...)
in the constructor of your algorithm
to declare this property to the framework;In the C++ code, declare two simple properties for now. A float
and
an std::string
one. Do this by adding this near the end of your
algorithm class’s declaration, in its header (MyxAODAnalysis.h
):
private:
/// Electron pT cut
double m_electronPtCut;
/// Sample name
std::string m_sampleName;
The names of the properties are just meant to give you an idea of what sort of things one would usually set up as a property on an algorithm. Don’t take these examples too seriously.
Now, add the following to the constructor of your algorithm to declare
these properties (MyxAODAnalysis.cxx
):
declareProperty( "ElectronPtCut", m_electronPtCut = 25000.0,
"Minimum electron pT (in MeV)" );
declareProperty( "SampleName", m_sampleName = "Unknown",
"Descriptive name for the processed sample" );
And to be able to double-check later on that we can modify these properties,
print their values in the initialize()
function with code like this:
ANA_MSG_INFO( "ElectronPtCut = " << m_electronPtCut );
ANA_MSG_INFO( "SampleName = " << m_sampleName );
There are a finite number of types supported as algorithm properties. In general try to use as simple properties as possible. The current list of supported types is:
double
;int
;std::string
;std::vector
of the previous types.ToolHandle
AnaToolHandle
if you useAnaToolHandle::declarePropertyFor
to declare the property
The main purpose of algorithm properties is to be able to customize them during the configuration step. Using the python configuration this is straightforward.
Go back to the ATestRun_eljob.py
macro (or ATestRun_jobOptions.py
in Athena) that you created earlier. In it you
create an algorithm object called alg
. You can set properties on
that object with:
alg.ElectronPtCut = 30000.0
alg.SampleName = 'Zee'
If you want, you can also directly specify the properties when you create the algorithms (in python).
For EventLoop that is:
from AnaAlgorithm.AnaAlgorithmConfig import AnaAlgorithmConfig
alg = AnaAlgorithmConfig( 'MyxAODAnalysis/AnalysisAlg',
ElectronPtCut = 30000.0,
SampleName = 'Zee' )
For Athena that is:
import AthenaCommon.CfgMgr as CfgMgr
alg = CfgMgr.MyxAODAnalysis( 'AnalysisAlg',
ElectronPtCut = 30000.0,
SampleName = 'Zee' )
The EL::AnaAlgorithm
base class declares some properties of its
own. The most important ones that you should be aware of are:
DEBUG
/
VERBOSE
messages for an algorithm, or to possibly turn off its
INFO
messages, if you don’t want to see those. You should set it
either from simple integers (1
: VERBOSE
, 2
: DEBUG
, etc.),
using the ROOT.MSG.VERBOSE
, ROOT.MSG.DEBUG
, etc. values (in
EventLoop jobs), or using the VERBOSE
, DEBUG
, etc. variables
(in Athena jobs).Make a property for your algorithm called JetPtCut and set it to 20,000 MeV.