23 trackerTopology_(trackerTopology),
25 alignableIndexer_(alignableIndexer)
32 alignmentLevels_.push_back(
std::move(level));
38 alignmentLevels_.clear();
45 auto highestLevel = alignmentLevels_.back()->levelType;
47 std::ostringstream ss;
48 ss <<
"building CompositeAlignables for " 49 << alignableObjectId_.idToString(highestLevel) <<
"\n";
51 unsigned int numCompositeAlignables = 0;
52 for (
unsigned int level = 1;
level < alignmentLevels_.size(); ++
level) {
53 numCompositeAlignables += buildLevel(
level, alignableMap, ss, update);
56 ss <<
"built " << numCompositeAlignables <<
" CompositeAlignables for " 57 << alignableObjectId_.idToString(highestLevel);
59 <<
"@SUB=AlignableCompositeBuilder::buildAll" << ss.str();
61 return numCompositeAlignables;
74 std::ostringstream& ss,
77 unsigned int childLevel = parentLevel - 1;
78 unsigned int maxNumParents = maxNumComponents(parentLevel);
80 auto childType = alignmentLevels_[childLevel] ->levelType;
81 auto parentType = alignmentLevels_[parentLevel]->levelType;
83 auto&
children = alignableMap.
find(alignableObjectId_.idToString(childType));
84 auto&
parents = alignableMap.
get (alignableObjectId_.idToString(parentType));
85 if (!update)
parents.reserve(maxNumParents);
94 const auto index = getIndexOfStructure(
child->id(), parentLevel);
99 if (!parent && !update) {
102 <<
"@SUB=AlignableCompositeBuilder::buildLevel\n" 103 <<
"trying to update a non-existing AlignableComposite";
107 if (alignmentLevels_[parentLevel]->isFlat) {
109 child->globalRotation());
116 if (alignmentLevels_[parentLevel]->isFlat) {
121 <<
"@SUB=AlignableCompositeBuilder::buildLevel\n" 122 <<
"trying to update a flat composite that is not of type " 123 <<
"AlignableComposite";
125 if (mother->id() ==
child->id()) {
126 mother->update(
child->id(), parentType,
child->globalRotation());
132 if (!update) parent->addComponent(
child);
135 ss <<
" built " <<
parents.size() <<
" " 136 << alignableObjectId_.idToString(alignmentLevels_[parentLevel]->levelType)
137 <<
"(s) (theoretical maximum: " << maxNumParents
138 <<
") consisting of " << children.size() <<
" " 139 << alignableObjectId_.idToString(alignmentLevels_[childLevel]->levelType)
151 for (
unsigned int level = startLevel;
152 level < alignmentLevels_.size();
154 components *= alignmentLevels_[
level]->maxNumComponents;
165 auto indexOf = alignableIndexer_.get(alignmentLevels_[level]->levelType,
168 if (alignmentLevels_.size() - 1 >
level) {
169 return getIndexOfStructure(
id, level + 1)
170 * alignmentLevels_[
level]->maxNumComponents
174 return indexOf(
id) - 1;
TkRotation< Scalar > RotationType
std::vector< Alignable * > Alignables
AlignableCompositeBuilder(const TrackerTopology *, const TrackerGeometry *, const AlignableIndexer &)
unsigned int getIndexOfStructure(align::ID, unsigned int level) const
Alignables & get(const std::string &name="")
Alignables & find(const std::string &name="")
void clearAlignmentLevels()
Resets the alignment-levels.
unsigned int maxNumComponents(unsigned int startLevel) const
unsigned int buildLevel(unsigned int parentLevel, AlignableMap &, std::ostringstream &, bool update=false)
Builds the components for a given level in the hierarchy.
unsigned int buildAll(AlignableMap &, bool update=false)
void addAlignmentLevel(std::unique_ptr< AlignmentLevel > level)