20 std::cout <<
" [LASAlignmentTubeAlgorithm::CalculateParameters] -- Starting." << std::endl;
32 int det, beam, disk,
pos;
35 const double phiPositions[8] = { 0.392699, 1.289799, 1.851794, 2.748894, 3.645995, 4.319690, 5.216791, 5.778784 };
36 std::vector<double> beamPhiPositions( 8, 0. );
37 for( beam = 0; beam < 8; ++beam ) beamPhiPositions.at( beam ) = phiPositions[beam];
43 const double radii[6] = { 564., 564., 514., 514., 600., 600. };
44 std::vector<double> beamRadii( 6, 0. );
45 for(
int aHalfbarrel = 0; aHalfbarrel < 6; ++aHalfbarrel ) beamRadii.at( aHalfbarrel ) = radii[aHalfbarrel];
49 std::vector<std::vector<std::vector<double> > > endFaceZPositions( 4, std::vector<std::vector<double> >( 2, std::vector<double>( 2, 0. ) ) );
50 endFaceZPositions.at( 0 ).at( 0 ).at( 0 ) = 1322.5;
51 endFaceZPositions.at( 0 ).at( 0 ).at( 1 ) = 2667.5;
52 endFaceZPositions.at( 1 ).at( 0 ).at( 0 ) = -2667.5;
53 endFaceZPositions.at( 1 ).at( 0 ).at( 1 ) = -1322.5;
54 endFaceZPositions.at( 2 ).at( 1 ).at( 0 ) = -700.;
55 endFaceZPositions.at( 2 ).at( 1 ).at( 1 ) = -300.;
56 endFaceZPositions.at( 2 ).at( 0 ).at( 0 ) = 300.;
57 endFaceZPositions.at( 2 ).at( 0 ).at( 1 ) = 700.;
58 endFaceZPositions.at( 3 ).at( 1 ).at( 0 ) = -1090.;
59 endFaceZPositions.at( 3 ).at( 1 ).at( 1 ) = -300.;
60 endFaceZPositions.at( 3 ).at( 0 ).at( 0 ) = 300.;
61 endFaceZPositions.at( 3 ).at( 0 ).at( 1 ) = 1090.;
64 double detReducedZ[2] = { 0., 0. };
66 double beamReducedZ[2] = { 0., 0. };
69 std::vector<double> disk9EndFaceZPositions( 2, 0. );
70 disk9EndFaceZPositions.at( 0 ) = -2667.5;
71 disk9EndFaceZPositions.at( 1 ) = 2667.5;
77 std::vector<double> sumOverPhiZPrime( 6, 0. );
78 std::vector<double> sumOverPhiZPrimePrime( 6, 0. );
79 std::vector<double> sumOverPhiZPrimeSinTheta( 6, 0. );
80 std::vector<double> sumOverPhiZPrimePrimeSinTheta( 6, 0. );
81 std::vector<double> sumOverPhiZPrimeCosTheta( 6, 0. );
82 std::vector<double> sumOverPhiZPrimePrimeCosTheta( 6, 0. );
85 std::vector<double> sumOverPhiZTPrime( 8, 0. );
86 std::vector<double> sumOverPhiZTPrimePrime( 8, 0. );
92 std::vector<double> sumOverZPrimeSquared( 6, 0. );
93 std::vector<double> sumOverZPrimePrimeSquared( 6, 0. );
94 std::vector<double> sumOverZPrimeZPrimePrime( 6, 0. );
95 std::vector<double> sumOverZPrimeZTPrime( 6, 0. );
96 std::vector<double> sumOverZPrimeZTPrimePrime( 6, 0. );
97 std::vector<double> sumOverZPrimePrimeZTPrime( 6, 0. );
98 std::vector<double> sumOverZPrimePrimeZTPrimePrime( 6, 0. );
101 double sumOverZTPrimeSquared = 0.;
102 double sumOverZTPrimePrimeSquared = 0.;
103 double sumOverZTPrimeZTPrimePrime = 0.;
110 det = 2; beam = 0; pos = 0;
114 const int theSide = pos<3 ? 0 : 1;
117 const int halfbarrel = det==2 ? det+theSide : det+1+theSide;
121 const double radialOffset = det==2 ? 50. : 36.;
124 detReducedZ[0] = measuredCoordinates.
GetTIBTOBEntry( det, beam, pos ).
GetZ() - endFaceZPositions.at( det ).at( theSide ).at( 0 );
125 detReducedZ[0] /= ( endFaceZPositions.at( det ).at( theSide ).at( 1 ) - endFaceZPositions.at( det ).at( theSide ).at( 0 ) );
126 detReducedZ[1] = endFaceZPositions.at( det ).at( theSide ).at( 1 ) - measuredCoordinates.
GetTIBTOBEntry( det, beam, pos ).
GetZ();
127 detReducedZ[1] /= ( endFaceZPositions.at( det ).at( theSide ).at( 1 ) - endFaceZPositions.at( det ).at( theSide ).at( 0 ) );
130 beamReducedZ[0] = ( measuredCoordinates.
GetTIBTOBEntry( det, beam, pos ).
GetZ() - radialOffset ) - disk9EndFaceZPositions.at( 0 );
131 beamReducedZ[0] /= ( disk9EndFaceZPositions.at( 1 ) - disk9EndFaceZPositions.at( 0 ) );
132 beamReducedZ[1] = disk9EndFaceZPositions.at( 1 ) - ( measuredCoordinates.
GetTIBTOBEntry( det, beam, pos ).
GetZ() - radialOffset );
133 beamReducedZ[1] /= ( disk9EndFaceZPositions.at( 1 ) - disk9EndFaceZPositions.at( 0 ) );
139 sumOverPhiZPrime.at( halfbarrel ) += phiResidual * detReducedZ[0];
140 sumOverPhiZPrimePrime.at( halfbarrel ) += phiResidual * detReducedZ[1];
141 sumOverPhiZPrimeSinTheta.at( halfbarrel ) += phiResidual * detReducedZ[0] *
sin( beamPhiPositions.at( beam ) );
142 sumOverPhiZPrimePrimeSinTheta.at( halfbarrel ) += phiResidual * detReducedZ[1] *
sin( beamPhiPositions.at( beam ) );
143 sumOverPhiZPrimeCosTheta.at( halfbarrel ) += phiResidual * detReducedZ[0] *
cos( beamPhiPositions.at( beam ) );
144 sumOverPhiZPrimePrimeCosTheta.at( halfbarrel ) += phiResidual * detReducedZ[1] *
cos( beamPhiPositions.at( beam ) );
146 sumOverPhiZTPrime.at( beam ) += phiResidual * beamReducedZ[0];
147 sumOverPhiZTPrimePrime.at( beam ) += phiResidual * beamReducedZ[1];
150 sumOverZPrimeSquared.at( halfbarrel ) +=
pow( detReducedZ[0], 2 ) / 8.;
151 sumOverZPrimePrimeSquared.at( halfbarrel ) +=
pow( detReducedZ[1], 2 ) / 8.;
152 sumOverZPrimeZPrimePrime.at( halfbarrel ) += detReducedZ[0] * detReducedZ[1] / 8.;
153 sumOverZPrimeZTPrime.at( halfbarrel ) += detReducedZ[0] * beamReducedZ[0] / 8.;
154 sumOverZPrimeZTPrimePrime.at( halfbarrel ) += detReducedZ[0] * beamReducedZ[1] / 8.;
155 sumOverZPrimePrimeZTPrime.at( halfbarrel ) += detReducedZ[1] * beamReducedZ[0] / 8.;
156 sumOverZPrimePrimeZTPrimePrime.at( halfbarrel ) += detReducedZ[1] * beamReducedZ[1] / 8.;
158 sumOverZTPrimeSquared +=
pow( beamReducedZ[0], 2 ) / 8.;
159 sumOverZTPrimePrimeSquared +=
pow( beamReducedZ[1], 2 ) / 8.;
160 sumOverZTPrimeZTPrimePrime += beamReducedZ[0] * beamReducedZ[1] / 8.;
162 }
while( globalLoop.
TIBTOBLoop( det, beam, pos ) );
172 det = 0; beam = 0; disk = 0;
176 const int halfbarrel = det;
179 const int theSide = 0;
182 const double radialOffset = 0.;
185 detReducedZ[0] = measuredCoordinates.
GetTEC2TECEntry( det, beam, disk ).
GetZ() - endFaceZPositions.at( det ).at( theSide ).at( 0 );
186 detReducedZ[0] /= ( endFaceZPositions.at( det ).at( theSide ).at( 1 ) - endFaceZPositions.at( det ).at( theSide ).at( 0 ) );
187 detReducedZ[1] = endFaceZPositions.at( det ).at( theSide ).at( 1 ) - measuredCoordinates.
GetTEC2TECEntry( det, beam, disk ).
GetZ();
188 detReducedZ[1] /= ( endFaceZPositions.at( det ).at( theSide ).at( 1 ) - endFaceZPositions.at( det ).at( theSide ).at( 0 ) );
191 beamReducedZ[0] = ( measuredCoordinates.
GetTEC2TECEntry( det, beam, disk ).
GetZ() - radialOffset ) - disk9EndFaceZPositions.at( 0 );
192 beamReducedZ[0] /= ( disk9EndFaceZPositions.at( 1 ) - disk9EndFaceZPositions.at( 0 ) );
193 beamReducedZ[1] = disk9EndFaceZPositions.at( 1 ) - ( measuredCoordinates.
GetTEC2TECEntry( det, beam, disk ).
GetZ() - radialOffset );
194 beamReducedZ[1] /= ( disk9EndFaceZPositions.at( 1 ) - disk9EndFaceZPositions.at( 0 ) );
200 sumOverPhiZPrime.at( halfbarrel ) += phiResidual * detReducedZ[0];
201 sumOverPhiZPrimePrime.at( halfbarrel ) += phiResidual * detReducedZ[1];
202 sumOverPhiZPrimeSinTheta.at( halfbarrel ) += phiResidual * detReducedZ[0] *
sin( beamPhiPositions.at( beam ) );
203 sumOverPhiZPrimePrimeSinTheta.at( halfbarrel ) += phiResidual * detReducedZ[1] *
sin( beamPhiPositions.at( beam ) );
204 sumOverPhiZPrimeCosTheta.at( halfbarrel ) += phiResidual * detReducedZ[0] *
cos( beamPhiPositions.at( beam ) );
205 sumOverPhiZPrimePrimeCosTheta.at( halfbarrel ) += phiResidual * detReducedZ[1] *
cos( beamPhiPositions.at( beam ) );
207 sumOverPhiZTPrime.at( beam ) += phiResidual * beamReducedZ[0];
208 sumOverPhiZTPrimePrime.at( beam ) += phiResidual * beamReducedZ[1];
211 sumOverZPrimeSquared.at( halfbarrel ) +=
pow( detReducedZ[0], 2 ) / 8.;
212 sumOverZPrimePrimeSquared.at( halfbarrel ) +=
pow( detReducedZ[1], 2 ) / 8.;
213 sumOverZPrimeZPrimePrime.at( halfbarrel ) += detReducedZ[0] * detReducedZ[1] / 8.;
214 sumOverZPrimeZTPrime.at( halfbarrel ) += detReducedZ[0] * beamReducedZ[0] / 8.;
215 sumOverZPrimeZTPrimePrime.at( halfbarrel ) += detReducedZ[0] * beamReducedZ[1] / 8.;
216 sumOverZPrimePrimeZTPrime.at( halfbarrel ) += detReducedZ[1] * beamReducedZ[0] / 8.;
217 sumOverZPrimePrimeZTPrimePrime.at( halfbarrel ) += detReducedZ[1] * beamReducedZ[1] / 8.;
219 sumOverZTPrimeSquared +=
pow( beamReducedZ[0], 2 ) / 8.;
220 sumOverZTPrimePrimeSquared +=
pow( beamReducedZ[1], 2 ) / 8.;
221 sumOverZTPrimeZTPrimePrime += beamReducedZ[0] * beamReducedZ[1] / 8.;
223 }
while( globalLoop.
TEC2TECLoop( det, beam, disk ) );
229 double sumOverSinTheta = 0.;
230 double sumOverCosTheta = 0.;
231 double sumOverSinThetaSquared = 0.;
232 double sumOverCosThetaSquared = 0.;
233 double sumOverCosThetaSinTheta = 0.;
234 double mixedTrigonometricTerm = 0.;
236 for( beam = 0; beam < 8; ++beam ) {
237 sumOverSinTheta +=
sin( beamPhiPositions.at( beam ) );
238 sumOverCosTheta +=
cos( beamPhiPositions.at( beam ) );
239 sumOverSinThetaSquared +=
pow(
sin( beamPhiPositions.at( beam ) ), 2 );
240 sumOverCosThetaSquared +=
pow(
cos( beamPhiPositions.at( beam ) ), 2 );
241 sumOverCosThetaSinTheta +=
cos( beamPhiPositions.at( beam ) ) *
sin( beamPhiPositions.at( beam ) );
244 mixedTrigonometricTerm = 8. * ( sumOverCosThetaSquared * sumOverSinThetaSquared -
pow( sumOverCosThetaSinTheta, 2 ) )
245 -
pow( sumOverCosTheta, 2 ) * sumOverSinThetaSquared
246 -
pow( sumOverSinTheta, 2 ) * sumOverCosThetaSquared
247 + 2. * sumOverCosTheta * sumOverSinTheta * sumOverCosThetaSinTheta;
252 double beamDenominator = (
pow( sumOverZTPrimeZTPrimePrime, 2 ) - sumOverZTPrimeSquared * sumOverZTPrimePrimeSquared ) * beamRadii.at( 0 );
253 std::vector<double> alignmentDenominator( 6, 0. );
254 std::vector<double> termA( 6, 0. ), termB( 6, 0. ), termC( 6, 0. ), termD( 6, 0. );
255 for(
unsigned int aHalfbarrel = 0; aHalfbarrel < 6; ++aHalfbarrel ) {
256 alignmentDenominator.at ( aHalfbarrel ) = (
pow( sumOverZPrimeZPrimePrime.at( aHalfbarrel ), 2 ) - sumOverZPrimeSquared.at( aHalfbarrel ) * sumOverZPrimePrimeSquared.at( aHalfbarrel ) ) * mixedTrigonometricTerm;
257 termA.at( aHalfbarrel ) = sumOverZPrimeZTPrime.at( aHalfbarrel ) * sumOverZTPrimeZTPrimePrime - sumOverZPrimeZTPrimePrime.at( aHalfbarrel ) * sumOverZTPrimeSquared;
258 termB.at( aHalfbarrel ) = sumOverZPrimePrimeZTPrime.at( aHalfbarrel ) * sumOverZTPrimeZTPrimePrime - sumOverZPrimePrimeZTPrimePrime.at( aHalfbarrel ) * sumOverZTPrimeSquared;
259 termC.at( aHalfbarrel ) = sumOverZPrimeZTPrimePrime.at( aHalfbarrel ) * sumOverZTPrimeZTPrimePrime - sumOverZPrimeZTPrime.at( aHalfbarrel ) * sumOverZTPrimePrimeSquared;
260 termD.at( aHalfbarrel ) = sumOverZPrimePrimeZTPrimePrime.at( aHalfbarrel ) * sumOverZTPrimeZTPrimePrime - sumOverZPrimePrimeZTPrime.at( aHalfbarrel ) * sumOverZTPrimePrimeSquared;
265 const int numberOfBeams = 8;
273 for(
int aHalfbarrel = 0; aHalfbarrel < 6; ++aHalfbarrel ) {
279 theResult.
GetParameter( aHalfbarrel, 0, 0 ).first = ( sumOverPhiZPrime.at( aHalfbarrel ) * sumOverZPrimeZPrimePrime.at( aHalfbarrel ) * sumOverCosThetaSquared * sumOverSinThetaSquared
280 - sumOverPhiZPrimePrime.at( aHalfbarrel ) * sumOverZPrimeSquared.at( aHalfbarrel ) * sumOverCosThetaSquared * sumOverSinThetaSquared
281 - sumOverPhiZPrimeCosTheta.at( aHalfbarrel ) * sumOverZPrimeZPrimePrime.at( aHalfbarrel ) * sumOverCosTheta * sumOverSinThetaSquared
282 + sumOverPhiZPrimePrimeCosTheta.at( aHalfbarrel ) * sumOverZPrimeSquared.at( aHalfbarrel ) * sumOverCosTheta * sumOverSinThetaSquared
283 + sumOverPhiZPrimeCosTheta.at( aHalfbarrel ) * sumOverZPrimeZPrimePrime.at( aHalfbarrel ) * sumOverCosThetaSinTheta * sumOverSinTheta
284 - sumOverPhiZPrimePrimeCosTheta.at( aHalfbarrel ) * sumOverZPrimeSquared.at( aHalfbarrel ) * sumOverCosThetaSinTheta * sumOverSinTheta
285 - sumOverPhiZPrimeSinTheta.at( aHalfbarrel ) * sumOverZPrimeZPrimePrime.at( aHalfbarrel ) * sumOverCosThetaSquared * sumOverSinTheta
286 + sumOverPhiZPrimePrimeSinTheta.at( aHalfbarrel ) * sumOverZPrimeSquared.at( aHalfbarrel ) * sumOverCosThetaSquared * sumOverSinTheta
287 - sumOverPhiZPrime.at( aHalfbarrel ) * sumOverZPrimeZPrimePrime.at( aHalfbarrel ) *
pow( sumOverCosThetaSinTheta, 2 )
288 + sumOverPhiZPrimePrime.at( aHalfbarrel ) * sumOverZPrimeSquared.at( aHalfbarrel ) *
pow( sumOverCosThetaSinTheta, 2 )
289 + sumOverPhiZPrimeSinTheta.at( aHalfbarrel ) * sumOverZPrimeZPrimePrime.at( aHalfbarrel ) * sumOverCosTheta * sumOverCosThetaSinTheta
290 - sumOverPhiZPrimePrimeSinTheta.at( aHalfbarrel ) * sumOverZPrimeSquared.at( aHalfbarrel ) * sumOverCosTheta * sumOverCosThetaSinTheta )
291 / alignmentDenominator.at ( aHalfbarrel );
294 theResult.
GetParameter( aHalfbarrel, 1, 0 ).first = ( sumOverPhiZPrimePrime.at( aHalfbarrel ) * sumOverZPrimeZPrimePrime.at( aHalfbarrel ) * sumOverCosThetaSquared * sumOverSinThetaSquared
295 - sumOverPhiZPrime.at( aHalfbarrel ) * sumOverZPrimePrimeSquared.at( aHalfbarrel ) * sumOverCosThetaSquared * sumOverSinThetaSquared
296 - sumOverPhiZPrimePrimeCosTheta.at( aHalfbarrel ) * sumOverZPrimeZPrimePrime.at( aHalfbarrel ) * sumOverCosTheta * sumOverSinThetaSquared
297 + sumOverPhiZPrimeCosTheta.at( aHalfbarrel ) * sumOverZPrimePrimeSquared.at( aHalfbarrel ) * sumOverCosTheta * sumOverSinThetaSquared
298 + sumOverPhiZPrimePrimeCosTheta.at( aHalfbarrel ) * sumOverZPrimeZPrimePrime.at( aHalfbarrel ) * sumOverCosThetaSinTheta * sumOverSinTheta
299 - sumOverPhiZPrimeCosTheta.at( aHalfbarrel ) * sumOverZPrimePrimeSquared.at( aHalfbarrel ) * sumOverCosThetaSinTheta * sumOverSinTheta
300 - sumOverPhiZPrimePrimeSinTheta.at( aHalfbarrel ) * sumOverZPrimeZPrimePrime.at( aHalfbarrel ) * sumOverCosThetaSquared * sumOverSinTheta
301 + sumOverPhiZPrimeSinTheta.at( aHalfbarrel ) * sumOverZPrimePrimeSquared.at( aHalfbarrel ) * sumOverCosThetaSquared * sumOverSinTheta
302 - sumOverPhiZPrimePrime.at( aHalfbarrel ) * sumOverZPrimeZPrimePrime.at( aHalfbarrel ) * sumOverCosThetaSinTheta * sumOverCosThetaSinTheta
303 + sumOverPhiZPrime.at( aHalfbarrel ) * sumOverZPrimePrimeSquared.at( aHalfbarrel ) * sumOverCosThetaSinTheta * sumOverCosThetaSinTheta
304 + sumOverPhiZPrimePrimeSinTheta.at( aHalfbarrel ) * sumOverZPrimeZPrimePrime.at( aHalfbarrel ) * sumOverCosTheta * sumOverCosThetaSinTheta
305 - sumOverPhiZPrimeSinTheta.at( aHalfbarrel ) * sumOverZPrimePrimeSquared.at( aHalfbarrel ) * sumOverCosTheta * sumOverCosThetaSinTheta )
306 / alignmentDenominator.at ( aHalfbarrel );
309 theResult.
GetParameter( aHalfbarrel, 0, 1 ).first = -1. * ( sumOverPhiZPrime.at( aHalfbarrel ) * sumOverZPrimeZPrimePrime.at( aHalfbarrel ) * sumOverCosThetaSquared * sumOverSinTheta
310 - sumOverPhiZPrimePrime.at( aHalfbarrel ) * sumOverZPrimeSquared.at( aHalfbarrel ) * sumOverCosThetaSquared * sumOverSinTheta
311 - sumOverPhiZPrimeCosTheta.at( aHalfbarrel ) * sumOverZPrimeZPrimePrime.at( aHalfbarrel ) * sumOverCosTheta * sumOverSinTheta
312 + sumOverPhiZPrimePrimeCosTheta.at( aHalfbarrel ) * sumOverZPrimeSquared.at( aHalfbarrel ) * sumOverCosTheta * sumOverSinTheta
313 - sumOverPhiZPrime.at( aHalfbarrel ) * sumOverZPrimeZPrimePrime.at( aHalfbarrel ) * sumOverCosTheta * sumOverCosThetaSinTheta
314 + sumOverPhiZPrimePrime.at( aHalfbarrel ) * sumOverZPrimeSquared.at( aHalfbarrel ) * sumOverCosTheta * sumOverCosThetaSinTheta
315 + sumOverPhiZPrimeCosTheta.at( aHalfbarrel ) * sumOverZPrimeZPrimePrime.at( aHalfbarrel ) * numberOfBeams * sumOverCosThetaSinTheta
316 - sumOverPhiZPrimePrimeCosTheta.at( aHalfbarrel ) * sumOverZPrimeSquared.at( aHalfbarrel ) * numberOfBeams * sumOverCosThetaSinTheta
317 - sumOverPhiZPrimeSinTheta.at( aHalfbarrel ) * sumOverZPrimeZPrimePrime.at( aHalfbarrel ) * numberOfBeams * sumOverCosThetaSquared
318 + sumOverPhiZPrimePrimeSinTheta.at( aHalfbarrel ) * sumOverZPrimeSquared.at( aHalfbarrel ) * numberOfBeams * sumOverCosThetaSquared
319 + sumOverPhiZPrimeSinTheta.at( aHalfbarrel ) * sumOverZPrimeZPrimePrime.at( aHalfbarrel ) * sumOverCosTheta * sumOverCosTheta
320 - sumOverPhiZPrimePrimeSinTheta.at( aHalfbarrel ) * sumOverZPrimeSquared.at( aHalfbarrel ) * sumOverCosTheta * sumOverCosTheta )
321 / alignmentDenominator.at ( aHalfbarrel ) * beamRadii.at( aHalfbarrel );
324 theResult.
GetParameter( aHalfbarrel, 1, 1 ).first = -1. * ( sumOverPhiZPrimePrime.at( aHalfbarrel ) * sumOverZPrimeZPrimePrime.at( aHalfbarrel ) * sumOverCosThetaSquared * sumOverSinTheta
325 - sumOverPhiZPrime.at( aHalfbarrel ) * sumOverZPrimePrimeSquared.at( aHalfbarrel ) * sumOverCosThetaSquared * sumOverSinTheta
326 - sumOverPhiZPrimePrimeCosTheta.at( aHalfbarrel ) * sumOverZPrimeZPrimePrime.at( aHalfbarrel ) * sumOverCosTheta * sumOverSinTheta
327 + sumOverPhiZPrimeCosTheta.at( aHalfbarrel ) * sumOverZPrimePrimeSquared.at( aHalfbarrel ) * sumOverCosTheta * sumOverSinTheta
328 - sumOverPhiZPrimePrime.at( aHalfbarrel ) * sumOverZPrimeZPrimePrime.at( aHalfbarrel ) * sumOverCosTheta * sumOverCosThetaSinTheta
329 + sumOverPhiZPrime.at( aHalfbarrel ) * sumOverZPrimePrimeSquared.at( aHalfbarrel ) * sumOverCosTheta * sumOverCosThetaSinTheta
330 + sumOverPhiZPrimePrimeCosTheta.at( aHalfbarrel ) * sumOverZPrimeZPrimePrime.at( aHalfbarrel ) * numberOfBeams * sumOverCosThetaSinTheta
331 - sumOverPhiZPrimeCosTheta.at( aHalfbarrel ) * sumOverZPrimePrimeSquared.at( aHalfbarrel ) * numberOfBeams * sumOverCosThetaSinTheta
332 - sumOverPhiZPrimePrimeSinTheta.at( aHalfbarrel ) * sumOverZPrimeZPrimePrime.at( aHalfbarrel ) * numberOfBeams * sumOverCosThetaSquared
333 + sumOverPhiZPrimeSinTheta.at( aHalfbarrel ) * sumOverZPrimePrimeSquared.at( aHalfbarrel ) * numberOfBeams * sumOverCosThetaSquared
334 + sumOverPhiZPrimePrimeSinTheta.at( aHalfbarrel ) * sumOverZPrimeZPrimePrime.at( aHalfbarrel ) * sumOverCosTheta * sumOverCosTheta
335 - sumOverPhiZPrimeSinTheta.at( aHalfbarrel ) * sumOverZPrimePrimeSquared.at( aHalfbarrel ) * sumOverCosTheta * sumOverCosTheta )
336 / alignmentDenominator.at ( aHalfbarrel ) * beamRadii.at( aHalfbarrel );
339 theResult.
GetParameter( aHalfbarrel, 0, 2 ).first = ( sumOverPhiZPrime.at( aHalfbarrel ) * sumOverZPrimeZPrimePrime.at( aHalfbarrel ) * sumOverCosTheta * sumOverSinThetaSquared
340 - sumOverPhiZPrimePrime.at( aHalfbarrel ) * sumOverZPrimeSquared.at( aHalfbarrel ) * sumOverCosTheta * sumOverSinThetaSquared
341 - sumOverPhiZPrimeCosTheta.at( aHalfbarrel ) * sumOverZPrimeZPrimePrime.at( aHalfbarrel ) * numberOfBeams * sumOverSinThetaSquared
342 + sumOverPhiZPrimePrimeCosTheta.at( aHalfbarrel ) * sumOverZPrimeSquared.at( aHalfbarrel ) * numberOfBeams * sumOverSinThetaSquared
343 + sumOverPhiZPrimeCosTheta.at( aHalfbarrel ) * sumOverZPrimeZPrimePrime.at( aHalfbarrel ) * sumOverSinTheta * sumOverSinTheta
344 - sumOverPhiZPrimePrimeCosTheta.at( aHalfbarrel ) * sumOverZPrimeSquared.at( aHalfbarrel ) * sumOverSinTheta * sumOverSinTheta
345 - sumOverPhiZPrime.at( aHalfbarrel ) * sumOverZPrimeZPrimePrime.at( aHalfbarrel ) * sumOverCosThetaSinTheta * sumOverSinTheta
346 + sumOverPhiZPrimePrime.at( aHalfbarrel ) * sumOverZPrimeSquared.at( aHalfbarrel ) * sumOverCosThetaSinTheta * sumOverSinTheta
347 - sumOverPhiZPrimeSinTheta.at( aHalfbarrel ) * sumOverZPrimeZPrimePrime.at( aHalfbarrel ) * sumOverCosTheta * sumOverSinTheta
348 + sumOverPhiZPrimePrimeSinTheta.at( aHalfbarrel ) * sumOverZPrimeSquared.at( aHalfbarrel ) * sumOverCosTheta * sumOverSinTheta
349 + sumOverPhiZPrimeSinTheta.at( aHalfbarrel ) * sumOverZPrimeZPrimePrime.at( aHalfbarrel ) * numberOfBeams * sumOverCosThetaSinTheta
350 - sumOverPhiZPrimePrimeSinTheta.at( aHalfbarrel ) * sumOverZPrimeSquared.at( aHalfbarrel ) * numberOfBeams * sumOverCosThetaSinTheta )
351 / alignmentDenominator.at ( aHalfbarrel ) * beamRadii.at( aHalfbarrel );
354 theResult.
GetParameter( aHalfbarrel, 1, 2 ).first = ( sumOverPhiZPrimePrime.at( aHalfbarrel ) * sumOverZPrimeZPrimePrime.at( aHalfbarrel ) * sumOverCosTheta * sumOverSinThetaSquared
355 - sumOverPhiZPrime.at( aHalfbarrel ) * sumOverZPrimePrimeSquared.at( aHalfbarrel ) * sumOverCosTheta * sumOverSinThetaSquared
356 - sumOverPhiZPrimePrimeCosTheta.at( aHalfbarrel ) * sumOverZPrimeZPrimePrime.at( aHalfbarrel ) * numberOfBeams * sumOverSinThetaSquared
357 + sumOverPhiZPrimeCosTheta.at( aHalfbarrel ) * sumOverZPrimePrimeSquared.at( aHalfbarrel ) * numberOfBeams * sumOverSinThetaSquared
358 + sumOverPhiZPrimePrimeCosTheta.at( aHalfbarrel ) * sumOverZPrimeZPrimePrime.at( aHalfbarrel ) * sumOverSinTheta * sumOverSinTheta
359 - sumOverPhiZPrimeCosTheta.at( aHalfbarrel ) * sumOverZPrimePrimeSquared.at( aHalfbarrel ) * sumOverSinTheta * sumOverSinTheta
360 - sumOverPhiZPrimePrime.at( aHalfbarrel ) * sumOverZPrimeZPrimePrime.at( aHalfbarrel ) * sumOverCosThetaSinTheta * sumOverSinTheta
361 + sumOverPhiZPrime.at( aHalfbarrel ) * sumOverZPrimePrimeSquared.at( aHalfbarrel ) * sumOverCosThetaSinTheta * sumOverSinTheta
362 - sumOverPhiZPrimePrimeSinTheta.at( aHalfbarrel ) * sumOverZPrimeZPrimePrime.at( aHalfbarrel ) * sumOverCosTheta * sumOverSinTheta
363 + sumOverPhiZPrimeSinTheta.at( aHalfbarrel ) * sumOverZPrimePrimeSquared.at( aHalfbarrel ) * sumOverCosTheta * sumOverSinTheta
364 + sumOverPhiZPrimePrimeSinTheta.at( aHalfbarrel ) * sumOverZPrimeZPrimePrime.at( aHalfbarrel ) * numberOfBeams * sumOverCosThetaSinTheta
365 - sumOverPhiZPrimeSinTheta.at( aHalfbarrel ) * sumOverZPrimePrimeSquared.at( aHalfbarrel ) * numberOfBeams * sumOverCosThetaSinTheta )
366 / alignmentDenominator.at ( aHalfbarrel ) * beamRadii.at( aHalfbarrel );
374 double vsumA = 0., vsumB = 0., vsumC = 0., vsumD = 0., vsumE = 0., vsumF = 0.;
375 for(
unsigned int aHalfbarrel = 0; aHalfbarrel < 6; ++aHalfbarrel ) {
376 vsumA += theResult.
GetParameter( aHalfbarrel, 1, 2 ).first * termA.at( aHalfbarrel ) + theResult.
GetParameter( aHalfbarrel, 0, 2 ).first * termB.at( aHalfbarrel );
377 vsumB += theResult.
GetParameter( aHalfbarrel, 1, 1 ).first * termA.at( aHalfbarrel ) + theResult.
GetParameter( aHalfbarrel, 0, 1 ).first * termB.at( aHalfbarrel );
378 vsumC += beamRadii.at( aHalfbarrel ) * ( theResult.
GetParameter( aHalfbarrel, 1, 0 ).first * termA.at( aHalfbarrel ) + theResult.
GetParameter( aHalfbarrel, 0, 0 ).first * termB.at( aHalfbarrel ) );
379 vsumD += theResult.
GetParameter( aHalfbarrel, 1, 2 ).first * termC.at( aHalfbarrel ) + theResult.
GetParameter( aHalfbarrel, 0, 2 ).first * termD.at( aHalfbarrel );
380 vsumE += theResult.
GetParameter( aHalfbarrel, 1, 1 ).first * termC.at( aHalfbarrel ) + theResult.
GetParameter( aHalfbarrel, 0, 1 ).first * termD.at( aHalfbarrel );
381 vsumF += beamRadii.at( aHalfbarrel ) * ( theResult.
GetParameter( aHalfbarrel, 1, 0 ).first * termC.at( aHalfbarrel ) + theResult.
GetParameter( aHalfbarrel, 0, 0 ).first * termD.at( aHalfbarrel ) );
387 for(
unsigned int beam = 0; beam < 8; ++beam ) {
391 -
sin( beamPhiPositions.at( beam ) ) * vsumB
393 + sumOverPhiZTPrime.at( beam ) * sumOverZTPrimeZTPrimePrime - sumOverPhiZTPrimePrime.at( beam ) * sumOverZTPrimeSquared )
397 std::cout <<
"BBBBBBBB: " <<
cos( beamPhiPositions.at( beam ) ) * vsumA <<
" "
398 << -1. *
sin( beamPhiPositions.at( beam ) ) * vsumB <<
" "
399 << -1. * vsumC <<
" "
400 << sumOverPhiZTPrime.at( beam ) * sumOverZTPrimeZTPrimePrime - sumOverPhiZTPrimePrime.at( beam ) * sumOverZTPrimeSquared <<
" "
408 -
sin( beamPhiPositions.at( beam ) ) * vsumE
410 + sumOverPhiZTPrimePrime.at( beam ) * sumOverZTPrimeZTPrimePrime - sumOverPhiZTPrime.at( beam ) * sumOverZTPrimePrimeSquared )
437 std::vector<std::vector<std::vector<double> > > endFaceZPositions( 4, std::vector<std::vector<double> >( 2, std::vector<double>( 2, 0. ) ) );
438 endFaceZPositions.at( 0 ).at( 0 ).at( 0 ) = 1322.5;
439 endFaceZPositions.at( 0 ).at( 0 ).at( 1 ) = 2667.5;
440 endFaceZPositions.at( 1 ).at( 0 ).at( 0 ) = -2667.5;
441 endFaceZPositions.at( 1 ).at( 0 ).at( 1 ) = -1322.5;
442 endFaceZPositions.at( 2 ).at( 1 ).at( 0 ) = -700.;
443 endFaceZPositions.at( 2 ).at( 1 ).at( 1 ) = -300.;
444 endFaceZPositions.at( 2 ).at( 0 ).at( 0 ) = 300.;
445 endFaceZPositions.at( 2 ).at( 0 ).at( 1 ) = 700.;
446 endFaceZPositions.at( 3 ).at( 1 ).at( 0 ) = -1090.;
447 endFaceZPositions.at( 3 ).at( 1 ).at( 1 ) = -300.;
448 endFaceZPositions.at( 3 ).at( 0 ).at( 0 ) = 300.;
449 endFaceZPositions.at( 3 ).at( 0 ).at( 1 ) = 1090.;
452 std::vector<double> disk9EndFaceZPositions( 2, 0. );
453 disk9EndFaceZPositions.at( 0 ) = -2667.5;
454 disk9EndFaceZPositions.at( 1 ) = 2667.5;
457 const int theSide = pos<3 ? 0 : 1;
460 const int halfbarrel = det==2 ? det+theSide : det+1+theSide;
464 const double radialOffset = det==2 ? 50. : 36.;
467 const double phiPositions[8] = { 0.392699, 1.289799, 1.851794, 2.748894, 3.645995, 4.319690, 5.216791, 5.778784 };
468 std::vector<double> beamPhiPositions( 8, 0. );
469 for(
unsigned int aBeam = 0; aBeam < 8; ++aBeam ) beamPhiPositions.at( aBeam ) = phiPositions[aBeam];
475 const double radii[6] = { 564., 564., 514., 514., 600., 600. };
476 std::vector<double> beamRadii( 6, 0. );
477 for(
int aHalfbarrel = 0; aHalfbarrel < 6; ++aHalfbarrel ) beamRadii.at( aHalfbarrel ) = radii[aHalfbarrel];
480 double detReducedZ[2] = { 0., 0. };
482 double beamReducedZ[2] = { 0., 0. };
485 detReducedZ[0] = nominalCoordinates.
GetTIBTOBEntry( det, beam, pos ).
GetZ() - endFaceZPositions.at( det ).at( theSide ).at( 0 );
486 detReducedZ[0] /= ( endFaceZPositions.at( det ).at( theSide ).at( 1 ) - endFaceZPositions.at( det ).at( theSide ).at( 0 ) );
487 detReducedZ[1] = endFaceZPositions.at( det ).at( theSide ).at( 1 ) - nominalCoordinates.
GetTIBTOBEntry( det, beam, pos ).
GetZ();
488 detReducedZ[1] /= ( endFaceZPositions.at( det ).at( theSide ).at( 1 ) - endFaceZPositions.at( det ).at( theSide ).at( 0 ) );
491 beamReducedZ[0] = ( nominalCoordinates.
GetTIBTOBEntry( det, beam, pos ).
GetZ() - radialOffset ) - disk9EndFaceZPositions.at( 0 );
492 beamReducedZ[0] /= ( disk9EndFaceZPositions.at( 1 ) - disk9EndFaceZPositions.at( 0 ) );
493 beamReducedZ[1] = disk9EndFaceZPositions.at( 1 ) - ( nominalCoordinates.
GetTIBTOBEntry( det, beam, pos ).
GetZ() - radialOffset );
494 beamReducedZ[1] /= ( disk9EndFaceZPositions.at( 1 ) - disk9EndFaceZPositions.at( 0 ) );
498 double phiCorrection = 0.;
501 phiCorrection += detReducedZ[1] * alignmentParameters.
GetParameter( halfbarrel, 0, 0 ).first;
504 phiCorrection += detReducedZ[0] * alignmentParameters.
GetParameter( halfbarrel, 1, 0 ).first;
507 phiCorrection += detReducedZ[1] *
sin( beamPhiPositions.at( beam ) ) * alignmentParameters.
GetParameter( halfbarrel, 0, 1 ).first / beamRadii.at( halfbarrel );
510 phiCorrection += detReducedZ[0] *
sin( beamPhiPositions.at( beam ) ) * alignmentParameters.
GetParameter( halfbarrel, 1, 1 ).first / beamRadii.at( halfbarrel );
513 phiCorrection -= detReducedZ[1] *
cos( beamPhiPositions.at( beam ) ) * alignmentParameters.
GetParameter( halfbarrel, 0, 2 ).first / beamRadii.at( halfbarrel );
516 phiCorrection -= detReducedZ[0] *
cos( beamPhiPositions.at( beam ) ) * alignmentParameters.
GetParameter( halfbarrel, 1, 2 ).first / beamRadii.at( halfbarrel );
521 phiCorrection += beamReducedZ[1] * alignmentParameters.
GetBeamParameter( beam, 0 ).first * beamRadii.at( 0 ) / beamRadii.at( halfbarrel );
522 phiCorrection += beamReducedZ[0] * alignmentParameters.
GetBeamParameter( beam, 1 ).first * beamRadii.at( 0 ) / beamRadii.at( halfbarrel );
525 return phiCorrection;
546 std::vector<std::vector<std::vector<double> > > endFaceZPositions( 4, std::vector<std::vector<double> >( 2, std::vector<double>( 2, 0. ) ) );
547 endFaceZPositions.at( 0 ).at( 0 ).at( 0 ) = 1322.5;
548 endFaceZPositions.at( 0 ).at( 0 ).at( 1 ) = 2667.5;
549 endFaceZPositions.at( 1 ).at( 0 ).at( 0 ) = -2667.5;
550 endFaceZPositions.at( 1 ).at( 0 ).at( 1 ) = -1322.5;
551 endFaceZPositions.at( 2 ).at( 1 ).at( 0 ) = -700.;
552 endFaceZPositions.at( 2 ).at( 1 ).at( 1 ) = -300.;
553 endFaceZPositions.at( 2 ).at( 0 ).at( 0 ) = 300.;
554 endFaceZPositions.at( 2 ).at( 0 ).at( 1 ) = 700.;
555 endFaceZPositions.at( 3 ).at( 1 ).at( 0 ) = -1090.;
556 endFaceZPositions.at( 3 ).at( 1 ).at( 1 ) = -300.;
557 endFaceZPositions.at( 3 ).at( 0 ).at( 0 ) = 300.;
558 endFaceZPositions.at( 3 ).at( 0 ).at( 1 ) = 1090.;
561 std::vector<double> disk9EndFaceZPositions( 2, 0. );
562 disk9EndFaceZPositions.at( 0 ) = -2667.5;
563 disk9EndFaceZPositions.at( 1 ) = 2667.5;
566 const int halfbarrel = det;
569 const int theSide = 0;
572 const double radialOffset = 0.;
575 const double phiPositions[8] = { 0.392699, 1.289799, 1.851794, 2.748894, 3.645995, 4.319690, 5.216791, 5.778784 };
576 std::vector<double> beamPhiPositions( 8, 0. );
577 for(
unsigned int aBeam = 0; aBeam < 8; ++aBeam ) beamPhiPositions.at( aBeam ) = phiPositions[aBeam];
583 const double radii[6] = { 564., 564., 514., 514., 600., 600. };
584 std::vector<double> beamRadii( 6, 0. );
585 for(
int aHalfbarrel = 0; aHalfbarrel < 6; ++aHalfbarrel ) beamRadii.at( aHalfbarrel ) = radii[aHalfbarrel];
588 double detReducedZ[2] = { 0., 0. };
590 double beamReducedZ[2] = { 0., 0. };
593 detReducedZ[0] = nominalCoordinates.
GetTEC2TECEntry( det, beam, disk ).
GetZ() - endFaceZPositions.at( det ).at( theSide ).at( 0 );
594 detReducedZ[0] /= ( endFaceZPositions.at( det ).at( theSide ).at( 1 ) - endFaceZPositions.at( det ).at( theSide ).at( 0 ) );
595 detReducedZ[1] = endFaceZPositions.at( det ).at( theSide ).at( 1 ) - nominalCoordinates.
GetTEC2TECEntry( det, beam, disk ).
GetZ();
596 detReducedZ[1] /= ( endFaceZPositions.at( det ).at( theSide ).at( 1 ) - endFaceZPositions.at( det ).at( theSide ).at( 0 ) );
599 beamReducedZ[0] = ( nominalCoordinates.
GetTEC2TECEntry( det, beam, disk ).
GetZ() - radialOffset ) - disk9EndFaceZPositions.at( 0 );
600 beamReducedZ[0] /= ( disk9EndFaceZPositions.at( 1 ) - disk9EndFaceZPositions.at( 0 ) );
601 beamReducedZ[1] = disk9EndFaceZPositions.at( 1 ) - ( nominalCoordinates.
GetTEC2TECEntry( det, beam, disk ).
GetZ() - radialOffset );
602 beamReducedZ[1] /= ( disk9EndFaceZPositions.at( 1 ) - disk9EndFaceZPositions.at( 0 ) );
607 double phiCorrection = 0.;
610 phiCorrection += detReducedZ[1] * alignmentParameters.
GetParameter( halfbarrel, 0, 0 ).first;
613 phiCorrection += detReducedZ[0] * alignmentParameters.
GetParameter( halfbarrel, 1, 0 ).first;
616 phiCorrection += detReducedZ[1] *
sin( beamPhiPositions.at( beam ) ) * alignmentParameters.
GetParameter( halfbarrel, 0, 1 ).first / beamRadii.at( halfbarrel );
619 phiCorrection += detReducedZ[0] *
sin( beamPhiPositions.at( beam ) ) * alignmentParameters.
GetParameter( halfbarrel, 1, 1 ).first / beamRadii.at( halfbarrel );
622 phiCorrection -= detReducedZ[1] *
cos( beamPhiPositions.at( beam ) ) * alignmentParameters.
GetParameter( halfbarrel, 0, 2 ).first / beamRadii.at( halfbarrel );
625 phiCorrection -= detReducedZ[0] *
cos( beamPhiPositions.at( beam ) ) * alignmentParameters.
GetParameter( halfbarrel, 1, 2 ).first / beamRadii.at( halfbarrel );
630 phiCorrection += beamReducedZ[1] * alignmentParameters.
GetBeamParameter( beam, 0 ).first * beamRadii.at( 0 ) / beamRadii.at( halfbarrel );
631 phiCorrection += beamReducedZ[0] * alignmentParameters.
GetBeamParameter( beam, 1 ).first * beamRadii.at( 0 ) / beamRadii.at( halfbarrel );
634 return phiCorrection;
655 std::ifstream
file( filename );
657 std::cerr <<
" [LASAlignmentTubeAlgorithm::ReadMisalignmentFromFile] ** ERROR: cannot open file \"" << filename <<
"\"." << std::endl;
661 std::cerr <<
" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" << std::endl;
662 std::cerr <<
" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" << std::endl;
663 std::cerr <<
" [LASAlignmentTubeAlgorithm::ReadMisalignmentFromFile] ** WARNING: you are reading a fake measurement from a file!" << std::endl;
664 std::cerr <<
" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" << std::endl;
665 std::cerr <<
" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" << std::endl;
670 measuredCoordinates = nominalCoordinates;
675 int det,
ring, beam, disk,
pos;
677 det = 0; ring = 0; beam = 0; disk = 0;
680 }
while( moduleLoop.
TECLoop( det, ring, beam, disk ) );
682 det = 2; beam = 0; pos = 0;
685 }
while( moduleLoop.
TIBTOBLoop( det, beam, pos ) );
687 det = 0; beam = 0; disk = 0;
690 }
while( moduleLoop.
TEC2TECLoop( det, beam, disk ) );
695 int det, beam,
z,
ring;
696 double phi, phiError;
698 while( !file.eof() ) {
701 if( file.eof() )
break;
703 file >> beam; file >>
z; file >>
ring;
704 file >>
phi; file >> phiError;
std::pair< double, double > & GetParameter(int aSubdetector, int aDisk, int aParameter)
void SetPhiError(double aPhiError)
Sin< T >::type sin(const T &t)
double GetPhi(void) const
bool TEC2TECLoop(int &, int &, int &) const
LASAlignmentTubeAlgorithm()
Cos< T >::type cos(const T &t)
std::pair< double, double > & GetBeamParameter(int aBeam, int aParameter)
T & GetTIBTOBEntry(int subdetector, int beam, int tibTobPosition)
double GetTEC2TECAlignmentParameterCorrection(int, int, int, LASGlobalData< LASCoordinateSet > &, LASBarrelAlignmentParameterSet &)
void ReadMisalignmentFromFile(const char *, LASGlobalData< LASCoordinateSet > &, LASGlobalData< LASCoordinateSet > &)
T & GetTEC2TECEntry(int subdetector, int beam, int tecDisk)
LASBarrelAlignmentParameterSet CalculateParameters(LASGlobalData< LASCoordinateSet > &, LASGlobalData< LASCoordinateSet > &)
T & GetTECEntry(int subdetector, int tecRing, int beam, int tecDisk)
bool TECLoop(int &, int &, int &, int &) const
bool TIBTOBLoop(int &, int &, int &) const
double GetTIBTOBAlignmentParameterCorrection(int, int, int, LASGlobalData< LASCoordinateSet > &, LASBarrelAlignmentParameterSet &)
Power< A, B >::type pow(const A &a, const B &b)