ATLAS Offline Software
TRT_DetElementsRoadUtils_xk.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include <cmath>
7 
10 #include "TrkSurfaces/DiscBounds.h"
12 
13 
15 // Output parameters: P[ 0] - radius centre of wafer
16 // P[ 1] - z centre of wafer
17 // P[ 2] - azimuthal angle centra of wifer
18 // P[ 3] - min. distance to surface
19 // P[ 4] - azimythal angle normal to surface
20 // P[ 5] - sin(P[4])
21 // P[ 6] - cos(P[4])
22 // P[ 7] - sin(Polar angle)
23 // P[ 8] - cos(Polar abgle)
24 // P[ 9] - min. radius
25 // P[10] - max. radius
26 // P[11] - min. z
27 // P[12] - max z
28 // P[13] - min. azimythal angle
29 // P[14] - max. azimuthal angle
30 // P[15] - tilt angle
31 // P[16] - min. dist to surface in XY-plane
32 // P[17] - Tilt angle
33 // P[18] - first local coordinate of wafer
34 // P[19] - second local coordinate of wafer
35 // P[20],P[21] - vector to -F boundary
36 // P[22],P[23] - vector to +ZR boundary
37 // P[24],P[25] - vector to +F boundary
38 // P[26],P[27] - vector to -ZR boundary
39 // P[28] - thikness of the detector element
40 // P[29] - Ax of Phi exis
41 // P[30] - Ay of Phi exis
42 // P[31] - Ax of Eta exis
43 // P[32] - Ay of Eta exis
45 
46 namespace InDet {
47  namespace TRT_DetElementsRoadUtils_xk {
49  {
50  const double pi2=2.*M_PI, pi=M_PI;
51 
52  const Trk::RectangleBounds* rb = dynamic_cast<const Trk::RectangleBounds*>(&E.bounds());
53  const Trk::DiscBounds* db = dynamic_cast<const Trk::DiscBounds*> (&E.bounds());
54 
55  Amg::Vector3D C = E.center(); double x0=C.x(), y0=C.y(), z0=C.z();
56  Amg::Vector3D AT = E.normal(); double A[3]={AT.x(),AT.y(),AT.z()};
57  const Amg::Transform3D& T = E.surface().transform();
58  double Ax[3] = {T(0,0),T(1,0),T(2,0)};
59  double Ay[3] = {T(0,1),T(1,1),T(2,1)};
60  double x[4],y[4],z[4];
61 
62  if(rb) {
63 
64  P[ 0] = sqrt(x0*x0+y0*y0);
65  P[ 1] = z0; if(fabs(P[1])<.00004) P[1]=0.;
66  P[ 2] = atan2(y0,x0);
67  P[ 3] = A[0]*x0+A[1]*y0+A[2]*z0;
68  if(P[3]<0.) {P[3]*=-1.; A[0]*=-1.; A[1]*=-1.; A[2]*=-1.;}
69  double B = A[0]*A[0]+A[1]*A[1];
70  if(B>.01) P[4]=atan2(A[1],A[0]); else P[4]=P[2];
71 
72  sincos(P[4],&P[5],&P[6]);
73 
74  if(fabs(P[5])<.00004) P[5]=0.;
75  if(fabs(P[6])<.00004) P[6]=0.;
76  P[ 7] = sqrt(A[0]*A[0]+A[1]*A[1]); if(fabs(P[7])<.00004) P[7]=0.;
77  P[ 8] = A[2]; if(fabs(P[8])<.00004) P[8]=0.;
78 
79  double dx = rb->halflengthX();
80  double dy = rb->halflengthY();
81 
82  x[ 0] = x0+dx*Ax[0]+dy*Ay[0];
83  y[ 0] = y0+dx*Ax[1]+dy*Ay[1];
84  z[ 0] = z0+dx*Ax[2]+dy*Ay[2];
85 
86  x[ 1] = x0+dx*Ax[0]-dy*Ay[0];
87  y[ 1] = y0+dx*Ax[1]-dy*Ay[1];
88  z[ 1] = z0+dx*Ax[2]-dy*Ay[2];
89 
90  x[ 2] = x0-dx*Ax[0]-dy*Ay[0];
91  y[ 2] = y0-dx*Ax[1]-dy*Ay[1];
92  z[ 2] = z0-dx*Ax[2]-dy*Ay[2];
93 
94  x[ 3] = x0-dx*Ax[0]+dy*Ay[0];
95  y[ 3] = y0-dx*Ax[1]+dy*Ay[1];
96  z[ 3] = z0-dx*Ax[2]+dy*Ay[2];
97  }
98  else if (db) {
99 
100  Ax[0]=T(0,1); Ax[1]=T(1,1); Ax[2]=T(2,1);
101  Ay[0]=T(0,0); Ay[1]=T(1,0); Ay[2]=T(2,0);
102 
103  P[ 0] = .5*(db->rMin()+db->rMax());
104  P[ 1] = z0;
105  P[ 2] = atan2(Ay[1],Ay[0]);
106  P[ 3] = A[0]*x0+A[1]*y0+A[2]*z0;
107  if(P[3]<0.) {P[3]*=-1.; A[0]*=-1.; A[1]*=-1.; A[2]*=-1.;}
108  P[ 4] = P[2];
109 
110  sincos(P[4],&P[5],&P[6]);
111  P[ 7] = sqrt(A[0]*A[0]+A[1]*A[1]); if(fabs(P[7])<.00004) P[7]=0.;
112  P[ 8] = A[2]; if(fabs(P[8])<.00004) P[8]=0.;
113  x0 = P[0]*P[6];
114  y0 = P[0]*P[5];
115  double df = db->halfPhiSector();
116  double sn1,sn2,cs1,cs2;
117 
118  sincos(P[2]+df,&sn1,&cs1);
119  sincos(P[2]-df,&sn2,&cs2);
120 
121  x[ 0] = db->rMax()*cs1;
122  y[ 0] = db->rMax()*sn1;
123  z[ 0] = z0;
124 
125  x[ 1] = db->rMin()*cs1;
126  y[ 1] = db->rMin()*sn1;
127  z[ 1] = z0;
128 
129  x[ 2] = db->rMin()*cs2;
130  y[ 2] = db->rMin()*sn2;
131  z[ 2] = z0;
132 
133  x[ 3] = db->rMax()*cs2;
134  y[ 3] = db->rMax()*sn2;
135  z[ 3] = z0;
136  }
137  else return;
138 
139  double rmin= 10000., rmax=-10000.;
140  double zmin= 10000., zmax=-10000.;
141  double fmin= 10000., fmax=-10000.;
142  for(int i=0; i!=4; ++i) {
143  double r = sqrt(x[i]*x[i]+y[i]*y[i]);
144  double f = atan2(y[i],x[i])-P[2]; if(f<-pi) f+=pi2; else if(f>pi) f-=pi2;
145  double zf= z[i];
146  if(r <rmin) rmin= r;
147  if(r >rmax) rmax= r;
148  if(zf<zmin) zmin=zf;
149  if(zf>zmax) zmax=zf;
150  if(f <fmin) fmin= f;
151  if(f >fmax) fmax= f;
152  }
153  P[ 9] = rmin;
154  P[10] = rmax;
155  P[11] = zmin;
156  P[12] = zmax;
157  P[13] = P[2]+fmin;
158  P[14] = P[2]+fmax;
159  P[15] = P[4]-P[2]; if(P[15]<-pi) P[15]+=pi2; else if(P[15]>pi) P[15]-=pi2;
160  P[16] = A[0]*x0+A[1]*y0;
161  P[17] = atan2(Ay[1],Ay[0]);
162  P[17] = P[17]-P[2]; if(P[17]<-pi) P[17]+=pi2; else if(P[17]>pi) P[17]-=pi2;
163 
164  // Calculation shape parameters
165  //
166  P[18] = y0*P[6]-x0*P[5]; // F center
167  P[19] = P[8]*(x0*P[6]+y0*P[5])-P[7]*z0; // ZR center
168  P[20] = +10000.; // -F
169  P[21] = 0. ; //
170  P[22] = 0. ; // +ZR
171  P[23] = -10000.; //
172  P[24] = -10000.; // +F
173  P[25] = 0. ; //
174  P[26] = 0. ; // -ZR
175  P[27] = +10000.; //
176  //
177  for(int i=0; i!=4; ++i) {
178 
179  int k1 = i;
180  int k2 = i+1; if(k2>3) k2=0;
181  double x1 = y[k1]*P[6]-x[k1]*P[5] -P[18];
182  double y1 = P[8]*(x[k1]*P[6]+y[k1]*P[5])-P[7]*z[k1]-P[19];
183  double x2 = y[k2]*P[6]-x[k2]*P[5] -P[18];
184  double y2 = P[8]*(x[k2]*P[6]+y[k2]*P[5])-P[7]*z[k2]-P[19];
185  double d = (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
186  double ax =-(y2-y1)*(y1*x2-x1*y2)/d;
187  double ay = (x2-x1)*(y1*x2-x1*y2)/d;
188  if(ax<P[20]) {P[20]=ax; P[21]=ay;}
189  if(ax>P[24]) {P[24]=ax; P[25]=ay;}
190  if(ay<P[27]) {P[26]=ax; P[27]=ay;}
191  if(ay>P[23]) {P[22]=ax; P[23]=ay;}
192  }
193  for(int i=15; i!=28; ++i) {if(fabs(P[i])<.0004 ) P[i]=0.;}
194 
195  // Directions Phi and Eta in local system coordinates
196  //
197  P[29] = Ax[1]*P[6]-Ax[0]*P[5];
198  P[30] = P[8]*(Ax[0]*P[6]+Ax[1]*P[5])-P[7]*Ax[2];
199  P[31] = Ay[1]*P[6]-Ay[0]*P[5];
200  P[32] = P[8]*(Ay[0]*P[6]+Ay[1]*P[5])-P[7]*Ay[2];
201  }
202  }
203 }
204 
TrapezoidBounds.h
beamspotman.r
def r
Definition: beamspotman.py:676
Trk::RectangleBounds
Definition: RectangleBounds.h:38
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
python.CaloRecoConfig.f
f
Definition: CaloRecoConfig.py:127
DiscBounds.h
fitman.ax
ax
Definition: fitman.py:522
RectangleBounds.h
WriteCellNoiseToCool.rb
rb
Definition: WriteCellNoiseToCool.py:229
PixelAthClusterMonAlgCfg.zmin
zmin
Definition: PixelAthClusterMonAlgCfg.py:176
hist_file_dump.d
d
Definition: hist_file_dump.py:137
InDet
DUMMY Primary Vertex Finder.
Definition: VP1ErrorUtils.h:36
CaloCondBlobAlgs_fillNoiseFromASCII.db
db
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:43
plotBeamSpotCompare.x2
x2
Definition: plotBeamSpotCompare.py:218
python.HLT.MinBias.MinBiasMenuSequences.zf
zf
Definition: MinBiasMenuSequences.py:187
python.PhysicalConstants.pi2
float pi2
Definition: PhysicalConstants.py:52
M_PI
#define M_PI
Definition: ActiveFraction.h:11
x
#define x
makeTRTBarrelCans.y1
tuple y1
Definition: makeTRTBarrelCans.py:15
pi
#define pi
Definition: TileMuonFitter.cxx:65
lumiFormat.i
int i
Definition: lumiFormat.py:92
z
#define z
makeTRTBarrelCans.y2
tuple y2
Definition: makeTRTBarrelCans.py:18
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
PixelAthClusterMonAlgCfg.zmax
zmax
Definition: PixelAthClusterMonAlgCfg.py:176
TRT_DetElementsRoadUtils_xk.h
TRT::Track::z0
@ z0
Definition: InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:63
VP1PartSpect::E
@ E
Definition: VP1PartSpectFlags.h:21
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
makeTRTBarrelCans.dy
tuple dy
Definition: makeTRTBarrelCans.py:21
y
#define y
InDet::TRT_DetElementsRoadUtils_xk::detElementInformation
void detElementInformation(const InDetDD::TRT_BaseElement &E, double *P)
Definition: TRT_DetElementsRoadUtils_xk.cxx:48
PlaneSurface.h
makeTRTBarrelCans.dx
tuple dx
Definition: makeTRTBarrelCans.py:20
python.TriggerAPI.TriggerAPISession.df
df
Definition: TriggerAPISession.py:359
Trk::DiscBounds
Definition: DiscBounds.h:44
InDetDD::TRT_BaseElement
Definition: TRT_BaseElement.h:57
fitman.ay
ay
Definition: fitman.py:525