CMS 3D CMS Logo

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