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 19 of file AlignableTrackerBuilder.h.

Member Typedef Documentation

Definition at line 20 of file AlignableTrackerBuilder.h.

Constructor & Destructor Documentation

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

Definition at line 25 of file AlignableTrackerBuilder.cc.

References buildAlignables(), Exception, AlignableObjectId::PhaseI, AlignableObjectId::PhaseII, and AlignableObjectId::RunI.

26  :
27  trackerGeometry_(trackerGeometry),
28  trackerTopology_(trackerTopology),
29  alignableObjectId_(trackerGeometry, nullptr, nullptr),
30  alignableMap_(nullptr),
31  trackerAlignmentLevelBuilder_(trackerTopology, trackerGeometry)
32 {
33  std::ostringstream ss;
34 
35  switch (alignableObjectId_.geometry()) {
36  case AlignableObjectId::Geometry::RunI: ss << "RunI geometry"; break;
37  case AlignableObjectId::Geometry::PhaseI: ss << "PhaseI geometry"; break;
38  case AlignableObjectId::Geometry::PhaseII: ss << "PhaseII geometry"; break;
39  default:
40  throw cms::Exception("LogicError")
41  << "[AlignableTrackerBuilder] unknown version of TrackerGeometry";
42  }
43 
44  edm::LogInfo("AlignableBuildProcess")
45  << "@SUB=AlignableTrackerBuilder::AlignableTrackerBuilder"
46  << "GeometryVersion: " << ss.str();
47 }
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 282 of file AlignableTrackerBuilder.cc.

References AlignableCompositeBuilder::addAlignmentLevel(), buildPixelDetector(), hcalDigis_cfi::level, and eostools::move().

Referenced by buildStripDetectorAlignable(), and objectIdProvider().

283 {
284  unsigned int numCompositeAlignables = 0;
285 
286  // tracker levels must be built before the indexer is created in order to pass
287  // a valid namespace to the indexer; an exception would be thrown if one tries
288  // to get the namespace w/o building the levels
289  auto trackerLevels = trackerAlignmentLevelBuilder_.build();
291  AlignableCompositeBuilder compositeBuilder{trackerTopology_, trackerGeometry_, trackerIndexer};
292 
293  for (auto& trackerSubLevels: trackerLevels) {
294  // first add all levels of the current subdetector to the builder
295  for (auto& level: trackerSubLevels) {
296  compositeBuilder.addAlignmentLevel(std::move(level));
297  }
298  // now build this tracker-level
299  numCompositeAlignables += compositeBuilder.buildAll(*alignableMap_, update);
300  // finally, reset the builder
301  compositeBuilder.clearAlignmentLevels();
302  }
303 
304  edm::LogInfo("AlignableBuildProcess")
305  << "@SUB=AlignableTrackerBuilder::buildAlignableComposites"
306  << "AlignableComposites built for Tracker: " << numCompositeAlignables
307  << " (note: without Pixel- and Strip-Alignable)";
308 }
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:510
void AlignableTrackerBuilder::buildAlignableDetUnits ( bool  update = false)
private

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

Definition at line 82 of file AlignableTrackerBuilder.cc.

References convertGeomDetsToAlignables(), align::TECModule, align::TIBModule, align::TIDModule, align::TOBModule, align::TPBModule, align::TPEModule, and update.

Referenced by buildAlignables(), and objectIdProvider().

83 {
84  // PixelBarrel
87  update
88  );
89 
90  // PixelEndcap
93  update
94  );
95 
96  // TIB
99  update
100  );
101 
102  // TID
105  update
106  );
107 
108  // TOB
111  update
112  );
113 
114  // TEC
117  update
118  );
119 }
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 51 of file AlignableTrackerBuilder.cc.

References AlignableTracker::alignableMap_, buildAlignableDetUnits(), AlignableComposite::components(), and Alignable::theId.

Referenced by AlignableTracker::AlignableTracker(), AlignableTrackerBuilder(), 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) return; // everything else not needed for the update
62 
63  // create pixel-detector
64  buildPixelDetector(trackerAlignables);
65  // create strip-detector
66  buildStripDetector(trackerAlignables);
67 
68  // tracker itself is of course also an Alignable
69  alignableMap_->get("Tracker").push_back(trackerAlignables);
70  // id is the id of first component (should be TPBBarrel)
71  trackerAlignables->theId = trackerAlignables->components()[0]->id();
72 }
const Alignables & components() const override
Return vector of direct components.
align::Alignables & get(const std::string &name="")
Definition: AlignableMap.cc:9
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:244
void buildAlignableComposites(bool update=false)
void AlignableTrackerBuilder::buildPixelDetector ( AlignableTracker trackerAlignables)
private

