CMS 3D CMS Logo

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

#include <AlignableTrackerBuilder.h>

Public Member Functions

 AlignableTrackerBuilder (const TrackerGeometry *, const TrackerTopology *)
 
void buildAlignables (AlignableTracker *, bool update=false)
 
const AlignableObjectIdobjectIdProvider () const
 Return tracker alignable object ID provider derived from the tracker's geometry. More...
 
const align::TrackerNameSpacetrackerNameSpace () const
 Return tracker name space derived from the tracker's topology. More...
 
virtual ~AlignableTrackerBuilder ()=default
 

Private Types

using Alignables = align::Alignables
 

Private Member Functions

void buildAlignableComposites (bool update=false)
 
void buildAlignableDetUnits (bool update=false)
 Builds Alignables on module-level for each part of the tracker. More...
 
void buildPixelDetector (AlignableTracker *)
 Builds the PixelDetector by hand. More...
 
void buildPixelDetectorAlignable (const GeomDet *, int subdetId, Alignables &aliDets, Alignables &aliDetUnits, bool update=false)
 Converts GeomDetUnits of PXB and PXE to AlignableDetUnits. More...
 
void buildStripDetector (AlignableTracker *)
 Builds the StripDetector by hand. More...
 
void buildStripDetectorAlignable (const GeomDet *, int subdetId, Alignables &aliDets, Alignables &aliDetUnits, bool update=false)
 
void convertGeomDetsToAlignables (const TrackingGeometry::DetContainer &, const std::string &moduleName, bool update=false)
 

Private Attributes

AlignableMapalignableMap_
 
const AlignableObjectId alignableObjectId_
 
int numDetUnits = 0
 
TrackerAlignmentLevelBuilder trackerAlignmentLevelBuilder_
 
const TrackerGeometrytrackerGeometry_
 
const TrackerTopologytrackerTopology_
 

Detailed Description

Definition at line 17 of file AlignableTrackerBuilder.h.

Member Typedef Documentation

Definition at line 18 of file AlignableTrackerBuilder.h.

Constructor & Destructor Documentation

AlignableTrackerBuilder::AlignableTrackerBuilder ( const TrackerGeometry trackerGeometry,
const TrackerTopology trackerTopology 
)

Definition at line 24 of file AlignableTrackerBuilder.cc.

References alignableObjectId_, Exception, AlignableObjectId::geometry(), AlignableObjectId::PhaseI, AlignableObjectId::PhaseII, AlignableObjectId::RunI, and contentValuesCheck::ss.

26  : trackerGeometry_(trackerGeometry),
27  trackerTopology_(trackerTopology),
28  alignableObjectId_(trackerGeometry, nullptr, nullptr),
29  alignableMap_(nullptr),
30  trackerAlignmentLevelBuilder_(trackerTopology, trackerGeometry) {
31  std::ostringstream ss;
32 
33  switch (alignableObjectId_.geometry()) {
35  ss << "RunI geometry";
36  break;
38  ss << "PhaseI geometry";
39  break;
41  ss << "PhaseII geometry";
42  break;
43  default:
44  throw cms::Exception("LogicError") << "[AlignableTrackerBuilder] unknown version of TrackerGeometry";
45  }
46 
47  edm::LogInfo("AlignableBuildProcess") << "@SUB=AlignableTrackerBuilder::AlignableTrackerBuilder"
48  << "GeometryVersion: " << ss.str();
49 }
const TrackerTopology * trackerTopology_
Geometry geometry() const
retrieve the geometry information
const AlignableObjectId alignableObjectId_
TrackerAlignmentLevelBuilder trackerAlignmentLevelBuilder_
const TrackerGeometry * trackerGeometry_
virtual AlignableTrackerBuilder::~AlignableTrackerBuilder ( )
virtualdefault

Member Function Documentation

void AlignableTrackerBuilder::buildAlignableComposites ( bool  update = false)
private

Builds all composite Alignables for the tracker. The hierarchy and numbers of components are determined in TrackerAlignmentLevelBuilder.

Definition at line 240 of file AlignableTrackerBuilder.cc.

