Difference: LHCbSoftwareTrainingPrinting (56 vs. 57)

Revision 572012-12-12 - JackWimberley

Line: 1 to 1
 
META TOPICPARENT name="LHCbSoftwareTutorials"
<!-- /ActionTrackerPlugin -->
<!-- Note to editors of this page: The following TWiki Variables are defined for this page: TUTORIALVERSION and DAVINCIVERSION -->
<!-- They correspond to the last version for which these instructions have been verified, and should be consistent with each other -->
<!-- To change their value, exit edit and go to "More topic actions" -> "Edit settings" -->
Line: 32 to 32
 
double m_jPsiMassWin;
  • Create the corresponding .cpp file
emacs src/MyFirstAlgorithm.cpp &
Changed:
<
<
  • In the class constructor, declare a name for the property, initialize it to a default value and document it
declareProperty( "MassWindow", <memberVariable> = <defaultValue>, "Documentation" );
>
>
  • In the class constructor, declare a property with a name by which the C++ variable can be accessed from Python, initialize it to a default value (pick something Gaudi uses units where MeV = 1); and document it
declareProperty( "MassWindow", m_jPsiMassWin = <defaultValue>, "The J/Psi mass window cut" );
 
  • Print the property's value twice, using two different units
Changed:
<
<
info() << "Mass window is " << value << " Units" << endmsg;
>
>
#include "GaudiKernel/SystemOfUnits.h"
...
// The following goes inside the initialize() method
info() << "Mass window: " << m_jPsiMassWin / Gaudi::Units::MeV << " MeV" << endmsg;
info() << "Mass window: " << m_jPsiMassWin / Gaudi::Units::GeV << " GeV" << endmsg;
 
  • Save both files and build a library with them. Recall that the cmt/requirements file sets build configuration choices such as this. There should be, by default, two lines
Changed:
<
<
...
library AnalysisTutorial ../src/*.cpp
...
apply_pattern component_library library=AnalysisTutorial
>
>
...
library AnalysisTutorial ../src/*.cpp
...
apply_pattern component_library library=AnalysisTutorial
 
Changed:
<
<
which set the build rule for the library named AnalysisTutorial and then tell cmt to build this as a component library. Running
>
>
which set the build rule for the library named AnalysisTutorial and then tell cmt to build this as a component library. Running
 
cmt make

in the cmt directory will then build this library.

Line: 76 to 76
 
myAlg.OutputLevel = DEBUG

Try any of the values VERBOSE, DEBUG, INFO, WARNING, ERROR

Changed:
<
<
  • Run two instances of your algorithm, with different values for the cut. Hint:
anAlg = SomeAlg("Alg1") #instantiates class SomeAlg with instance name "Alg1" and assigns it to python variable anAlg
>
>
  • Run two instances of your algorithm, with different values for the cut. You cannot simply create a second variable using the constructor MyFirstAlgorithm(), because then there will be two objects with different Python variable names but referring to C++ class instantiations with the same variable name (by default, MyFirstAlgorithm() makes an instantiation with the name "MyFirstAlgorithm"). Instead,
anAlg = MyFirstAlgorithm("Alg1") #instantiates class MyFirstAlgorithm with instance name "Alg1" and assigns it to python variable anAlg

Then you can add this to the list of algorithms to be run by changing the list of algorithms [myAlg] to [myAlg,anAlg].

 
  • A more detailed discussion of python configurables, including examples for configuring tools, can be found in the TupleToolsAndConfigurables FAQ.

Modify the job behaviour with StatusCode

 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback