92 for(G4int i=0;i<30;i++)
94 for (G4int j=0;j<8;j++)
97 G4ThreeVector* pPnt =
new G4ThreeVector(param[i][j],param[i][j+8],param[i][j+16]-WorldZPosition);
101 if(i==5||i==6||i==14||i==15||i==16)
103 for(G4int j=0;j<8;j++)
104 fPnt[30+pentaNb][j] = fPnt[i][j];
107 G4double y0,y1,y4,y5;
108 G4ThreeVector v0,v1,v4,v5;
109 y0 = penta[pentaNb][0];
110 y1 = penta[pentaNb][1];
111 y4 = penta[pentaNb][2];
112 y5 = penta[pentaNb][3];
113 v0 = (y0-fPnt[i][3].getY())*(fPnt[i][0]-fPnt[i][3])/(fPnt[i][0].getY()-fPnt[i][3].getY())
115 v1 = (y1-fPnt[i][2].getY())*(fPnt[i][1]-fPnt[i][2])/(fPnt[i][1].getY()-fPnt[i][2].getY())
117 v4 = (y4-fPnt[i][7].getY())*(fPnt[i][4]-fPnt[i][7])/(fPnt[i][4].getY()-fPnt[i][7].getY())
119 v5 = (y5-fPnt[i][6].getY())*(fPnt[i][5]-fPnt[i][6])/(fPnt[i][5].getY()-fPnt[i][6].getY())
123 x1 = penta[pentaNb][4];
124 x5 = penta[pentaNb][5];
125 v1 = (x1-v0.getX())*(v1-v0)/(v1.getX()-v0.getX())+v0;
126 v5 = (x5-v4.getX())*(v5-v4)/(v5.getX()-v4.getX())+v4;
133 fPnt[30+pentaNb][2] = v1;
134 fPnt[30+pentaNb][3] = v0;
135 fPnt[30+pentaNb][6] = v5;
136 fPnt[30+pentaNb][7] = v4;
143 G4ThreeVector temp[35][8];
144 for(G4int i=0;i<35;i++)
146 for (G4int j=0;j<8;j++)
148 temp[i][j]=fPnt[i][j];
149 fPnt[i][j].rotateZ(157.5*deg);
150 fPnt[i][j].setX(-fPnt[i][j].getX());
154 for (G4int j=0;j<8;j++)
158 G4ThreeVector
v=fPnt[i][j];
159 fPnt[i][j]=fPnt[i][3-j];
164 G4ThreeVector
v=fPnt[i][j];
165 fPnt[i][j]=fPnt[i][11-j];
185 for(G4int i=0;i<35;i++)
187 for (G4int j=0;j<8;j++)
189 G4ThreeVector pPnt1 = temp[i][j];
190 fPnt1[i][j] = pPnt1.rotateZ(67.5*deg);
192 if((i==3)||(i==7)||(i==12)||(i==17)||(i==23)||(i==29))
194 fPnt1[i][0].setX(10);
195 fPnt1[i][1].setX(10);
196 fPnt1[i][4].setX(10);
197 fPnt1[i][5].setX(10);
199 G4double y0 = fPnt1[i][0].getY()+10*(fPnt1[i][3].getY()-fPnt1[i][0].getY())/fPnt1[i][3].getX();
200 G4double y1 = fPnt1[i][1].getY()+10*(fPnt1[i][2].getY()-fPnt1[i][1].getY())/fPnt1[i][2].getX();
201 G4double y4 = fPnt1[i][4].getY()+10*(fPnt1[i][7].getY()-fPnt1[i][4].getY())/fPnt1[i][7].getX();
202 G4double y5 = fPnt1[i][5].getY()+10*(fPnt1[i][6].getY()-fPnt1[i][5].getY())/fPnt1[i][6].getX();
204 G4double z0 = fPnt1[i][0].getZ()+10*(fPnt1[i][3].getZ()-fPnt1[i][0].getZ())/fPnt1[i][3].getX();
205 G4double z1 = fPnt1[i][1].getZ()+10*(fPnt1[i][2].getZ()-fPnt1[i][1].getZ())/fPnt1[i][2].getX();
206 G4double z4 = fPnt1[i][4].getZ()+10*(fPnt1[i][7].getZ()-fPnt1[i][4].getZ())/fPnt1[i][7].getX();
207 G4double z5 = fPnt1[i][5].getZ()+10*(fPnt1[i][6].getZ()-fPnt1[i][5].getZ())/fPnt1[i][6].getX();
209 fPnt1[i][0].setY(y0);
210 fPnt1[i][1].setY(y1);
211 fPnt1[i][4].setY(y4);
212 fPnt1[i][5].setY(y5);
214 fPnt1[i][0].setZ(z0);
215 fPnt1[i][1].setZ(z1);
216 fPnt1[i][4].setZ(z4);
217 fPnt1[i][5].setZ(z5);
261 G4ThreeVector center1(0,0,0);
262 G4ThreeVector center2(0,0,0);
264 if(CryNb==5||CryNb==6||CryNb==14||CryNb==15||CryNb==16)
266 center1 = (pos[0]+pos[1])/2;
267 center2 = (pos[4]+pos[5])/2;
269 else if(CryNb>=30&&CryNb<35)
271 center1 = (pos[2]+pos[3])/2;
272 center2 = (pos[6]+pos[7])/2;
276 center1 = (pos[0]+pos[1]+pos[2]+pos[3])/4;
277 center2 = (pos[4]+pos[5]+pos[6]+pos[7])/4;
280 G4double r1=(pos[1]-center1).r();
281 G4double r2=(pos[2]-center1).r();
282 G4double r12=(pos[1]-pos[2]).r();
283 G4double theta=acos((r2*r2+r12*r12-r1*r1)/(2*r2*r12));
284 G4double h=r2*
sin(theta);
285 G4double t1=totalThickness/h;
287 r1=(pos[5]-center2).r();
288 r2=(pos[6]-center2).r();
289 r12=(pos[5]-pos[6]).r();
290 theta=acos((r2*r2+r12*r12-r1*r1)/(2*r2*r12));
292 G4double t2=totalThickness/h;
294 for(G4int i=0;i<8;i++)
298 cryPoint[i] = (1-t1)*pos[i]+t1*center1;
302 G4ThreeVector temp = (1-t2)*pos[i]+t2*center2;
303 cryPoint[i] = (1-totalThickness/CrystalLength)*temp+(totalThickness/CrystalLength)*pos[i-4];
310(
const G4int partId,
const G4int numTheta,
const G4int numPhi)
313 G4int sector=-1, cryNb=-1;
318 G4double A1=0,a1=0,B1=0,b1=0,C1=0,c1=0,D1=0,d1=0,E1=0,
e1=0;
320 G4ThreeVector position(0,0,0);
321 G4int cryInOneSector = cryNumInOneLayer[numTheta]/16;
322 G4ThreeVector pos[8];
326 if(numPhi>=0&&numPhi<8*cryInOneSector)
327 m_numPhi=8*cryInOneSector-1-numPhi;
328 else if(numPhi>=8*cryInOneSector&&numPhi<16*cryInOneSector)
329 m_numPhi=16*cryInOneSector-1-numPhi;
334 if(numPhi>=4*cryInOneSector&&numPhi<5*cryInOneSector)
337 m_numPhi=8*cryInOneSector-1-numPhi;
339 else if(numPhi>=11*cryInOneSector&&numPhi<12*cryInOneSector)
343 m_numPhi=numPhi-8*cryInOneSector;
345 if(numPhi>=12*cryInOneSector&&numPhi<13*cryInOneSector)
348 m_numPhi=16*cryInOneSector-1-numPhi;
352 G4int cryNbOffset = 0;
353 for(G4int i=0;i<numTheta;i++)
354 cryNbOffset += cryNumInOneLayer[i]/16;
356 sector = m_numPhi/cryInOneSector;
357 cryNb = m_numPhi-cryInOneSector*sector+cryNbOffset;
359 if(sector>15&§or<=18)
364 for(G4int i=0;i<8;i++)
365 pos[i]=fPnt1[cryNb][i];
367 for(G4int i=0;i<8;i++)
369 pos[i]=fPnt[cryNb][i];
370 pos[i].rotateZ(-67.5*deg+sector*22.5*deg);
375 G4double A = (cryPoint[0]-cryPoint[3]).r();
376 G4double a = (cryPoint[4]-cryPoint[7]).r();
377 G4double B = (cryPoint[1]-cryPoint[2]).r();
378 G4double
b = (cryPoint[5]-cryPoint[6]).r();
379 G4double
C = (cryPoint[0]-cryPoint[1]).r();
380 G4double c = (cryPoint[4]-cryPoint[5]).r();
381 G4double D = (cryPoint[2]-cryPoint[3]).r();
382 G4double d = (cryPoint[6]-cryPoint[7]).r();
385 for(G4int i=0;i<8;i++)
387 pos[i].setZ(pos[i].getZ()+WorldZPosition);
389 pos[i].setX(-pos[i].getX());
391 pos[i].setY(-pos[i].getY());
394 pos[i].setX(-pos[i].getX());
395 pos[i].setZ(-pos[i].getZ());
400 for(G4int j=4;j<8;j++)
405 for(G4int i=0;i<5;i++)
407 if(cryNb==pentaInOneSector[i])
410 G4ThreeVector penta[8];
414 for(G4int j=0;j<8;j++)
415 penta[j]=fPnt1[30+i][j];
417 for(G4int j=0;j<8;j++)
419 penta[j]=fPnt[30+i][j];
420 penta[j].rotateZ(-67.5*deg+sector*22.5*deg);
425 A1 = (cryPoint[1]-cryPoint[2]).r();
426 a1 = (cryPoint[5]-cryPoint[6]).r();
427 B1 = (cryPoint[1]-cryPoint[0]).r();
428 b1 = (cryPoint[5]-cryPoint[4]).r();
429 C1 = (cryPoint[0]-cryPoint[3]).r()+A;
430 c1 = (cryPoint[4]-cryPoint[7]).r()+a;
437 for(G4int j=0;j<8;j++)
439 penta[j].setZ(penta[j].getZ()+WorldZPosition);
441 penta[j].setX(-penta[j].getX());
443 penta[j].setY(-penta[j].getY());
446 penta[j].setX(-penta[j].getX());
447 penta[j].setZ(-penta[j].getZ());
452 for(G4int j=4;j<8;j++)
456 if(j==0||j==1||j==4||j==5)
457 position += penta[j];
461 flag = leftFlag+downFlag;
464 G4double temp1 = B1; B1 = D1; D1 = temp1;
465 temp1 = A1; A1 = E1; E1 = temp1;
466 temp1 = b1; b1 = d1; d1 = temp1;
467 temp1 = a1; a1 =
e1;
e1 = temp1;
474 flag = leftFlag+downFlag+partId/2;
477 G4double temp =
C;
C = D; D = temp;
478 temp = c; c = d; d = temp;