References alignableMap_, TrackerAlignmentLevelBuilder::build(), personalPlayback::level, eostools::move(), trackerAlignmentLevelBuilder_, trackerGeometry_, TrackerAlignmentLevelBuilder::trackerNameSpace(), and trackerTopology_.

Referenced by buildAlignables(), and objectIdProvider().

240  {
241  unsigned int numCompositeAlignables = 0;
242 
243  // tracker levels must be built before the indexer is created in order to pass
244  // a valid namespace to the indexer; an exception would be thrown if one tries
245  // to get the namespace w/o building the levels
246  auto trackerLevels = trackerAlignmentLevelBuilder_.build();
248  AlignableCompositeBuilder compositeBuilder{trackerTopology_, trackerGeometry_, trackerIndexer};
249 
250  for (auto& trackerSubLevels : trackerLevels) {
251  // first add all levels of the current subdetector to the builder
252  for (auto& level : trackerSubLevels) {
253  compositeBuilder.addAlignmentLevel(std::move(level));
254  }
255  // now build this tracker-level
256  numCompositeAlignables += compositeBuilder.buildAll(*alignableMap_, update);
257  // finally, reset the builder
258  compositeBuilder.clearAlignmentLevels();
259  }
260 
261  edm::LogInfo("AlignableBuildProcess") << "@SUB=AlignableTrackerBuilder::buildAlignableComposites"
262  << "AlignableComposites built for Tracker: " << numCompositeAlignables
263  << " (note: without Pixel- and Strip-Alignable)";
264 }
const TrackerTopology * trackerTopology_
std::vector< align::AlignmentLevels > build()
const align::TrackerNameSpace & trackerNameSpace() const
TrackerAlignmentLevelBuilder trackerAlignmentLevelBuilder_
#define update(a, b)
const TrackerGeometry * trackerGeometry_
def move(src, dest)
Definition: eostools.py:511
void AlignableTrackerBuilder::buildAlignableDetUnits ( bool  update = false)
private

Builds Alignables on module-level for each part of the tracker.

Definition at line 80 of file AlignableTrackerBuilder.cc.

References alignableObjectId_, convertGeomDetsToAlignables(), TrackerGeometry::detsPXB(), TrackerGeometry::detsPXF(), TrackerGeometry::detsTEC(), TrackerGeometry::detsTIB(), TrackerGeometry::detsTID(), TrackerGeometry::detsTOB(), AlignableObjectId::idToString(), align::TECModule, align::TIBModule, align::TIDModule, align::TOBModule, align::TPBModule, align::TPEModule, trackerGeometry_, and update.

Referenced by buildAlignables(), and objectIdProvider().

80  {
81  // PixelBarrel
83 
84  // PixelEndcap
86 
87  // TIB
89 
90  // TID
92 
93  // TOB
95 
96  // TEC
98 }
const DetContainer & detsTEC() const
const DetContainer & detsPXB() const
const AlignableObjectId alignableObjectId_
const DetContainer & detsTIB() const
const char * idToString(align::StructureType type) const
#define update(a, b)
const DetContainer & detsPXF() const
const DetContainer & detsTOB() const
void convertGeomDetsToAlignables(const TrackingGeometry::DetContainer &, const std::string &moduleName, bool update=false)
const TrackerGeometry * trackerGeometry_
const DetContainer & detsTID() const
void AlignableTrackerBuilder::buildAlignables ( AlignableTracker trackerAlignables,
bool  update = false 
)

Builds all Alignables (units and composites) of the tracker, based on the given TrackerGeometry.

Definition at line 52 of file AlignableTrackerBuilder.cc.

References alignableMap_, AlignableTracker::alignableMap_, buildAlignableComposites(), buildAlignableDetUnits(), buildPixelDetector(), buildStripDetector(), AlignableComposite::components(), AlignableMap::get(), and Alignable::theId.

Referenced by AlignableTracker::AlignableTracker(), and AlignableTracker::update().

