Difference between revisions of "FinalExercise"

From Atlas Wiki
Jump to navigation Jump to search
Line 40: Line 40:
 
  7 log << MSG::INFO << "position = (" << position.x() << ", "  
 
  7 log << MSG::INFO << "position = (" << position.x() << ", "  
 
                                       << position.y() << ", "
 
                                       << position.y() << ", "
                                       << position.z() << ", " << endreq;
+
                                       << position.z() << ", )" << endreq;
 
  8 return StatusCode::SUCCESS;
 
  8 return StatusCode::SUCCESS;
 
</pre>
 
</pre>

Revision as of 14:39, 30 October 2006

Introduction

The goal of this exercise is to combine the skills needed for the previous exercises into one final assignment. After finishing this assignment, you've shown that you're able to create your own Tool, to use an Algorithm and configure it with jobOptions. You're skilled in using the important services such as messageSvc, toolSvc and storeGateSvc. Undefinately you are now an expert in using LXR and CVSview and you understand the structure of packages. Not bad!

Up till now

If you've modified ExampleAlg as explained in the previous exercise, ExampleAlg now has acces to DummyTracks which are stored in the collection DummyTrackCollection. This will be our starting point. A logical way to proceed is:

  • modify the IToolExample such that it has a method able to handle DummyTracks.
  • modify the ToolExample accordingly.
  • copy the ToolExample into another class ToolExampleSimple (don't forget to make the factory too).
  • create a new property for the ExampleAlg (in both the jobOptions and class).
  • implement the two ToolExample's method.

IToolExample

The IToolExample must have a method taking a DummyTrack to process, since the concrete implementations of the ToolExample(s) will have the method too. The IToolExample will have the following lines added:

 1 class DummyTrack;
 2 class IToolExample : virtual public IAlgTool {
      ...
 3    virtual StatusCode handleTrack(const DummyTrack* track) const = 0; 
 4 };

Line 1 is a forward declaration so that the class will recognize the DummyTrack class. The method on line 3 is the method taking the DummyTrack and both ToolExamples will implement this method. Note the '= 0' after the method, denoting that the method is pure abstract and requires a concrete implementation.

ToolExample

One ToolExample will just dump the trackparameters, the other will store HepPoints with the position and direction of the tracks. In this ToolExample we'll discuss the latter. The headerfile needs to follow the interface with the method:

 1 class ToolExample : public AlgTool, virtual public IToolExample {
      ...
 2    StatusCode handleTrack(const DummyTrack* track) const ; 
 3 };

The implementation of the method will be done in the sourcefile ToolExample.cxx:

 1 #include "AlgorithmExample/DummyTrack.h"
 2 #include "CLHEP/Geometry/Point3D.h"
   ...
 3 StatusCode ToolExample::handleTrack(const DummyTrack* track) const {
 4 Point3D position( ... );
 5 Point3D location( ... );
 6 MsgStream log(msgSvc(), name());
 7 log << MSG::INFO << "position = (" << position.x() << ", " 
                                      << position.y() << ", "
                                      << position.z() << ", )" << endreq;
 8 return StatusCode::SUCCESS;

ToolExampleSimple

ExampleAlg and properties

Calling the different Tools

Implementing the Tools