CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
AlignableTracker.cc
Go to the documentation of this file.
2 
4 
5 // Geometry
12 
13 // Alignment
18 
22 
23 //__________________________________________________________________________________________________
25  AlignableComposite( 0, align::Tracker, RotationType() ), tTopo_(tTopo) // id not yet known
26 {
27 
28  // Get levels from geometry
29  // for strip we create also <TIB/TID/TOB/TEC>ModuleUnit list for 1D components of 2D layers
30  detsToAlignables(tkGeom->detsPXB(), "TPBModule");
31  detsToAlignables(tkGeom->detsPXF(), "TPEModule");
32  detsToAlignables(tkGeom->detsTIB(), "TIBModule");
33  detsToAlignables(tkGeom->detsTID(), "TIDModule");
34  detsToAlignables(tkGeom->detsTOB(), "TOBModule");
35  detsToAlignables(tkGeom->detsTEC(), "TECModule");
36 
37  buildTPB();
38  buildTPE();
39  buildTIB();
40  buildTID();
41  buildTOB();
42  buildTEC();
43  buildTRK();
44 
45  theId = this->components()[0]->id(); // as all composites: id of first component
46 }
47 
48 
49 //__________________________________________________________________________________________________
51  const std::string& moduleName )
52 {
53  unsigned int nDet = dets.size();
54 
55  align::Alignables& alis = alignableLists_.get(moduleName);
56  alis.reserve(nDet);
57  align::Alignables *aliUnits = 0;// If we need also units, they will be at moduleName + "Unit".
58 
59  for (unsigned int i = 0; i < nDet; ++i) {
60 
61  const unsigned int subdetId = dets[i]->geographicalId().subdetId();//don't check det()==Tracker
62  if (subdetId == PixelSubdetector::PixelBarrel || subdetId == PixelSubdetector::PixelEndcap) {
63  // Treat all pixel dets in same way with one AlignableDetUnit.
64  auto detUnit = dets[i];
65  if (!detUnit->isLeaf()) {
66  throw cms::Exception("BadHierarchy")
67  << "[AlignableTracker] Pixel GeomDet (subdetector " << subdetId << ") not GeomDetUnit.\n";
68  }
69  alis.push_back(new AlignableDetUnit(detUnit));
70 
71  // Add pixel modules to list of units since they are in fact units
72  if (!aliUnits) {
73  aliUnits = &alignableLists_.get(moduleName + "Unit");
74  aliUnits->reserve(576); // ugly hardcode to save some memory due to vector doubling
75  }
76  aliUnits->push_back(alis.back());
77 
78  } else if (subdetId == SiStripDetId::TIB || subdetId == SiStripDetId::TID
79  || subdetId == SiStripDetId::TOB || subdetId == SiStripDetId::TEC) {
80  // In strip we have:
81  // 1) 'Pure' 1D-modules like TOB layers 3-6 (not glued): AlignableDetUnit
82  // 2) Composite 2D-modules like TOB layers 1&2 (not glued): AlignableDet
83  // 3) The two 1D-components of case 2 (glued): AlignableDetUnit that is constructed
84  // inside AlignableDet-constructor of 'mother', only need to add to alignableLists_
85  const SiStripDetId detId(dets[i]->geographicalId());
86  if (!detId.glued()) { // 2D- or 'pure' 1D-module
87  if (dets[i]->components().size()) { // 2D-module
88  const GluedGeomDet *gluedDet = dynamic_cast<const GluedGeomDet*>(dets[i]);
89  if (!gluedDet) {
90  throw cms::Exception("LogicError")
91  << "[AlignableTracker]" << "dynamic_cast<const GluedGeomDet*> failed.\n";
92  }
93  alis.push_back(new AlignableSiStripDet(gluedDet)); // components constructed within
94  const align::Alignables detUnits(alis.back()->components());
95  // Ensure pointer existence and make list available via moduleName appended with "Unit"
96  if (!aliUnits) {
97  aliUnits = &alignableLists_.get(moduleName + "Unit");
98  aliUnits->reserve(576); // ugly hardcode to save some memory due to vector doubling
99  }
100  aliUnits->insert(aliUnits->end(), detUnits.begin(), detUnits.end()); // only 2...
101  } else { // no components: pure 1D-module
102  auto detUnit = dets[i];
103  if (!detUnit->isLeaf()) {
104  throw cms::Exception("BadHierarchy")
105  << "[AlignableTracker] pure 1D GeomDet (subdetector " << subdetId << ") not GeomDetUnit.\n";
106  }
107  alis.push_back(new AlignableDetUnit(detUnit));
108 
109  // Add pure 1D-modules to list of units since they are in fact units
110  if (!aliUnits) {
111  aliUnits = &alignableLists_.get(moduleName + "Unit");
112  aliUnits->reserve(576); // ugly hardcode to save some memory due to vector doubling
113  }
114  aliUnits->push_back(alis.back());
115  }
116  } // no else: glued components of AlignableDet constructed within AlignableDet, see above
117  } else {
118  throw cms::Exception("LogicError")
119  << "[AlignableTracker] GeomDet of unknown subdetector.";
120  }
121  }
122 
123  LogDebug("Alignment") << "@SUB=AlignableTracker"
124  << alis.size() << " AlignableDet(Unit)s for " << moduleName;
125  if (aliUnits) {
126  LogDebug("Alignment") << "@SUB=AlignableTracker"
127  << aliUnits->size() << " AlignableDetUnits for "
128  << moduleName + "Unit (capacity = " << aliUnits->capacity() << ").";
129  }
130 
131 }
132 
133 
134 //__________________________________________________________________________________________________
136 {
137  align::Alignables& halfBarrels = alignableLists_.find(subDet + "HalfBarrel");
138 
139  const std::string barrelName(subDet + "Barrel");
141  barrel.reserve(1);
142  barrel.push_back(new AlignableComposite(halfBarrels[0]->id(),AlignableObjectId::stringToId(barrelName),
143  RotationType()));
144  barrel[0]->addComponent(halfBarrels[0]);
145  barrel[0]->addComponent(halfBarrels[1]);
146 }
147 
148 //__________________________________________________________________________________________________
150 {
152 
153  builder.addLevelInfo(align::TPBLadder , true, 22); // max 22 ladders per layer
154  builder.addLevelInfo(align::TPBLayer , false, 3); // 3 layers per half barrel
155  builder.addLevelInfo(align::TPBHalfBarrel, false, 2); // 2 half barrels in TPB
156  builder.buildAll( alignableLists_ );
157 
158  buildBarrel("TPB");
159 }
160 
161 //__________________________________________________________________________________________________
163 {
165 
166  builder.addLevelInfo(align::TPEPanel , true, 2); // 2 panels per blade
167  builder.addLevelInfo(align::TPEBlade , true, 12); // 12 blades per half disk
168  builder.addLevelInfo(align::TPEHalfDisk , false, 3); // max 3 disks per cylinder
169  builder.addLevelInfo(align::TPEHalfCylinder, false, 2); // 2 HC per endcap
170  builder.addLevelInfo(align::TPEEndcap , false, 2); // 2 endcaps in TPE
171  builder.buildAll( alignableLists_ );
172 }
173 
174 //__________________________________________________________________________________________________
176 {
178 
179  builder.addLevelInfo(align::TIBString , true, 28); // max 22 strings per surface
180  builder.addLevelInfo(align::TIBSurface , false, 2); // 2 surfaces per half shell
181  builder.addLevelInfo(align::TIBHalfShell , false, 2); // 2 half shells per layer
182  builder.addLevelInfo(align::TIBLayer , false, 4); // 4 layers per half barrel
183  builder.addLevelInfo(align::TIBHalfBarrel, false, 2); // 2 half barrels in TIB
184  builder.buildAll( alignableLists_ );
185 
186  buildBarrel("TIB");
187 }
188 
189 //__________________________________________________________________________________________________
191 {
193 
194  builder.addLevelInfo(align::TIDSide , false, 2); // 2 sides per ring
195  builder.addLevelInfo(align::TIDRing , false, 3); // 3 rings per disk
196  builder.addLevelInfo(align::TIDDisk , false, 3); // 3 disks per endcap
197  builder.addLevelInfo(align::TIDEndcap, false, 2); // 2 endcaps in TID
198  builder.buildAll( alignableLists_ );
199 }
200 
201 //__________________________________________________________________________________________________
203 {
205 
206  builder.addLevelInfo(align::TOBRod , true, 74); // max 74 rods per layer
207  builder.addLevelInfo(align::TOBLayer , false, 6); // 6 layers per half barrel
208  builder.addLevelInfo(align::TOBHalfBarrel, false, 2); // 2 half barrels in TOB
209  builder.buildAll( alignableLists_ );
210 
211  buildBarrel("TOB");
212 }
213 
214 //__________________________________________________________________________________________________
216 {
218 
219  builder.addLevelInfo(align::TECRing , true, 7); // max 7 rings per petal
220  builder.addLevelInfo(align::TECPetal , true, 8); // 8 petals per side
221  builder.addLevelInfo(align::TECSide , false, 2); // 2 sides per disk
222  builder.addLevelInfo(align::TECDisk , false, 9); // 9 disks per endcap
223  builder.addLevelInfo(align::TECEndcap, false, 2); // 2 endcaps in TEC
224  builder.buildAll( alignableLists_ );
225 }
226 
227 //__________________________________________________________________________________________________
229 {
230  // Build pixel, strip and full tracker 'by hand':
231 
232  // First create pixel:
233  const align::Alignables &pixelBarrel = alignableLists_.find("TPBBarrel");
234  const align::Alignables &pixelEndcap = alignableLists_.find("TPEEndcap");
235  align::Alignables &pixel = alignableLists_.get("Pixel");
236  pixel.reserve(1);
237  pixel.push_back(new AlignableComposite(pixelBarrel[0]->id(), align::Pixel, RotationType()));
238  pixel[0]->addComponent(pixelBarrel[0]);
239  pixel[0]->addComponent(pixelEndcap[0]);
240  pixel[0]->addComponent(pixelEndcap[1]);
241 
242  // Now create strip:
243  const align::Alignables &innerBarrel = alignableLists_.find("TIBBarrel");
244  const align::Alignables &outerBarrel = alignableLists_.find("TOBBarrel");
245  const align::Alignables &innerEndcap = alignableLists_.find("TIDEndcap");
246  const align::Alignables &outerEndcap = alignableLists_.find("TECEndcap");
247  align::Alignables &strip = alignableLists_.get("Strip");
248  strip.reserve(1);
249  strip.push_back(new AlignableComposite(innerBarrel[0]->id(), align::Strip, RotationType()));
250  strip[0]->addComponent(innerBarrel[0]);
251  strip[0]->addComponent(innerEndcap[0]);
252  strip[0]->addComponent(innerEndcap[1]);
253  strip[0]->addComponent(outerBarrel[0]);
254  strip[0]->addComponent(outerEndcap[0]);
255  strip[0]->addComponent(outerEndcap[1]);
256 
257  // Finally add strip and pixel to tracker - that of course already exists:
259  tracker.reserve(1);
260  tracker.push_back(this);
261  this->addComponent(pixel[0]); // add to tracker
262  this->addComponent(strip[0]); // add to tracker
263 
264 }
265 
266 
267 //__________________________________________________________________________________________________
269  const Alignables& list2 ) const
270 {
271  Alignables all = list1;
272 
273  all.insert( all.end(), list2.begin(), list2.end() );
274 
275  return all;
276 }
277 
278 
279 //__________________________________________________________________________________________________
281 {
282 
284  Alignments* m_alignments = new Alignments();
285  // Add components recursively
286  for ( align::Alignables::iterator i=comp.begin(); i!=comp.end(); i++ )
287  {
288  Alignments* tmpAlignments = (*i)->alignments();
289  std::copy( tmpAlignments->m_align.begin(), tmpAlignments->m_align.end(),
290  std::back_inserter(m_alignments->m_align) );
291  delete tmpAlignments;
292  }
293 
294  std::sort( m_alignments->m_align.begin(), m_alignments->m_align.end(),
296 
297  return m_alignments;
298 
299 }
300 
301 
302 //__________________________________________________________________________________________________
304 {
305 
307  AlignmentErrorsExtended* m_alignmentErrors = new AlignmentErrorsExtended();
308 
309  // Add components recursively
310  for ( align::Alignables::iterator i=comp.begin(); i!=comp.end(); i++ )
311  {
312  AlignmentErrorsExtended* tmpAlignmentErrorsExtended = (*i)->alignmentErrors();
313  std::copy( tmpAlignmentErrorsExtended->m_alignError.begin(), tmpAlignmentErrorsExtended->m_alignError.end(),
314  std::back_inserter(m_alignmentErrors->m_alignError) );
315  delete tmpAlignmentErrorsExtended;
316  }
317 
318  std::sort( m_alignmentErrors->m_alignError.begin(), m_alignmentErrors->m_alignError.end(),
320 
321  return m_alignmentErrors;
322 
323 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
Type & find(const std::string &name="")
Definition: AlignSetup.h:58
std::vector< Alignable * > Alignables
Definition: Alignable.h:251
AlignableComposite()
default constructor hidden
void detsToAlignables(const TrackingGeometry::DetContainer &dets, const std::string &moduleName)
Create list of lower-level modules.
AlignmentErrorsExtended * alignmentErrors() const
Return alignment errors, sorted by DetId.
Alignables merge(const Alignables &list1, const Alignables &list2) const
AlignableTracker(const TrackerGeometry *tracker, const TrackerTopology *tTopo)
Constructor (builds the full hierarchy)
void buildAll(AlignSetup< align::Alignables > &setup) const
Build the components for all levels given by user.
std::vector< AlignTransform > m_align
Definition: Alignments.h:19
const TrackerTopology * tTopo_
static align::StructureType stringToId(const char *)
std::string moduleName(Provenance const &provenance)
Definition: Provenance.cc:27
void addLevelInfo(align::StructureType, bool flat, unsigned int maxComponent)
Add info required to build a level to the list.
const DetContainer & detsTEC() const
Type & get(const std::string &name="")
Definition: AlignSetup.h:52
const DetContainer & detsPXB() const
const DetContainer & detsTIB() const
void buildBarrel(const std::string &subDet)
Build a barrel for a given sub-detector (TPB, TIB, TOB).
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:17
uint32_t glued() const
Definition: SiStripDetId.h:171
std::vector< AlignTransformErrorExtended > m_alignError
align::RotationType RotationType
Definition: Alignable.h:36
std::vector< Alignable * > Alignables
Definition: Utilities.h:28
const DetContainer & detsPXF() const
const DetContainer & detsTOB() const
TrackerCounters tkCounters_
virtual Alignables components() const
Return vector of direct components.
Alignments * alignments() const
Return alignments, sorted by DetId.
align::ID theId
Definition: Alignable.h:225
std::vector< GeomDet const * > DetContainer
virtual void addComponent(Alignable *component)
AlignSetup< Alignables > alignableLists_
const DetContainer & detsTID() const