52  {
53  alignableMap_ = &trackerAlignables->alignableMap_;
54 
55  // first, build Alignables on module-level (AlignableDetUnits)
57 
58  // now build the composite Alignables (Ladders, Layers etc.)
60 
61  if (update)
62  return; // everything else not needed for the update
63 
64  // create pixel-detector
65  buildPixelDetector(trackerAlignables);
66  // create strip-detector
67  buildStripDetector(trackerAlignables);
68 
69  // tracker itself is of course also an Alignable
70  alignableMap_->get("Tracker").push_back(trackerAlignables);
71  // id is the id of first component (should be TPBBarrel)
72  trackerAlignables->theId = trackerAlignables->components()[0]->id();
73 }
const Alignables & components() const override
Return vector of direct components.
align::Alignables & get(const std::string &name="")
Definition: AlignableMap.cc:7
void buildPixelDetector(AlignableTracker *)
Builds the PixelDetector by hand.
AlignableMap alignableMap_
void buildAlignableDetUnits(bool update=false)
Builds Alignables on module-level for each part of the tracker.
void buildStripDetector(AlignableTracker *)
Builds the StripDetector by hand.
#define update(a, b)
align::ID theId
Definition: Alignable.h:235
void buildAlignableComposites(bool update=false)
void AlignableTrackerBuilder::buildPixelDetector ( AlignableTracker trackerAlignables)
private

Builds the PixelDetector by hand.

Definition at line 267 of file AlignableTrackerBuilder.cc.

References AlignableComposite::addComponent(), alignableMap_, alignableObjectId_, AlignableMap::find(), AlignableMap::get(), AlignableObjectId::idToString(), align::Pixel, AlCaHLTBitMon_QueryRunRegistry::string, align::TPBBarrel, and align::TPEEndcap.

Referenced by buildAlignables(), and objectIdProvider().

267  {
271 
272  auto& pxbAlignables = alignableMap_->find(pxbName);
273  auto& pxeAlignables = alignableMap_->find(pxeName);
274  auto& pixelAlignables = alignableMap_->get(pixelName);
275 
276  pixelAlignables.push_back(new AlignableComposite(pxbAlignables[0]->id(), align::Pixel, align::RotationType()));
277 
278  pixelAlignables[0]->addComponent(pxbAlignables[0]);
279  pixelAlignables[0]->addComponent(pxeAlignables[0]);
280  pixelAlignables[0]->addComponent(pxeAlignables[1]);
281 
282  trackerAlignables->addComponent(pixelAlignables[0]);
283 
284  edm::LogInfo("AlignableBuildProcess") << "@SUB=AlignableTrackerBuilder::buildPixelDetector"
285  << "Built " << pixelName << "-detector Alignable, consisting of Alignables"
286  << " of " << pxbName << " and " << pxeName;
287 }
align::Alignables & get(const std::string &name="")
Definition: AlignableMap.cc:7
align::Alignables & find(const std::string &name="")
Definition: AlignableMap.cc:10
const AlignableObjectId alignableObjectId_
const char * idToString(align::StructureType type) const
void addComponent(Alignable *component) final
void AlignableTrackerBuilder::buildPixelDetectorAlignable ( const GeomDet geomDetUnit,
int  subdetId,
Alignables aliDets,
Alignables aliDetUnits,
bool  update = false 
)
private

Converts GeomDetUnits of PXB and PXE to AlignableDetUnits.

Definition at line 147 of file AlignableTrackerBuilder.cc.

References align::AlignableDetUnit, Exception, GeomDet::geographicalId(), mps_fire::i, GeomDet::isLeaf(), numDetUnits, DetId::rawId(), and AlignableDetUnit::update().

Referenced by buildStripDetectorAlignable(), convertGeomDetsToAlignables(), and objectIdProvider().

