CMS 3D CMS Logo

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