CMS 3D CMS Logo

LASGeometryUpdater.cc
Go to the documentation of this file.
1 
4 
5 
13 
15  isReverseDirection = false;
17  lasConstants = aLasConstants;
18 
19 }
20 
21 
22 
23 
24 
30 
33  for( unsigned int det = 0; det < 2; ++det ) {
34  for( unsigned int ring = 0; ring < 2; ++ring ) {
35  for( unsigned int beam = 0; beam < 8; ++beam ) {
36 
37  // corrections have different sign for TEC+/-
38  const double endcapSign = det==0 ? 1.: -1.;
39 
40  // the correction is applied to the last 4 disks
41  for( unsigned int disk = 5; disk < 9; ++disk ) {
42 
43  measuredCoordinates.GetTECEntry( det, ring, beam, disk ).SetPhi(
44  measuredCoordinates.GetTECEntry( det, ring, beam, disk ).GetPhi() -
46  ( lasConstants.GetTecZPosition( det, disk ) - endcapSign * lasConstants.GetTecBsZPosition( det ) )
47  );
48 
49  }
50  }
51  }
52  }
53 
54 
57 
58 }
59 
60 
61 
62 
63 
70 
71  // radius of TEC ring4 laser in mm
72  const double radius = 564.;
73 
74  // loop objects and its variables
75  LASGlobalLoop moduleLoop;
76  int det = 0, beam = 0, disk = 0;
77 
78 
79 
80  // update the TEC2TEC measurements
81  do {
82 
83  // the measured phi value for this module
84  const double currentPhi = measuredCoordinates.GetTEC2TECEntry( det, beam, disk ).GetPhi();
85 
86  // the correction to phi from the endcap algorithm;
87  // it is defined such that the correction is to be subtracted
88  double phiCorrection = 0.;
89 
90  // plain phi component
91  phiCorrection -= endcapParameters.GetDiskParameter( det, disk, 0 ).first;
92 
93  // phi component from x deviation
94  phiCorrection += sin( nominalCoordinates.GetTEC2TECEntry( det, beam, disk ).GetPhi() ) / radius * endcapParameters.GetDiskParameter( det, disk, 1 ).first;
95 
96  // phi component from y deviation
97  phiCorrection -= cos( nominalCoordinates.GetTEC2TECEntry( det, beam, disk ).GetPhi() ) / radius * endcapParameters.GetDiskParameter( det, disk, 2 ).first;
98 
99  measuredCoordinates.GetTEC2TECEntry( det, beam, disk ).SetPhi( currentPhi - phiCorrection );
100 
101  } while( moduleLoop.TEC2TECLoop( det, beam, disk ) );
102 
103 }
104 
105 
106 
107 
108 
116  LASBarrelAlignmentParameterSet& barrelParameters,
117  AlignableTracker& theAlignableTracker ) {
118 
119 
120  // this constant defines the sense of *ALL* translations/rotations
121  // of the alignables in the AlignableTracker object
122  const int direction = ( isReverseDirection || isMisalignmentFromRefGeometry ) ? -1 : 1;
123 
124  // first, we access the half barrels of TIB and TOB
125  const align::Alignables& theOuterHalfBarrels = theAlignableTracker.outerHalfBarrels();
126  const align::Alignables& theInnerHalfBarrels = theAlignableTracker.innerHalfBarrels();
127 
128  // then the TECs and treat them also as half barrels
129  const align::Alignables& theEndcaps = theAlignableTracker.endCaps();
130 
131  // re-arrange to match the structure in LASBarrelAlignmentParameterSet and simplify the loop
132  // 2 (TIB+), 3 (TIB-), 4 (TOB+), 5 (TOB-)
133  align::Alignables theHalfBarrels( 6 );
134  theHalfBarrels.at( 0 ) = theEndcaps.at( 0 ); // TEC+
135  theHalfBarrels.at( 1 ) = theEndcaps.at( 1 ); // TEC-
136  theHalfBarrels.at( 2 ) = theInnerHalfBarrels.at( 1 ); // TIB+
137  theHalfBarrels.at( 3 ) = theInnerHalfBarrels.at( 0 ); // TIB-
138  theHalfBarrels.at( 4 ) = theOuterHalfBarrels.at( 1 ); // TOB+
139  theHalfBarrels.at( 5 ) = theOuterHalfBarrels.at( 0 ); // TOB-
140 
141  // the z positions of the lower/upper-z halfbarrel_end_faces / outer_TEC_disks (in mm)
142  // indices are: halfbarrel (0-5), endface(0=lowerZ,1=upperZ)
143  std::vector<std::vector<double> > halfbarrelEndfaceZPositions( 6, std::vector<double>( 2, 0. ) );
144  halfbarrelEndfaceZPositions.at( 0 ).at( 0 ) = 1322.5;
145  halfbarrelEndfaceZPositions.at( 0 ).at( 1 ) = 2667.5;
146  halfbarrelEndfaceZPositions.at( 1 ).at( 0 ) = -2667.5;
147  halfbarrelEndfaceZPositions.at( 1 ).at( 1 ) = -1322.5;
148  halfbarrelEndfaceZPositions.at( 2 ).at( 0 ) = 300.;
149  halfbarrelEndfaceZPositions.at( 2 ).at( 1 ) = 700.;
150  halfbarrelEndfaceZPositions.at( 3 ).at( 0 ) = -700.;
151  halfbarrelEndfaceZPositions.at( 3 ).at( 1 ) = -300.;
152  halfbarrelEndfaceZPositions.at( 4 ).at( 0 ) = 300.;
153  halfbarrelEndfaceZPositions.at( 4 ).at( 1 ) = 1090.;
154  halfbarrelEndfaceZPositions.at( 5 ).at( 0 ) = -1090.;
155  halfbarrelEndfaceZPositions.at( 5 ).at( 1 ) = -300.;
156 
157  // z difference of half barrel end faces (= hb-length) in mm
158  // do all this geometry stuff more intelligent later..
159  std::vector<double> theBarrelLength( 6, 0. );
160  theBarrelLength.at( 0 ) = 1345.; // TEC
161  theBarrelLength.at( 1 ) = 1345.;
162  theBarrelLength.at( 2 ) = 400.; // TIB
163  theBarrelLength.at( 3 ) = 400.;
164  theBarrelLength.at( 4 ) = 790.; // TOB
165  theBarrelLength.at( 5 ) = 790.;
166 
167 
168  // the halfbarrel centers as defined in the AlignableTracker object,
169  // needed for offset corrections; code to be improved later
170  std::vector<double> theHalfbarrelCenters( 6, 0. );
171  for( int halfbarrel = 0; halfbarrel < 6; ++halfbarrel ) {
172  theHalfbarrelCenters.at( halfbarrel ) = theHalfBarrels.at( halfbarrel )->globalPosition().z() * 10.; // in mm
173  }
174 
175 
176 
177  // mm to cm conversion factor (use by division)
178  const double fromMmToCm = 10.;
179 
180  // half barrel loop (no TECs -> det>1)
181  for( int halfBarrel = 2; halfBarrel < 6; ++halfBarrel ) {
182 
183  // A word on the factors of -1 in the below move/rotate statements:
184  //
185  // Since it is not possible to misalign simulated low-level objects like SiStripDigis in CMSSW,
186  // LAS monte carlo digis are always ideally aligned, and misalignment is introduced
187  // by displacing the reference geometry (AlignableTracker) instead which is used for stripNumber->phi conversion.
188  // Hence, in case MC are used in that way, factors of -1 must be introduced
189  // for rotations around x,y and translations in x,y. The variable "xyDirection" takes care of this.
190  //
191  // However, for rotations around z (phi) there is a complication:
192  // in the analytical AlignmentTubeAlgorithm, the alignment parameter phi (z-rotation)
193  // is defined such that a positive value results in a positive contribution to the residual. In the real detector,
194  // the opposite is true. The resulting additional factor of -1 thus compensates for the abovementioned reference geometry effect.
195  //
196  // this behavior can be reversed using the "direction" factor.
197 
198 
199  // rotation around x axis = (dy1-dy2)/L
200  const align::Scalar rxLocal = ( barrelParameters.GetParameter( halfBarrel, 0, 2 ).first - barrelParameters.GetParameter( halfBarrel, 1, 2 ).first ) / theBarrelLength.at( halfBarrel );
201  theHalfBarrels.at( halfBarrel )->rotateAroundLocalX( direction * rxLocal );
202 
203  // rotation around y axis = (dx2-dx1)/L
204  const align::Scalar ryLocal = ( barrelParameters.GetParameter( halfBarrel, 1, 1 ).first - barrelParameters.GetParameter( halfBarrel, 0, 1 ).first ) / theBarrelLength.at( halfBarrel );
205  theHalfBarrels.at( halfBarrel )->rotateAroundLocalY( direction * ryLocal );
206 
207  // average rotation around z axis = (dphi1+dphi2)/2
208  const align::Scalar rzLocal = ( barrelParameters.GetParameter( halfBarrel, 0, 0 ).first + barrelParameters.GetParameter( halfBarrel, 1, 0 ).first ) / 2.;
209  theHalfBarrels.at( halfBarrel )->rotateAroundLocalZ( -1. * direction * rzLocal ); // this is phi, additional -1 here, see comment above
210 
211  // now that the rotational displacements are removed, the remaining translational offsets can be corrected for.
212  // for this, the effect of the rotations is subtracted from the measured endface offsets
213 
214  // @@@ the +/-/-/+ signs for the correction parameters are not yet fully understood -
215  // @@@ do they flip when switching from reference-geometry-misalignment to true misalignment???
216  std::vector<double> correctedEndfaceOffsetsX( 2, 0. ); // lowerZ/upperZ endface
217  correctedEndfaceOffsetsX.at( 0 ) = barrelParameters.GetParameter( halfBarrel, 0, 1 ).first
218  + ( theHalfbarrelCenters.at( halfBarrel ) - halfbarrelEndfaceZPositions.at( halfBarrel ).at( 0 ) ) * ryLocal;
219  correctedEndfaceOffsetsX.at( 1 ) = barrelParameters.GetParameter( halfBarrel, 1, 1 ).first
220  - ( halfbarrelEndfaceZPositions.at( halfBarrel ).at( 1 ) - theHalfbarrelCenters.at( halfBarrel ) ) * ryLocal;
221 
222  std::vector<double> correctedEndfaceOffsetsY( 2, 0. ); // lowerZ/upperZ endface
223  correctedEndfaceOffsetsY.at( 0 ) = barrelParameters.GetParameter( halfBarrel, 0, 2 ).first
224  - ( theHalfbarrelCenters.at( halfBarrel ) - halfbarrelEndfaceZPositions.at( halfBarrel ).at( 0 ) ) * rxLocal;
225  correctedEndfaceOffsetsY.at( 1 ) = barrelParameters.GetParameter( halfBarrel, 1, 2 ).first
226  + ( halfbarrelEndfaceZPositions.at( halfBarrel ).at( 1 ) - theHalfbarrelCenters.at( halfBarrel ) ) * rxLocal;
227 
228  // average x displacement = (cd1+cd2)/2
229  const align::GlobalVector dxLocal( ( correctedEndfaceOffsetsX.at( 0 ) + correctedEndfaceOffsetsX.at( 1 ) ) / 2. / fromMmToCm, 0., 0. );
230  theHalfBarrels.at( halfBarrel )->move( direction * ( dxLocal ) );
231 
232  // average y displacement = (cd1+cd2)/s
233  const align::GlobalVector dyLocal( 0., ( correctedEndfaceOffsetsY.at( 0 ) + correctedEndfaceOffsetsY.at( 1 ) ) / 2. / fromMmToCm, 0. );
234  theHalfBarrels.at( halfBarrel )->move( direction * ( dyLocal ) );
235 
236  }
237 
238 
239  // now fit the endcaps into that alignment tube frame. the strategy is the following:
240  //
241  // 1. apply the parameters from the endcap algorithm to the individual disks
242  // 2. the tec as a whole is rotated and moved such that the innermost disk (1) (= halfbarrel inner endface)
243  // reaches the position determined by the barrel algorithm.
244  // 3. then, the TEC is twisted and sheared until the outermost disk (9) reaches nominal position
245  // (since it has been fixed there in the alignment tube frame). this resolves any common
246  // shear and torsion within the TEC coordinate frame.
247 
248 
249  // shortcut to the z positions of the disks' mechanical structures (TEC+/-, 9*disk)
250  std::vector<std::vector<double> > wheelZPositions( 2, std::vector<double>( 9, 0. ) );
251  for( int wheel = 0; wheel < 9; ++wheel ) {
252  wheelZPositions.at( 0 ).at( wheel ) = theEndcaps.at( 0 )->components().at( wheel )->globalPosition().z();
253  wheelZPositions.at( 1 ).at( wheel ) = theEndcaps.at( 1 )->components().at( wheel )->globalPosition().z();
254  }
255 
256 
257  // we can do this for both TECs in one go;
258  // only real difference is the index change in the second argument to barrelParameters::GetParameter:
259  // here the disk index changes from 0(+) to 1(-), since the end faces are sorted according to z (-->side=det)
260 
261  for( int det = 0; det < 2; ++det ) {
262 
263  const int& side = det;
264 
265  // step 1: apply the endcap algorithm parameters
266 
267  // factors of -1. within the move/rotate statements: see comment above.
268  // difference here: in the the endcap algorithm, the alignment parameter phi (z-rotation) is defined
269  // in the opposite sense compared with the AT algorithm, thus the factor of -1 applies also to phi rotations.
270 
271  for( int wheel = 0; wheel < 9; ++wheel ) {
272  theEndcaps.at( det )->components().at( wheel )->rotateAroundLocalZ( direction * endcapParameters.GetDiskParameter( det, wheel, 0 ).first );
273  const align::GlobalVector dXY( endcapParameters.GetDiskParameter( det, wheel, 1 ).first / fromMmToCm, endcapParameters.GetDiskParameter( det, wheel, 2 ).first / fromMmToCm, 0. );
274  theEndcaps.at( det )->components().at( wheel )->move( direction * dXY );
275  }
276 
277 
278 
279  // step 2: attach the innermost disk (disk 1) by rotating/moving the complete endcap
280 
281  // rotation around z of disk 1
282  const align::Scalar dphi1 = barrelParameters.GetParameter( det, side, 0 ).first;
283  theEndcaps.at( det )->rotateAroundLocalZ( -1. * direction * dphi1 ); // dphi1 is from the AT algorithm, so additional sign (s.above)
284 
285  // displacement in x,y of disk 1
286  const align::GlobalVector dxy1( barrelParameters.GetParameter( det, side, 1 ).first / fromMmToCm,
287  barrelParameters.GetParameter( det, side, 2 ).first / fromMmToCm,
288  0. );
289  theEndcaps.at( det )->move( direction * dxy1 );
290 
291 
292 
293 
294  // determine the resulting phi, x, y of disk 9 after step 2
295  // the wrong sign for TEC- is soaked up by the reducedZ in step 3
296  const align::Scalar resultingPhi9 = barrelParameters.GetParameter( det, 1, 0 ).first - barrelParameters.GetParameter( det, 0, 0 ).first;
297  const align::GlobalVector resultingXY9( ( barrelParameters.GetParameter( det, 1, 1 ).first - barrelParameters.GetParameter( det, 0, 1 ).first ) / fromMmToCm,
298  ( barrelParameters.GetParameter( det, 1, 2 ).first - barrelParameters.GetParameter( det, 0, 2 ).first ) / fromMmToCm,
299  0. );
300 
301  // step 3: twist and shear back
302 
303  // the individual rotation/movement of the wheels is a function of their z-position
304  for( int wheel = 0; wheel < 9; ++wheel ) {
305  const double reducedZ = ( wheelZPositions.at( det ).at( wheel ) - wheelZPositions.at( det ).at( 0 ) ) / theBarrelLength.at( det ) * fromMmToCm;
306  theEndcaps.at( det )->components().at( wheel )->rotateAroundLocalZ( -1. * direction * reducedZ * resultingPhi9 ); // twist
307  theEndcaps.at( det )->components().at( wheel )->move( direction * reducedZ * resultingXY9 ); // shear
308  }
309 
310  }
311 
312 }
313 
314 
315 
316 
317 
322 
323  isReverseDirection = isSet;
324 
325 }
326 
327 
328 
329 
330 
335 
337 
338 }
void SetPhi(double aPhi)
std::pair< double, double > & GetParameter(int aSubdetector, int aDisk, int aParameter)
double Scalar
Definition: Definitions.h:27
void TrackerUpdate(LASEndcapAlignmentParameterSet &, LASBarrelAlignmentParameterSet &, AlignableTracker &)
void SetMisalignmentFromRefGeometry(bool)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
double GetTecRadius(unsigned int ring) const
Definition: LASConstants.cc:92
LASGeometryUpdater(LASGlobalData< LASCoordinateSet > &, LASConstants &)
double GetPhi(void) const
LASGlobalData< LASCoordinateSet > * aNominalCoordinates
bool TEC2TECLoop(int &, int &, int &) const
Alignables & endCaps()
Return TECs.
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
std::pair< double, double > & GetDiskParameter(int aSubdetector, int aDisk, int aParameter)
LASConstants lasConstants
double GetEndcapBsKink(unsigned int det, unsigned int ring, unsigned int beam) const
Definition: LASConstants.cc:58
T & GetTEC2TECEntry(int subdetector, int beam, int tecDisk)
T & GetTECEntry(int subdetector, int tecRing, int beam, int tecDisk)
Definition: LASGlobalData.h:91
double GetTecZPosition(unsigned int det, unsigned int disk) const
double GetTecBsZPosition(unsigned int det) const
std::vector< Alignable * > Alignables
Definition: Utilities.h:32
void ApplyBeamKinkCorrections(LASGlobalData< LASCoordinateSet > &) const
Alignables & innerHalfBarrels()
Return TIB half barrels.
LASGlobalData< LASCoordinateSet > nominalCoordinates
void EndcapUpdate(LASEndcapAlignmentParameterSet &, LASGlobalData< LASCoordinateSet > &)
Alignables & outerHalfBarrels()
Return TOB half barrels.