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 16 of file AlignableCompositeBuilder.h.

Constructor & Destructor Documentation

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

Definition at line 20 of file AlignableCompositeBuilder.cc.

References addAlignmentLevel().

22  :
23  trackerTopology_(trackerTopology),
24  alignableObjectId_(trackerGeometry, nullptr, nullptr),
25  alignableIndexer_(alignableIndexer)
26 {
27 }
const AlignableObjectId alignableObjectId_
const TrackerTopology * trackerTopology_
virtual AlignableCompositeBuilder::~AlignableCompositeBuilder ( )
virtualdefault

Member Function Documentation

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 31 of file AlignableCompositeBuilder.cc.

References clearAlignmentLevels(), and eostools::move().

Referenced by AlignableCompositeBuilder(), and AlignableTrackerBuilder::buildAlignableComposites().

31  {
32  alignmentLevels_.push_back(std::move(level));
33 }
align::AlignmentLevels alignmentLevels_
def move(src, dest)
Definition: eostools.py:510
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 43 of file AlignableCompositeBuilder.cc.

References buildLevel(), and hcalDigis_cfi::level.

Referenced by clearAlignmentLevels().

44 {
45  auto highestLevel = alignmentLevels_.back()->levelType;
46 
47  std::ostringstream ss;
48  ss << "building CompositeAlignables for "
49  << alignableObjectId_.idToString(highestLevel) << "\n";
50 
51  unsigned int numCompositeAlignables = 0;
52  for (unsigned int level = 1; level < alignmentLevels_.size(); ++level) {
53  numCompositeAlignables += buildLevel(level, alignableMap, ss, update);
54  }
55 
56  ss << "built " << numCompositeAlignables << " CompositeAlignables for "
57  << alignableObjectId_.idToString(highestLevel);
58  edm::LogInfo("AlignableBuildProcess")
59  << "@SUB=AlignableCompositeBuilder::buildAll" << ss.str();
60 
61  return numCompositeAlignables;
62 }
align::AlignmentLevels alignmentLevels_
const AlignableObjectId alignableObjectId_
const char * idToString(align::StructureType type) const
#define update(a, b)
unsigned int buildLevel(unsigned int parentLevel, AlignableMap &, std::ostringstream &, bool update=false)
Builds the components for a given level in the hierarchy.
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 72 of file AlignableCompositeBuilder.cc.

References class-composition::children, Exception, AlignableMap::find(), AlignableMap::get(), maxNumComponents(), class-composition::parent, and parents.

Referenced by buildAll(), and objectIdProvider().

76 {
77  unsigned int childLevel = parentLevel - 1;
78  unsigned int maxNumParents = maxNumComponents(parentLevel);
79 
80  auto childType = alignmentLevels_[childLevel] ->levelType;
81  auto parentType = alignmentLevels_[parentLevel]->levelType;
82 
83  auto& children = alignableMap.find(alignableObjectId_.idToString(childType));
84  auto& parents = alignableMap.get (alignableObjectId_.idToString(parentType));
85  if (!update) parents.reserve(maxNumParents);
86 
87  // This vector is used indicate if a parent already exists. It is initialized
88  // with 'naked' Alignables-pointers; if the pointer is not naked (!= nullptr)
89  // for one of the child-IDs, its parent was already built before.
90  align::Alignables tmpParents(maxNumParents, nullptr);
91 
92  for (auto* child: children) {
93  // get the number of the child-Alignable ...
94  const auto index = getIndexOfStructure(child->id(), parentLevel);
95  // ... and use it as index to get the parent of this child
96  auto& parent = tmpParents[index];
97 
98  // if parent was not built yet ...
99  if (!parent && !update) {
100  if (update) {
101  throw cms::Exception("LogicError")
102  << "@SUB=AlignableCompositeBuilder::buildLevel\n"
103  << "trying to update a non-existing AlignableComposite";
104  }
105  // ... build new composite Alignable with ID of child (obviously its the
106  // first child of the Alignable)
107  if (alignmentLevels_[parentLevel]->isFlat) {
108  parent = new AlignableComposite(child->id(), parentType,
109  child->globalRotation());
110  } else {
111  parent = new AlignableComposite(child->id(), parentType,
113  }
114  parents.push_back(parent);
115  } else if (update) {
116  if (alignmentLevels_[parentLevel]->isFlat) {
117  // needed to update rotation of flat composites
118  auto mother = dynamic_cast<AlignableComposite*>(child->mother());
119  if (!mother) {
120  throw cms::Exception("LogicError")
121  << "@SUB=AlignableCompositeBuilder::buildLevel\n"
122  << "trying to update a flat composite that is not of type "
123  << "AlignableComposite";
124  }
125  if (mother->id() == child->id()) {
126  mother->update(child->id(), parentType, child->globalRotation());
127  }
128  }
129  }
130 
131  // in all cases (except updates) add the child to the parent Alignable
132  if (!update) parent->addComponent(child);
133  }
134 
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)
140  << "(s)\n";
141 
142  return parents.size();
143 }
TkRotation< Scalar > RotationType
Definition: Definitions.h:29
align::Alignables & get(const std::string &name="")
Definition: AlignableMap.cc:9
TPRegexp parents
Definition: eve_filter.cc:21
unsigned int getIndexOfStructure(align::ID, unsigned int level) const
align::AlignmentLevels alignmentLevels_
const AlignableObjectId alignableObjectId_
align::Alignables & find(const std::string &name="")
Definition: AlignableMap.cc:15
const char * idToString(align::StructureType type) const
unsigned int maxNumComponents(unsigned int startLevel) const
std::vector< Alignable * > Alignables
Definition: Utilities.h:32
#define update(a, b)
void AlignableCompositeBuilder::clearAlignmentLevels ( )

