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
std::string one. Do this by adding this near the end of your
algorithm class’s declaration, in its header:
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:
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:
std::vectorof the previous types.
AnaToolHandleif you use
AnaToolHandle::declarePropertyForto declare the property
The main purpose of algorithm properties is to be able to customize them during the configuration step. If you use the python configuration this is straightforward.
Go back to the
ATestRun_eljob.py macro (or
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 are using the C++ configuration instead, you would add these lines to your
alg.setProperty( "ElectronPtCut", 30000.0 ).ignore(); alg.setProperty( "SampleName", "Zee" ).ignore();
If you want, you can also directly specify the properties when you create the algorithms (in python).
For EventLoop that is:
alg = AnaAlgorithmConfig( 'MyxAODAnalysis/AnalysisAlg', ElectronPtCut = 30000.0, SampleName = 'Zee' )
For Athena that is:
alg = CfgMgr.MyxAODAnalysis( 'AnalysisAlg', ElectronPtCut = 30000.0, SampleName = 'Zee' )
EL::AnaAlgorithm base class declares some properties of its
own. The most important ones that you should be aware of are:
VERBOSEmessages for an algorithm, or to possibly turn off its
INFOmessages, if you don’t want to see those. You should set it either from simple integers (
DEBUG, etc.), using the
ROOT.MSG.DEBUG, etc. values (in EventLoop jobs), or using the
DEBUG, etc. variables (in Athena jobs).