310{
311
312 G4int sector=-1, cryNb=-1;
313 G4int leftFlag=0;
314 G4int downFlag=0;
315 G4int pentaFlag=0;
316 G4int flag=0;
317 G4double A1=0,a1=0,B1=0,b1=0,C1=0,
c1=0,D1=0,d1=0,E1=0,
e1=0;
318 G4int m_numPhi=0;
319 G4ThreeVector position=0;
320 G4int cryInOneSector = cryNumInOneLayer[numTheta]/16;
321 G4ThreeVector pos[8];
322
323 if(partId==2)
324 {
325 if(numPhi>=0&&numPhi<8*cryInOneSector)
326 m_numPhi=8*cryInOneSector-1-numPhi;
327 else if(numPhi>=8*cryInOneSector&&numPhi<16*cryInOneSector)
328 m_numPhi=16*cryInOneSector-1-numPhi;
329 }
330 else
331 m_numPhi=numPhi;
332
333 if(numPhi>=4*cryInOneSector&&numPhi<5*cryInOneSector)
334 {
335 leftFlag = 1;
336 m_numPhi=8*cryInOneSector-1-numPhi;
337 }
338 else if(numPhi>=11*cryInOneSector&&numPhi<12*cryInOneSector)
339 {
340 leftFlag = 1;
341 downFlag = 1;
342 m_numPhi=numPhi-8*cryInOneSector;
343 }
344 if(numPhi>=12*cryInOneSector&&numPhi<13*cryInOneSector)
345 {
346 downFlag = 1;
347 m_numPhi=16*cryInOneSector-1-numPhi;
348 }
349
350
351 G4int cryNbOffset = 0;
352 for(G4int i=0;i<numTheta;i++)
353 cryNbOffset += cryNumInOneLayer[i]/16;
354 if(cryInOneSector)
355 sector = m_numPhi/cryInOneSector;
356 cryNb = m_numPhi-cryInOneSector*sector+cryNbOffset;
357 sector += 3;
358 if(sector>15&§or<=18)
359 sector -= 16;
360
361
362 if(sector==6)
363 for(G4int i=0;i<8;i++)
364 pos[i]=fPnt1[cryNb][i];
365 else
366 for(G4int i=0;i<8;i++)
367 {
368 pos[i]=fPnt[cryNb][i];
369 pos[i].rotateZ(-67.5*deg+sector*22.5*deg);
370 }
371
372
374 G4double
A = (cryPoint[0]-cryPoint[3]).r();
375 G4double a = (cryPoint[4]-cryPoint[7]).r();
376 G4double
B = (cryPoint[1]-cryPoint[2]).r();
377 G4double b = (cryPoint[5]-cryPoint[6]).r();
378 G4double
C = (cryPoint[0]-cryPoint[1]).r();
379 G4double c = (cryPoint[4]-cryPoint[5]).r();
380 G4double D = (cryPoint[2]-cryPoint[3]).r();
381 G4double d = (cryPoint[6]-cryPoint[7]).r();
382
383
384 for(G4int i=0;i<8;i++)
385 {
386 pos[i].setZ(pos[i].getZ()+WorldZPosition);
387 if(leftFlag==1)
388 pos[i].setX(-pos[i].getX());
389 if(downFlag==1)
390 pos[i].setY(-pos[i].getY());
391 if(partId==2)
392 {
393 pos[i].setX(-pos[i].getX());
394 pos[i].setZ(-pos[i].getZ());
395 }
396 }
397
398
399 for(G4int j=4;j<8;j++)
400 position += pos[j];
401 position /= 4;
402
403
404 for(G4int i=0;i<5;i++)
405 {
406 if(cryNb==pentaInOneSector[i])
407 {
408 pentaFlag = 1;
409 G4ThreeVector penta[8];
410
411
412 if(sector==6)
413 for(G4int j=0;j<8;j++)
414 penta[j]=fPnt1[30+i][j];
415 else
416 for(G4int j=0;j<8;j++)
417 {
418 penta[j]=fPnt[30+i][j];
419 penta[j].rotateZ(-67.5*deg+sector*22.5*deg);
420 }
421
422
424 A1 = (cryPoint[1]-cryPoint[2]).r();
425 a1 = (cryPoint[5]-cryPoint[6]).r();
426 B1 = (cryPoint[1]-cryPoint[0]).r();
427 b1 = (cryPoint[5]-cryPoint[4]).r();
428 C1 = (cryPoint[0]-cryPoint[3]).r()+
A;
429 c1 = (cryPoint[4]-cryPoint[7]).r()+a;
430 D1 = D;
431 d1 = d;
434
435
436 for(G4int j=0;j<8;j++)
437 {
438 penta[j].setZ(penta[j].getZ()+WorldZPosition);
439 if(leftFlag==1)
440 penta[j].setX(-penta[j].getX());
441 if(downFlag==1)
442 penta[j].setY(-penta[j].getY());
443 if(partId==2)
444 {
445 penta[j].setX(-penta[j].getX());
446 penta[j].setZ(-penta[j].getZ());
447 }
448 }
449
450
451 for(G4int j=4;j<8;j++)
452 {
453 if(j!=0&&j!=4)
454 position += pos[j];
455 if(j==0||j==1||j==4||j==5)
456 position += penta[j];
457 }
458 position /= 10;
459
460 flag = leftFlag+downFlag;
461 if(flag==1)
462 {
463 G4double temp1 = B1; B1 = D1; D1 = temp1;
464 temp1 = A1; A1 = E1; E1 = temp1;
465 temp1 = b1; b1 = d1; d1 = temp1;
466 temp1 = a1; a1 =
e1;
e1 = temp1;
467 }
468
469 break;
470 }
471 }
472
473 flag = leftFlag+downFlag+partId/2;
474 if(flag==1||flag==3)
475 {
476 G4double temp =
C;
C = D; D = temp;
477 temp = c; c = d; d = temp;
478 }
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494 return position;
495}
***************************************************************************************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)