25 std::cout <<
" [LASEndcapAlgorithm::CalculateParameters] -- Starting." << std::endl;
29 int det,
ring, beam, disk;
33 const double zPositions[9] = { 1322.5, 1462.5, 1602.5, 1742.5, 1882.5, 2057.5, 2247.5, 2452.5, 2667.5 };
34 std::vector<std::vector<double> > diskZPositions( 2, std::vector<double>( 9, 0. ) );
35 for( det = 0; det < 2; ++det ) {
36 for( disk = 0; disk < 9; ++disk ) {
38 diskZPositions.at( det ).at( disk ) = ( det==0 ? zPositions[disk] : -1. * zPositions[disk] );
44 const double phiPositions[8] = { 0.392699, 1.178097, 1.963495, 2.748894, 3.534292, 4.319690, 5.105088, 5.890486 };
45 std::vector<std::vector<double> > beamPhiPositions( 2, std::vector<double>( 8, 0. ) );
46 for( det = 0; det < 2; ++ det ) {
47 for( beam = 0; beam < 8; ++beam ) {
48 beamPhiPositions.at( det ).at( beam ) = phiPositions[beam];
53 std::vector<double>
radius( 2, 0. );
57 const double endcapLength = 1345.;
66 std::vector<std::vector<double> > sumOverY( 2, std::vector<double>( 9, 0. ) );
67 std::vector<std::vector<double> > sumOverPhi( 2, std::vector<double>( 9, 0. ) );
71 std::vector<std::vector<double> > kSumOverPhi( 2, std::vector<double>( 8, 0. ) );
75 std::vector<double> doubleSumOverY( 2, 0. );
76 std::vector<double> doubleSumOverPhi( 2, 0. );
80 std::vector<std::vector<double> > kSumOverPhiZ( 2, std::vector<double>( 8, 0. ) );
84 std::vector<double> doubleSumOverYZ( 2, 0. );
85 std::vector<double> doubleSumOverPhiZ( 2, 0. );
88 std::vector<std::vector<double> > sumOverSinThetaY( 2, std::vector<double>( 9, 0. ) );
91 std::vector<std::vector<double> > sumOverCosThetaY( 2, std::vector<double>( 9, 0. ) );
94 std::vector<double> doubleSumOverSinThetaY( 2, 0. );
95 std::vector<double> doubleSumOverCosThetaY( 2, 0. );
98 std::vector<double> doubleSumOverSinThetaYZ( 2, 0. );
99 std::vector<double> doubleSumOverCosThetaYZ( 2, 0. );
102 std::vector<double> sumOverZ( 2, 0. );
103 std::vector<double> sumOverZSquared( 2, 0. );
107 det = 0; ring = 0; beam = 0; disk = 0;
109 if( ring == 1 )
continue;
114 const double residual = ( measuredCoordinates.
GetTECEntry( det, ring, beam, disk ).
GetPhi() - nominalCoordinates.
GetTECEntry( det, ring, beam, disk ).
GetPhi() ) * radius;
116 sumOverY.at( det ).at( disk ) += residual;
117 sumOverPhi.at( det ).at( disk ) += residual /
radius;
118 kSumOverPhi.at( det ).at( beam ) += residual /
radius;
120 doubleSumOverY.at( det ) += residual;
121 doubleSumOverPhi.at( det ) += residual /
radius;
123 kSumOverPhiZ.at( det ).at( beam ) += diskZPositions.at( det ).at( disk ) * residual /
radius;
125 doubleSumOverYZ.at( det ) += diskZPositions.at( det ).at( disk ) * residual;
126 doubleSumOverPhiZ.at( det ) += diskZPositions.at( det ).at( disk ) * residual /
radius;
128 sumOverSinThetaY.at( det ).at( disk ) +=
sin( nominalCoordinates.
GetTECEntry( det, ring, beam, disk ).
GetPhi() ) * residual;
129 sumOverCosThetaY.at( det ).at( disk ) +=
cos( nominalCoordinates.
GetTECEntry( det, ring, beam, disk ).
GetPhi() ) * residual;
131 doubleSumOverSinThetaY.at( det ) +=
sin( nominalCoordinates.
GetTECEntry( det, ring, beam, disk ).
GetPhi() ) * residual;
132 doubleSumOverCosThetaY.at( det ) +=
cos( nominalCoordinates.
GetTECEntry( det, ring, beam, disk ).
GetPhi() ) * residual;
134 doubleSumOverSinThetaYZ.at( det ) +=
sin( nominalCoordinates.
GetTECEntry( det, ring, beam, disk ).
GetPhi() ) * diskZPositions.at( det ).at( disk ) * residual;
135 doubleSumOverCosThetaYZ.at( det ) +=
cos( nominalCoordinates.
GetTECEntry( det, ring, beam, disk ).
GetPhi() ) * diskZPositions.at( det ).at( disk ) * residual;
137 }
while( globalLoop.
TECLoop( det, ring, beam, disk ) );
141 for( disk = 0; disk < 9; ++disk ) {
142 sumOverZ.at( 0 ) += diskZPositions.at( 0 ).at( disk ); sumOverZ.at( 1 ) += diskZPositions.at( 1 ).at( disk );
143 sumOverZSquared.at( 0 ) +=
pow( diskZPositions.at( 0 ).at( disk ), 2 ); sumOverZSquared.at( 1 ) +=
pow( diskZPositions.at( 1 ).at( disk ), 2 );
154 std::vector<double> deltaPhi0( 2, 0. );
157 std::vector<double> deltaPhiT( 2, 0. );
160 std::vector<std::vector<double> > deltaPhiK( 2, std::vector<double>( 9, 0. ) );
163 std::vector<double> deltaX0( 2, 0. );
166 std::vector<double> deltaXT( 2, 0. );
169 std::vector<std::vector<double> > deltaXK( 2, std::vector<double>( 9, 0. ) );
172 std::vector<double> deltaY0( 2, 0. );
175 std::vector<double> deltaYT( 2, 0. );
178 std::vector<std::vector<double> > deltaYK( 2, std::vector<double>( 9, 0. ) );
181 std::vector<std::vector<double> > deltaTA( 2, std::vector<double>( 8, 0. ) );
182 std::vector<std::vector<double> > deltaTB( 2, std::vector<double>( 8, 0. ) );
188 for( det = 0; det < 2; ++det ) {
192 deltaPhi0.at( det ) = ( sumOverZSquared.at( det ) * doubleSumOverPhi.at( det ) - sumOverZ.at( det ) * doubleSumOverPhiZ.at( det ) )
193 / ( 8. * (
pow( sumOverZ.at( det ), 2 ) - 9. * sumOverZSquared.at( det ) ) );
197 deltaPhiT.at( det ) = endcapLength * ( 9. * doubleSumOverPhiZ.at( det ) - sumOverZ.at( det ) * doubleSumOverPhi.at( det ) )
198 / ( 8. * (
pow( sumOverZ.at( det ), 2 ) - 9. * sumOverZSquared.at( det ) ) );
202 for( disk = 0; disk < 9; ++disk ) {
203 deltaPhiK.at( det ).at( disk ) = ( -1. * diskZPositions.at( det ).at( disk ) * deltaPhiT.at( det ) / endcapLength )
204 - ( deltaPhi0.at( det ) ) - sumOverPhi.at( det ).at( disk ) / 8.;
208 deltaX0.at( det ) = 2. * ( sumOverZ.at( det ) * doubleSumOverSinThetaYZ.at( det ) - sumOverZSquared.at( det ) * doubleSumOverSinThetaY.at( det ) )
209 / ( 8. * (
pow( sumOverZ.at( det ), 2 ) - 9. * sumOverZSquared.at( det ) ) );
212 deltaXT.at( det ) = 2. * endcapLength * ( sumOverZ.at( det ) * doubleSumOverSinThetaY.at( det ) - 9. * doubleSumOverSinThetaYZ.at( det ) )
213 / ( 8. * (
pow( sumOverZ.at( det ), 2 ) - 9. * sumOverZSquared.at( det ) ) );
216 for( disk = 0; disk < 9; ++disk ) {
217 deltaXK.at( det ).at( disk ) = ( -1. * diskZPositions.at( det ).at( disk ) * deltaXT.at( det ) / endcapLength )
218 - ( deltaX0.at( det ) ) + 2. * sumOverSinThetaY.at( det ).at( disk ) / 8.;
222 deltaY0.at( det ) = 2. * ( sumOverZSquared.at( det ) * doubleSumOverCosThetaY.at( det ) - sumOverZ.at( det ) * doubleSumOverCosThetaYZ.at( det ) )
223 / ( 8. * (
pow( sumOverZ.at( det ), 2 ) - 9. * sumOverZSquared.at( det ) ) );
226 deltaYT.at( det ) = 2. * endcapLength * ( 9. * doubleSumOverCosThetaYZ.at( det ) - sumOverZ.at( det ) * doubleSumOverCosThetaY.at( det ) )
227 / ( 8. * (
pow( sumOverZ.at( det ), 2 ) - 9. * sumOverZSquared.at( det ) ) );
230 for( disk = 0; disk < 9; ++disk ) {
231 deltaYK.at( det ).at( disk ) = ( -1. * diskZPositions.at( det ).at( disk ) * deltaYT.at( det ) / endcapLength )
232 - ( deltaY0.at( det ) ) - 2. * sumOverCosThetaY.at( det ).at( disk ) / 8.;
237 for( beam = 0; beam < 8; ++beam ) {
239 deltaTA.at( det ).at( beam ) = deltaPhi0.at( det )
240 - ( kSumOverPhi.at( det ).at( beam ) * sumOverZSquared.at( det ) - kSumOverPhiZ.at( det ).at( beam ) * sumOverZ.at( det ) )
241 / (
pow( sumOverZ.at( det ), 2 ) - 9. * sumOverZSquared.at( det ) )
242 + (
cos( beamPhiPositions.at( det ).at( beam ) ) * deltaY0.at( det ) -
sin( beamPhiPositions.at( det ).at( beam ) ) * deltaX0.at( det ) ) / radius.at( 0 );
246 deltaTB.at( det ).at( beam ) = -1. * deltaPhiT.at( det ) - deltaPhi0.at( det )
247 - ( kSumOverPhi.at( det ).at( beam ) * sumOverZ.at( det ) - 9. * kSumOverPhiZ.at( det ).at( beam ) )
248 * endcapLength / (
pow( sumOverZ.at( det ), 2 ) - 9. * sumOverZSquared.at( det ) )
249 - ( kSumOverPhiZ.at( det ).at( beam ) * sumOverZ.at( det ) - kSumOverPhi.at( det ).at( beam ) * sumOverZSquared.at( det ) )
250 / (
pow( sumOverZ.at( det ), 2 ) - 9. * sumOverZSquared.at( det ) )
251 + ( ( deltaXT.at( det ) + deltaX0.at( det ) ) *
sin( beamPhiPositions.at( det ).at( beam ) ) - ( deltaYT.at( det ) + deltaY0.at( det ) ) *
cos( beamPhiPositions.at( det ).at( beam ) ) )
268 for( det = 0; det < 2; ++det ) {
269 for( disk = 0; disk < 9; ++disk ) {
271 theResult.
GetDiskParameter( det, disk, 0 ).first = deltaPhiK.at( det ).at( disk );
273 theResult.
GetDiskParameter( det, disk, 1 ).first = deltaXK.at( det ).at( disk );
275 theResult.
GetDiskParameter( det, disk, 2 ).first = deltaYK.at( det ).at( disk );
280 for(
int det = 0; det < 2; ++det ) {
290 for(
int det = 0; det < 2; ++det ) {
291 for(
int beam = 0; beam < 8; ++beam ) {
292 theResult.
GetBeamParameter( det, 1 , beam, 0 ).first = deltaTA.at( det ).at( beam );
293 theResult.
GetBeamParameter( det, 1 , beam, 1 ).first = deltaTB.at( det ).at( beam );
297 std::cout <<
" [LASEndcapAlgorithm::CalculateParameters] -- Done." << std::endl;
Sin< T >::type sin(const T &t)
std::pair< double, double > & GetGlobalParameter(int aSubdetector, int aParameter)
double GetPhi(void) const
Cos< T >::type cos(const T &t)
std::pair< double, double > & GetDiskParameter(int aSubdetector, int aDisk, int aParameter)
std::pair< double, double > & GetBeamParameter(int aSubdetector, int aRing, int aBeam, int aParameter)
T & GetTECEntry(int subdetector, int tecRing, int beam, int tecDisk)
bool TECLoop(int &, int &, int &, int &) const
Power< A, B >::type pow(const A &a, const B &b)