Builds the PixelDetector by hand.

Definition at line 312 of file AlignableTrackerBuilder.cc.

References AlignableComposite::addComponent(), buildStripDetector(), align::Pixel, AlCaHLTBitMon_QueryRunRegistry::string, align::TPBBarrel, and align::TPEEndcap.

Referenced by buildAlignableComposites(), and objectIdProvider().

313 {
317 
318  auto& pxbAlignables = alignableMap_->find(pxbName);
319  auto& pxeAlignables = alignableMap_->find(pxeName);
320  auto& pixelAlignables = alignableMap_->get (pixelName);
321 
322  pixelAlignables.push_back(
323  new AlignableComposite(pxbAlignables[0]->id(), align::Pixel, align::RotationType())
324  );
325 
326  pixelAlignables[0]->addComponent(pxbAlignables[0]);
327  pixelAlignables[0]->addComponent(pxeAlignables[0]);
328  pixelAlignables[0]->addComponent(pxeAlignables[1]);
329 
330  trackerAlignables->addComponent(pixelAlignables[0]);
331 
332  edm::LogInfo("AlignableBuildProcess")
333  << "@SUB=AlignableTrackerBuilder::buildPixelDetector"
334  << "Built " << pixelName << "-detector Alignable, consisting of Alignables"
335  << " of " << pxbName << " and " << pxeName;
336 }
align::Alignables & get(const std::string &name="")
Definition: AlignableMap.cc:9
align::Alignables & find(const std::string &name="")
Definition: AlignableMap.cc:15
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 173 of file AlignableTrackerBuilder.cc.

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

Referenced by convertGeomDetsToAlignables(), and objectIdProvider().

176 {
177  // treat all pixel dets in same way with one AlignableDetUnit
178  if (!geomDetUnit->isLeaf()) {
179  throw cms::Exception("BadHierarchy")
180  << "[AlignableTrackerBuilder] Pixel GeomDet (subdetector " << subdetId
181  << ") is not a GeomDetUnit.";
182  }
183 
184  if (update) {
185  auto ali =
186  std::find_if(aliDets.cbegin(), aliDets.cend(),
187  [&geomDetUnit](const auto& i) {
188  return i->id() == geomDetUnit->geographicalId().rawId(); });
189  if (ali != aliDets.end()) {
190  // add dynamic cast here to get AlignableDetUnit!
191  auto aliDetUnit = dynamic_cast<AlignableDetUnit*>(*ali);
192  if (aliDetUnit) {
193  aliDetUnit->update(geomDetUnit);
194  } else {
195  throw cms::Exception("LogicError")
196  << "[AlignableTrackerBuilder::buildPixelDetectorAlignable] "
197  << "cast to 'AlignableDetUnit*' failed while it should not\n";
198  }
199  } else {
200  throw cms::Exception("GeometryMismatch")
201  << "[AlignableTrackerBuilder::buildPixelDetectorAlignable] "
202  << "GeomDet with DetId " << geomDetUnit->geographicalId().rawId()
203  << " not found in current geometry.\n";
204  }
205  } else {
206  aliDets.push_back(new AlignableDetUnit(geomDetUnit));
207  aliDetUnits.push_back(aliDets.back());
208  }
209  numDetUnits += 1;
210 }
void update(const GeomDetUnit *geomDetUnit)
uint32_t rawId() const
get the raw id
Definition: DetId.h:44
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:79
virtual bool isLeaf() const
is a Unit
Definition: GeomDet.h:85
#define update(a, b)
void AlignableTrackerBuilder::buildStripDetector ( AlignableTracker trackerAlignables)
private

Builds the StripDetector by hand.

Definition at line 340 of file AlignableTrackerBuilder.cc.

References AlignableComposite::addComponent(), AlCaHLTBitMon_QueryRunRegistry::string, align::Strip, align::TECEndcap, align::TIBBarrel, align::TIDEndcap, and align::TOBBarrel.

Referenced by buildPixelDetector(), and objectIdProvider().

