StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
StiDetectorTreeBuilder Class Reference

#include <StiDetectorTreeBuilder.h>

Public Member Functions

 StiDetectorTreeBuilder ()
 Default Contstructor.
virtual ~StiDetectorTreeBuilder ()
 Default Destructor.
StiDetectorNodebuild (StiDetectorBuilder *builder)
 Build the Detector model. More...

Protected Member Functions

void loopOnDetectors ()
 Iterate over the detector objects served by StiDetectorBuilder.
void buildRoot ()
 Assemble detector objects into tree.
void addToTree (StiDetector *)
 Actually hang an individual detector object on the tree.
StiDetectorNodehangWhere (StiDetectorNode *parent, const StiOrderKey &order, string &keystring, int newOne=0)
 Decide where to hang the detector object on the tree.

Protected Attributes

 Store a pointer to the root of the tree.
Factory< StiDetectorNode > * mnodefactory
 This object is assumed not to be owned by this class. More...
 Store a pointer to the StiDetectorBuilder instance.
 Pointer to the current region in the tree (e.g., mid rapidity)

Detailed Description

StiDetectorTreeBuilder is a utility class that uses objects it gets from two factories to build a full model of the STAR detector material. StiDetectorTreeBuilder is the class responsible for actually organizing the StiDetector objects into a tree structure. As such, it uses the utility class StiDetectorBuilder to generate StiDetector objects, and then these objects are organized as belonging to an StiCompositeTreeNode<StiDetector> object. This is all accomplished via the call to build().

The general flow of execution is as follows. First, in the constructor of StiDetectorTreeBuilder, the member mDetectorBuilder is set to point to an instance of StiCodedDetectorBuilder created on the heap. Once a call to build() is made, the tree is assembled by looping on detectors that are generated by mDetectorBuilder. Each detector object returned by the mDetectorBuilder is then hung on the tree by a call to addToTree which calls hangWhere(). By using mDetectorBuilder polymorphically, StiDetectorTreeBuilder becomes extremely flexible. That is, it does not care how the StiDetector objects are created (e.g., from root macro, data base, or geant). However, to really take advantage of this flexibility one should remove ownership of mDetectorBuilder from StiDetectorTreeBuilder and instead set the polymorphic pointer by hand before a call to build(). This is work to be done.

M.L. Miller (Yale Software)
There is some internal protection against build being called more then once. See the documenation for the build() method.
Member of type StiDetectoBuilder* defaults to StiCodedDetectorBuilder.

Definition at line 57 of file StiDetectorTreeBuilder.h.

Member Function Documentation

StiDetectorNode * StiDetectorTreeBuilder::build ( StiDetectorBuilder builder)

Build the Detector model.

There is some internal protection against building more than one instance of the detector model. That is, StiDetectorTreeBuilder stores a pointer to the root of the tree that it builds. build() first checks that this pointer is null. If not, the call to build() will return 0. However, once the StiDetectorTreeBuilder instance that originally built the tree goes out of scope, so does the stored pointer to the root, and thus the protection becomes impossible. Additionaly, the root of the tree is assumed to be owned by the nodefactory.

Definition at line 34 of file StiDetectorTreeBuilder.cxx.

References buildRoot(), loopOnDetectors(), mDetectorBuilder, mnodefactory, and mroot.

Referenced by StiDetectorContainer::build().

Member Data Documentation

Factory<StiDetectorNode>* StiDetectorTreeBuilder::mnodefactory

This object is assumed not to be owned by this class.

Store a pointer to the factory of tree nodes. This is used for internal convenience. This object is not owned by this class.

Definition at line 99 of file StiDetectorTreeBuilder.h.

Referenced by build(), buildRoot(), and hangWhere().

The documentation for this class was generated from the following files: