CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
AlignableCompositeBuilder Class Reference

#include <AlignableCompositeBuilder.h>

Public Member Functions

void addAlignmentLevel (std::unique_ptr< AlignmentLevel > level)
 
 AlignableCompositeBuilder (const TrackerTopology *, const TrackerGeometry *, const AlignableIndexer &)
 
unsigned int buildAll (AlignableMap &, bool update=false)
 
void clearAlignmentLevels ()
 Resets the alignment-levels. More...
 
const AlignableObjectIdobjectIdProvider () const
 Return tracker alignable object ID provider derived from the tracker's geometry. More...
 
virtual ~AlignableCompositeBuilder ()=default
 

Private Member Functions

unsigned int buildLevel (unsigned int parentLevel, AlignableMap &, std::ostringstream &, bool update=false)
 Builds the components for a given level in the hierarchy. More...
 
unsigned int getIndexOfStructure (align::ID, unsigned int level) const
 
unsigned int maxNumComponents (unsigned int startLevel) const
 

Private Attributes

AlignableIndexer alignableIndexer_
 
const AlignableObjectId alignableObjectId_
 
align::AlignmentLevels alignmentLevels_
 
const TrackerTopologytrackerTopology_
 

Detailed Description

Definition at line 14 of file AlignableCompositeBuilder.h.

Constructor & Destructor Documentation

◆ AlignableCompositeBuilder()

AlignableCompositeBuilder::AlignableCompositeBuilder ( const TrackerTopology trackerTopology,
const TrackerGeometry trackerGeometry,
const AlignableIndexer alignableIndexer 
)

Definition at line 17 of file AlignableCompositeBuilder.cc.

20  : trackerTopology_(trackerTopology),
21  alignableObjectId_(trackerGeometry, nullptr, nullptr),
22  alignableIndexer_(alignableIndexer) {}

◆ ~AlignableCompositeBuilder()

virtual AlignableCompositeBuilder::~AlignableCompositeBuilder ( )
virtualdefault

Member Function Documentation

◆ addAlignmentLevel()

void AlignableCompositeBuilder::addAlignmentLevel ( std::unique_ptr< AlignmentLevel level)

Add all desired AlignmentLevels for a sub-detector to the builder before calling buildAll(), the order matters! Example for PixelBarrel-RunI geometry: -> PXBModule, PXBLadder, TPBLayer, TPBHalfBarrel, TPBBarrel

Definition at line 25 of file AlignableCompositeBuilder.cc.

25  {
26  alignmentLevels_.push_back(std::move(level));
27 }

References alignmentLevels_, personalPlayback::level, and eostools::move().

◆ buildAll()

unsigned int AlignableCompositeBuilder::buildAll ( AlignableMap alignableMap,
bool  update = false 
)

Builds all composite Alignables according to the levels added before via addAlignmentLevel(). The Alignables were built from bottom- to the top- hierarchy, e.g. for PixelBarrel-RunI geometry:

  • PXBLadder (with PXBModule as children)
  • TPBLayer (with PXBLadder as children)
  • TPBHalfBarrel (with TPBLayer as children)
  • TPBBarrel (with TPBHalfBarrel as children) Returns the number of composite Alignables which were built.

Definition at line 33 of file AlignableCompositeBuilder.cc.

33  {
34  auto highestLevel = alignmentLevels_.back()->levelType;
35 
36  std::ostringstream ss;
37  ss << "building CompositeAlignables for " << alignableObjectId_.idToString(highestLevel) << "\n";
38 
39  unsigned int numCompositeAlignables = 0;
40  for (unsigned int level = 1; level < alignmentLevels_.size(); ++level) {
41  numCompositeAlignables += buildLevel(level, alignableMap, ss, update);
42  }
43 
44  ss << "built " << numCompositeAlignables << " CompositeAlignables for "
45  << alignableObjectId_.idToString(highestLevel);
46  edm::LogInfo("AlignableBuildProcess") << "@SUB=AlignableCompositeBuilder::buildAll" << ss.str();
47 
48  return numCompositeAlignables;
49 }

References alignableObjectId_, alignmentLevels_, buildLevel(), AlignableObjectId::idToString(), personalPlayback::level, contentValuesCheck::ss, and update.

◆ buildLevel()

unsigned int AlignableCompositeBuilder::buildLevel ( unsigned int  parentLevel,
AlignableMap alignableMap,
std::ostringstream &  ss,
bool  update = false 
)
private

