CMS 3D CMS Logo

LASGeometryUpdater.cc

Go to the documentation of this file.
00001 
00002 #include "Alignment/LaserAlignment/src/LASGeometryUpdater.h"
00003 
00004 
00008 LASGeometryUpdater::LASGeometryUpdater() {
00009 }
00010 
00011 
00012 
00013 
00014 
00021 void LASGeometryUpdater::Update( LASEndcapAlignmentParameterSet& endcapParameters,
00022                                  LASBarrelAlignmentParameterSet& barrelParameters, 
00023                                  AlignableTracker& theAlignableTracker ) {
00024 
00025 
00026   // first, we access the half barrels of TIB and TOB
00027   const align::Alignables& theOuterHalfBarrels = theAlignableTracker.outerHalfBarrels();
00028   const align::Alignables& theInnerHalfBarrels = theAlignableTracker.innerHalfBarrels();
00029 
00030   // then the TECs and treat them also as half barrels 
00031   const align::Alignables& theEndcaps = theAlignableTracker.endCaps();
00032 
00033   // re-arrange to match the structure in LASBarrelAlignmentParameterSet and simplify the loop
00034   // 2 (TIB+), 3 (TIB-), 4 (TOB+), 5 (TOB-)
00035   std::vector<Alignable*> theHalfBarrels( 6 );
00036   theHalfBarrels.at( 0 ) = theEndcaps.at( 0 ); // TEC+
00037   theHalfBarrels.at( 1 ) = theEndcaps.at( 1 ); // TEC-
00038   theHalfBarrels.at( 2 ) = theInnerHalfBarrels.at( 1 ); // TIB+
00039   theHalfBarrels.at( 3 ) = theInnerHalfBarrels.at( 0 ); // TIB-
00040   theHalfBarrels.at( 4 ) = theOuterHalfBarrels.at( 1 ); // TOB+
00041   theHalfBarrels.at( 5 ) = theOuterHalfBarrels.at( 0 ); // TOB-
00042 
00043   // z difference of half barrel end faces (= hb-length)
00044   // do this more intelligent later..
00045   std::vector<double> theBarrelLength( 6, 0. );
00046   theBarrelLength.at( 0 ) = 1348.65; // TEC
00047   theBarrelLength.at( 1 ) = 1348.65;
00048   theBarrelLength.at( 2 ) = 400.;  // TIB
00049   theBarrelLength.at( 3 ) = 400.;
00050   theBarrelLength.at( 4 ) = 790.;  // TOB
00051   theBarrelLength.at( 5 ) = 790.;
00052 
00053 
00054   // half barrel loop (no TECs -> det>1)
00055   for( int halfBarrel = 2; halfBarrel < 6; ++halfBarrel ) {
00056     
00057     // average x displacement = (dx1+dx2)/2
00058     const align::GlobalVector dxLocal( ( barrelParameters.GetParameter( halfBarrel, 0, 0 ).first + barrelParameters.GetParameter( halfBarrel, 1, 0 ).first ) / 2., 0., 0. );
00059     theHalfBarrels.at( halfBarrel )->move( dxLocal );
00060 
00061     // average y displacement = (dy1+dy2)/2
00062     const align::GlobalVector dyLocal( 0., ( barrelParameters.GetParameter( halfBarrel, 0, 1 ).first + barrelParameters.GetParameter( halfBarrel, 1, 1 ).first ) / 2., 0. );
00063     theHalfBarrels.at( halfBarrel )->move( dyLocal );
00064 
00065     // rotation around x axis = (dy2-dy1)/L
00066     const align::Scalar rxLocal = ( barrelParameters.GetParameter( halfBarrel, 1, 2 ).first - barrelParameters.GetParameter( halfBarrel, 0, 2 ).first ) / theBarrelLength.at( halfBarrel );
00067     theHalfBarrels.at( halfBarrel )->rotateAroundLocalX( rxLocal );
00068     
00069     // rotation around y axis = (dx1-dx2)/L
00070     const align::Scalar ryLocal = ( barrelParameters.GetParameter( halfBarrel, 0, 1 ).first - barrelParameters.GetParameter( halfBarrel, 1, 1 ).first ) / theBarrelLength.at( halfBarrel );
00071     theHalfBarrels.at( halfBarrel )->rotateAroundLocalY( ryLocal );
00072     
00073     // average rotation around z axis = (dphi1+dphi2)/2
00074     const align::Scalar rzLocal = ( barrelParameters.GetParameter( halfBarrel, 0, 0 ).first + barrelParameters.GetParameter( halfBarrel, 1, 0 ).first ) / 2.;
00075     theHalfBarrels.at( halfBarrel )->rotateAroundLocalZ( rzLocal );
00076 
00077   }
00078 
00079 
00080   // now fit the endcaps into that alignment tube frame. the strategy is the following:
00081   //
00082   // 1. apply the parameters from the endcap algorithm to the individual disks
00083   // 2. the tec as a whole is rotated and moved such that the innermost disk (1) (= halfbarrel inner endface) 
00084   //    reaches the position determined by the barrel algorithm. 
00085   // 3. then, the TEC is twisted and sheared until the outermost disk (9) reaches nominal position 
00086   //    (since it has been fixed there in the alignment tube frame). this resolves any common
00087   //    shear and torsion within the TEC coordinate frame.
00088 
00089 
00090   // shortcut to the z positions of the disks' mechanical structures (TEC+/-, 9*disk)
00091   std::vector<std::vector<double> > wheelZPositions( 2, std::vector<double>( 9, 0. ) );
00092   for( int wheel = 0; wheel < 9; ++wheel ) {
00093     wheelZPositions.at( 0 ).at( wheel ) = 10. * theEndcaps.at( 0 )->components().at( wheel )->globalPosition().z(); // 10.*: these are in cm!
00094     wheelZPositions.at( 1 ).at( wheel ) = 10. * theEndcaps.at( 1 )->components().at( wheel )->globalPosition().z();
00095   }
00096 
00097   // we can do this for both TECs in one go;
00098   // only real difference is the index change in the second argument to barrelParameters::GetParameter:
00099   // here the disk index changes from 0(+) to 1(-), since the end faces are sorted according to z (-->side=det)
00100   for( int det = 0; det < 2; ++ det ) {
00101 
00102     const int& side = det;
00103 
00104     // step 1: apply the endcap algorithm parameters
00105     for( int wheel = 0; wheel < 9; ++ wheel ) {
00106       theEndcaps.at( det )->components().at( wheel )->rotateAroundLocalZ( endcapParameters.GetParameter( det, wheel, 0 ).first );
00107       const align::GlobalVector dXY( endcapParameters.GetParameter( det, wheel, 1 ).first, endcapParameters.GetParameter( det, wheel, 2 ).first, 0. );
00108       theEndcaps.at( det )->components().at( wheel )->move( dXY );
00109     }
00110     
00111     // step 2: attach the innermost disk (1)
00112     
00113     // rotation around z of disk 1
00114     const align::Scalar dphi1 = barrelParameters.GetParameter( det, side, 0 ).first - endcapParameters.GetParameter( det, 0, 0 ).first;
00115     theEndcaps.at( det )->rotateAroundLocalZ( dphi1 );
00116     
00117     // displacement in x,y of disk 1
00118     const align::GlobalVector dxy1( barrelParameters.GetParameter( det, side, 1 ).first - endcapParameters.GetParameter( det, 0, 1 ).first, 
00119                                     barrelParameters.GetParameter( det, side, 2 ).first - endcapParameters.GetParameter( det, 0, 2 ).first,
00120                                     0. );
00121     theEndcaps.at( det )->move( dxy1 );
00122     
00123     // determine the resulting phi, x, y of disk 9 after step 2
00124     const align::Scalar resultingPhi9 = endcapParameters.GetParameter( det, 8, 0 ).first + dphi1; // better calculate this rather than use a getter
00125     const align::GlobalVector resultingXY9( theEndcaps.at( det )->components().at( 8 )->globalPosition().x(),
00126                                             theEndcaps.at( det )->components().at( 8 )->globalPosition().y(),
00127                                             0. );
00128     
00129     
00130     // step 3: twist and shear back
00131     
00132     // the individual rotation/movement of the wheels is a function of their z-position
00133     for( int wheel = 0; wheel < 9; ++wheel ) {
00134       const double reducedZ = fabs( wheelZPositions.at( det ).at( wheel ) - wheelZPositions.at( det ).at( 0 ) ) / theBarrelLength.at( det );
00135       theEndcaps.at( det )->components().at( wheel )->rotateAroundLocalZ( -1. * reducedZ * resultingPhi9 ); // twist
00136       theEndcaps.at( det )->components().at( wheel )->move( -1. * reducedZ * resultingXY9 ); // shear
00137     }
00138 
00139   } 
00140 
00141 
00142 
00143   // this should now give all zero
00144 //   std::cout << theEndcaps.at( 0 )->components().at( 8 )->rotation().xy() << std::endl; /////////////////////////////////
00145 //   std::cout << "000+: " << theEndcaps.at( 0 )->components().at( 8 )->globalPosition().x() << "  "
00146 //          << theEndcaps.at( 0 )->components().at( 8 )->globalPosition().y() << std::endl; /////////////////////////////////
00147     
00148 //   std::cout << "---------------------------------" << std::endl;
00149 
00150 //   std::cout << theEndcaps.at( 1 )->components().at( 8 )->rotation().xy() << std::endl; /////////////////////////////////
00151 //   std::cout << "000-: " << theEndcaps.at( 1 )->components().at( 8 )->globalPosition().x() << "  "
00152 //          << theEndcaps.at( 1 )->components().at( 8 )->globalPosition().y() << std::endl; /////////////////////////////////
00153   
00154 }

Generated on Tue Jun 9 17:24:09 2009 for CMSSW by  doxygen 1.5.4