User Tools

Site Tools


gaudi:declareproperty

declareProperty

Idea

In your python options file, you may want to pass values to a certain used C++ class (e.g. in DaVinci in the TupleToolMCTruth you may want to switch on the association by Chi2 or not).

Example

The following example treats the case, if you want to pass a string to your C++ class (to save output, for instance).

Additions to your .h-file

In the .h-file of your class, add:

private:
  std::string m_outputName;

Of course, it does not necessarily need to be private.

Additions to your .cpp-file

In the constructor, add:

declareProperty( "OutputName", m_outputName = "defaultOutputName");

The first argument defines the name in the python options file, the second argument sets the variable to a default value, if there is no input from the python options file.

In the initialize() add (for example):

fstream out = new fstream(m_outputName, ios::out);

Note: Only add the declareProperty in the constructor, but don't do anything with the variable, it won't work (at least considering my experience…)

Additions to your python options file

To your instance of your class, add:

myInstance.OutputName = "myOutputName.txt"
gaudi/declareproperty.txt · Last modified: 2009/01/28 15:27 by decianm