CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 //--------------------------------------------------------------------------------------------------
68 {
69 
70  LogDebug("Position") << "Constructing AlignableDTBarrel";
71 
72  // Temporary container for chambers in a given station and stations in a given wheel
73  std::vector<AlignableDTChamber*> tmpDTChambersInStation;
74  std::vector<AlignableDTStation*> tmpDTStationsInWheel;
75 
76 
77  // Loop over wheels ( -2..2 )
78  for( int iwh = -2 ; iwh < 3 ; iwh++ ){
79 
80  // Loop over stations ( 1..4 )
81  for( int ist = 1 ; ist < 5 ; ist++ ){
82 
83  // Loop over geom DT Chambers
84  std::vector<const GeomDet*> theSLs;
85  for(auto det = pDT->chambers().begin();
86  det != pDT->chambers().end(); ++det ){
87  // Get the chamber ID
88  DTChamberId chamberId = (*det)->id();
89 
90  // Get wheel,station and sector of the chamber
91  int wh = chamberId.wheel();
92  int st = chamberId.station();
93  //int se = chamberId.sector();
94 
95  // Select the chambers in a given wheel in a given station
96  if ( iwh == wh && ist == st ){
97 
98  // Create the alignable DT chamber
99  AlignableDTChamber* tmpDTChamber = new AlignableDTChamber( *det );
100 
101  // Store the DT chambers in a given DT Station and Wheel
102  tmpDTChambersInStation.push_back( tmpDTChamber );
103 
104  // End chamber selection
105  }
106 
107  // End loop over chambers
108  }
109 
110  // Store the DT chambers
111  theDTChambers.insert( theDTChambers.end(), tmpDTChambersInStation.begin(),
112  tmpDTChambersInStation.end() );
113 
114  // Create the alignable DT station with chambers in a given station and wheel
115  AlignableDTStation* tmpDTStation = new AlignableDTStation( tmpDTChambersInStation );
116 
117  // Store the DT stations in a given wheel
118  tmpDTStationsInWheel.push_back( tmpDTStation );
119 
120  // Clear the temporary vector of chambers in a station
121  tmpDTChambersInStation.clear();
122 
123  // End loop over stations
124  }
125 
126  // Store The DT stations
127  theDTStations.insert( theDTStations.end(), tmpDTStationsInWheel.begin(),
128  tmpDTStationsInWheel.end() );
129 
130  // Create the alignable DT wheel
131  AlignableDTWheel* tmpWheel = new AlignableDTWheel( tmpDTStationsInWheel );
132 
133 
134  // Store the DT wheels
135  theDTWheels.push_back( tmpWheel );
136 
137  // Clear temporary vector of stations in a wheel
138  tmpDTStationsInWheel.clear();
139 
140 
141  // End loop over wheels
142  }
143 
144  // Create the alignable Muon Barrel
145  AlignableDTBarrel* tmpDTBarrel = new AlignableDTBarrel( theDTWheels );
146 
147  // Store the barrel
148  theDTBarrel.push_back( tmpDTBarrel );
149 
150  // Store the barrel in the muon
151  theMuonComponents.push_back( tmpDTBarrel );
152 
153 
154 }
155 
156 
157 
158 //--------------------------------------------------------------------------------------------------
159 
160 
162 {
163 
164  LogDebug("Position") << "Constructing AlignableCSCBarrel";
165 
166  // Temporary container for stations in a given endcap
167  std::vector<AlignableCSCStation*> tmpCSCStationsInEndcap;
168 
169  // Loop over endcaps ( 1..2 )
170  for( int iec = 1 ; iec < 3 ; iec++ ){
171 
172  // Temporary container for rings in a given station
173  std::vector<AlignableCSCRing*> tmpCSCRingsInStation;
174 
175  // Loop over stations ( 1..4 )
176  for( int ist = 1 ; ist < 5 ; ist++ ){
177 
178  // Temporary container for chambers in a given ring
179  std::vector<AlignableCSCChamber*> tmpCSCChambersInRing;
180 
181  // Loop over rings ( 1..4 )
182  for ( int iri = 1; iri < 5; iri++ ){
183 
184  // Loop over geom CSC Chambers
185  const CSCGeometry::ChamberContainer& vc = pCSC->chambers();
186  for( auto det = vc.begin(); det != vc.end(); ++det ){
187 
188  // Get the CSCDet ID
189  CSCDetId cscId = (*det)->id();
190 
191  // Get chamber, station, ring, layer and endcap labels of the CSC chamber
192  int ec = cscId.endcap();
193  int st = cscId.station();
194  int ri = cscId.ring();
195  //int ch = cscId.chamber();
196 
197  // Select the chambers in a given endcap, station, and ring
198  if ( iec == ec && ist == st && iri == ri ) {
199 
200  // Create the alignable CSC chamber
201  AlignableCSCChamber* tmpCSCChamber = new AlignableCSCChamber( *det );
202 
203  // Store the alignable CSC chambers
204  tmpCSCChambersInRing.push_back( tmpCSCChamber );
205 
206  // End If chamber selection
207  }
208 
209  // End loop over geom CSC chambers
210  }
211 
212  // Not all stations have 4 rings: only add the rings that exist (have chambers associated with them)
213  if (tmpCSCChambersInRing.size() > 0) {
214 
215  // Store the alignable CSC chambers
216  theCSCChambers.insert( theCSCChambers.end(), tmpCSCChambersInRing.begin(), tmpCSCChambersInRing.end() );
217 
218  // Create the alignable CSC ring with chambers in a given ring
219  AlignableCSCRing* tmpCSCRing = new AlignableCSCRing( tmpCSCChambersInRing );
220 
221  // Store the CSC rings in a given station
222  tmpCSCRingsInStation.push_back( tmpCSCRing );
223 
224  // Clear the temporary vector of chambers in ring
225  tmpCSCChambersInRing.clear();
226 
227  // End if this ring exists
228  }
229 
230  // End loop over rings
231  }
232 
233  // Create the alignable CSC station with rings in a given station
234  AlignableCSCStation* tmpCSCStation = new AlignableCSCStation( tmpCSCRingsInStation );
235 
236  // Store the alignable CSC rings
237  theCSCRings.insert( theCSCRings.end(), tmpCSCRingsInStation.begin(), tmpCSCRingsInStation.end() );
238 
239  // Store the CSC stations in a given endcap
240  tmpCSCStationsInEndcap.push_back( tmpCSCStation );
241 
242  // Clear the temporary vector of rings in station
243  tmpCSCRingsInStation.clear();
244 
245  // End loop over stations
246  }
247 
248  // Create the alignable CSC endcap
249  AlignableCSCEndcap* tmpEndcap = new AlignableCSCEndcap( tmpCSCStationsInEndcap );
250 
251  // Store the alignable CSC stations
252  theCSCStations.insert( theCSCStations.end(), tmpCSCStationsInEndcap.begin(), tmpCSCStationsInEndcap.end() );
253 
254  // Store the alignable CSC endcaps
255  theCSCEndcaps.push_back( tmpEndcap );
256 
257  // Clear the temporary vector of stations in endcap
258  tmpCSCStationsInEndcap.clear();
259 
260  // End loop over endcaps
261  }
262 
263  // Store the encaps in the muon components
264  theMuonComponents.insert( theMuonComponents.end(), theCSCEndcaps.begin(), theCSCEndcaps.end() );
265 
266 
267 }
268 
269 //--------------------------------------------------------------------------------------------------
271 {
273 
275  for (align::Alignables::const_iterator chamberIter = chambers.begin(); chamberIter != chambers.end(); ++chamberIter) {
276  align::Alignables superlayers = (*chamberIter)->components();
277  for (align::Alignables::const_iterator superlayerIter = superlayers.begin(); superlayerIter != superlayers.end(); ++superlayerIter) {
278  align::Alignables layers = (*superlayerIter)->components();
279  for (align::Alignables::const_iterator layerIter = layers.begin(); layerIter != layers.end(); ++layerIter) {
280  result.push_back(*layerIter);
281  }
282  }
283  }
284 
285  return result;
286 }
287 
288 //--------------------------------------------------------------------------------------------------
290 {
292 
294  for (align::Alignables::const_iterator chamberIter = chambers.begin(); chamberIter != chambers.end(); ++chamberIter) {
295  align::Alignables superlayers = (*chamberIter)->components();
296  for (align::Alignables::const_iterator superlayerIter = superlayers.begin(); superlayerIter != superlayers.end(); ++superlayerIter) {
297  result.push_back(*superlayerIter);
298  }
299  }
300 
301  return result;
302 }
303 
304 //--------------------------------------------------------------------------------------------------
306 {
308  copy( theDTChambers.begin(), theDTChambers.end(), back_inserter(result) );
309  return result;
310 }
311 
312 //--------------------------------------------------------------------------------------------------
314 {
316  copy( theDTStations.begin(), theDTStations.end(), back_inserter(result) );
317  return result;
318 }
319 
320 
321 //--------------------------------------------------------------------------------------------------
323 {
325  copy( theDTWheels.begin(), theDTWheels.end(), back_inserter(result) );
326  return result;
327 }
328 
329 //--------------------------------------------------------------------------------------------------
331 {
333  copy( theDTBarrel.begin(), theDTBarrel.end(), back_inserter(result) );
334  return result;
335 }
336 
337 //--------------------------------------------------------------------------------------------------
339 {
341 
343  for (align::Alignables::const_iterator chamberIter = chambers.begin(); chamberIter != chambers.end(); ++chamberIter) {
344  align::Alignables layers = (*chamberIter)->components();
345  for (align::Alignables::const_iterator layerIter = layers.begin(); layerIter != layers.end(); ++layerIter) {
346  result.push_back(*layerIter);
347  }
348  }
349 
350  return result;
351 }
352 
353 //--------------------------------------------------------------------------------------------------
355 {
357  copy( theCSCChambers.begin(), theCSCChambers.end(), back_inserter(result) );
358  return result;
359 }
360 
361 //--------------------------------------------------------------------------------------------------
363 {
365  copy( theCSCRings.begin(), theCSCRings.end(), back_inserter(result) );
366  return result;
367 }
368 
369 //--------------------------------------------------------------------------------------------------
371 {
373  copy( theCSCStations.begin(), theCSCStations.end(), back_inserter(result) );
374  return result;
375 }
376 
377 //--------------------------------------------------------------------------------------------------
379 {
381  copy( theCSCEndcaps.begin(), theCSCEndcaps.end(), back_inserter(result) );
382  return result;
383 }
384 
385 
386 //__________________________________________________________________________________________________
388 {
389 
390  align::Alignables components = alignable->components();
391  for ( align::Alignables::iterator iter = components.begin();
392  iter != components.end(); iter++ )
393  {
394  (*iter)->setMother( alignable );
395  recursiveSetMothers( *iter );
396  }
397 
398 }
399 //__________________________________________________________________________________________________
401 {
402 
404  Alignments* m_alignments = new Alignments();
405  // Add components recursively
406  for ( align::Alignables::iterator i=comp.begin(); i!=comp.end(); i++ )
407  {
408  Alignments* tmpAlignments = (*i)->alignments();
409  std::copy( tmpAlignments->m_align.begin(), tmpAlignments->m_align.end(),
410  std::back_inserter(m_alignments->m_align) );
411  delete tmpAlignments;
412  }
413 
414  std::sort( m_alignments->m_align.begin(), m_alignments->m_align.end(),
416 
417  return m_alignments;
418 
419 }
420 //__________________________________________________________________________________________________
422 {
423 
425  AlignmentErrorsExtended* m_alignmentErrors = new AlignmentErrorsExtended();
426 
427  // Add components recursively
428  for ( align::Alignables::iterator i=comp.begin(); i!=comp.end(); i++ )
429  {
430  AlignmentErrorsExtended* tmpAlignmentErrorsExtended = (*i)->alignmentErrors();
431  std::copy( tmpAlignmentErrorsExtended->m_alignError.begin(), tmpAlignmentErrorsExtended->m_alignError.end(),
432  std::back_inserter(m_alignmentErrors->m_alignError) );
433  delete tmpAlignmentErrorsExtended;
434  }
435 
436  std::sort( m_alignmentErrors->m_alignError.begin(), m_alignmentErrors->m_alignError.end(),
438 
439  return m_alignmentErrors;
440 
441 }
442 //__________________________________________________________________________________________________
444 {
445  // Retrieve muon barrel alignments
446  Alignments* tmpAlignments = this->DTBarrel().front()->alignments();
447 
448  return tmpAlignments;
449 
450 }
451 //__________________________________________________________________________________________________
453 {
454  // Retrieve muon barrel alignment errors
455  AlignmentErrorsExtended* tmpAlignmentErrorsExtended = this->DTBarrel().front()->alignmentErrors();
456 
457  return tmpAlignmentErrorsExtended;
458 
459 }
460 //__________________________________________________________________________________________________
462 {
463 
464  // Retrieve muon endcaps alignments
465  Alignments* cscEndCap1 = this->CSCEndcaps().front()->alignments();
466  Alignments* cscEndCap2 = this->CSCEndcaps().back()->alignments();
467  Alignments* tmpAlignments = new Alignments();
468 
469  std::copy( cscEndCap1->m_align.begin(), cscEndCap1->m_align.end(), back_inserter( tmpAlignments->m_align ) );
470  std::copy( cscEndCap2->m_align.begin(), cscEndCap2->m_align.end(), back_inserter( tmpAlignments->m_align ) );
471 
472  return tmpAlignments;
473 
474 }
475 //__________________________________________________________________________________________________
477 {
478 
479  // Retrieve muon endcaps alignment errors
480  AlignmentErrorsExtended* cscEndCap1Errors = this->CSCEndcaps().front()->alignmentErrors();
481  AlignmentErrorsExtended* cscEndCap2Errors = this->CSCEndcaps().back()->alignmentErrors();
482  AlignmentErrorsExtended* tmpAlignmentErrorsExtended = new AlignmentErrorsExtended();
483 
484  std::copy(cscEndCap1Errors->m_alignError.begin(), cscEndCap1Errors->m_alignError.end(), back_inserter(tmpAlignmentErrorsExtended->m_alignError) );
485  std::copy(cscEndCap2Errors->m_alignError.begin(), cscEndCap2Errors->m_alignError.end(), back_inserter(tmpAlignmentErrorsExtended->m_alignError) );
486 
487  return tmpAlignmentErrorsExtended;
488 
489 }
#define LogDebug(id)
A muon DT Chamber( an AlignableDet )
int i
Definition: DBlmapReader.cc:9
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()
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
virtual Alignables components() const =0
Return vector of all direct components.
std::vector< AlignTransform > m_align
Definition: Alignments.h:19
Alignments * alignments() const
Return alignment data.
std::vector< AlignableCSCEndcap * > theCSCEndcaps
tuple result
Definition: mps_fire.py:84
int endcap() const
Definition: CSCDetId.h:93
Alignments * dtAlignments()
align::Alignables CSCEndcaps()
align::Alignables theMuonComponents
align::Alignables DTChambers()
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:50
std::vector< AlignableDTStation * > theDTStations
AlignmentErrorsExtended * cscAlignmentErrorsExtended()
align::Alignables CSCLayers()
int ring() const
Definition: CSCDetId.h:75
std::vector< AlignableDTChamber * > theDTChambers
std::vector< AlignableCSCRing * > theCSCRings
std::vector< AlignTransformErrorExtended > m_alignError
align::Alignables DTSuperLayers()
Alignments * cscAlignments()
AlignmentErrorsExtended * alignmentErrors() const
Return vector of alignment errors.
AlignableMuon(const DTGeometry *, const CSCGeometry *)
Constructor from geometries.
AlignmentErrorsExtended * dtAlignmentErrorsExtended()
std::vector< Alignable * > Alignables
Definition: Utilities.h:30
void buildDTBarrel(const DTGeometry *)
std::vector< const CSCChamber * > ChamberContainer
Definition: CSCGeometry.h:32
align::Alignables CSCRings()
std::vector< AlignableDTBarrel * > theDTBarrel
int station() const
Definition: CSCDetId.h:86
~AlignableMuon()
Destructor.
std::vector< AlignableDTWheel * > theDTWheels
align::ID theId
Definition: Alignable.h:225
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
void buildCSCEndcap(const CSCGeometry *)
std::vector< AlignableCSCChamber * > theCSCChambers
A muon CSC Chamber( an AlignableDet )