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() ) // 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  const GeomDetUnit *detUnit = dynamic_cast<const GeomDetUnit*>(dets[i]);
65  if (!detUnit) {
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<GluedGeomDet*>(dets[i]);
89  if (!gluedDet) {
90  throw cms::Exception("LogicError")
91  << "[AlignableTracker]" << "dynamic_cast<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  const GeomDetUnit *detUnit = dynamic_cast<const GeomDetUnit*>(dets[i]);
103  if (!detUnit) {
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 //__________________________________________________________________________________________________
135 void AlignableTracker::buildBarrel(const std::string& subDet)
136 {
137  AlignableObjectId objId;
138 
139  align::Alignables& halfBarrels = alignableLists_.find(subDet + "HalfBarrel");
140 
141  const std::string barrelName(subDet + "Barrel");
143  barrel.reserve(1);
144  barrel.push_back(new AlignableComposite(halfBarrels[0]->id(), objId.nameToType(barrelName),
145  RotationType()));
146  barrel[0]->addComponent(halfBarrels[0]);
147  barrel[0]->addComponent(halfBarrels[1]);
148 }
149 
150 //__________________________________________________________________________________________________
152 {
154 
155  builder.addLevelInfo(align::TPBLadder , true, 22); // max 22 ladders per layer
156  builder.addLevelInfo(align::TPBLayer , false, 3); // 3 layers per half barrel
157  builder.addLevelInfo(align::TPBHalfBarrel, false, 2); // 2 half barrels in TPB
158  builder.buildAll( alignableLists_ );
159 
160  buildBarrel("TPB");
161 }
162 
163 //__________________________________________________________________________________________________
165 {
167 
168  builder.addLevelInfo(align::TPEPanel , true, 2); // 2 panels per blade
169  builder.addLevelInfo(align::TPEBlade , true, 12); // 12 blades per half disk
170  builder.addLevelInfo(align::TPEHalfDisk , false, 3); // max 3 disks per cylinder
171  builder.addLevelInfo(align::TPEHalfCylinder, false, 2); // 2 HC per endcap
172  builder.addLevelInfo(align::TPEEndcap , false, 2); // 2 endcaps in TPE
173  builder.buildAll( alignableLists_ );
174 }
175 
176 //__________________________________________________________________________________________________
178 {
180 
181  builder.addLevelInfo(align::TIBString , true, 28); // max 22 strings per surface
182  builder.addLevelInfo(align::TIBSurface , false, 2); // 2 surfaces per half shell
183  builder.addLevelInfo(align::TIBHalfShell , false, 2); // 2 half shells per layer
184  builder.addLevelInfo(align::TIBLayer , false, 4); // 4 layers per half barrel
185  builder.addLevelInfo(align::TIBHalfBarrel, false, 2); // 2 half barrels in TIB
186  builder.buildAll( alignableLists_ );
187 
188  buildBarrel("TIB");
189 }
190 
191 //__________________________________________________________________________________________________
193 {
195 
196  builder.addLevelInfo(align::TIDSide , false, 2); // 2 sides per ring
197  builder.addLevelInfo(align::TIDRing , false, 3); // 3 rings per disk
198  builder.addLevelInfo(align::TIDDisk , false, 3); // 3 disks per endcap
199  builder.addLevelInfo(align::TIDEndcap, false, 2); // 2 endcaps in TID
200  builder.buildAll( alignableLists_ );
201 }
202 
203 //__________________________________________________________________________________________________
205 {
207 
208  builder.addLevelInfo(align::TOBRod , true, 74); // max 74 rods per layer
209  builder.addLevelInfo(align::TOBLayer , false, 6); // 6 layers per half barrel
210  builder.addLevelInfo(align::TOBHalfBarrel, false, 2); // 2 half barrels in TOB
211  builder.buildAll( alignableLists_ );
212 
213  buildBarrel("TOB");
214 }
215 
216 //__________________________________________________________________________________________________
218 {
220 
221  builder.addLevelInfo(align::TECRing , true, 7); // max 7 rings per petal
222  builder.addLevelInfo(align::TECPetal , true, 8); // 8 petals per side
223  builder.addLevelInfo(align::TECSide , false, 2); // 2 sides per disk
224  builder.addLevelInfo(align::TECDisk , false, 9); // 9 disks per endcap
225  builder.addLevelInfo(align::TECEndcap, false, 2); // 2 endcaps in TEC
226  builder.buildAll( alignableLists_ );
227 }
228 
229 //__________________________________________________________________________________________________
231 {
232  // Build pixel, strip and full tracker 'by hand':
233 
234  // First create pixel:
235  const align::Alignables &pixelBarrel = alignableLists_.find("TPBBarrel");
236  const align::Alignables &pixelEndcap = alignableLists_.find("TPEEndcap");
237  align::Alignables &pixel = alignableLists_.get("Pixel");
238  pixel.reserve(1);
239  pixel.push_back(new AlignableComposite(pixelBarrel[0]->id(), align::Pixel, RotationType()));
240  pixel[0]->addComponent(pixelBarrel[0]);
241  pixel[0]->addComponent(pixelEndcap[0]);
242  pixel[0]->addComponent(pixelEndcap[1]);
243 
244  // Now create strip:
245  const align::Alignables &innerBarrel = alignableLists_.find("TIBBarrel");
246  const align::Alignables &outerBarrel = alignableLists_.find("TOBBarrel");
247  const align::Alignables &innerEndcap = alignableLists_.find("TIDEndcap");
248  const align::Alignables &outerEndcap = alignableLists_.find("TECEndcap");
250  strip.reserve(1);
251  strip.push_back(new AlignableComposite(innerBarrel[0]->id(), align::Strip, RotationType()));
252  strip[0]->addComponent(innerBarrel[0]);
253  strip[0]->addComponent(innerEndcap[0]);
254  strip[0]->addComponent(innerEndcap[1]);
255  strip[0]->addComponent(outerBarrel[0]);
256  strip[0]->addComponent(outerEndcap[0]);
257  strip[0]->addComponent(outerEndcap[1]);
258 
259  // Finally add strip and pixel to tracker - that of course already exists:
261  tracker.reserve(1);
262  tracker.push_back(this);
263  this->addComponent(pixel[0]); // add to tracker
264  this->addComponent(strip[0]); // add to tracker
265 
266 }
267 
268 
269 //__________________________________________________________________________________________________
271  const Alignables& list2 ) const
272 {
273  Alignables all = list1;
274 
275  all.insert( all.end(), list2.begin(), list2.end() );
276 
277  return all;
278 }
279 
280 
281 //__________________________________________________________________________________________________
283 {
284 
285  align::Alignables comp = this->components();
286  Alignments* m_alignments = new Alignments();
287  // Add components recursively
288  for ( align::Alignables::iterator i=comp.begin(); i!=comp.end(); i++ )
289  {
290  Alignments* tmpAlignments = (*i)->alignments();
291  std::copy( tmpAlignments->m_align.begin(), tmpAlignments->m_align.end(),
292  std::back_inserter(m_alignments->m_align) );
293  delete tmpAlignments;
294  }
295 
296  std::sort( m_alignments->m_align.begin(), m_alignments->m_align.end(),
298 
299  return m_alignments;
300 
301 }
302 
303 
304 //__________________________________________________________________________________________________
306 {
307 
308  align::Alignables comp = this->components();
309  AlignmentErrors* m_alignmentErrors = new AlignmentErrors();
310 
311  // Add components recursively
312  for ( align::Alignables::iterator i=comp.begin(); i!=comp.end(); i++ )
313  {
314  AlignmentErrors* tmpAlignmentErrors = (*i)->alignmentErrors();
315  std::copy( tmpAlignmentErrors->m_alignError.begin(), tmpAlignmentErrors->m_alignError.end(),
316  std::back_inserter(m_alignmentErrors->m_alignError) );
317  delete tmpAlignmentErrors;
318  }
319 
320  std::sort( m_alignmentErrors->m_alignError.begin(), m_alignmentErrors->m_alignError.end(),
322 
323  return m_alignmentErrors;
324 
325 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
Type & find(const std::string &name="")
Definition: AlignSetup.h:58
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
AlignableComposite()
default constructor hidden
void detsToAlignables(const TrackingGeometry::DetContainer &dets, const std::string &moduleName)
Create list of lower-level modules.
Alignables merge(const Alignables &list1, const Alignables &list2) const
std::vector< AlignTransformError > m_alignError
void buildAll(AlignSetup< align::Alignables > &setup) const
Build the components for all levels given by user.
std::vector< GeomDet * > DetContainer
std::vector< AlignTransform > m_align
Definition: Alignments.h:14
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
AlignmentErrors * alignmentErrors() const
Return alignment errors, sorted by DetId.
Allows conversion between type and name, and vice-versa.
AlignableTracker(const TrackerGeometry *tracker)
Constructor (builds the full hierarchy)
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:154
align::RotationType RotationType
Definition: Alignable.h:36
std::vector< Alignable * > Alignables
Definition: Utilities.h:28
align::StructureType nameToType(const std::string &name) const
Convert name to type.
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:220
align::Alignables Alignables
Definition: Alignable.h:39
virtual void addComponent(Alignable *component)
AlignSetup< Alignables > alignableLists_
const DetContainer & detsTID() const