148  {
149  // treat all pixel dets in same way with one AlignableDetUnit
150  if (!geomDetUnit->isLeaf()) {
151  throw cms::Exception("BadHierarchy") << "[AlignableTrackerBuilder] Pixel GeomDet (subdetector " << subdetId
152  << ") is not a GeomDetUnit.";
153  }
154 
155  if (update) {
156  auto ali = std::find_if(aliDets.cbegin(), aliDets.cend(), [&geomDetUnit](const auto& i) {
157  return i->id() == geomDetUnit->geographicalId().rawId();
158  });
159  if (ali != aliDets.end()) {
160  // add dynamic cast here to get AlignableDetUnit!
161  auto aliDetUnit = dynamic_cast<AlignableDetUnit*>(*ali);
162  if (aliDetUnit) {
163  aliDetUnit->update(geomDetUnit);
164  } else {
165  throw cms::Exception("LogicError") << "[AlignableTrackerBuilder::buildPixelDetectorAlignable] "
166  << "cast to 'AlignableDetUnit*' failed while it should not\n";
167  }
168  } else {
169  throw cms::Exception("GeometryMismatch")
170  << "[AlignableTrackerBuilder::buildPixelDetectorAlignable] "
171  << "GeomDet with DetId " << geomDetUnit->geographicalId().rawId() << " not found in current geometry.\n";
172  }
173  } else {
174  aliDets.push_back(new AlignableDetUnit(geomDetUnit));
175  aliDetUnits.push_back(aliDets.back());
176  }
177  numDetUnits += 1;
178 }
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
void update(const GeomDetUnit *geomDetUnit)
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
virtual bool isLeaf() const
is a Unit
Definition: GeomDet.h:70
#define update(a, b)
void AlignableTrackerBuilder::buildStripDetector ( AlignableTracker trackerAlignables)
private

Builds the StripDetector by hand.

Definition at line 290 of file AlignableTrackerBuilder.cc.

References AlignableComposite::addComponent(), alignableMap_, alignableObjectId_, AlignableMap::find(), AlignableMap::get(), AlignableObjectId::idToString(), AlCaHLTBitMon_QueryRunRegistry::string, align::Strip, align::TECEndcap, align::TIBBarrel, align::TIDEndcap, and align::TOBBarrel.

Referenced by buildAlignables(), and objectIdProvider().

290  {
296 
297  auto& tibAlignables = alignableMap_->find(tibName);
298  auto& tidAlignables = alignableMap_->find(tidName);
299  auto& tobAlignables = alignableMap_->find(tobName);
300  auto& tecAlignables = alignableMap_->find(tecName);
301  auto& stripAlignables = alignableMap_->get(stripName);
302 
303  stripAlignables.push_back(new AlignableComposite(tibAlignables[0]->id(), align::Strip, align::RotationType()));
304 
305  stripAlignables[0]->addComponent(tibAlignables[0]);
306  stripAlignables[0]->addComponent(tidAlignables[0]);
307  stripAlignables[0]->addComponent(tidAlignables[1]);
308  stripAlignables[0]->addComponent(tobAlignables[0]);
309  stripAlignables[0]->addComponent(tecAlignables[0]);
310  stripAlignables[0]->addComponent(tecAlignables[1]);
311 
312  trackerAlignables->addComponent(stripAlignables[0]);
313 
314  edm::LogInfo("AlignableBuildProcess") << "@SUB=AlignableTrackerBuilder::buildStripDetector"
315  << "Built " << stripName << "-detector Alignable, consisting of Alignables"
316  << " of " << tibName << ", " << tidName << ", " << tobName << " and "
317  << tecName;
318 }
align::Alignables & get(const std::string &name="")
Definition: AlignableMap.cc:7
align::Alignables & find(const std::string &name="")
Definition: AlignableMap.cc:10
const AlignableObjectId alignableObjectId_
const char * idToString(align::StructureType type) const
void addComponent(Alignable *component) final
void AlignableTrackerBuilder::buildStripDetectorAlignable ( const GeomDet geomDet,
int  subdetId,
Alignables aliDets,
Alignables aliDetUnits,
bool  update = false 
)
private

Converts GeomDets of TIB, TID, TOB and TEC either to AlignableDetUnits or AlignableSiStripDet, depending on the module-type (2D or 1D).

Definition at line 181 of file AlignableTrackerBuilder.cc.

References buildPixelDetectorAlignable(), GeomDet::components(), Exception, GeomDet::geographicalId(), mps_fire::i, numDetUnits, DetId::rawId(), and AlignableDet::update().

Referenced by convertGeomDetsToAlignables(), and objectIdProvider().