Resets the alignment-levels.

Definition at line 37 of file AlignableCompositeBuilder.cc.

References buildAll().

Referenced by addAlignmentLevel().

37  {
38  alignmentLevels_.clear();
39 }
align::AlignmentLevels alignmentLevels_
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 162 of file AlignableCompositeBuilder.cc.

References hcalDigis_cfi::level.

Referenced by maxNumComponents(), and objectIdProvider().

163 {
164  // indexer returns a function pointer for the structure-type
165  auto indexOf = alignableIndexer_.get(alignmentLevels_[level]->levelType,
167 
168  if (alignmentLevels_.size() - 1 > level) {
169  return getIndexOfStructure(id, level + 1)
170  * alignmentLevels_[level]->maxNumComponents
171  + indexOf(id) - 1;
172  }
173 
174  return indexOf(id) - 1;
175 }
unsigned int getIndexOfStructure(align::ID, unsigned int level) const
align::AlignmentLevels alignmentLevels_
const AlignableObjectId alignableObjectId_
virtual align::Counter get(align::StructureType, const AlignableObjectId &) const
Get a counter based on its structure type.
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 147 of file AlignableCompositeBuilder.cc.

References makeMuonMisalignmentScenario::components, getIndexOfStructure(), and hcalDigis_cfi::level.

Referenced by buildLevel(), and objectIdProvider().

148 {
149  unsigned int components = 1;
150 
151  for (unsigned int level = startLevel;
152  level < alignmentLevels_.size();
153  ++level) {
154  components *= alignmentLevels_[level]->maxNumComponents;
155  }
156 
157  return components;
158 }
align::AlignmentLevels alignmentLevels_
const AlignableObjectId& AlignableCompositeBuilder::objectIdProvider ( ) const
inline

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

Definition at line 45 of file AlignableCompositeBuilder.h.

References alignableObjectId_, buildLevel(), getIndexOfStructure(), maxNumComponents(), and update.

45 { return alignableObjectId_; }
const AlignableObjectId alignableObjectId_

Member Data Documentation

AlignableIndexer AlignableCompositeBuilder::alignableIndexer_
private

Definition at line 73 of file AlignableCompositeBuilder.h.

const AlignableObjectId AlignableCompositeBuilder::alignableObjectId_
private

Definition at line 71 of file AlignableCompositeBuilder.h.

Referenced by objectIdProvider().

align::AlignmentLevels AlignableCompositeBuilder::alignmentLevels_
private

Definition at line 75 of file AlignableCompositeBuilder.h.

const TrackerTopology* AlignableCompositeBuilder::trackerTopology_
private

Definition at line 70 of file AlignableCompositeBuilder.h.