CMS 3D CMS Logo

List of all members | Public Member Functions | 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 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 18 of file AlignableTrackerBuilder.h.

Constructor & Destructor Documentation

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

Definition at line 26 of file AlignableTrackerBuilder.cc.

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

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

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

Referenced by buildStripDetectorAlignable(), and objectIdProvider().

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

84 {
85  // PixelBarrel
88  update
89  );
90 
91  // PixelEndcap
94  update
95  );
96 
97  // TIB
100  update
101  );
102 
103  // TID
106  update
107  );
108 
109  // TOB
112  update
113  );
114 
115  // TEC
118  update
119  );
120 }
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 AlignableTracker::alignableMap_, buildAlignableDetUnits(), AlignableComposite::components(), and Alignable::theId.

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

53 {
54  alignableMap_ = &trackerAlignables->alignableMap_;
55 
56  // first, build Alignables on module-level (AlignableDetUnits)
58 
59  // now build the composite Alignables (Ladders, Layers etc.)
61 
62  if (update) 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 }
void buildPixelDetector(AlignableTracker *)
Builds the PixelDetector by hand.
AlignableMap alignableMap_
Alignables & get(const std::string &name="")
Definition: AlignableMap.cc:9
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)
virtual Alignables components() const
Return vector of direct components.
align::ID theId
Definition: Alignable.h:241
void buildAlignableComposites(bool update=false)
void AlignableTrackerBuilder::buildPixelDetector ( AlignableTracker trackerAlignables)
private

Builds the PixelDetector by hand.

Definition at line 313 of file AlignableTrackerBuilder.cc.

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

Referenced by buildAlignableComposites(), and objectIdProvider().

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

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

Referenced by convertGeomDetsToAlignables(), and objectIdProvider().

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

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

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

Referenced by buildPixelDetectorAlignable(), and objectIdProvider().

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

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

References trackerAlignmentLevelBuilder_, and TrackerAlignmentLevelBuilder::trackerNameSpace().

Referenced by AlignableTracker::AlignableTracker().

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

Member Data Documentation

AlignableMap* AlignableTrackerBuilder::alignableMap_
private

Definition at line 73 of file AlignableTrackerBuilder.h.

const AlignableObjectId AlignableTrackerBuilder::alignableObjectId_
private

Definition at line 71 of file AlignableTrackerBuilder.h.

Referenced by objectIdProvider().

int AlignableTrackerBuilder::numDetUnits = 0
private

Definition at line 77 of file AlignableTrackerBuilder.h.

TrackerAlignmentLevelBuilder AlignableTrackerBuilder::trackerAlignmentLevelBuilder_
private

Definition at line 75 of file AlignableTrackerBuilder.h.

Referenced by trackerNameSpace().

const TrackerGeometry* AlignableTrackerBuilder::trackerGeometry_
private

Definition at line 69 of file AlignableTrackerBuilder.h.

const TrackerTopology* AlignableTrackerBuilder::trackerTopology_
private

Definition at line 70 of file AlignableTrackerBuilder.h.