CMS 3D CMS Logo

AlignableMuon.cc
Go to the documentation of this file.
1 
9 // Framework
11 
19 
20 // Muon components
29 
30 //--------------------------------------------------------------------------------------------------
31 AlignableMuon::AlignableMuon( const DTGeometry* dtGeometry , const CSCGeometry* cscGeometry )
32  : AlignableComposite(0, align::AlignableMuon), // cannot yet set id, use 0
33  alignableObjectId_(nullptr, dtGeometry, cscGeometry)
34 {
35 
36  // Build the muon barrel
37  buildDTBarrel( dtGeometry );
38 
39  // Build the muon end caps
40  buildCSCEndcap( cscGeometry );
41 
42  // Set links to mothers recursively
43  recursiveSetMothers( this );
44 
45  // now can set id as for all composites: id of first component
46  theId = this->components()[0]->id();
47 
48  edm::LogInfo("AlignableMuon") << "Constructing alignable muon objects DONE";
49 
50 
51 }
52 
53 //--------------------------------------------------------------------------------------------------
55 {
56 
57  for ( align::Alignables::iterator iter=theMuonComponents.begin();
58  iter != theMuonComponents.end(); iter++){
59  delete *iter;
60  }
61 
62 
63 }
64 
65 
66 //------------------------------------------------------------------------------
67 void AlignableMuon::update(const DTGeometry* dtGeometry ,
68  const CSCGeometry* cscGeometry)
69 {
70  // update the muon barrel
71  buildDTBarrel(dtGeometry, /* update = */ true);
72 
73  // update the muon end caps
74  buildCSCEndcap(cscGeometry, /* update = */ true);
75 
76  edm::LogInfo("Alignment")
77  << "@SUB=AlignableMuon::update" << "Updating alignable muon objects DONE";
78 }
79 
80 
81 //------------------------------------------------------------------------------
83 {
84 
85  LogDebug("Position") << "Constructing AlignableDTBarrel";
86 
87  // Temporary container for chambers in a given station and stations in a given wheel
88  std::vector<AlignableDTChamber*> tmpDTChambersInStation;
89  std::vector<AlignableDTStation*> tmpDTStationsInWheel;
90 
91 
92  // Loop over wheels ( -2..2 )
93  for( int iwh = -2 ; iwh < 3 ; iwh++ ){
94 
95  // Loop over stations ( 1..4 )
96  for( int ist = 1 ; ist < 5 ; ist++ ){
97 
98  // Loop over geom DT Chambers
99  int iChamber{0};
100  std::vector<const GeomDet*> theSLs; // FIXME: What is this vector meant to be for? Probably redundant since super layers are handled inside of the AlignableDTChamber.
101  for(const auto& det: pDT->chambers()){
102  // Get the chamber ID
103  DTChamberId chamberId = det->id();
104 
105  // Get wheel,station and sector of the chamber
106  int wh = chamberId.wheel();
107  int st = chamberId.station();
108  //int se = chamberId.sector();
109 
110  // Select the chambers in a given wheel in a given station
111  if ( iwh == wh && ist == st ){
112 
113  if (update) {
114  // Update the alignable DT chamber
115  theDTBarrel.back()->wheel(iwh+2).station(ist-1).chamber(iChamber).update(det);
116  } else {
117  // Create the alignable DT chamber
118  AlignableDTChamber* tmpDTChamber = new AlignableDTChamber(det);
119 
120  // Store the DT chambers in a given DT Station and Wheel
121  tmpDTChambersInStation.push_back( tmpDTChamber );
122  }
123 
124  ++iChamber;
125  // End chamber selection
126  }
127 
128  // End loop over chambers
129  }
130 
131  if (!update) {
132  // Store the DT chambers
133  theDTChambers.insert(theDTChambers.end(), tmpDTChambersInStation.begin(),
134  tmpDTChambersInStation.end());
135 
136  // Create the alignable DT station with chambers in a given station and wheel
137  AlignableDTStation* tmpDTStation = new AlignableDTStation(tmpDTChambersInStation);
138 
139  // Store the DT stations in a given wheel
140  tmpDTStationsInWheel.push_back(tmpDTStation);
141 
142  // Clear the temporary vector of chambers in a station
143  tmpDTChambersInStation.clear();
144  }
145  // End loop over stations
146  }
147 
148  if (!update) {
149  // Store The DT stations
150  theDTStations.insert(theDTStations.end(),tmpDTStationsInWheel.begin(),
151  tmpDTStationsInWheel.end());
152 
153  // Create the alignable DT wheel
154  AlignableDTWheel* tmpWheel = new AlignableDTWheel(tmpDTStationsInWheel);
155 
156 
157  // Store the DT wheels
158  theDTWheels.push_back(tmpWheel);
159 
160  // Clear temporary vector of stations in a wheel
161  tmpDTStationsInWheel.clear();
162  }
163 
164  // End loop over wheels
165  }
166 
167  if (!update) {
168  // Create the alignable Muon Barrel
169  AlignableDTBarrel* tmpDTBarrel = new AlignableDTBarrel(theDTWheels);
170 
171  // Store the barrel
172  theDTBarrel.push_back(tmpDTBarrel);
173 
174  // Store the barrel in the muon
175  theMuonComponents.push_back(tmpDTBarrel);
176  }
177 }
178 
179 
180 
181 //------------------------------------------------------------------------------
183 {
184 
185  LogDebug("Position") << "Constructing AlignableCSCBarrel";
186 
187  // Temporary container for stations in a given endcap
188  std::vector<AlignableCSCStation*> tmpCSCStationsInEndcap;
189 
190  // Loop over endcaps ( 1..2 )
191  for( int iec = 1 ; iec < 3 ; iec++ ){
192 
193  // Temporary container for rings in a given station
194  std::vector<AlignableCSCRing*> tmpCSCRingsInStation;
195 
196  // Loop over stations ( 1..4 )
197  for( int ist = 1 ; ist < 5 ; ist++ ){
198 
199  // Temporary container for chambers in a given ring
200  std::vector<AlignableCSCChamber*> tmpCSCChambersInRing;
201 
202  // Loop over rings ( 1..4 )
203  for ( int iri = 1; iri < 5; iri++ ){
204 
205  // Loop over geom CSC Chambers
206  int iChamber{0};
207  const CSCGeometry::ChamberContainer& vc = pCSC->chambers();
208  for(const auto& det: vc){
209 
210  // Get the CSCDet ID
211  CSCDetId cscId = det->id();
212 
213  // Get chamber, station, ring, layer and endcap labels of the CSC chamber
214  int ec = cscId.endcap();
215  int st = cscId.station();
216  int ri = cscId.ring();
217  //int ch = cscId.chamber();
218 
219  // Select the chambers in a given endcap, station, and ring
220  if ( iec == ec && ist == st && iri == ri ) {
221 
222  if (update) {
223  // Update the alignable CSC chamber
224  theCSCEndcaps[iec-1]->station(ist-1).ring(iri-1).chamber(iChamber).update(det);
225  } else {
226  AlignableCSCChamber* tmpCSCChamber = new AlignableCSCChamber(det);
227 
228  // Store the alignable CSC chambers
229  tmpCSCChambersInRing.push_back(tmpCSCChamber);
230  }
231 
232  ++iChamber;
233  // End If chamber selection
234  }
235 
236  // End loop over geom CSC chambers
237  }
238 
239  if (!update) {
240  // Not all stations have 4 rings: only add the rings that exist (have chambers associated with them)
241  if (tmpCSCChambersInRing.size() > 0) {
242 
243  // Store the alignable CSC chambers
244  theCSCChambers.insert(theCSCChambers.end(),
245  tmpCSCChambersInRing.begin(),
246  tmpCSCChambersInRing.end());
247 
248  // Create the alignable CSC ring with chambers in a given ring
249  AlignableCSCRing* tmpCSCRing = new AlignableCSCRing(tmpCSCChambersInRing);
250 
251  // Store the CSC rings in a given station
252  tmpCSCRingsInStation.push_back(tmpCSCRing);
253 
254  // Clear the temporary vector of chambers in ring
255  tmpCSCChambersInRing.clear();
256 
257  // End if this ring exists
258  }
259  }
260 
261  // End loop over rings
262  }
263 
264  if (!update) {
265  // Create the alignable CSC station with rings in a given station
266  AlignableCSCStation* tmpCSCStation = new AlignableCSCStation(tmpCSCRingsInStation);
267 
268  // Store the alignable CSC rings
269  theCSCRings.insert(theCSCRings.end(), tmpCSCRingsInStation.begin(),
270  tmpCSCRingsInStation.end());
271 
272  // Store the CSC stations in a given endcap
273  tmpCSCStationsInEndcap.push_back(tmpCSCStation);
274 
275  // Clear the temporary vector of rings in station
276  tmpCSCRingsInStation.clear();
277  }
278 
279  // End loop over stations
280  }
281 
282  if (!update) {
283  // Create the alignable CSC endcap
284  AlignableCSCEndcap* tmpEndcap = new AlignableCSCEndcap(tmpCSCStationsInEndcap);
285 
286  // Store the alignable CSC stations
287  theCSCStations.insert(theCSCStations.end(), tmpCSCStationsInEndcap.begin(),
288  tmpCSCStationsInEndcap.end());
289 
290  // Store the alignable CSC endcaps
291  theCSCEndcaps.push_back(tmpEndcap);
292 
293  // Clear the temporary vector of stations in endcap
294  tmpCSCStationsInEndcap.clear();
295  }
296 
297  // End loop over endcaps
298  }
299 
300  if (!update) {
301  // Store the encaps in the muon components
302  theMuonComponents.insert(theMuonComponents.end(), theCSCEndcaps.begin(),
303  theCSCEndcaps.end());
304  }
305 }
306 
307 
308 //--------------------------------------------------------------------------------------------------
310 {
312 
314  for (align::Alignables::const_iterator chamberIter = chambers.begin(); chamberIter != chambers.end(); ++chamberIter) {
315  align::Alignables superlayers = (*chamberIter)->components();
316  for (align::Alignables::const_iterator superlayerIter = superlayers.begin(); superlayerIter != superlayers.end(); ++superlayerIter) {
317  align::Alignables layers = (*superlayerIter)->components();
318  for (align::Alignables::const_iterator layerIter = layers.begin(); layerIter != layers.end(); ++layerIter) {
319  result.push_back(*layerIter);
320  }
321  }
322  }
323 
324  return result;
325 }
326 
327 //--------------------------------------------------------------------------------------------------
329 {
331 
333  for (align::Alignables::const_iterator chamberIter = chambers.begin(); chamberIter != chambers.end(); ++chamberIter) {
334  align::Alignables superlayers = (*chamberIter)->components();
335  for (align::Alignables::const_iterator superlayerIter = superlayers.begin(); superlayerIter != superlayers.end(); ++superlayerIter) {
336  result.push_back(*superlayerIter);
337  }
338  }
339 
340  return result;
341 }
342 
343 //--------------------------------------------------------------------------------------------------
345 {
347  copy( theDTChambers.begin(), theDTChambers.end(), back_inserter(result) );
348  return result;
349 }
350 
351 //--------------------------------------------------------------------------------------------------
353 {
355  copy( theDTStations.begin(), theDTStations.end(), back_inserter(result) );
356  return result;
357 }
358 
359 
360 //--------------------------------------------------------------------------------------------------
362 {
364  copy( theDTWheels.begin(), theDTWheels.end(), back_inserter(result) );
365  return result;
366 }
367 
368 //--------------------------------------------------------------------------------------------------
370 {
372  copy( theDTBarrel.begin(), theDTBarrel.end(), back_inserter(result) );
373  return result;
374 }
375 
376 //--------------------------------------------------------------------------------------------------
378 {
380 
382  for (align::Alignables::const_iterator chamberIter = chambers.begin(); chamberIter != chambers.end(); ++chamberIter) {
383  align::Alignables layers = (*chamberIter)->components();
384  for (align::Alignables::const_iterator layerIter = layers.begin(); layerIter != layers.end(); ++layerIter) {
385  result.push_back(*layerIter);
386  }
387  }
388 
389  return result;
390 }
391 
392 //--------------------------------------------------------------------------------------------------
394 {
396  copy( theCSCChambers.begin(), theCSCChambers.end(), back_inserter(result) );
397  return result;
398 }
399 
400 //--------------------------------------------------------------------------------------------------
402 {
404  copy( theCSCRings.begin(), theCSCRings.end(), back_inserter(result) );
405  return result;
406 }
407 
408 //--------------------------------------------------------------------------------------------------
410 {
412  copy( theCSCStations.begin(), theCSCStations.end(), back_inserter(result) );
413  return result;
414 }
415 
416 //--------------------------------------------------------------------------------------------------
418 {
420  copy( theCSCEndcaps.begin(), theCSCEndcaps.end(), back_inserter(result) );
421  return result;
422 }
423 
424 
425 //__________________________________________________________________________________________________
427 {
428 
429  align::Alignables components = alignable->components();
430  for ( align::Alignables::iterator iter = components.begin();
431  iter != components.end(); iter++ )
432  {
433  (*iter)->setMother( alignable );
434  recursiveSetMothers( *iter );
435  }
436 
437 }
438 //__________________________________________________________________________________________________
440 {
441 
443  Alignments* m_alignments = new Alignments();
444  // Add components recursively
445  for ( align::Alignables::iterator i=comp.begin(); i!=comp.end(); i++ )
446  {
447  Alignments* tmpAlignments = (*i)->alignments();
448  std::copy( tmpAlignments->m_align.begin(), tmpAlignments->m_align.end(),
449  std::back_inserter(m_alignments->m_align) );
450  delete tmpAlignments;
451  }
452 
453  std::sort( m_alignments->m_align.begin(), m_alignments->m_align.end(),
455 
456  return m_alignments;
457 
458 }
459 //__________________________________________________________________________________________________
461 {
462 
464  AlignmentErrorsExtended* m_alignmentErrors = new AlignmentErrorsExtended();
465 
466  // Add components recursively
467  for ( align::Alignables::iterator i=comp.begin(); i!=comp.end(); i++ )
468  {
469  AlignmentErrorsExtended* tmpAlignmentErrorsExtended = (*i)->alignmentErrors();
470  std::copy( tmpAlignmentErrorsExtended->m_alignError.begin(), tmpAlignmentErrorsExtended->m_alignError.end(),
471  std::back_inserter(m_alignmentErrors->m_alignError) );
472  delete tmpAlignmentErrorsExtended;
473  }
474 
475  std::sort( m_alignmentErrors->m_alignError.begin(), m_alignmentErrors->m_alignError.end(),
477 
478  return m_alignmentErrors;
479 
480 }
481 //__________________________________________________________________________________________________
483 {
484  // Retrieve muon barrel alignments
485  Alignments* tmpAlignments = this->DTBarrel().front()->alignments();
486 
487  return tmpAlignments;
488 
489 }
490 //__________________________________________________________________________________________________
492 {
493  // Retrieve muon barrel alignment errors
494  AlignmentErrorsExtended* tmpAlignmentErrorsExtended = this->DTBarrel().front()->alignmentErrors();
495 
496  return tmpAlignmentErrorsExtended;
497 
498 }
499 //__________________________________________________________________________________________________
501 {
502 
503  // Retrieve muon endcaps alignments
504  Alignments* cscEndCap1 = this->CSCEndcaps().front()->alignments();
505  Alignments* cscEndCap2 = this->CSCEndcaps().back()->alignments();
506  Alignments* tmpAlignments = new Alignments();
507 
508  std::copy( cscEndCap1->m_align.begin(), cscEndCap1->m_align.end(), back_inserter( tmpAlignments->m_align ) );
509  std::copy( cscEndCap2->m_align.begin(), cscEndCap2->m_align.end(), back_inserter( tmpAlignments->m_align ) );
510 
511  return tmpAlignments;
512 
513 }
514 //__________________________________________________________________________________________________
516 {
517 
518  // Retrieve muon endcaps alignment errors
519  AlignmentErrorsExtended* cscEndCap1Errors = this->CSCEndcaps().front()->alignmentErrors();
520  AlignmentErrorsExtended* cscEndCap2Errors = this->CSCEndcaps().back()->alignmentErrors();
521  AlignmentErrorsExtended* tmpAlignmentErrorsExtended = new AlignmentErrorsExtended();
522 
523  std::copy(cscEndCap1Errors->m_alignError.begin(), cscEndCap1Errors->m_alignError.end(), back_inserter(tmpAlignmentErrorsExtended->m_alignError) );
524  std::copy(cscEndCap2Errors->m_alignError.begin(), cscEndCap2Errors->m_alignError.end(), back_inserter(tmpAlignmentErrorsExtended->m_alignError) );
525 
526  return tmpAlignmentErrorsExtended;
527 
528 }
#define LogDebug(id)
A muon DT Chamber( an AlignableDet )
const std::vector< const DTChamber * > & chambers() const
Return a vector of all Chamber.
Definition: DTGeometry.cc:85
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
Definition: LayerTriplets.cc:4
align::Alignables DTLayers()
Methods to return specific of components.
void update(const DTGeometry *, const CSCGeometry *)
align::Alignables CSCChambers()
align::Alignables DTBarrel()
align::Alignables CSCStations()
align::Alignables DTStations()
const ChamberContainer & chambers() const
Return a vector of all chambers.
Definition: CSCGeometry.cc:106
#define nullptr
std::vector< AlignTransform > m_align
Definition: Alignments.h:19
Alignments * alignments() const
Get alignments sorted by DetId.
std::vector< AlignableCSCEndcap * > theCSCEndcaps
int endcap() const
Definition: CSCDetId.h:93
Alignments * dtAlignments()
Get DT alignments sorted by DetId.
align::Alignables CSCEndcaps()
align::Alignables theMuonComponents
align::Alignables DTChambers()
virtual Alignables components() const =0
Return vector of all direct components.
align::Alignables DTWheels()
std::vector< AlignableCSCStation * > theCSCStations
void recursiveSetMothers(Alignable *alignable)
Set mothers recursively.
virtual align::Alignables components() const
Return all components.
Definition: AlignableMuon.h:53
std::vector< AlignableDTStation * > theDTStations
AlignmentErrorsExtended * cscAlignmentErrorsExtended()
Get CSC alignment errors sorted by DetId.
align::Alignables CSCLayers()
int ring() const
Definition: CSCDetId.h:75
void buildCSCEndcap(const CSCGeometry *, bool update=false)
Build muon end caps.
std::vector< AlignableDTChamber * > theDTChambers
Containers of separate components.
std::vector< AlignableCSCRing * > theCSCRings
std::vector< AlignTransformErrorExtended > m_alignError
align::Alignables DTSuperLayers()
Alignments * cscAlignments()
Get CSC alignments sorted by DetId.
AlignmentErrorsExtended * alignmentErrors() const
Get alignment errors sorted by DetId.
AlignableMuon(const DTGeometry *, const CSCGeometry *)
Constructor from geometries.
AlignmentErrorsExtended * dtAlignmentErrorsExtended()
Get DT alignment errors sorted by DetId.
std::vector< Alignable * > Alignables
Definition: Utilities.h:31
std::vector< const CSCChamber * > ChamberContainer
Definition: CSCGeometry.h:32
align::Alignables CSCRings()
void buildDTBarrel(const DTGeometry *, bool update=false)
Build muon barrel.
std::vector< AlignableDTBarrel * > theDTBarrel
int station() const
Definition: CSCDetId.h:86
~AlignableMuon()
Destructor.
std::vector< AlignableDTWheel * > theDTWheels
align::ID theId
Definition: Alignable.h:241
int station() const
Return the station number.
Definition: DTChamberId.h:51
static char chambers[264][20]
Definition: ReadPGInfo.cc:243
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:45
Constructor of the full muon geometry.
Definition: AlignableMuon.h:37
std::vector< AlignableCSCChamber * > theCSCChambers
A muon CSC Chamber( an AlignableDet )