341 {
347 
348  auto& tibAlignables = alignableMap_->find(tibName);
349  auto& tidAlignables = alignableMap_->find(tidName);
350  auto& tobAlignables = alignableMap_->find(tobName);
351  auto& tecAlignables = alignableMap_->find(tecName);
352  auto& stripAlignables = alignableMap_->get (stripName);
353 
354  stripAlignables.push_back(
355  new AlignableComposite(tibAlignables[0]->id(), align::Strip, align::RotationType())
356  );
357 
358  stripAlignables[0]->addComponent(tibAlignables[0]);
359  stripAlignables[0]->addComponent(tidAlignables[0]);
360  stripAlignables[0]->addComponent(tidAlignables[1]);
361  stripAlignables[0]->addComponent(tobAlignables[0]);
362  stripAlignables[0]->addComponent(tecAlignables[0]);
363  stripAlignables[0]->addComponent(tecAlignables[1]);
364 
365  trackerAlignables->addComponent(stripAlignables[0]);
366 
367  edm::LogInfo("AlignableBuildProcess")
368  << "@SUB=AlignableTrackerBuilder::buildStripDetector"
369  << "Built " << stripName << "-detector Alignable, consisting of Alignables"
370  << " of " << tibName << ", " << tidName
371  << ", " << tobName << " and " << tecName;
372 }
align::Alignables & get(const std::string &name="")
Definition: AlignableMap.cc:9
align::Alignables & find(const std::string &name="")
Definition: AlignableMap.cc:15
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 214 of file AlignableTrackerBuilder.cc.

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

Referenced by buildPixelDetectorAlignable(), and objectIdProvider().

217 {
218  // In strip we have:
219  // 1) 'Pure' 1D-modules like TOB layers 3-6 (not glued): AlignableDetUnit
220  // 2) Composite 2D-modules like TOB layers 1&2 (not glued): AlignableDet
221  // 3) The two 1D-components of case 2 (glued): AlignableDetUnit that is constructed
222  // inside AlignableDet-constructor of 'mother', only need to add to alignableLists
223  const SiStripDetId detId(geomDet->geographicalId());
224 
225  // 2D- or 'pure' 1D-module
226  if (!detId.glued()) {
227  if (!geomDet->components().empty()) {
228  // 2D-module, convert it to GluedGeomDet
229  const GluedGeomDet* gluedGeomDet = dynamic_cast<const GluedGeomDet*>(geomDet);
230  if (!gluedGeomDet) {
231  throw cms::Exception("LogicError")
232  << "[AlignableTrackerBuilder] dynamic_cast<const GluedGeomDet*> "
233  << "failed.";
234  }
235 
236  // components (AlignableDetUnits) constructed within
237  if (update) {
238  auto ali =
239  std::find_if(aliDets.cbegin(), aliDets.cend(),
240  [&gluedGeomDet](const auto& i) {
241  return i->id() == gluedGeomDet->geographicalId().rawId(); });
242  if (ali != aliDets.end()) {
243  auto aliSiStripDet = dynamic_cast<AlignableSiStripDet*>(*ali);
244  if (aliSiStripDet) {
245  aliSiStripDet->update(gluedGeomDet);
246  } else {
247  throw cms::Exception("LogicError")
248  << "[AlignableTrackerBuilder::buildStripDetectorAlignable] "
249  << "cast to 'AlignableSiStripDet*' failed while it should not\n";
250  }
251  } else {
252  throw cms::Exception("GeometryMismatch")
253  << "[AlignableTrackerBuilder::buildStripDetectorAlignable] "
254  << "GeomDet with DetId " << gluedGeomDet->geographicalId().rawId()
255  << " not found in current geometry.\n";
256  }
257  } else {
258  aliDets.push_back(new AlignableSiStripDet(gluedGeomDet));
259  }
260  const auto& addAliDetUnits = aliDets.back()->components();
261  const auto& nAddedUnits = addAliDetUnits.size();
262 
263  if (!update) {
264  // reserve space for the additional units:
265  aliDetUnits.reserve(aliDetUnits.size() + nAddedUnits -1);
266  aliDetUnits.insert(aliDetUnits.end(), addAliDetUnits.begin(), addAliDetUnits.end());
267  }
268  numDetUnits += nAddedUnits;
269 
270  } else {
271  // no components: pure 1D-module
272  buildPixelDetectorAlignable(geomDet, subdetId, aliDets, aliDetUnits, update);
273  }
274  } // no else: glued components of AlignableDet constructed within
275  // AlignableSiStripDet -> AlignableDet, see above
276 }
void buildPixelDetectorAlignable(const GeomDet *, int subdetId, Alignables &aliDets, Alignables &aliDetUnits, bool update=false)
Converts GeomDetUnits of PXB and PXE to AlignableDetUnits.
uint32_t rawId() const
get the raw id
Definition: DetId.h:44
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:79
virtual std::vector< const GeomDet * > components() const
Returns direct components, if any.
Definition: GeomDet.h:88
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:17
#define update(a, b)
void update(const GeomDet *geomDet, bool updateComponents=true)
Definition: AlignableDet.cc:62
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 123 of file AlignableTrackerBuilder.cc.

