#include <Alignment/LaserAlignment/interface/AlignmentAlgorithmBW.h>
Public Types | |
typedef LASvector< double > | LASvec |
define vector and matrix formats for easier calculation of the alignment corrections | |
typedef LASvector2D< double > | LASvec2D |
Public Member Functions | |
AlignmentAlgorithmBW () | |
constructor | |
std::vector < LASAlignmentParameter > | run (const std::string theName, LASvec2D &data, LASvec2D &errors, bool useBSframe, int theRing) |
the actual algorithm | |
virtual | ~AlignmentAlgorithmBW () |
destructor | |
Private Member Functions | |
LASvec | makeZPositions (bool useBSframe) |
create the z positions of the discs |
The details of this algorithm are given in his PhD Thesis
Definition at line 19 of file AlignmentAlgorithmBW.h.
typedef LASvector<double> AlignmentAlgorithmBW::LASvec |
define vector and matrix formats for easier calculation of the alignment corrections
Definition at line 23 of file AlignmentAlgorithmBW.h.
typedef LASvector2D<double> AlignmentAlgorithmBW::LASvec2D |
Definition at line 24 of file AlignmentAlgorithmBW.h.
AlignmentAlgorithmBW::AlignmentAlgorithmBW | ( | ) |
AlignmentAlgorithmBW::~AlignmentAlgorithmBW | ( | ) | [virtual] |
AlignmentAlgorithmBW::LASvec AlignmentAlgorithmBW::makeZPositions | ( | bool | useBSframe | ) | [private] |
create the z positions of the discs
Definition at line 272 of file AlignmentAlgorithmBW.cc.
Referenced by run().
00272 { 00273 00274 // if the BS frame is used, the BS is positioned at 0.0, disc 1 to 5: z < 0, disc 6 to 9: z > 0. 00275 LASvec zPos(9); 00276 zPos[0] = 0.0; 00277 zPos[1] = 14.0; 00278 zPos[2] = 28.0; 00279 zPos[3] = 42.0; 00280 zPos[4] = 56.0; 00281 zPos[5] = 73.5; 00282 zPos[6] = 92.5; 00283 zPos[7] = 113.0; 00284 zPos[8] = 134.5; 00285 00286 if(useBSframe) zPos -= 70.5; // Beamsplitter at z = 0 00287 00288 return zPos; 00289 }
std::vector< LASAlignmentParameter > AlignmentAlgorithmBW::run | ( | const std::string | theName, | |
LASvec2D & | data, | |||
LASvec2D & | errors, | |||
bool | useBSframe, | |||
int | theRing | |||
) |
the actual algorithm
sZ =
sZq =
nenn1 =
sT =
sTq =
nenn2 =
nenn3 =
A = sum of all beam positions
B = sum of data[i][j]*zPositions[i]
Ai = vector containing sum of the columns in dataTrans (i.e. beam positions on disc i in all sectors)
Ak = vector containing sum of the rows in dataTrans (i.e. beam position in sector j on all discs)
C = sum of dataTrans[i][j] * sin(phiPositions[i])
Ci = vector containing sum of the columns in dataTrans*sin(phiPositions) (i.e. position of disc i in all sectors * sin(phiPositions))
D = sum of trans(dataTrans * sin(phiPositions)) * zPositions
E = sum of dataTrans[i][j] * cos(phiPositions[i])
Ei = vector containing sum of the columns in dataTrans*cos(phiPositions) (i.e. position of disc i in all sectors * cos(phiPositions))
F = sum of trans(dataTrans * cos(phiPositions)) * zPositions
dphi0 = (sZq * A - sZ * B)/nenn1/r0
dphit = theTECLength * (nDiscs * B - sZ * A)/nenn1/r0
dphik = -(zPositions * dphit/theTECLength + dphi0 + Ai/nSectors/r0)
dx0 = 2*(sZ * D - sZq * C)/nenn1
dxt = 2*theTECLength*(sZ*C - nDiscs * D)/nenn1
dxk = -zPositions * dxt/theTECLength - dx0 + Ci * 2/nSectors
dy0 = 2*(sZq * E - sZ * F)/nenn1
dyt = 2*theTECLength*(nDiscs*F-sZ*E)/nenn1
dyk = -zPositions * dyt/theTECLength - dy0 - Ei * 2/nSectors
Definition at line 37 of file AlignmentAlgorithmBW.cc.
References funct::A, funct::C, LASvector< Element >::cosine(), funct::D, lat::endl(), Exception, i, LogDebug, makeZPositions(), funct::pow(), LASvector< Element >::sine(), size, sum(), LASvector2D< Element >::sum(), and LASvector2D< Element >::transpose().
Referenced by LaserAlignment::endJob().
00037 { 00038 00039 // run the actual algorithm to calculate the alignment parameters 00040 edm::LogInfo("AlignmentAlgorithmBW") << " running the alignment algorithm for " << theName; 00041 00042 // create vector to store the alignment parameters 00043 std::vector<LASAlignmentParameter> theResult; 00044 00045 // transpose the data 00046 LASvec2D dataTrans(data[0].size(),data.size()); 00047 dataTrans.transpose(data); 00048 00049 // create vector with the z positions of the discs 00050 LASvec zPositions = makeZPositions( useBSframe ); 00051 00052 // set the radius and the phi positions of the beams 00053 double r0; 00054 LASvec phiPositions(8); 00055 00056 switch( theRing ) { 00057 case 4: 00058 r0 = 56.4; // radius of Ring 4 00059 for( unsigned int i = 0; i < 8; ++i ) { 00060 // calculate the right phi for the current beam 00061 phiPositions[i] = 0.3927 + double(i * double(double(2 * M_PI) / 8)); 00062 } 00063 break; 00064 case 6: 00065 r0 = 84.0; // radius of Ring 6 00066 for( unsigned int i = 0; i < 8; ++i ) { 00067 // calculate the right phi for the current beam 00068 phiPositions[i] = 0.3927 + double(i * double(double(2 * M_PI) / 8)); 00069 } 00070 break; 00071 default: 00072 throw cms::Exception("WrongRingNumber","Not a valid ring number") << theRing << " is not a valid ring number for this alignment algorithm!!!\n"; 00073 } 00074 00075 // lenght of an endcap 00076 double theTECLength = zPositions[8] - zPositions[0]; 00077 // number of sectors and discs 00078 int nSectors = data.size(); 00079 int nDiscs = data[0].size(); 00080 // calculate first some constant parameters 00084 double sZ=zPositions.sum(); 00088 double sZq=(zPositions*zPositions).sum(); 00092 double nenn1 = nSectors * (pow(sZ,2)-nDiscs*sZq); 00096 // double sT = phiPositions.sum(); 00100 // double sTq = (phiPositions*phiPositions).sum(); 00104 // double nenn2 = nSectors * sTq - pow(sT,2); 00108 // double nenn3 = nDiscs * sZq - pow(sZ,2); 00112 double A = dataTrans.sum(); 00116 double B = (data * zPositions).sum(); 00120 LASvec Ai = dataTrans.sumC(); 00124 LASvec Ak = dataTrans.sumR(); 00128 LASvec sinPhiPositions(8); 00129 sinPhiPositions.sine(phiPositions); 00130 double C = (dataTrans * sinPhiPositions).sum(); 00134 LASvec Ci = (dataTrans * sinPhiPositions).sumC(); 00138 LASvec2D dataTransSin(8,9); 00139 dataTransSin.transpose(dataTrans * sinPhiPositions); 00140 double D = (dataTransSin * zPositions).sum(); 00144 LASvec cosPhiPositions(8); 00145 cosPhiPositions.cosine(phiPositions); 00146 double E = (dataTrans * cosPhiPositions).sum(); 00150 LASvec Ei = (dataTrans * cosPhiPositions).sumC(); 00154 LASvec2D dataTransCos(8,9); 00155 dataTransCos.transpose(dataTrans * cosPhiPositions); 00156 double F = (dataTransCos * zPositions).sum(); 00157 // ********************************************************************** // 00158 // ** Calculate the alignment parameters ** // 00159 // ********************************************************************** // 00160 00164 double dphi0 = (sZq * A - sZ * B)/nenn1/r0; 00168 double dphit = theTECLength * (nDiscs * B - sZ * A)/nenn1/r0; 00172 LASvec dphik = (zPositions * dphit/theTECLength + dphi0 + Ai *1.0/nSectors/r0) * -1.0; 00176 double dx0 = 2.0 * (sZ * D - sZq * C)/nenn1; 00180 double dxt = 2.0 * theTECLength * (sZ * C - nDiscs * D)/nenn1; 00184 LASvec dxk = zPositions * (-1.0) * dxt/theTECLength - dx0 + Ci * 2.0/nSectors; 00188 double dy0 = 2.0 * (sZq * E - sZ * F)/nenn1; 00192 double dyt = 2.0 * theTECLength * (nDiscs * F - sZ * E)/nenn1; 00196 LASvec dyk = zPositions *(-1.0)* dyt/theTECLength - dy0 - Ei * 2.0/nSectors; 00197 00198 // print the parameters 00199 LogDebug("AlignmentAlgorithmBW") << " here are the calculated alignment parameters:" << std::endl 00200 << " Dphi0 = " << dphi0 << " Dx0 = " << dx0 << " Dy0 = " << dy0 << std::endl 00201 << " Dphit = " << dphit << " Dxt = " << dxt << " Dyt = " << dyt << std::endl << std::endl 00202 << " Dphi[1] = " << dphik[0] << " Dx[1] = " << dxk[0] << " Dy[1] = " << dyk[0] << std::endl 00203 << " Dphi[2] = " << dphik[1] << " Dx[2] = " << dxk[1] << " Dy[2] = " << dyk[1] << std::endl 00204 << " Dphi[3] = " << dphik[2] << " Dx[3] = " << dxk[2] << " Dy[3] = " << dyk[2] << std::endl 00205 << " Dphi[4] = " << dphik[3] << " Dx[4] = " << dxk[3] << " Dy[4] = " << dyk[3] << std::endl 00206 << " Dphi[5] = " << dphik[4] << " Dx[5] = " << dxk[4] << " Dy[5] = " << dyk[4] << std::endl 00207 << " Dphi[6] = " << dphik[5] << " Dx[6] = " << dxk[5] << " Dy[6] = " << dyk[5] << std::endl 00208 << " Dphi[7] = " << dphik[6] << " Dx[7] = " << dxk[6] << " Dy[7] = " << dyk[6] << std::endl 00209 << " Dphi[8] = " << dphik[7] << " Dx[8] = " << dxk[7] << " Dy[8] = " << dyk[7] << std::endl 00210 << " Dphi[9] = " << dphik[8] << " Dx[9] = " << dxk[8] << " Dy[9] = " << dyk[8] << std::endl; 00211 00212 // std::cout << " here are the calculated alignment parameters:" << std::endl 00213 // << " Dphi0 = " << dphi0 << " Dx0 = " << dx0 << " Dy0 = " << dy0 << std::endl 00214 // << " Dphit = " << dphit << " Dxt = " << dxt << " Dyt = " << dyt << std::endl << std::endl 00215 // << " Dphi[1] = " << dphik[0] << " Dx[1] = " << dxk[0] << " Dy[1] = " << dyk[0] << std::endl 00216 // << " Dphi[2] = " << dphik[1] << " Dx[2] = " << dxk[1] << " Dy[2] = " << dyk[1] << std::endl 00217 // << " Dphi[3] = " << dphik[2] << " Dx[3] = " << dxk[2] << " Dy[3] = " << dyk[2] << std::endl 00218 // << " Dphi[4] = " << dphik[3] << " Dx[4] = " << dxk[3] << " Dy[4] = " << dyk[3] << std::endl 00219 // << " Dphi[5] = " << dphik[4] << " Dx[5] = " << dxk[4] << " Dy[5] = " << dyk[4] << std::endl 00220 // << " Dphi[6] = " << dphik[5] << " Dx[6] = " << dxk[5] << " Dy[6] = " << dyk[5] << std::endl 00221 // << " Dphi[7] = " << dphik[6] << " Dx[7] = " << dxk[6] << " Dy[7] = " << dyk[6] << std::endl 00222 // << " Dphi[8] = " << dphik[7] << " Dx[8] = " << dxk[7] << " Dy[8] = " << dyk[7] << std::endl 00223 // << " Dphi[9] = " << dphik[8] << " Dx[9] = " << dxk[8] << " Dy[9] = " << dyk[8] << std::endl; 00224 // 00225 // //____________________________________________________________________________________________________ 00226 // // ONLY FOR DEBUGGING 00227 // for (int j = 0; j < 8; ++j) 00228 // { 00229 // // calculate the corrections and the errors 00230 // double thePhiCorrected = dphik[0] 00231 // - (sin(phiPositions[0])/r0) * dxk[0] 00232 // + (cos(phiPositions[0])/r0) * dyk[0] 00233 // - ( dphik[j+1] 00234 // - (sin(phiPositions[0])/r0) * dxk[j+1] 00235 // + (cos(phiPositions[0])/r0) * dyk[j+1] ); 00236 // 00237 // // for debugging 00238 // std::cout << " Fitted relative Correction for " << theName << " in Phi[" << j << "] = " << thePhiCorrected << std::endl; 00239 // } 00240 // 00241 // for (int j = 0; j < 9; ++j) 00242 // { 00243 // // calculate the correction for each disk (not relative to disk one) 00244 // double theAbsPhiCorrected = dphik[j] 00245 // - (sin(phiPositions[0])/r0) * dxk[j] 00246 // + (cos(phiPositions[0])/r0) * dyk[j]; 00247 // 00248 // // for debugging 00249 // std::cout << " Fitted Correction for " << theName << " in Phi[" << j << "] = " << theAbsPhiCorrected << std::endl; 00250 // } 00251 // // ONLY FOR DEBUGGING 00252 // //____________________________________________________________________________________________________ 00253 00254 // we want to store this parameters in a separate DataFormat to study them later in more detail 00255 // unfortunately storing a std::valarray is not working due to reflex dictionary troubles. Therefore 00256 // store the calculated corrections into a std::vector<double> 00257 std::vector<double> dphik_, dxk_, dyk_; 00258 for( unsigned int i = 0; i < 9; ++i ) { 00259 dphik_.push_back(dphik[i]); 00260 dxk_.push_back(dxk[i]); 00261 dyk_.push_back(dyk[i]); 00262 } 00263 00264 theResult.push_back(LASAlignmentParameter(theName,dphi0,dphit,dphik_,dx0,dxt,dxk_,dy0,dyt,dyk_)); 00265 return theResult; 00266 }