182  {
183  // In strip we have:
184  // 1) 'Pure' 1D-modules like TOB layers 3-6 (not glued): AlignableDetUnit
185  // 2) Composite 2D-modules like TOB layers 1&2 (not glued): AlignableDet
186  // 3) The two 1D-components of case 2 (glued): AlignableDetUnit that is constructed
187  // inside AlignableDet-constructor of 'mother', only need to add to alignableLists
188  const SiStripDetId detId(geomDet->geographicalId());
189 
190  // 2D- or 'pure' 1D-module
191  if (!detId.glued()) {
192  if (!geomDet->components().empty()) {
193  // 2D-module, convert it to GluedGeomDet
194  const GluedGeomDet* gluedGeomDet = dynamic_cast<const GluedGeomDet*>(geomDet);
195  if (!gluedGeomDet) {
196  throw cms::Exception("LogicError") << "[AlignableTrackerBuilder] dynamic_cast<const GluedGeomDet*> "
197  << "failed.";
198  }
199 
200  // components (AlignableDetUnits) constructed within
201  if (update) {
202  auto ali = std::find_if(aliDets.cbegin(), aliDets.cend(), [&gluedGeomDet](const auto& i) {
203  return i->id() == gluedGeomDet->geographicalId().rawId();
204  });
205  if (ali != aliDets.end()) {
206  auto aliSiStripDet = dynamic_cast<AlignableSiStripDet*>(*ali);
207  if (aliSiStripDet) {
208  aliSiStripDet->update(gluedGeomDet);
209  } else {
210  throw cms::Exception("LogicError") << "[AlignableTrackerBuilder::buildStripDetectorAlignable] "
211  << "cast to 'AlignableSiStripDet*' failed while it should not\n";
212  }
213  } else {
214  throw cms::Exception("GeometryMismatch")
215  << "[AlignableTrackerBuilder::buildStripDetectorAlignable] "
216  << "GeomDet with DetId " << gluedGeomDet->geographicalId().rawId() << " not found in current geometry.\n";
217  }
218  } else {
219  aliDets.push_back(new AlignableSiStripDet(gluedGeomDet));
220  }
221  const auto& addAliDetUnits = aliDets.back()->components();
222  const auto& nAddedUnits = addAliDetUnits.size();
223 
224  if (!update) {
225  // reserve space for the additional units:
226  aliDetUnits.reserve(aliDetUnits.size() + nAddedUnits - 1);
227  aliDetUnits.insert(aliDetUnits.end(), addAliDetUnits.begin(), addAliDetUnits.end());
228  }
229  numDetUnits += nAddedUnits;
230 
231  } else {
232  // no components: pure 1D-module
233  buildPixelDetectorAlignable(geomDet, subdetId, aliDets, aliDetUnits, update);
234  }
235  } // no else: glued components of AlignableDet constructed within
236  // AlignableSiStripDet -> AlignableDet, see above
237 }
void buildPixelDetectorAlignable(const GeomDet *, int subdetId, Alignables &aliDets, Alignables &aliDetUnits, bool update=false)
Converts GeomDetUnits of PXB and PXE to AlignableDetUnits.
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
virtual std::vector< const GeomDet * > components() const
Returns direct components, if any.
Definition: GeomDet.h:73
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:18
#define update(a, b)
void update(const GeomDet *geomDet, bool updateComponents=true)
Definition: AlignableDet.cc:50
void AlignableTrackerBuilder::convertGeomDetsToAlignables ( const TrackingGeometry::DetContainer geomDets,
const std::string &  moduleName,
bool  update = false 
)
private

Decides whether a GeomDet is from Pixel- or Strip-Detector and calls the according method to build the Alignable.

Definition at line 101 of file AlignableTrackerBuilder.cc.

References TrackerAlignmentLevelBuilder::addDetUnitInfo(), alignableMap_, buildPixelDetectorAlignable(), buildStripDetectorAlignable(), Exception, AlignableMap::get(), numDetUnits, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, SiStripDetId::TEC, SiStripDetId::TIB, SiStripDetId::TID, SiStripDetId::TOB, and trackerAlignmentLevelBuilder_.

Referenced by buildAlignableDetUnits(), and objectIdProvider().