Builds the components for a given level in the hierarchy.

Definition at line 56 of file AlignableCompositeBuilder.cc.

59  {
60  unsigned int childLevel = parentLevel - 1;
61  unsigned int maxNumParents = maxNumComponents(parentLevel);
62 
63  auto childType = alignmentLevels_[childLevel]->levelType;
64  auto parentType = alignmentLevels_[parentLevel]->levelType;
65 
66  auto& children = alignableMap.find(alignableObjectId_.idToString(childType));
67  auto& parents = alignableMap.get(alignableObjectId_.idToString(parentType));
68  if (!update)
69  parents.reserve(maxNumParents);
70 
71  // This vector is used indicate if a parent already exists. It is initialized
72  // with 'naked' Alignables-pointers; if the pointer is not naked (!= nullptr)
73  // for one of the child-IDs, its parent was already built before.
74  align::Alignables tmpParents(maxNumParents, nullptr);
75 
76  for (auto* child : children) {
77  // get the number of the child-Alignable ...
78  const auto index = getIndexOfStructure(child->id(), parentLevel);
79  // ... and use it as index to get the parent of this child
80  auto& parent = tmpParents[index];
81 
82  // if parent was not built yet ...
83  if (!parent && !update) {
84  if (update) {
85  throw cms::Exception("LogicError") << "@SUB=AlignableCompositeBuilder::buildLevel\n"
86  << "trying to update a non-existing AlignableComposite";
87  }
88  // ... build new composite Alignable with ID of child (obviously its the
89  // first child of the Alignable)
90  if (alignmentLevels_[parentLevel]->isFlat) {
91  parent = new AlignableComposite(child->id(), parentType, child->globalRotation());
92  } else {
93  parent = new AlignableComposite(child->id(), parentType, align::RotationType());
94  }
95  parents.push_back(parent);
96  } else if (update) {
97  if (alignmentLevels_[parentLevel]->isFlat) {
98  // needed to update rotation of flat composites
99  auto mother = dynamic_cast<AlignableComposite*>(child->mother());
100  if (!mother) {
101  throw cms::Exception("LogicError") << "@SUB=AlignableCompositeBuilder::buildLevel\n"
102  << "trying to update a flat composite that is not of type "
103  << "AlignableComposite";
104  }
105  if (mother->id() == child->id()) {
106  mother->update(child->id(), parentType, child->globalRotation());
107  }
108  }
109  }
110 
111  // in all cases (except updates) add the child to the parent Alignable
112  if (!update)
113  parent->addComponent(child);
114  }
115 
116  ss << " built " << parents.size() << " " << alignableObjectId_.idToString(alignmentLevels_[parentLevel]->levelType)
117  << "(s) (theoretical maximum: " << maxNumParents << ") consisting of " << children.size() << " "
118  << alignableObjectId_.idToString(alignmentLevels_[childLevel]->levelType) << "(s)\n";
119 
120  return parents.size();
121 }

References alignableObjectId_, alignmentLevels_, class-composition::children, Exception, AlignableMap::find(), AlignableMap::get(), getIndexOfStructure(), AlignableObjectId::idToString(), maxNumComponents(), class-composition::parent, parents, contentValuesCheck::ss, and update.

Referenced by buildAll().

◆ clearAlignmentLevels()

void AlignableCompositeBuilder::clearAlignmentLevels ( )

Resets the alignment-levels.

Definition at line 30 of file AlignableCompositeBuilder.cc.

30 { alignmentLevels_.clear(); }

References alignmentLevels_.

◆ getIndexOfStructure()

unsigned int AlignableCompositeBuilder::getIndexOfStructure ( align::ID  id,
unsigned int  level 
) const
private

Calculates the index of an Alignable within the hierarchy; unique for each component of a given structure-type.

Definition at line 135 of file AlignableCompositeBuilder.cc.

135  {
136  // indexer returns a function pointer for the structure-type
137  auto indexOf = alignableIndexer_.get(alignmentLevels_[level]->levelType, alignableObjectId_);
138 
139  if (alignmentLevels_.size() - 1 > level) {
140  return getIndexOfStructure(id, level + 1) * alignmentLevels_[level]->maxNumComponents + indexOf(id) - 1;
141  }
142 
143  return indexOf(id) - 1;
144 }

