CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
AlignableBuilder Class Reference

#include <AlignableBuilder.h>

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. More...
 
 AlignableBuilder (align::StructureType moduleType, Counters &counter)
 Init the module type. More...
 
void buildAll (AlignSetup< align::Alignables > &setup) const
 Build the components for all levels given by user. More...
 

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. More...
 
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. More...
 

Private Attributes

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

Detailed Description

A class to build alignable composites.

Date:
2007/10/08 13:36:11
Revision:
1.1
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.

18  :
19  theModuleType(moduleType),
20  theCounters(counters)
21 {
22 }
align::StructureType theModuleType

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().

28 {
29  theLevelInfos.push_back( LevelInfo(type, flat, maxComponent) );
30 }
type
Definition: HCALResponse.h:22
std::vector< LevelInfo > theLevelInfos
unsigned int maxComponent(unsigned int level) const
Find max number of components for a given level in the hierarchy.
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(), index(), testEve_cfg::level, maxComponent(), theLevelInfos, AlignableBuilder::LevelInfo::type_, and AlignableObjectId::typeToName().

Referenced by buildAll().

71 {
72  AlignableObjectId objId;
73 
74  const LevelInfo& momInfo = theLevelInfos[level];
75 
76  align::StructureType momType = momInfo.type_;
77 
78  const align::Alignables& daus = setup.find( objId.typeToName(dauType) );
79 
80  unsigned int nDau = daus.size();
81 
82  align::Alignables& moms = setup.get( objId.typeToName(momType) );
83 
84  moms.reserve(nDau);
85 
86  // In order not to depend on the order of the daughter list,
87  // we define flags to indicate the existence of a mother;
88  // 0 if it hasn't been created.
89  // We use vector instead of map for speed.
90  align::Alignables tempMoms(maxComponent(level), 0); // init all to 0
91 
92  for (unsigned int i = 0; i < nDau; ++i)
93  {
94  Alignable* dau = daus[i];
95 
96  Alignable*& mom = tempMoms[index( level, dau->id() )];
97 
98  if (0 == mom)
99  {
100  // create new mom with id and rot of 1st dau
101  if ( momInfo.flat_ )
102  mom = new AlignableComposite( dau->id(), momType, dau->globalRotation() );
103  else
104  mom = new AlignableComposite( dau->id(), momType, align::RotationType() );
105 
106  moms.push_back(mom);
107  }
108 
109  mom->addComponent(dau);
110  }
111 }
TkRotation< Scalar > RotationType
Definition: Definitions.h:29
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:180
int i
Definition: DBlmapReader.cc:9
Type & find(const std::string &name="")
Definition: AlignSetup.h:58
std::vector< LevelInfo > theLevelInfos
const RotationType & globalRotation() const
Return the global orientation of the object.
Definition: Alignable.h:132
const std::string & typeToName(align::StructureType type) const
Convert type to name.
unsigned int index(unsigned int level, align::ID) const
Type & get(const std::string &name="")
Definition: AlignSetup.h:52
Allows conversion between type and name, and vice-versa.
std::vector< Alignable * > Alignables
Definition: Utilities.h:28
unsigned int maxComponent(unsigned int level) const
Find max number of components for a given level in the hierarchy.
tuple level
Definition: testEve_cfg.py:34
virtual void addComponent(Alignable *component)
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().

34 {
35  build(0, theModuleType, setup); // build the first level above the modules
36 
37  for (unsigned int l = 1; l < theLevelInfos.size(); ++l)
38  build(l, theLevelInfos[l - 1].type_, setup);
39 }
void build(unsigned int level, align::StructureType dauType, AlignSetup< align::Alignables > &setup) const
Build the components for a given level in the hierarchy.
std::vector< LevelInfo > theLevelInfos
align::StructureType theModuleType
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(), ExpressReco_HICollisions_FallBack::id, info, testEve_cfg::level, AlignableBuilder::LevelInfo::maxComponent_, theCounters, theLevelInfos, and AlignableBuilder::LevelInfo::type_.

Referenced by build().

56 {
57  const LevelInfo& info = theLevelInfos[level];
58 
59  if (theLevelInfos.size() - 1 > level)
60  {
61  return index(level + 1, id) * info.maxComponent_ + theCounters.get(info.type_)(id) - 1;
62  }
63 
64  return theCounters.get(info.type_)(id) - 1;
65 }
std::vector< LevelInfo > theLevelInfos
virtual align::Counter get(align::StructureType) const
Get a counter based on its structure type.
Definition: Counters.cc:8
unsigned int index(unsigned int level, align::ID) const
tuple level
Definition: testEve_cfg.py:34
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().

43 {
44  unsigned int max = 1;
45 
46  for (unsigned int l = level; l < theLevelInfos.size(); ++l)
47  {
48  max *= theLevelInfos[l].maxComponent_;
49  }
50 
51  return max;
52 }
std::vector< LevelInfo > theLevelInfos
const T & max(const T &a, const T &b)
tuple level
Definition: testEve_cfg.py:34

Member Data Documentation

Counters AlignableBuilder::theCounters
private

Definition at line 64 of file AlignableBuilder.h.

Referenced by index().

std::vector<LevelInfo> AlignableBuilder::theLevelInfos
private

Definition at line 62 of file AlignableBuilder.h.

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

align::StructureType AlignableBuilder::theModuleType
private

Definition at line 60 of file AlignableBuilder.h.

Referenced by buildAll().