CMS 3D CMS Logo

Classes | Public Member Functions | Private Member Functions | Private Attributes

AlignableBuilder Class Reference

#include <AlignableBuilder.h>

List of all members.

Classes

struct  LevelInfo

Public Member Functions

void addLevelInfo (align::StructureType, bool flat, unsigned int maxComponent)
 Add info required to build a level to the list.
 AlignableBuilder (align::StructureType moduleType, Counters &counter)
 Init the module type.
void buildAll (AlignSetup< align::Alignables > &setup) const
 Build the components for all levels given by user.

Private Member Functions

void build (unsigned int level, align::StructureType dauType, AlignSetup< align::Alignables > &setup) const
 Build the components for a given level in the hierarchy.
unsigned int index (unsigned int level, align::ID) const
unsigned int maxComponent (unsigned int level) const
 Find max number of components for a given level in the hierarchy.

Private Attributes

Counters theCounters
std::vector< LevelInfotheLevelInfos
align::StructureType theModuleType

Detailed Description

A class to build alignable composites.

Date:
2007/10/18 09:41:07
Revision:
1.2
Author:
Chung Khim Lae

Definition at line 19 of file AlignableBuilder.h.


Constructor & Destructor Documentation

AlignableBuilder::AlignableBuilder ( align::StructureType  moduleType,
Counters counter 
)

Init the module type.

Definition at line 18 of file AlignableBuilder.cc.

                                                                                    :
  theModuleType(moduleType),
  theCounters(counters)
{
}

Member Function Documentation

void AlignableBuilder::addLevelInfo ( align::StructureType  type,
bool  flat,
unsigned int  maxComponent 
)

Add info required to build a level to the list.

Definition at line 25 of file AlignableBuilder.cc.

References theLevelInfos.

Referenced by AlignableTracker::buildTEC(), AlignableTracker::buildTIB(), AlignableTracker::buildTID(), AlignableTracker::buildTOB(), AlignableTracker::buildTPB(), and AlignableTracker::buildTPE().

{
  theLevelInfos.push_back( LevelInfo(type, flat, maxComponent) );
}
void AlignableBuilder::build ( unsigned int  level,
align::StructureType  dauType,
AlignSetup< align::Alignables > &  setup 
) const [private]

Build the components for a given level in the hierarchy.

Definition at line 69 of file AlignableBuilder.cc.

References Alignable::addComponent(), AlignSetup< Type >::find(), AlignableBuilder::LevelInfo::flat_, AlignSetup< Type >::get(), Alignable::globalRotation(), i, Alignable::id(), AlignableObjectId::idToString(), index(), testEve_cfg::level, maxComponent(), theLevelInfos, and AlignableBuilder::LevelInfo::type_.

Referenced by buildAll().

{
  const LevelInfo& momInfo = theLevelInfos[level];

  align::StructureType momType = momInfo.type_;

  const align::Alignables& daus = setup.find( AlignableObjectId::idToString(dauType) );

  unsigned int nDau = daus.size();

  align::Alignables& moms = setup.get( AlignableObjectId::idToString(momType) );

  moms.reserve(nDau);

  // In order not to depend on the order of the daughter list,
  // we define flags to indicate the existence of a mother;
  // 0 if it hasn't been created.
  // We use vector instead of map for speed.
  align::Alignables tempMoms(maxComponent(level), 0); // init all to 0

  for (unsigned int i = 0; i < nDau; ++i)
  {
    Alignable* dau = daus[i];

    Alignable*& mom = tempMoms[index( level, dau->id() )];

    if (0 == mom)
    { 
      // create new mom with id and rot of 1st dau
      if ( momInfo.flat_ )
        mom = new AlignableComposite( dau->id(), momType, dau->globalRotation() );
      else
        mom = new AlignableComposite( dau->id(), momType, align::RotationType() );

      moms.push_back(mom);
    }

    mom->addComponent(dau);
  }
}
void AlignableBuilder::buildAll ( AlignSetup< align::Alignables > &  setup) const

Build the components for all levels given by user.

Definition at line 33 of file AlignableBuilder.cc.

References build(), prof2calltree::l, theLevelInfos, and theModuleType.

Referenced by AlignableTracker::buildTEC(), AlignableTracker::buildTIB(), AlignableTracker::buildTID(), AlignableTracker::buildTOB(), AlignableTracker::buildTPB(), and AlignableTracker::buildTPE().

{
  build(0, theModuleType, setup); // build the first level above the modules

  for (unsigned int l = 1; l < theLevelInfos.size(); ++l) 
    build(l, theLevelInfos[l - 1].type_, setup);
}
unsigned int AlignableBuilder::index ( unsigned int  level,
align::ID  id 
) const [private]

A way to index a component of a certain level in the hierarchy. Unique for each component of a given structure type. It starts from 0 and doesn't have to be continuous.

Definition at line 55 of file AlignableBuilder.cc.

References Counters::get(), info, testEve_cfg::level, AlignableBuilder::LevelInfo::maxComponent_, theCounters, theLevelInfos, and AlignableBuilder::LevelInfo::type_.

Referenced by build().

{
  const LevelInfo& info = theLevelInfos[level];

  if (theLevelInfos.size() - 1 > level)
  {
    return index(level + 1, id) * info.maxComponent_ + theCounters.get(info.type_)(id) - 1;
  }

  return theCounters.get(info.type_)(id) - 1;
}
unsigned int AlignableBuilder::maxComponent ( unsigned int  level) const [private]

Find max number of components for a given level in the hierarchy.

Definition at line 42 of file AlignableBuilder.cc.

References prof2calltree::l, max(), and theLevelInfos.

Referenced by build().

{
  unsigned int max = 1;

  for (unsigned int l = level; l < theLevelInfos.size(); ++l)
  {
    max *= theLevelInfos[l].maxComponent_;
  }

  return max;
}

Member Data Documentation

Definition at line 64 of file AlignableBuilder.h.

Referenced by index().

Definition at line 62 of file AlignableBuilder.h.

Referenced by addLevelInfo(), build(), buildAll(), index(), and maxComponent().

Definition at line 60 of file AlignableBuilder.h.

Referenced by buildAll().