CMS 3D CMS Logo

AlignableTrackerBuilder.cc
Go to the documentation of this file.
2 
3 // Original Author: Max Stark
4 // Created: Thu, 13 Jan 2016 10:22:57 CET
5 
6 // geometry
9 
10 // alignment
16 
18 
19 //=============================================================================
20 //=== PUBLIC METHOD IMPLEMENTATION ===
21 //=============================================================================
22 
23 //_____________________________________________________________________________
25  const TrackerTopology* trackerTopology)
26  : trackerGeometry_(trackerGeometry),
27  trackerTopology_(trackerTopology),
28  alignableObjectId_(trackerGeometry, nullptr, 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 }
50 
51 //_____________________________________________________________________________
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 }
74 
75 //=============================================================================
76 //=== PRIVATE METHOD IMPLEMENTATION ===
77 //=============================================================================
78 
79 //_____________________________________________________________________________
81  // PixelBarrel
83 
84  // PixelEndcap
86 
87  // TIB
89 
90  // TID
92 
93  // TOB
95 
96  // TEC
98 }
99 
100 //_____________________________________________________________________________
102  const std::string& moduleName,
103  bool update) {
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 }
145 
146 //_____________________________________________________________________________
148  const GeomDet* geomDetUnit, int subdetId, Alignables& aliDets, Alignables& aliDetUnits, bool update) {
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 }
179 
180 //_____________________________________________________________________________
182  const GeomDet* geomDet, int subdetId, Alignables& aliDets, Alignables& aliDetUnits, bool update) {
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 }
238 
239 //_____________________________________________________________________________
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 }
265 
266 //_____________________________________________________________________________
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 }
288 
289 //_____________________________________________________________________________
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 }
personalPlayback.level
level
Definition: personalPlayback.py:22
AlignableTrackerBuilder::buildAlignableComposites
void buildAlignableComposites(bool update=false)
Definition: AlignableTrackerBuilder.cc:240
AlignableTrackerBuilder::buildStripDetectorAlignable
void buildStripDetectorAlignable(const GeomDet *, int subdetId, Alignables &aliDets, Alignables &aliDetUnits, bool update=false)
Definition: AlignableTrackerBuilder.cc:181
TkRotation< Scalar >
AlignableObjectId::Geometry::RunI
mps_fire.i
i
Definition: mps_fire.py:428
align::TPBBarrel
Definition: StructureType.h:27
AlignableDetUnit.h
PixelSubdetector::PixelEndcap
Definition: PixelSubdetector.h:11
align::TECEndcap
Definition: StructureType.h:66
GeomDet
Definition: GeomDet.h:27
PixelSubdetector::PixelBarrel
Definition: PixelSubdetector.h:11
align::TOBBarrel
Definition: StructureType.h:58
AlignableComposite::components
const Alignables & components() const override
Return vector of direct components.
Definition: AlignableComposite.h:45
AlignableTrackerBuilder::buildPixelDetectorAlignable
void buildPixelDetectorAlignable(const GeomDet *, int subdetId, Alignables &aliDets, Alignables &aliDetUnits, bool update=false)
Converts GeomDetUnits of PXB and PXE to AlignableDetUnits.
Definition: AlignableTrackerBuilder.cc:147
TrackerAlignmentLevelBuilder::trackerNameSpace
const align::TrackerNameSpace & trackerNameSpace() const
Definition: TrackerAlignmentLevelBuilder.cc:66
TrackerTopology
Definition: TrackerTopology.h:16
align::TOBModule
Definition: StructureType.h:54
AlignableComposite
Definition: AlignableComposite.h:25
align::TPEEndcap
Definition: StructureType.h:35
align::TIBModule
Definition: StructureType.h:38
TrackerAlignableIndexer.h
GluedGeomDet.h
SiStripDetId.h
GeomDet::components
virtual std::vector< const GeomDet * > components() const
Returns direct components, if any.
Definition: GeomDet.h:73
AlignableObjectId::Geometry::PhaseII
AlignableCompositeBuilder
Definition: AlignableCompositeBuilder.h:14
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
AlignableTrackerBuilder::buildPixelDetector
void buildPixelDetector(AlignableTracker *)
Builds the PixelDetector by hand.
Definition: AlignableTrackerBuilder.cc:267
TrackerGeometry::detsPXB
const DetContainer & detsPXB() const
Definition: TrackerGeometry.cc:171
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
AlignableSiStripDet.h
TrackerGeometry::detsTOB
const DetContainer & detsTOB() const
Definition: TrackerGeometry.cc:179
AlignableTrackerBuilder::trackerTopology_
const TrackerTopology * trackerTopology_
Definition: AlignableTrackerBuilder.h:64
AlignableCompositeBuilder.h
AlignableTrackerBuilder::trackerAlignmentLevelBuilder_
TrackerAlignmentLevelBuilder trackerAlignmentLevelBuilder_
Definition: AlignableTrackerBuilder.h:69
AlignableTrackerBuilder.h
AlignableTracker
Definition: AlignableTracker.h:17
TrackerGeometry::detsPXF
const DetContainer & detsPXF() const
Definition: TrackerGeometry.cc:173
AlignableTracker::alignableMap_
AlignableMap alignableMap_
Definition: AlignableTracker.h:118
AlignableComposite::addComponent
void addComponent(Alignable *component) final
Definition: AlignableComposite.cc:53
AlignableTrackerBuilder::alignableMap_
AlignableMap * alignableMap_
Definition: AlignableTrackerBuilder.h:67
SiStripDetId::TEC
static constexpr auto TEC
Definition: SiStripDetId.h:40
TrackerGeometry::detsTID
const DetContainer & detsTID() const
Definition: TrackerGeometry.cc:177
GluedGeomDet
Definition: GluedGeomDet.h:7
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
GeomDet::geographicalId
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
AlignableTrackerBuilder::numDetUnits
int numDetUnits
Definition: AlignableTrackerBuilder.h:71
align::AlignableDetUnit
Definition: StructureType.h:19
TrackerAlignableIndexer
Definition: TrackerAlignableIndexer.h:24
AlignableMap::find
align::Alignables & find(const std::string &name="")
Definition: AlignableMap.cc:10
TrackingGeometry::DetContainer
std::vector< const GeomDet * > DetContainer
Definition: TrackingGeometry.h:29
EcalCalibMonitorClient_cfi.moduleName
moduleName
Definition: EcalCalibMonitorClient_cfi.py:17
TrackerGeometry::detsTIB
const DetContainer & detsTIB() const
Definition: TrackerGeometry.cc:175
SiStripDetId::TOB
static constexpr auto TOB
Definition: SiStripDetId.h:39
align::TIDModule
Definition: StructureType.h:47
align::TIDEndcap
Definition: StructureType.h:51
AlignableTrackerBuilder::buildAlignableDetUnits
void buildAlignableDetUnits(bool update=false)
Builds Alignables on module-level for each part of the tracker.
Definition: AlignableTrackerBuilder.cc:80
TrackerAlignmentLevelBuilder::addDetUnitInfo
void addDetUnitInfo(const DetId &detId)
Definition: TrackerAlignmentLevelBuilder.cc:27
AlignableTrackerBuilder::buildStripDetector
void buildStripDetector(AlignableTracker *)
Builds the StripDetector by hand.
Definition: AlignableTrackerBuilder.cc:290
AlignableSiStripDet
Definition: AlignableSiStripDet.h:23
AlignableTrackerBuilder::alignableObjectId_
const AlignableObjectId alignableObjectId_
Definition: AlignableTrackerBuilder.h:65
AlignableObjectId.h
SiStripDetId::TID
static constexpr auto TID
Definition: SiStripDetId.h:38
AlignableTrackerBuilder::convertGeomDetsToAlignables
void convertGeomDetsToAlignables(const TrackingGeometry::DetContainer &, const std::string &moduleName, bool update=false)
Definition: AlignableTrackerBuilder.cc:101
GeomDet.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
AlignableTrackerBuilder::trackerGeometry_
const TrackerGeometry * trackerGeometry_
Definition: AlignableTrackerBuilder.h:63
align::TPEModule
Definition: StructureType.h:30
AlignableTrackerBuilder::Alignables
align::Alignables Alignables
Definition: AlignableTrackerBuilder.h:18
TrackerGeometry::detsTEC
const DetContainer & detsTEC() const
Definition: TrackerGeometry.cc:181
align::TIBBarrel
Definition: StructureType.h:44
Exception
Definition: hltDiff.cc:245
align::Strip
Definition: StructureType.h:69
AlignableTrackerBuilder::AlignableTrackerBuilder
AlignableTrackerBuilder(const TrackerGeometry *, const TrackerTopology *)
Definition: AlignableTrackerBuilder.cc:24
SiStripDetId::TIB
static constexpr auto TIB
Definition: SiStripDetId.h:37
Alignable::theId
align::ID theId
Definition: Alignable.h:235
AlignableMap::get
align::Alignables & get(const std::string &name="")
Definition: AlignableMap.cc:7
align::Pixel
Definition: StructureType.h:68
AlignableObjectId::idToString
const char * idToString(align::StructureType type) const
Definition: AlignableObjectId.cc:272
AlignableObjectId::geometry
Geometry geometry() const
retrieve the geometry information
Definition: AlignableObjectId.h:27
TrackerAlignmentLevelBuilder::build
std::vector< align::AlignmentLevels > build()
Definition: TrackerAlignmentLevelBuilder.cc:53
SiStripDetId
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:18
AlignableTrackerBuilder::buildAlignables
void buildAlignables(AlignableTracker *, bool update=false)
Definition: AlignableTrackerBuilder.cc:52
GeomDet::isLeaf
virtual bool isLeaf() const
is a Unit
Definition: GeomDet.h:70
AlignableObjectId::Geometry::PhaseI
align::TECModule
Definition: StructureType.h:61
update
#define update(a, b)
Definition: TrackClassifier.cc:10
TrackerGeometry
Definition: TrackerGeometry.h:14
align::TPBModule
Definition: StructureType.h:23