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