References buildPixelDetectorAlignable(), Exception, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, SiStripDetId::TEC, SiStripDetId::TIB, SiStripDetId::TID, and SiStripDetId::TOB.

Referenced by buildAlignableDetUnits(), and objectIdProvider().

125 {
126  numDetUnits = 0;
127 
128  auto& alignables = alignableMap_->get(moduleName);
129  if (!update) alignables.reserve(geomDets.size());
130 
131  // units are added for each moduleName, which are at moduleName + "Unit"
132  // in the pixel Module and ModuleUnit are equivalent
133  auto & aliUnits = alignableMap_->get(moduleName+"Unit");
134  if (!update) aliUnits.reserve(geomDets.size()); // minimal number space needed
135 
136  for (auto& geomDet : geomDets) {
137  int subdetId = geomDet->geographicalId().subdetId(); //don't check det()==Tracker
138 
139  if (subdetId == PixelSubdetector::PixelBarrel ||
140  subdetId == PixelSubdetector::PixelEndcap) {
141  buildPixelDetectorAlignable(geomDet, subdetId, alignables, aliUnits, update);
142 
143  } else if (subdetId == SiStripDetId::TIB ||
144  subdetId == SiStripDetId::TID ||
145  subdetId == SiStripDetId::TOB ||
146  subdetId == SiStripDetId::TEC) {
147  // for strip we create also <TIB/TID/TOB/TEC>ModuleUnit list
148  // for 1D components of 2D layers
149  buildStripDetectorAlignable(geomDet, subdetId, alignables, aliUnits, update);
150 
151  } else {
152  throw cms::Exception("LogicError")
153  << "[AlignableTrackerBuilder] GeomDet of unknown subdetector";
154  }
155 
156  trackerAlignmentLevelBuilder_.addDetUnitInfo(geomDet->geographicalId());
157  }
158 
159  // JFI: For PXB and PXE we exclusively build AlignableDetUnit, hence
160  // alignables.size() and numDetUnits are equal. But for modules in Strip
161  // we also create AlignableSiStripDets, which consist of multiple
162  // AlignableDetUnits, hence alignables.size() and numDetUnits are not equal.
163 
164  edm::LogInfo("AlignableBuildProcess")
165  << "@SUB=AlignableTrackerBuilder::convertGeomDetsToAlignables"
166  << "converted GeomDets to Alignables for " << moduleName << "\n"
167  << " GeomDets: " << geomDets.size() << "\n"
168  << " AlignableDetUnits: " << numDetUnits;
169 }
align::Alignables & get(const std::string &name="")
Definition: AlignableMap.cc:9
void buildPixelDetectorAlignable(const GeomDet *, int subdetId, Alignables &aliDets, Alignables &aliDetUnits, bool update=false)
Converts GeomDetUnits of PXB and PXE to AlignableDetUnits.
std::string moduleName(Provenance const &provenance)
Definition: Provenance.cc:27
TrackerAlignmentLevelBuilder trackerAlignmentLevelBuilder_
#define update(a, b)
void buildStripDetectorAlignable(const GeomDet *, int subdetId, Alignables &aliDets, Alignables &aliDetUnits, bool update=false)
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 33 of file AlignableTrackerBuilder.h.

References trackerAlignmentLevelBuilder_, and TrackerAlignmentLevelBuilder::trackerNameSpace().

Referenced by AlignableTracker::AlignableTracker().

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

Member Data Documentation

AlignableMap* AlignableTrackerBuilder::alignableMap_
private

Definition at line 75 of file AlignableTrackerBuilder.h.

const AlignableObjectId AlignableTrackerBuilder::alignableObjectId_
private

Definition at line 73 of file AlignableTrackerBuilder.h.

Referenced by objectIdProvider().

int AlignableTrackerBuilder::numDetUnits = 0
private

Definition at line 79 of file AlignableTrackerBuilder.h.

TrackerAlignmentLevelBuilder AlignableTrackerBuilder::trackerAlignmentLevelBuilder_
private

Definition at line 77 of file AlignableTrackerBuilder.h.

Referenced by trackerNameSpace().

const TrackerGeometry* AlignableTrackerBuilder::trackerGeometry_
private

Definition at line 71 of file AlignableTrackerBuilder.h.

const TrackerTopology* AlignableTrackerBuilder::trackerTopology_
private

Definition at line 72 of file AlignableTrackerBuilder.h.