377{
378
379 G4int sector=-1, cryNb=-1;
380 G4int leftFlag=0;
381 G4int downFlag=0;
382 G4int pentaFlag=0;
383 G4int flag=0;
384 G4double A1=0,a1=0,B1=0,b1=0,C1=0,
c1=0,D1=0,d1=0,E1=0,
e1=0;
385 G4int m_numPhi=0;
386 G4ThreeVector position=0;
387 G4int cryInOneSector = cryNumInOneLayer[numTheta]/16;
388 G4ThreeVector pos[8];
389
390 if(partId==2)
391 {
392 if(numPhi>=0&&numPhi<8*cryInOneSector)
393 m_numPhi=8*cryInOneSector-1-numPhi;
394 else if(numPhi>=8*cryInOneSector&&numPhi<16*cryInOneSector)
395 m_numPhi=16*cryInOneSector-1-numPhi;
396 }
397 else
398 m_numPhi=numPhi;
399
400 if(numPhi>=4*cryInOneSector&&numPhi<5*cryInOneSector)
401 {
402 leftFlag = 1;
403 m_numPhi=8*cryInOneSector-1-numPhi;
404 }
405 else if(numPhi>=11*cryInOneSector&&numPhi<12*cryInOneSector)
406 {
407 leftFlag = 1;
408 downFlag = 1;
409 m_numPhi=numPhi-8*cryInOneSector;
410 }
411 if(numPhi>=12*cryInOneSector&&numPhi<13*cryInOneSector)
412 {
413 downFlag = 1;
414 m_numPhi=16*cryInOneSector-1-numPhi;
415 }
416
417
418 G4int cryNbOffset = 0;
419 for(G4int i=0;i<numTheta;i++)
420 cryNbOffset += cryNumInOneLayer[i]/16;
421 if(cryInOneSector)
422 sector = m_numPhi/cryInOneSector;
423 cryNb = m_numPhi-cryInOneSector*sector+cryNbOffset;
424 sector += 3;
425 if(sector>15&§or<=18)
426 sector -= 16;
427
428
429 if(sector==6)
430 for(G4int i=0;i<8;i++)
431 pos[i]=fPnt1[cryNb][i];
432 else
433 for(G4int i=0;i<8;i++)
434 {
435 pos[i]=fPnt[cryNb][i];
436 pos[i].rotateZ(-67.5*deg+sector*22.5*deg);
437 }
438
439
442 G4double
A = (cryPoint[0]-cryPoint[3]).r();
443 G4double a = (cryPoint[4]-cryPoint[7]).r();
444 G4double
B = (cryPoint[1]-cryPoint[2]).r();
445 G4double b = (cryPoint[5]-cryPoint[6]).r();
446 G4double
C = (cryPoint[0]-cryPoint[1]).r();
447 G4double c = (cryPoint[4]-cryPoint[5]).r();
448 G4double D = (cryPoint[2]-cryPoint[3]).r();
449 G4double d = (cryPoint[6]-cryPoint[7]).r();
450
451
452 for(G4int i=0;i<8;i++)
453 {
454 pos[i].setZ(pos[i].getZ()+WorldZPosition+SectorZPosition);
455 if(leftFlag==1)
456 pos[i].setX(-pos[i].getX());
457 if(downFlag==1)
458 pos[i].setY(-pos[i].getY());
459 if(partId==2)
460 {
461 pos[i].setX(-pos[i].getX());
462 pos[i].setZ(-pos[i].getZ());
463 }
464 }
465
466
467 for(G4int j=4;j<8;j++)
468 position += pos[j];
469 position /= 4;
470
471
472 for(G4int i=0;i<5;i++)
473 {
474 if(cryNb==pentaInOneSector[i])
475 {
476 pentaFlag = 1;
477 G4ThreeVector penta[8];
478
479
480 if(sector==6)
481 for(G4int j=0;j<8;j++)
482 penta[j]=fPnt1[30+i][j];
483 else
484 for(G4int j=0;j<8;j++)
485 {
486 penta[j]=fPnt[30+i][j];
487 penta[j].rotateZ(-67.5*deg+sector*22.5*deg);
488 }
489
490
492 A1 = (cryPoint[1]-cryPoint[2]).r();
493 a1 = (cryPoint[5]-cryPoint[6]).r();
494 B1 = (cryPoint[1]-cryPoint[0]).r();
495 b1 = (cryPoint[5]-cryPoint[4]).r();
496 C1 = (cryPoint[0]-cryPoint[3]).r()+
A;
497 c1 = (cryPoint[4]-cryPoint[7]).r()+a;
498 D1 = D;
499 d1 = d;
502
503
504 for(G4int j=0;j<8;j++)
505 {
506 penta[j].setZ(penta[j].getZ()+WorldZPosition+SectorZPosition);
507 if(leftFlag==1)
508 penta[j].setX(-penta[j].getX());
509 if(downFlag==1)
510 penta[j].setY(-penta[j].getY());
511 if(partId==2)
512 {
513 penta[j].setX(-penta[j].getX());
514 penta[j].setZ(-penta[j].getZ());
515 }
516 }
517
518
519 for(G4int j=4;j<8;j++)
520 {
521 if(j!=0&&j!=4)
522 position += pos[j];
523 if(j==0||j==1||j==4||j==5)
524 position += penta[j];
525 }
526 position /= 10;
527
528 flag = leftFlag+downFlag;
529 if(flag==1)
530 {
531 G4double temp1 = B1; B1 = D1; D1 = temp1;
532 temp1 = A1; A1 = E1; E1 = temp1;
533 temp1 = b1; b1 = d1; d1 = temp1;
534 temp1 = a1; a1 =
e1;
e1 = temp1;
535 }
536
537 break;
538 }
539 }
540
541 flag = leftFlag+downFlag+partId/2;
542 if(flag==1||flag==3)
543 {
544 G4double temp =
C;
C = D; D = temp;
545 temp = c; c = d; d = temp;
546 }
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562 return position;
563}
***************************************************************************************Pseudo Class RRes *****************************************************************************************Parameters and physical constants **Maarten sept ************************************************************************DOUBLE PRECISION xsmu **************************************************************************PARTICLE DATA all others are from PDG *Only resonances with known widths into electron pairs are sept ************************************************************************C Declarations C
void ModifyForCasing(G4ThreeVector pos[8], G4int CryNb)
void Zoom(const G4ThreeVector pos[8], const G4double factor)