00001
00002 #include "Alignment/LaserAlignment/interface/LASGeometryUpdater.h"
00003
00004
00011 LASGeometryUpdater::LASGeometryUpdater( LASGlobalData<LASCoordinateSet>& aNominalCoordinates, LASConstants& aLasConstants ) {
00012
00013 nominalCoordinates = aNominalCoordinates;
00014 isReverseDirection = false;
00015 isMisalignmentFromRefGeometry = false;
00016 lasConstants = aLasConstants;
00017
00018 }
00019
00020
00021
00022
00023
00028 void LASGeometryUpdater::ApplyBeamKinkCorrections( LASGlobalData<LASCoordinateSet>& measuredCoordinates ) const {
00029
00032 for( unsigned int det = 0; det < 2; ++det ) {
00033 for( unsigned int ring = 0; ring < 2; ++ring ) {
00034 for( unsigned int beam = 0; beam < 8; ++beam ) {
00035
00036
00037 const double endcapSign = det==0 ? 1.: -1.;
00038
00039
00040 for( unsigned int disk = 5; disk < 9; ++disk ) {
00041
00042 measuredCoordinates.GetTECEntry( det, ring, beam, disk ).SetPhi(
00043 measuredCoordinates.GetTECEntry( det, ring, beam, disk ).GetPhi() -
00044 tan( lasConstants.GetEndcapBsKink( det, ring, beam ) ) / lasConstants.GetTecRadius( ring ) *
00045 ( lasConstants.GetTecZPosition( det, disk ) - endcapSign * lasConstants.GetTecBsZPosition( det ) )
00046 );
00047
00048 }
00049 }
00050 }
00051 }
00052
00053
00056
00057 }
00058
00059
00060
00061
00062
00068 void LASGeometryUpdater::EndcapUpdate( LASEndcapAlignmentParameterSet& endcapParameters, LASGlobalData<LASCoordinateSet>& measuredCoordinates ) {
00069
00070
00071 const double radius = 564.;
00072
00073
00074 LASGlobalLoop moduleLoop;
00075 int det = 0, beam = 0, disk = 0;
00076
00077
00078
00079
00080 do {
00081
00082
00083 const double currentPhi = measuredCoordinates.GetTEC2TECEntry( det, beam, disk ).GetPhi();
00084
00085
00086
00087 double phiCorrection = 0.;
00088
00089
00090 phiCorrection -= endcapParameters.GetDiskParameter( det, disk, 0 ).first;
00091
00092
00093 phiCorrection += sin( nominalCoordinates.GetTEC2TECEntry( det, beam, disk ).GetPhi() ) / radius * endcapParameters.GetDiskParameter( det, disk, 1 ).first;
00094
00095
00096 phiCorrection -= cos( nominalCoordinates.GetTEC2TECEntry( det, beam, disk ).GetPhi() ) / radius * endcapParameters.GetDiskParameter( det, disk, 2 ).first;
00097
00098 measuredCoordinates.GetTEC2TECEntry( det, beam, disk ).SetPhi( currentPhi - phiCorrection );
00099
00100 } while( moduleLoop.TEC2TECLoop( det, beam, disk ) );
00101
00102 }
00103
00104
00105
00106
00107
00114 void LASGeometryUpdater::TrackerUpdate( LASEndcapAlignmentParameterSet& endcapParameters,
00115 LASBarrelAlignmentParameterSet& barrelParameters,
00116 AlignableTracker& theAlignableTracker ) {
00117
00118
00119
00120
00121 const int direction = ( isReverseDirection || isMisalignmentFromRefGeometry ) ? -1 : 1;
00122
00123
00124 const align::Alignables& theOuterHalfBarrels = theAlignableTracker.outerHalfBarrels();
00125 const align::Alignables& theInnerHalfBarrels = theAlignableTracker.innerHalfBarrels();
00126
00127
00128 const align::Alignables& theEndcaps = theAlignableTracker.endCaps();
00129
00130
00131
00132 std::vector<Alignable*> theHalfBarrels( 6 );
00133 theHalfBarrels.at( 0 ) = theEndcaps.at( 0 );
00134 theHalfBarrels.at( 1 ) = theEndcaps.at( 1 );
00135 theHalfBarrels.at( 2 ) = theInnerHalfBarrels.at( 1 );
00136 theHalfBarrels.at( 3 ) = theInnerHalfBarrels.at( 0 );
00137 theHalfBarrels.at( 4 ) = theOuterHalfBarrels.at( 1 );
00138 theHalfBarrels.at( 5 ) = theOuterHalfBarrels.at( 0 );
00139
00140
00141
00142 std::vector<std::vector<double> > halfbarrelEndfaceZPositions( 6, std::vector<double>( 2, 0. ) );
00143 halfbarrelEndfaceZPositions.at( 0 ).at( 0 ) = 1322.5;
00144 halfbarrelEndfaceZPositions.at( 0 ).at( 1 ) = 2667.5;
00145 halfbarrelEndfaceZPositions.at( 1 ).at( 0 ) = -2667.5;
00146 halfbarrelEndfaceZPositions.at( 1 ).at( 1 ) = -1322.5;
00147 halfbarrelEndfaceZPositions.at( 2 ).at( 0 ) = 300.;
00148 halfbarrelEndfaceZPositions.at( 2 ).at( 1 ) = 700.;
00149 halfbarrelEndfaceZPositions.at( 3 ).at( 0 ) = -700.;
00150 halfbarrelEndfaceZPositions.at( 3 ).at( 1 ) = -300.;
00151 halfbarrelEndfaceZPositions.at( 4 ).at( 0 ) = 300.;
00152 halfbarrelEndfaceZPositions.at( 4 ).at( 1 ) = 1090.;
00153 halfbarrelEndfaceZPositions.at( 5 ).at( 0 ) = -1090.;
00154 halfbarrelEndfaceZPositions.at( 5 ).at( 1 ) = -300.;
00155
00156
00157
00158 std::vector<double> theBarrelLength( 6, 0. );
00159 theBarrelLength.at( 0 ) = 1345.;
00160 theBarrelLength.at( 1 ) = 1345.;
00161 theBarrelLength.at( 2 ) = 400.;
00162 theBarrelLength.at( 3 ) = 400.;
00163 theBarrelLength.at( 4 ) = 790.;
00164 theBarrelLength.at( 5 ) = 790.;
00165
00166
00167
00168
00169 std::vector<double> theHalfbarrelCenters( 6, 0. );
00170 for( int halfbarrel = 0; halfbarrel < 6; ++halfbarrel ) {
00171 theHalfbarrelCenters.at( halfbarrel ) = theHalfBarrels.at( halfbarrel )->globalPosition().z() * 10.;
00172 }
00173
00174
00175
00176
00177 const double fromMmToCm = 10.;
00178
00179
00180 for( int halfBarrel = 2; halfBarrel < 6; ++halfBarrel ) {
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199 const align::Scalar rxLocal = ( barrelParameters.GetParameter( halfBarrel, 0, 2 ).first - barrelParameters.GetParameter( halfBarrel, 1, 2 ).first ) / theBarrelLength.at( halfBarrel );
00200 theHalfBarrels.at( halfBarrel )->rotateAroundLocalX( direction * rxLocal );
00201
00202
00203 const align::Scalar ryLocal = ( barrelParameters.GetParameter( halfBarrel, 1, 1 ).first - barrelParameters.GetParameter( halfBarrel, 0, 1 ).first ) / theBarrelLength.at( halfBarrel );
00204 theHalfBarrels.at( halfBarrel )->rotateAroundLocalY( direction * ryLocal );
00205
00206
00207 const align::Scalar rzLocal = ( barrelParameters.GetParameter( halfBarrel, 0, 0 ).first + barrelParameters.GetParameter( halfBarrel, 1, 0 ).first ) / 2.;
00208 theHalfBarrels.at( halfBarrel )->rotateAroundLocalZ( -1. * direction * rzLocal );
00209
00210
00211
00212
00213
00214
00215 std::vector<double> correctedEndfaceOffsetsX( 2, 0. );
00216 correctedEndfaceOffsetsX.at( 0 ) = barrelParameters.GetParameter( halfBarrel, 0, 1 ).first
00217 + ( theHalfbarrelCenters.at( halfBarrel ) - halfbarrelEndfaceZPositions.at( halfBarrel ).at( 0 ) ) * ryLocal;
00218 correctedEndfaceOffsetsX.at( 1 ) = barrelParameters.GetParameter( halfBarrel, 1, 1 ).first
00219 - ( halfbarrelEndfaceZPositions.at( halfBarrel ).at( 1 ) - theHalfbarrelCenters.at( halfBarrel ) ) * ryLocal;
00220
00221 std::vector<double> correctedEndfaceOffsetsY( 2, 0. );
00222 correctedEndfaceOffsetsY.at( 0 ) = barrelParameters.GetParameter( halfBarrel, 0, 2 ).first
00223 - ( theHalfbarrelCenters.at( halfBarrel ) - halfbarrelEndfaceZPositions.at( halfBarrel ).at( 0 ) ) * rxLocal;
00224 correctedEndfaceOffsetsY.at( 1 ) = barrelParameters.GetParameter( halfBarrel, 1, 2 ).first
00225 + ( halfbarrelEndfaceZPositions.at( halfBarrel ).at( 1 ) - theHalfbarrelCenters.at( halfBarrel ) ) * rxLocal;
00226
00227
00228 const align::GlobalVector dxLocal( ( correctedEndfaceOffsetsX.at( 0 ) + correctedEndfaceOffsetsX.at( 1 ) ) / 2. / fromMmToCm, 0., 0. );
00229 theHalfBarrels.at( halfBarrel )->move( direction * ( dxLocal ) );
00230
00231
00232 const align::GlobalVector dyLocal( 0., ( correctedEndfaceOffsetsY.at( 0 ) + correctedEndfaceOffsetsY.at( 1 ) ) / 2. / fromMmToCm, 0. );
00233 theHalfBarrels.at( halfBarrel )->move( direction * ( dyLocal ) );
00234
00235 }
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249 std::vector<std::vector<double> > wheelZPositions( 2, std::vector<double>( 9, 0. ) );
00250 for( int wheel = 0; wheel < 9; ++wheel ) {
00251 wheelZPositions.at( 0 ).at( wheel ) = theEndcaps.at( 0 )->components().at( wheel )->globalPosition().z();
00252 wheelZPositions.at( 1 ).at( wheel ) = theEndcaps.at( 1 )->components().at( wheel )->globalPosition().z();
00253 }
00254
00255
00256
00257
00258
00259
00260 for( int det = 0; det < 2; ++det ) {
00261
00262 const int& side = det;
00263
00264
00265
00266
00267
00268
00269
00270 for( int wheel = 0; wheel < 9; ++wheel ) {
00271 theEndcaps.at( det )->components().at( wheel )->rotateAroundLocalZ( direction * endcapParameters.GetDiskParameter( det, wheel, 0 ).first );
00272 const align::GlobalVector dXY( endcapParameters.GetDiskParameter( det, wheel, 1 ).first / fromMmToCm, endcapParameters.GetDiskParameter( det, wheel, 2 ).first / fromMmToCm, 0. );
00273 theEndcaps.at( det )->components().at( wheel )->move( direction * dXY );
00274 }
00275
00276
00277
00278
00279
00280
00281 const align::Scalar dphi1 = barrelParameters.GetParameter( det, side, 0 ).first;
00282 theEndcaps.at( det )->rotateAroundLocalZ( -1. * direction * dphi1 );
00283
00284
00285 const align::GlobalVector dxy1( barrelParameters.GetParameter( det, side, 1 ).first / fromMmToCm,
00286 barrelParameters.GetParameter( det, side, 2 ).first / fromMmToCm,
00287 0. );
00288 theEndcaps.at( det )->move( direction * dxy1 );
00289
00290
00291
00292
00293
00294
00295 const align::Scalar resultingPhi9 = barrelParameters.GetParameter( det, 1, 0 ).first - barrelParameters.GetParameter( det, 0, 0 ).first;
00296 const align::GlobalVector resultingXY9( ( barrelParameters.GetParameter( det, 1, 1 ).first - barrelParameters.GetParameter( det, 0, 1 ).first ) / fromMmToCm,
00297 ( barrelParameters.GetParameter( det, 1, 2 ).first - barrelParameters.GetParameter( det, 0, 2 ).first ) / fromMmToCm,
00298 0. );
00299
00300
00301
00302
00303 for( int wheel = 0; wheel < 9; ++wheel ) {
00304 const double reducedZ = ( wheelZPositions.at( det ).at( wheel ) - wheelZPositions.at( det ).at( 0 ) ) / theBarrelLength.at( det ) * fromMmToCm;
00305 theEndcaps.at( det )->components().at( wheel )->rotateAroundLocalZ( -1. * direction * reducedZ * resultingPhi9 );
00306 theEndcaps.at( det )->components().at( wheel )->move( direction * reducedZ * resultingXY9 );
00307 }
00308
00309 }
00310
00311 }
00312
00313
00314
00315
00316
00320 void LASGeometryUpdater::SetReverseDirection( bool isSet ) {
00321
00322 isReverseDirection = isSet;
00323
00324 }
00325
00326
00327
00328
00329
00333 void LASGeometryUpdater::SetMisalignmentFromRefGeometry( bool isSet ) {
00334
00335 isMisalignmentFromRefGeometry = isSet;
00336
00337 }