References alignableIndexer_, alignableObjectId_, alignmentLevels_, AlignableIndexer::get(), and personalPlayback::level.

Referenced by buildLevel().

◆ maxNumComponents()

unsigned int AlignableCompositeBuilder::maxNumComponents ( unsigned int  startLevel) const
private

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

Definition at line 124 of file AlignableCompositeBuilder.cc.

124  {
125  unsigned int components = 1;
126 
127  for (unsigned int level = startLevel; level < alignmentLevels_.size(); ++level) {
128  components *= alignmentLevels_[level]->maxNumComponents;
129  }
130 
131  return components;
132 }

References alignmentLevels_, makeMuonMisalignmentScenario::components, and personalPlayback::level.

Referenced by buildLevel().

◆ objectIdProvider()

const AlignableObjectId& AlignableCompositeBuilder::objectIdProvider ( ) const
inline

Return tracker alignable object ID provider derived from the tracker's geometry.

Definition at line 40 of file AlignableCompositeBuilder.h.

40 { return alignableObjectId_; }

References alignableObjectId_.

Member Data Documentation

◆ alignableIndexer_

AlignableIndexer AlignableCompositeBuilder::alignableIndexer_
private

Definition at line 66 of file AlignableCompositeBuilder.h.

Referenced by getIndexOfStructure().

◆ alignableObjectId_

const AlignableObjectId AlignableCompositeBuilder::alignableObjectId_
private

◆ alignmentLevels_

align::AlignmentLevels AlignableCompositeBuilder::alignmentLevels_
private

◆ trackerTopology_

const TrackerTopology* AlignableCompositeBuilder::trackerTopology_
private

Definition at line 63 of file AlignableCompositeBuilder.h.

personalPlayback.level
level
Definition: personalPlayback.py:22
AlignableIndexer::get
virtual align::Counter get(align::StructureType, const AlignableObjectId &) const
Get a counter based on its structure type.
Definition: AlignableIndexer.cc:7
align::RotationType
TkRotation< Scalar > RotationType
Definition: Definitions.h:27
class-composition.children
children
Definition: class-composition.py:88
AlignableCompositeBuilder::alignmentLevels_
align::AlignmentLevels alignmentLevels_
Definition: AlignableCompositeBuilder.h:68
edm::LogInfo
Definition: MessageLogger.h:254
AlignableComposite
Definition: AlignableComposite.h:25
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
AlignableCompositeBuilder::alignableObjectId_
const AlignableObjectId alignableObjectId_
Definition: AlignableCompositeBuilder.h:64
AlignableCompositeBuilder::alignableIndexer_
AlignableIndexer alignableIndexer_
Definition: AlignableCompositeBuilder.h:66
AlignableCompositeBuilder::buildLevel
unsigned int buildLevel(unsigned int parentLevel, AlignableMap &, std::ostringstream &, bool update=false)
Builds the components for a given level in the hierarchy.
Definition: AlignableCompositeBuilder.cc:56
AlignableMap::find
align::Alignables & find(const std::string &name="")
Definition: AlignableMap.cc:10
AlignableCompositeBuilder::maxNumComponents
unsigned int maxNumComponents(unsigned int startLevel) const
Definition: AlignableCompositeBuilder.cc:124
AlignableCompositeBuilder::trackerTopology_
const TrackerTopology * trackerTopology_
Definition: AlignableCompositeBuilder.h:63
align::Alignables
std::vector< Alignable * > Alignables
Definition: Utilities.h:31
eostools.move
def move(src, dest)
Definition: eostools.py:511
makeMuonMisalignmentScenario.components
string components
Definition: makeMuonMisalignmentScenario.py:58
Exception
Definition: hltDiff.cc:246
AlignableCompositeBuilder::getIndexOfStructure
unsigned int getIndexOfStructure(align::ID, unsigned int level) const
Definition: AlignableCompositeBuilder.cc:135
AlignableMap::get
align::Alignables & get(const std::string &name="")
Definition: AlignableMap.cc:7
AlignableObjectId::idToString
const char * idToString(align::StructureType type) const
Definition: AlignableObjectId.cc:259
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
parents
TPRegexp parents
Definition: eve_filter.cc:21
child
Definition: simpleInheritance.h:11
class-composition.parent
parent
Definition: class-composition.py:88
update
#define update(a, b)
Definition: TrackClassifier.cc:10