99 for(G4int i=0;i<30;i++)
101 for (G4int j=0;j<8;j++)
104 G4ThreeVector* pPnt =
new G4ThreeVector(param[i][j],param[i][j+8],param[i][j+16]-WorldZPosition-SectorZPosition);
108 if(i==5||i==6||i==14||i==15||i==16)
111 for(G4int j=0;j<8;j++)
112 fPnt[30+pentaNb][j] = fPnt[i][j];
115 G4double y0,y1,y4,y5;
116 G4ThreeVector v0,v1,v4,v5;
117 y0 = penta[pentaNb][0];
118 y1 = penta[pentaNb][1];
119 y4 = penta[pentaNb][2];
120 y5 = penta[pentaNb][3];
121 v0 = (y0-fPnt[i][3].getY())*(fPnt[i][0]-fPnt[i][3])/(fPnt[i][0].getY()-fPnt[i][3].getY())
123 v1 = (y1-fPnt[i][2].getY())*(fPnt[i][1]-fPnt[i][2])/(fPnt[i][1].getY()-fPnt[i][2].getY())
125 v4 = (y4-fPnt[i][7].getY())*(fPnt[i][4]-fPnt[i][7])/(fPnt[i][4].getY()-fPnt[i][7].getY())
127 v5 = (y5-fPnt[i][6].getY())*(fPnt[i][5]-fPnt[i][6])/(fPnt[i][5].getY()-fPnt[i][6].getY())
131 x1 = penta[pentaNb][4];
132 x5 = penta[pentaNb][5];
133 v1 = (x1-v0.getX())*(v1-v0)/(v1.getX()-v0.getX())+v0;
134 v5 = (x5-v4.getX())*(v5-v4)/(v5.getX()-v4.getX())+v4;
141 fPnt[30+pentaNb][2] = v1;
142 fPnt[30+pentaNb][3] = v0;
143 fPnt[30+pentaNb][6] = v5;
144 fPnt[30+pentaNb][7] = v4;
151 G4ThreeVector temp[35][8];
152 for(G4int i=0;i<35;i++)
154 for (G4int j=0;j<8;j++)
156 temp[i][j]=fPnt[i][j];
157 fPnt[i][j].rotateZ(157.5*deg);
158 fPnt[i][j].setX(-fPnt[i][j].getX());
162 for (G4int j=0;j<8;j++)
166 G4ThreeVector
v=fPnt[i][j];
167 fPnt[i][j]=fPnt[i][3-j];
172 G4ThreeVector
v=fPnt[i][j];
173 fPnt[i][j]=fPnt[i][11-j];
197 for(G4int i=0;i<35;i++)
199 for (G4int j=0;j<8;j++)
201 G4ThreeVector pPnt1 = temp[i][j];
202 fPnt1[i][j] = pPnt1.rotateZ(67.5*deg);
204 if((i==3)||(i==7)||(i==12)||(i==17)||(i==23)||(i==29))
206 fPnt1[i][0].setX(10);
207 fPnt1[i][1].setX(10);
208 fPnt1[i][4].setX(10);
209 fPnt1[i][5].setX(10);
211 G4double y0 = fPnt1[i][0].getY()+10*(fPnt1[i][3].getY()-fPnt1[i][0].getY())/fPnt1[i][3].getX();
212 G4double y1 = fPnt1[i][1].getY()+10*(fPnt1[i][2].getY()-fPnt1[i][1].getY())/fPnt1[i][2].getX();
213 G4double y4 = fPnt1[i][4].getY()+10*(fPnt1[i][7].getY()-fPnt1[i][4].getY())/fPnt1[i][7].getX();
214 G4double y5 = fPnt1[i][5].getY()+10*(fPnt1[i][6].getY()-fPnt1[i][5].getY())/fPnt1[i][6].getX();
216 G4double z0 = fPnt1[i][0].getZ()+10*(fPnt1[i][3].getZ()-fPnt1[i][0].getZ())/fPnt1[i][3].getX();
217 G4double z1 = fPnt1[i][1].getZ()+10*(fPnt1[i][2].getZ()-fPnt1[i][1].getZ())/fPnt1[i][2].getX();
218 G4double z4 = fPnt1[i][4].getZ()+10*(fPnt1[i][7].getZ()-fPnt1[i][4].getZ())/fPnt1[i][7].getX();
219 G4double z5 = fPnt1[i][5].getZ()+10*(fPnt1[i][6].getZ()-fPnt1[i][5].getZ())/fPnt1[i][6].getX();
221 fPnt1[i][0].setY(y0);
222 fPnt1[i][1].setY(y1);
223 fPnt1[i][4].setY(y4);
224 fPnt1[i][5].setY(y5);
226 fPnt1[i][0].setZ(z0);
227 fPnt1[i][1].setZ(z1);
228 fPnt1[i][4].setZ(z4);
229 fPnt1[i][5].setZ(z5);
328 G4ThreeVector center1(0,0,0);
329 G4ThreeVector center2(0,0,0);
331 const G4double
dt=1e-5;
333 if(CryNb==5||CryNb==6||CryNb==14||CryNb==15||CryNb==16)
335 center1 = (pos[0]+pos[1])*(1-
dt)/2+(pos[2]+pos[3])*
dt/2;
336 center2 = (pos[4]+pos[5])*(1-
dt)/2+(pos[6]+pos[7])*
dt/2;
338 else if(CryNb>=30&&CryNb<35)
340 center1 = (pos[0]+pos[1])*
dt/2+(pos[2]+pos[3])*(1-
dt)/2;
341 center2 = (pos[4]+pos[5])*
dt/2+(pos[6]+pos[7])*(1-
dt)/2;
345 center1 = (pos[0]+pos[1]+pos[2]+pos[3])/4;
346 center2 = (pos[4]+pos[5]+pos[6]+pos[7])/4;
349 G4double r1=(pos[1]-center1).r();
350 G4double r2=(pos[2]-center1).r();
351 G4double r12=(pos[1]-pos[2]).r();
352 G4double theta=acos((r2*r2+r12*r12-r1*r1)/(2*r2*r12));
353 G4double h=r2*
sin(theta);
354 G4double t1=totalThickness/h;
356 r1=(pos[5]-center2).r();
357 r2=(pos[6]-center2).r();
358 r12=(pos[5]-pos[6]).r();
359 theta=acos((r2*r2+r12*r12-r1*r1)/(2*r2*r12));
361 G4double t2=totalThickness/h;
363 for(G4int i=0;i<8;i++)
367 cryPoint[i] = (1-t1)*pos[i]+t1*center1;
371 G4ThreeVector temp = (1-t2)*pos[i]+t2*center2;
372 cryPoint[i] = (1-totalThickness/CrystalLength)*temp+(totalThickness/CrystalLength)*pos[i-4];
379(
const G4int partId,
const G4int numTheta,
const G4int numPhi)
382 G4int sector=-1, cryNb=-1;
387 G4double A1=0,a1=0,B1=0,b1=0,C1=0,c1=0,D1=0,d1=0,E1=0,
e1=0;
389 G4ThreeVector position(0,0,0);
390 G4int cryInOneSector = cryNumInOneLayer[numTheta]/16;
391 G4ThreeVector pos[8];
395 if(numPhi>=0&&numPhi<8*cryInOneSector)
396 m_numPhi=8*cryInOneSector-1-numPhi;
397 else if(numPhi>=8*cryInOneSector&&numPhi<16*cryInOneSector)
398 m_numPhi=16*cryInOneSector-1-numPhi;
403 if(numPhi>=4*cryInOneSector&&numPhi<5*cryInOneSector)
406 m_numPhi=8*cryInOneSector-1-numPhi;
408 else if(numPhi>=11*cryInOneSector&&numPhi<12*cryInOneSector)
412 m_numPhi=numPhi-8*cryInOneSector;
414 if(numPhi>=12*cryInOneSector&&numPhi<13*cryInOneSector)
417 m_numPhi=16*cryInOneSector-1-numPhi;
421 G4int cryNbOffset = 0;
422 for(G4int i=0;i<numTheta;i++)
423 cryNbOffset += cryNumInOneLayer[i]/16;
425 sector = m_numPhi/cryInOneSector;
426 cryNb = m_numPhi-cryInOneSector*sector+cryNbOffset;
428 if(sector>15&§or<=18)
433 for(G4int i=0;i<8;i++)
434 pos[i]=fPnt1[cryNb][i];
436 for(G4int i=0;i<8;i++)
438 pos[i]=fPnt[cryNb][i];
439 pos[i].rotateZ(-67.5*deg+sector*22.5*deg);
445 G4double A = (cryPoint[0]-cryPoint[3]).r();
446 G4double a = (cryPoint[4]-cryPoint[7]).r();
447 G4double B = (cryPoint[1]-cryPoint[2]).r();
448 G4double
b = (cryPoint[5]-cryPoint[6]).r();
449 G4double
C = (cryPoint[0]-cryPoint[1]).r();
450 G4double c = (cryPoint[4]-cryPoint[5]).r();
451 G4double D = (cryPoint[2]-cryPoint[3]).r();
452 G4double d = (cryPoint[6]-cryPoint[7]).r();
455 for(G4int i=0;i<8;i++)
457 pos[i].setZ(pos[i].getZ()+WorldZPosition+SectorZPosition);
459 pos[i].setX(-pos[i].getX());
461 pos[i].setY(-pos[i].getY());
464 pos[i].setX(-pos[i].getX());
465 pos[i].setZ(-pos[i].getZ());
470 for(G4int j=4;j<8;j++)
475 for(G4int i=0;i<5;i++)
477 if(cryNb==pentaInOneSector[i])
480 G4ThreeVector penta[8];
484 for(G4int j=0;j<8;j++)
485 penta[j]=fPnt1[30+i][j];
487 for(G4int j=0;j<8;j++)
489 penta[j]=fPnt[30+i][j];
490 penta[j].rotateZ(-67.5*deg+sector*22.5*deg);
495 A1 = (cryPoint[1]-cryPoint[2]).r();
496 a1 = (cryPoint[5]-cryPoint[6]).r();
497 B1 = (cryPoint[1]-cryPoint[0]).r();
498 b1 = (cryPoint[5]-cryPoint[4]).r();
499 C1 = (cryPoint[0]-cryPoint[3]).r()+A;
500 c1 = (cryPoint[4]-cryPoint[7]).r()+a;
507 for(G4int j=0;j<8;j++)
509 penta[j].setZ(penta[j].getZ()+WorldZPosition+SectorZPosition);
511 penta[j].setX(-penta[j].getX());
513 penta[j].setY(-penta[j].getY());
516 penta[j].setX(-penta[j].getX());
517 penta[j].setZ(-penta[j].getZ());
522 for(G4int j=4;j<8;j++)
526 if(j==0||j==1||j==4||j==5)
527 position += penta[j];
531 flag = leftFlag+downFlag;
534 G4double temp1 = B1; B1 = D1; D1 = temp1;
535 temp1 = A1; A1 = E1; E1 = temp1;
536 temp1 = b1; b1 = d1; d1 = temp1;
537 temp1 = a1; a1 =
e1;
e1 = temp1;
544 flag = leftFlag+downFlag+partId/2;
547 G4double temp =
C;
C = D; D = temp;
548 temp = c; c = d; d = temp;