1#include "CgemGeomSvc/CgemGeoAlign.h"
3#include "GaudiKernel/MsgStream.h"
4#include "GaudiKernel/IMessageSvc.h"
5#include "GaudiKernel/StatusCode.h"
6#include "GaudiKernel/ISvcLocator.h"
7#include "GaudiKernel/Bootstrap.h"
8#include "GaudiKernel/SmartDataPtr.h"
9#include "GaudiKernel/IDataProviderSvc.h"
10#include "GaudiKernel/PropertyMgr.h"
27 ifstream fin(alignFile.c_str());
29 fin.getline(strtmp,1000);
31 for (
int layer=0; layer<3; layer++){
32 fin >> str[layer] >> m_dx[layer] >> m_dy[layer] >> m_dz[layer]
33 >> m_rx[layer] >> m_ry[layer] >> m_rz[layer];
35 m_dxOrig[layer] = m_dx[layer];
36 m_dyOrig[layer] = m_dy[layer];
37 m_dzOrig[layer] = m_dz[layer];
38 m_rxOrig[layer] = m_rx[layer];
39 m_ryOrig[layer] = m_ry[layer];
40 m_rzOrig[layer] = m_rz[layer];
46 for (
int layer=0; layer<3; layer++){
47 m_dx[layer] = m_dxOrig[layer];
48 m_dy[layer] = m_dyOrig[layer];
49 m_dz[layer] = m_dzOrig[layer];
50 m_rx[layer] = m_rxOrig[layer];
51 m_ry[layer] = m_ryOrig[layer];
52 m_rz[layer] = m_rzOrig[layer];
61 double dist = p1.distance2(p2);
62 if(fabs(dist) < 0.001){
63 double s1 = lineOriginal.
sAtR(m_r[layer], -1);
64 double s2 = lineOriginal.
sAtR(m_r[layer], 1);
66 p1 = lineOriginal.
x(s1);
67 p2 = lineOriginal.
x(s2);
106 double drho = lineOriginal[0];
107 double phi0 = lineOriginal[1];
108 double dz = lineOriginal[2];
109 double tgl = lineOriginal[3];
117 int flg_parallel_x = 0;
118 int flg_parallel_y = 0;
120 if(phi0 == TMath::Pi()/2. || phi0 == -1.*TMath::Pi()/2.) flg_parallel_x = 1;
121 if(phi0 == 0 || phi0 == TMath::Pi()) flg_parallel_y = 1;
123 double a, b, x0, x1, x2, y0, y1, y2, s1, s2, z1, z2;
127 if(flg_parallel_x == 0 && flg_parallel_y == 0){
128 a =
tan(TMath::Pi()/2.+phi0);
129 b = drho /
cos(phi0);
132 y1 = drho /
cos(phi0);
133 s1 = sqrt((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0));
134 z1 = -1.*tgl*s1 + dz;
138 s2 = sqrt((x2-x0)*(x2-x0)+(y2-y0)*(y2-y0));
139 z2 = -1.*tgl*s2 + dz;
140 if(x1==x2 || y1==y2 || z1==z2){
143 s2 = sqrt((x2-x0)*(x2-x0)+(y2-y0)*(y2-y0));
144 z2 = -1.*tgl*s2 + dz;
147 else if(flg_parallel_x == 1){
148 x1 = drho; y1 = 0; s1 = sqrt((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0)); z1 = -1.*tgl*s1 + dz;
149 x2 = drho; y2 = 1; s2 = sqrt((x2-x0)*(x2-x0)+(y2-y0)*(y2-y0)); z2 = -1.*tgl*s2 + dz;
151 else if(flg_parallel_y == 1){
152 x1 = 0; y1 = drho; s1 = sqrt((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0)); z1 = -1.*tgl*s1 + dz;
153 x2 = 1; y2 = drho; s2 = sqrt((x2-x0)*(x2-x0)+(y2-y0)*(y2-y0)); z2 = -1.*tgl*s2 + dz;
158 double shift_x = m_dx[layer];
159 double shift_y = m_dy[layer];
160 double shift_z = m_dz[layer];
161 double rotation_z = m_rz[layer];
200 if(x1!=x2 && y1!=y2){
201 new_a = (y1-y2)/(x1-x2);
203 new_phi0 = atan(new_a)+TMath::Pi()/2.;
204 new_drho = new_b*
cos(phi0);
205 new_tgl = (z1-z2)/(-1.*(sqrt((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0))-sqrt((x2-x0)*(x2-x0)+(y2-y0)*(y2-y0))));
206 new_dz = z1 + new_tgl*sqrt((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0));
211 new_tgl = (z1-z2)/(-1.*(sqrt((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0))-sqrt((x2-x0)*(x2-x0)+(y2-y0)*(y2-y0))));
212 new_dz = z1 + new_tgl*sqrt((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0));
215 new_phi0 = TMath::Pi()/2.;
217 new_tgl = (z1-z2)/(-1.*(sqrt((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0))-sqrt((x2-x0)*(x2-x0)+(y2-y0)*(y2-y0))));
218 new_dz = z1 + new_tgl*sqrt((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0));
221 lineConverted[0] = new_drho;
222 lineConverted[1] = new_phi0;
223 lineConverted[2] = new_dz;
224 lineConverted[3] = new_tgl;
237 double x_shift = pos.x() - m_dx[layer];
238 double y_shift = pos.y() - m_dy[layer];
239 double z_shift = pos.z() - m_dz[layer];
241 double x = x_shift*
cos(m_rz[layer]) + y_shift*
sin(m_rz[layer]);
242 double y = -1.*x_shift*
sin(m_rz[layer]) + y_shift*
cos(m_rz[layer]);
249 double shift_y,
double shift_z,
double rotation_z){
266 double x_shift =
x - shift_x;
267 double y_shift = y - shift_y;
268 double z_shift = z - shift_z;
270 x = x_shift*
cos(rotation_z) + y_shift*
sin(rotation_z);
271 y = -1.*x_shift*
sin(rotation_z) + y_shift*
cos(rotation_z);
280 double rz = -1.*m_rz[layer];
281 double xrot = xp*
cos(rz) + yp*
sin(rz);
282 double yrot = -1.*xp*
sin(rz) + yp*
cos(rz);
284 double x = xrot + m_dx[layer];
285 double y = yrot + m_dy[layer];
286 double z = zp + m_dz[layer];
HepGeom::Point3D< double > HepPoint3D
double tan(const BesAngle a)
double sin(const BesAngle a)
double cos(const BesAngle a)
void StraightLineConversion_v1(int layer, double lineOriginal[], double lineConverted[])
StraightLine StraightLineConversion(int layer, StraightLine lineOriginal)
void initAlignPar(std::string alignFile)
HepPoint3D point_transform(int layer, HepPoint3D pos)
HepPoint3D point_invTransform(int layer, HepPoint3D pos)
void HelixConversion(int layer, double helixOriginal[], double helixConverted[])
HepPoint3D x(double s=0.) const
returns position after moving s in downwoards
HepPoint3D xAtR(double R, int direction=1) const
double sAtR(double R, int direction=1) const