CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
AlignableBuilder.cc
Go to the documentation of this file.
3 
5 
6 
7 //__________________________________________________________________________________________________
9  bool flat,
10  unsigned int maxComponent ) :
11  type_(type),
12  flat_(flat),
13  maxComponent_(maxComponent)
14 {
15 }
16 
17 //__________________________________________________________________________________________________
19  theModuleType(moduleType),
20  theCounters(counters),
21  theTopology(tTopo)
22 {
23 }
24 
25 //__________________________________________________________________________________________________
27  bool flat,
28  unsigned int maxComponent)
29 {
30  theLevelInfos.push_back( LevelInfo(type, flat, maxComponent) );
31 }
32 
33 //__________________________________________________________________________________________________
35 {
36  build(0, theModuleType, setup); // build the first level above the modules
37 
38  for (unsigned int l = 1; l < theLevelInfos.size(); ++l)
39  build(l, theLevelInfos[l - 1].type_, setup);
40 }
41 
42 //__________________________________________________________________________________________________
43 unsigned int AlignableBuilder::maxComponent(unsigned int level) const
44 {
45  unsigned int max = 1;
46 
47  for (unsigned int l = level; l < theLevelInfos.size(); ++l)
48  {
49  max *= theLevelInfos[l].maxComponent_;
50  }
51 
52  return max;
53 }
54 
55 //__________________________________________________________________________________________________
56 unsigned int AlignableBuilder::index( unsigned int level, align::ID id, const TrackerTopology* tTopo) const
57 {
59 
60  if (theLevelInfos.size() - 1 > level)
61  {
62  return index(level + 1, id, tTopo) * info.maxComponent_ + theCounters.get(info.type_)(id, tTopo) - 1;
63  }
64 
65  return theCounters.get(info.type_)(id, tTopo) - 1;
66 }
67 
68 
69 //__________________________________________________________________________________________________
72 {
73  const LevelInfo& momInfo = theLevelInfos[level];
74 
75  align::StructureType momType = momInfo.type_;
76 
77  const align::Alignables& daus = setup.find( AlignableObjectId::idToString(dauType) );
78 
79  unsigned int nDau = daus.size();
80 
81  align::Alignables& moms = setup.get( AlignableObjectId::idToString(momType) );
82 
83  moms.reserve(nDau);
84 
85  // In order not to depend on the order of the daughter list,
86  // we define flags to indicate the existence of a mother;
87  // 0 if it hasn't been created.
88  // We use vector instead of map for speed.
89  align::Alignables tempMoms(maxComponent(level), 0); // init all to 0
90 
91  for (unsigned int i = 0; i < nDau; ++i)
92  {
93  Alignable* dau = daus[i];
94 
95  Alignable*& mom = tempMoms[index( level, dau->id(), theTopology )];
96 
97  if (0 == mom)
98  {
99  // create new mom with id and rot of 1st dau
100  if ( momInfo.flat_ )
101  mom = new AlignableComposite( dau->id(), momType, dau->globalRotation() );
102  else
103  mom = new AlignableComposite( dau->id(), momType, align::RotationType() );
104 
105  moms.push_back(mom);
106  }
107 
108  mom->addComponent(dau);
109  }
110 }
TkRotation< Scalar > RotationType
Definition: Definitions.h:29
type
Definition: HCALResponse.h:21
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:185
int i
Definition: DBlmapReader.cc:9
static const TGPicture * info(bool iBackgroundIsBlack)
Type & find(const std::string &name="")
Definition: AlignSetup.h:58
void build(unsigned int level, align::StructureType dauType, AlignSetup< align::Alignables > &setup) const
Build the components for a given level in the hierarchy.
uint32_t ID
Definition: Definitions.h:26
std::vector< LevelInfo > theLevelInfos
const RotationType & globalRotation() const
Return the global orientation of the object.
Definition: Alignable.h:137
virtual align::Counter get(align::StructureType) const
Get a counter based on its structure type.
Definition: Counters.cc:8
void buildAll(AlignSetup< align::Alignables > &setup) const
Build the components for all levels given by user.
LevelInfo(align::StructureType, bool flat, unsigned int maxComponent)
void addLevelInfo(align::StructureType, bool flat, unsigned int maxComponent)
Add info required to build a level to the list.
Type & get(const std::string &name="")
Definition: AlignSetup.h:52
align::StructureType theModuleType
virtual void addComponent(Alignable *)=0
AlignableBuilder(align::StructureType moduleType, Counters &counter, const TrackerTopology *tTopo)
Init the module type.
unsigned int index(unsigned int level, align::ID, const TrackerTopology *tTopo) const
align::StructureType type_
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
static const char * idToString(align::StructureType type)
const TrackerTopology * theTopology