File indexing completed on 2025-01-18 09:59:15
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044 #ifndef G4TWISTEDTUBS_HH
0045 #define G4TWISTEDTUBS_HH
0046
0047 #include "G4VSolid.hh"
0048 #include "G4TwistTubsFlatSide.hh"
0049 #include "G4TwistTubsSide.hh"
0050 #include "G4TwistTubsHypeSide.hh"
0051
0052 class G4SolidExtentList;
0053 class G4ClippablePolygon;
0054
0055 class G4TwistedTubs : public G4VSolid
0056 {
0057 public:
0058
0059 G4TwistedTubs(const G4String& pname,
0060 G4double twistedangle,
0061 G4double endinnerrad,
0062 G4double endouterrad,
0063 G4double halfzlen,
0064 G4double dphi);
0065
0066 G4TwistedTubs(const G4String& pname,
0067 G4double twistedangle,
0068 G4double endinnerrad,
0069 G4double endouterrad,
0070 G4double halfzlen,
0071 G4int nseg,
0072 G4double totphi);
0073
0074 G4TwistedTubs(const G4String& pname,
0075 G4double twistedangle,
0076 G4double innerrad,
0077 G4double outerrad,
0078 G4double negativeEndz,
0079 G4double positiveEndz,
0080 G4double dphi);
0081
0082 G4TwistedTubs(const G4String& pname,
0083 G4double twistedangle,
0084 G4double innerrad,
0085 G4double outerrad,
0086 G4double negativeEndz,
0087 G4double positiveEndz,
0088 G4int nseg,
0089 G4double totphi);
0090
0091 ~G4TwistedTubs() override;
0092
0093 void ComputeDimensions(G4VPVParameterisation* ,
0094 const G4int ,
0095 const G4VPhysicalVolume* ) override;
0096
0097 void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
0098
0099 G4bool CalculateExtent(const EAxis pAxis,
0100 const G4VoxelLimits& pVoxelLimit,
0101 const G4AffineTransform& pTransform,
0102 G4double& pMin,
0103 G4double& pMax ) const override;
0104
0105 G4double DistanceToIn (const G4ThreeVector& p,
0106 const G4ThreeVector& v ) const override;
0107
0108 G4double DistanceToIn (const G4ThreeVector& p ) const override;
0109
0110 G4double DistanceToOut(const G4ThreeVector& p,
0111 const G4ThreeVector& v,
0112 const G4bool calcnorm = false,
0113 G4bool* validnorm = nullptr,
0114 G4ThreeVector* n = nullptr ) const override;
0115
0116 G4double DistanceToOut(const G4ThreeVector& p) const override;
0117
0118 EInside Inside (const G4ThreeVector& p) const override;
0119
0120 G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const override;
0121
0122 void DescribeYourselfTo (G4VGraphicsScene& scene) const override;
0123 G4Polyhedron* CreatePolyhedron () const override;
0124 G4Polyhedron* GetPolyhedron () const override;
0125
0126 std::ostream &StreamInfo(std::ostream& os) const override;
0127
0128
0129
0130 inline G4double GetDPhi () const { return fDPhi ; }
0131 inline G4double GetPhiTwist () const { return fPhiTwist ; }
0132 inline G4double GetInnerRadius () const { return fInnerRadius; }
0133 inline G4double GetOuterRadius () const { return fOuterRadius; }
0134 inline G4double GetInnerStereo () const { return fInnerStereo; }
0135 inline G4double GetOuterStereo () const { return fOuterStereo; }
0136 inline G4double GetZHalfLength () const { return fZHalfLength; }
0137 inline G4double GetKappa () const { return fKappa ; }
0138
0139 inline G4double GetTanInnerStereo () const { return fTanInnerStereo ; }
0140 inline G4double GetTanInnerStereo2() const { return fTanInnerStereo2 ; }
0141 inline G4double GetTanOuterStereo () const { return fTanOuterStereo ; }
0142 inline G4double GetTanOuterStereo2() const { return fTanOuterStereo2 ; }
0143
0144 inline G4double GetEndZ (G4int i) const { return fEndZ[i] ; }
0145 inline G4double GetEndPhi (G4int i) const { return fEndPhi[i]; }
0146 inline G4double GetEndInnerRadius (G4int i) const
0147 { return fEndInnerRadius[i]; }
0148 inline G4double GetEndOuterRadius (G4int i) const
0149 { return fEndOuterRadius[i]; }
0150 inline G4double GetEndInnerRadius () const
0151 { return (fEndInnerRadius[0] > fEndInnerRadius[1] ?
0152 fEndInnerRadius[0] : fEndInnerRadius[1]); }
0153 inline G4double GetEndOuterRadius () const
0154 { return (fEndOuterRadius[0] > fEndOuterRadius[1] ?
0155 fEndOuterRadius[0] : fEndOuterRadius[1]); }
0156
0157 G4VisExtent GetExtent () const override;
0158 G4GeometryType GetEntityType() const override;
0159 G4VSolid* Clone() const override;
0160
0161 G4double GetCubicVolume() override;
0162
0163
0164 G4double GetSurfaceArea() override;
0165
0166
0167
0168 G4ThreeVector GetPointOnSurface() const override ;
0169
0170 G4TwistedTubs(__void__&);
0171
0172
0173
0174
0175 G4TwistedTubs(const G4TwistedTubs& rhs);
0176 G4TwistedTubs& operator=(const G4TwistedTubs& rhs);
0177
0178
0179 #ifdef G4TWISTDEBUG
0180 G4VTwistSurface* GetOuterHype() const { return fOuterHype; }
0181 #endif
0182
0183 private:
0184
0185 inline void SetFields(G4double phitwist, G4double innerrad,
0186 G4double outerrad,
0187 G4double negativeEndz, G4double positiveEndz);
0188 void CreateSurfaces();
0189 G4double GetLateralArea(G4double a, G4double r, G4double z) const;
0190 G4double GetPhiCutArea(G4double a, G4double r, G4double z) const;
0191
0192 private:
0193
0194 G4double fPhiTwist;
0195 G4double fInnerRadius;
0196 G4double fOuterRadius;
0197 G4double fEndZ[2];
0198 G4double fDPhi;
0199 G4double fZHalfLength;
0200
0201 G4double fInnerStereo;
0202 G4double fOuterStereo;
0203 G4double fTanInnerStereo;
0204 G4double fTanOuterStereo;
0205 G4double fKappa;
0206 G4double fEndInnerRadius[2];
0207 G4double fEndOuterRadius[2];
0208 G4double fEndPhi[2];
0209
0210 G4double fInnerRadius2;
0211 G4double fOuterRadius2;
0212 G4double fTanInnerStereo2;
0213 G4double fTanOuterStereo2;
0214 G4double fEndZ2[2];
0215
0216 G4VTwistSurface* fLowerEndcap;
0217 G4VTwistSurface* fUpperEndcap;
0218 G4VTwistSurface* fLatterTwisted;
0219 G4VTwistSurface* fFormerTwisted;
0220 G4VTwistSurface* fInnerHype;
0221 G4VTwistSurface* fOuterHype;
0222
0223 G4double fCubicVolume = 0.0;
0224 G4double fSurfaceArea = 0.0;
0225
0226 mutable G4bool fRebuildPolyhedron = false;
0227 mutable G4Polyhedron* fpPolyhedron = nullptr;
0228
0229 };
0230
0231
0232
0233
0234
0235
0236
0237 inline
0238 void G4TwistedTubs::SetFields(G4double phitwist, G4double innerrad,
0239 G4double outerrad, G4double negativeEndz,
0240 G4double positiveEndz)
0241 {
0242 fCubicVolume = 0.;
0243 fPhiTwist = phitwist;
0244 fEndZ[0] = negativeEndz;
0245 fEndZ[1] = positiveEndz;
0246 fEndZ2[0] = fEndZ[0] * fEndZ[0];
0247 fEndZ2[1] = fEndZ[1] * fEndZ[1];
0248 fInnerRadius = innerrad;
0249 fOuterRadius = outerrad;
0250 fInnerRadius2 = fInnerRadius * fInnerRadius;
0251 fOuterRadius2 = fOuterRadius * fOuterRadius;
0252
0253 if (std::fabs(fEndZ[0]) >= std::fabs(fEndZ[1]))
0254 {
0255 fZHalfLength = std::fabs(fEndZ[0]);
0256 }
0257 else
0258 {
0259 fZHalfLength = std::fabs(fEndZ[1]);
0260 }
0261
0262 G4double parity = (fPhiTwist > 0 ? 1 : -1);
0263 G4double tanHalfTwist = std::tan(0.5 * fPhiTwist);
0264 G4double innerNumerator = std::fabs(fInnerRadius * tanHalfTwist) * parity;
0265 G4double outerNumerator = std::fabs(fOuterRadius * tanHalfTwist) * parity;
0266
0267 fTanInnerStereo = innerNumerator / fZHalfLength;
0268 fTanOuterStereo = outerNumerator / fZHalfLength;
0269 fTanInnerStereo2 = fTanInnerStereo * fTanInnerStereo;
0270 fTanOuterStereo2 = fTanOuterStereo * fTanOuterStereo;
0271 fInnerStereo = std::atan2(innerNumerator, fZHalfLength);
0272 fOuterStereo = std::atan2(outerNumerator, fZHalfLength);
0273 fEndInnerRadius[0] = std::sqrt(fInnerRadius2 + fEndZ2[0] * fTanInnerStereo2);
0274 fEndInnerRadius[1] = std::sqrt(fInnerRadius2 + fEndZ2[1] * fTanInnerStereo2);
0275 fEndOuterRadius[0] = std::sqrt(fOuterRadius2 + fEndZ2[0] * fTanOuterStereo2);
0276 fEndOuterRadius[1] = std::sqrt(fOuterRadius2 + fEndZ2[1] * fTanOuterStereo2);
0277
0278 fKappa = tanHalfTwist / fZHalfLength;
0279 fEndPhi[0] = std::atan2(fEndZ[0] * tanHalfTwist, fZHalfLength);
0280 fEndPhi[1] = std::atan2(fEndZ[1] * tanHalfTwist, fZHalfLength);
0281
0282 #ifdef G4TWISTDEBUG
0283 G4cout << "/********* G4TwistedTubs::SetFields() Field Parameters ***************** " << G4endl;
0284 G4cout << "/* fPhiTwist : " << fPhiTwist << G4endl;
0285 G4cout << "/* fEndZ(0, 1) : " << fEndZ[0] << " , " << fEndZ[1] << G4endl;
0286 G4cout << "/* fEndPhi(0, 1) : " << fEndPhi[0] << " , " << fEndPhi[1] << G4endl;
0287 G4cout << "/* fInnerRadius, fOuterRadius : " << fInnerRadius << " , " << fOuterRadius << G4endl;
0288 G4cout << "/* fEndInnerRadius(0, 1) : " << fEndInnerRadius[0] << " , "
0289 << fEndInnerRadius[1] << G4endl;
0290 G4cout << "/* fEndOuterRadius(0, 1) : " << fEndOuterRadius[0] << " , "
0291 << fEndOuterRadius[1] << G4endl;
0292 G4cout << "/* fInnerStereo, fOuterStereo : " << fInnerStereo << " , " << fOuterStereo << G4endl;
0293 G4cout << "/* tanHalfTwist, fKappa : " << tanHalfTwist << " , " << fKappa << G4endl;
0294 G4cout << "/*********************************************************************** " << G4endl;
0295 #endif
0296 }
0297
0298 #endif