2 #include "G4SystemOfUnits.hh"
6 G4ThreeVector& p1 = pt[iface[0]];
7 G4ThreeVector& p2 = pt[iface[1]];
8 G4ThreeVector& p3 = pt[iface[2]];
9 G4ThreeVector& p4 = pt[iface[3]];
16 G4ThreeVector normal = ((p4 - p2).cross(p3 - p1)).unit();
17 if (std::abs(normal.x()) < DBL_EPSILON) normal.setX(0);
18 if (std::abs(normal.y()) < DBL_EPSILON) normal.setY(0);
19 if (std::abs(normal.z()) < DBL_EPSILON) normal.setZ(0);
20 normal = normal.unit();
22 G4ThreeVector centre = (p1 + p2 + p3 + p4)*0.25;
26 plane.d = -normal.dot(centre);
29 G4double sd1 = (normal.dot(p1) + plane.d);
30 G4double sd2 = (normal.dot(p2) + plane.d);
31 G4double sd3 = (normal.dot(p3) + plane.d);
32 G4double sd4 = (normal.dot(p4) + plane.d);
33 if (std::sqrt(sd1*sd1+sd2*sd2+sd3*sd3+sd4*sd4)/4.0 > 1*mm) {
34 G4cerr <<
"Warning! Not even QweakSimTrap is going to help here." << G4endl;
35 G4cerr <<
"There is something wrong with your QweakSimTrap parameters." << G4endl;
39 G4ThreeVector xhat(1.0,0.0,0.0);
40 G4double xd = (normal.dot(centre + xhat) + plane.d);
47 G4double sd1c = (normal.dot(p1) + plane.d);
48 G4double sd2c = (normal.dot(p2) + plane.d);
49 G4double sd3c = (normal.dot(p3) + plane.d);
50 G4double sd4c = (normal.dot(p4) + plane.d);
52 return std::sqrt(sd1c*sd1c+sd2c*sd2c+sd3c*sd3c+sd4c*sd4c)/4.0;
56 G4double pDz, G4double pTheta, G4double pPhi,
57 G4double pDy1, G4double pDx1, G4double pDx2, G4double pAlp1,
58 G4double pDy2, G4double pDx3, G4double pDx4, G4double pAlp2)
61 G4cout <<
"You are using a QweakSim trapezoid." << G4endl;
64 G4double fTthetaCphi = std::tan(pTheta)*std::cos(pPhi);
65 G4double fTthetaSphi = std::tan(pTheta)*std::sin(pPhi);
67 G4double fDy1, fDx1, fDx2, fTalpha1;
68 G4double fDy2, fDx3, fDx4, fTalpha2;
69 fDy1 = pDy1; fDx1 = pDx1; fDx2 = pDx2; fTalpha1 = std::tan(pAlp1);
70 fDy2 = pDy2; fDx3 = pDx3; fDx4 = pDx4; fTalpha2 = std::tan(pAlp2);
72 G4double DzTthetaCphi = fDz*fTthetaCphi;
73 G4double DzTthetaSphi = fDz*fTthetaSphi;
74 G4double Dy1Talpha1 = fDy1*fTalpha1;
75 G4double Dy2Talpha2 = fDy2*fTalpha2;
79 G4ThreeVector(-DzTthetaCphi-Dy1Talpha1-fDx1,-DzTthetaSphi-fDy1,-fDz),
80 G4ThreeVector(-DzTthetaCphi-Dy1Talpha1+fDx1,-DzTthetaSphi-fDy1,-fDz),
81 G4ThreeVector(-DzTthetaCphi+Dy1Talpha1-fDx2,-DzTthetaSphi+fDy1,-fDz),
82 G4ThreeVector(-DzTthetaCphi+Dy1Talpha1+fDx2,-DzTthetaSphi+fDy1,-fDz),
83 G4ThreeVector( DzTthetaCphi-Dy2Talpha2-fDx3, DzTthetaSphi-fDy2, fDz),
84 G4ThreeVector( DzTthetaCphi-Dy2Talpha2+fDx3, DzTthetaSphi-fDy2, fDz),
85 G4ThreeVector( DzTthetaCphi+Dy2Talpha2-fDx4, DzTthetaSphi+fDy2, fDz),
86 G4ThreeVector( DzTthetaCphi+Dy2Talpha2+fDx4, DzTthetaSphi+fDy2, fDz)
89 G4int iface[2][4] = { {0,2,6,4}, {1,3,5,7} };
90 for (G4int i=0; i<2; ++i)
95 fDx1 = 0.5*(pt[1]-pt[0]).x();
96 fDx2 = 0.5*(pt[3]-pt[2]).x();
97 fDx3 = 0.5*(pt[5]-pt[4]).x();
98 fDx4 = 0.5*(pt[7]-pt[6]).x();
101 SetAllParameters(pDz, pTheta, pPhi, pDy1, fDx1, fDx2, pAlp1, pDy2, fDx3, fDx4, pAlp2);
QweakSimTrap(const G4String &pName, G4double pDz, G4double pTheta, G4double pPhi, G4double pDy1, G4double pDx1, G4double pDx2, G4double pAlp1, G4double pDy2, G4double pDx3, G4double pDx4, G4double pAlp2)
G4double FixPlane(G4ThreeVector pt[8], G4int iface[4])