103  {
104  numDetUnits = 0;
105 
106  auto& alignables = alignableMap_->get(moduleName);
107  if (!update)
108  alignables.reserve(geomDets.size());
109 
110  // units are added for each moduleName, which are at moduleName + "Unit"
111  // in the pixel Module and ModuleUnit are equivalent
112  auto& aliUnits = alignableMap_->get(moduleName + "Unit");
113  if (!update)
114  aliUnits.reserve(geomDets.size()); // minimal number space needed
115 
116  for (auto& geomDet : geomDets) {
117  int subdetId = geomDet->geographicalId().subdetId(); //don't check det()==Tracker
118 
119  if (subdetId == PixelSubdetector::PixelBarrel || subdetId == PixelSubdetector::PixelEndcap) {
120  buildPixelDetectorAlignable(geomDet, subdetId, alignables, aliUnits, update);
121 
122  } else if (subdetId == SiStripDetId::TIB || subdetId == SiStripDetId::TID || subdetId == SiStripDetId::TOB ||
123  subdetId == SiStripDetId::TEC) {
124  // for strip we create also <TIB/TID/TOB/TEC>ModuleUnit list
125  // for 1D components of 2D layers
126  buildStripDetectorAlignable(geomDet, subdetId, alignables, aliUnits, update);
127 
128  } else {
129  throw cms::Exception("LogicError") << "[AlignableTrackerBuilder] GeomDet of unknown subdetector";
130  }
131 
132  trackerAlignmentLevelBuilder_.addDetUnitInfo(geomDet->geographicalId());
133  }
134 
135  // JFI: For PXB and PXE we exclusively build AlignableDetUnit, hence
136  // alignables.size() and numDetUnits are equal. But for modules in Strip
137  // we also create AlignableSiStripDets, which consist of multiple
138  // AlignableDetUnits, hence alignables.size() and numDetUnits are not equal.
139 
140  edm::LogInfo("AlignableBuildProcess") << "@SUB=AlignableTrackerBuilder::convertGeomDetsToAlignables"
141  << "converted GeomDets to Alignables for " << moduleName << "\n"
142  << " GeomDets: " << geomDets.size() << "\n"
143  << " AlignableDetUnits: " << numDetUnits;
144 }
align::Alignables & get(const std::string &name="")
Definition: AlignableMap.cc:7
void buildPixelDetectorAlignable(const GeomDet *, int subdetId, Alignables &aliDets, Alignables &aliDetUnits, bool update=false)
Converts GeomDetUnits of PXB and PXE to AlignableDetUnits.
static constexpr auto TID
Definition: SiStripDetId.h:38
TrackerAlignmentLevelBuilder trackerAlignmentLevelBuilder_
static constexpr auto TOB
Definition: SiStripDetId.h:39
static constexpr auto TIB
Definition: SiStripDetId.h:37
#define update(a, b)
void buildStripDetectorAlignable(const GeomDet *, int subdetId, Alignables &aliDets, Alignables &aliDetUnits, bool update=false)
static constexpr auto TEC
Definition: SiStripDetId.h:40
const AlignableObjectId& AlignableTrackerBuilder::objectIdProvider ( ) const
inline
const align::TrackerNameSpace& AlignableTrackerBuilder::trackerNameSpace ( ) const
inline

Return tracker name space derived from the tracker's topology.

Definition at line 30 of file AlignableTrackerBuilder.h.

References trackerAlignmentLevelBuilder_, and TrackerAlignmentLevelBuilder::trackerNameSpace().

Referenced by AlignableTracker::AlignableTracker().

const align::TrackerNameSpace & trackerNameSpace() const
TrackerAlignmentLevelBuilder trackerAlignmentLevelBuilder_

Member Data Documentation

AlignableMap* AlignableTrackerBuilder::alignableMap_
private
const AlignableObjectId AlignableTrackerBuilder::alignableObjectId_
private
int AlignableTrackerBuilder::numDetUnits = 0
private
TrackerAlignmentLevelBuilder AlignableTrackerBuilder::trackerAlignmentLevelBuilder_
private
const TrackerGeometry* AlignableTrackerBuilder::trackerGeometry_
private

Definition at line 63 of file AlignableTrackerBuilder.h.

Referenced by buildAlignableComposites(), and buildAlignableDetUnits().

const TrackerTopology* AlignableTrackerBuilder::trackerTopology_
private

Definition at line 64 of file AlignableTrackerBuilder.h.

Referenced by buildAlignableComposites().