|
|
|||
File indexing completed on 2026-09-18 08:31:49
0001 // 0002 // ******************************************************************** 0003 // * License and Disclaimer * 0004 // * * 0005 // * The Geant4 software is copyright of the Copyright Holders of * 0006 // * the Geant4 Collaboration. It is provided under the terms and * 0007 // * conditions of the Geant4 Software License, included in the file * 0008 // * LICENSE and available at http://cern.ch/geant4/license . These * 0009 // * include a list of copyright holders. * 0010 // * * 0011 // * Neither the authors of this software system, nor their employing * 0012 // * institutes,nor the agencies providing financial support for this * 0013 // * work make any representation or warranty, express or implied, * 0014 // * regarding this software system or assume any liability for its * 0015 // * use. Please see the license in the file LICENSE and URL above * 0016 // * for the full disclaimer and the limitation of liability. * 0017 // * * 0018 // * This code implementation is the result of the scientific and * 0019 // * technical work of the GEANT4 collaboration. * 0020 // * By using, copying, modifying or distributing the software (or * 0021 // * any work based on the software) you agree to acknowledge its * 0022 // * use in resulting scientific publications, and indicate your * 0023 // * acceptance of all terms of the Geant4 Software license. * 0024 // ******************************************************************** 0025 // 0026 /// \file F04ElementField.hh 0027 /// \brief Definition of the F04ElementField class 0028 0029 #ifndef F04ElementField_h 0030 #define F04ElementField_h 1 0031 0032 #include "CLHEP/Units/SystemOfUnits.h" 0033 0034 #include "G4Navigator.hh" 0035 #include "G4TransportationManager.hh" 0036 #include "G4UserLimits.hh" 0037 #include "G4VisAttributes.hh" 0038 #include "globals.hh" 0039 0040 // class F04ElementField - interface for the EM field of one element 0041 0042 // This is the interface class used by GlobalField to compute the field 0043 // value at a given point[]. 0044 0045 // An element that represents an element with an EM field will 0046 // derive a class from this one and implement the computation for the 0047 // element. The Construct() function will add the derived object into 0048 // GlobalField. 0049 0050 class F04ElementField 0051 { 0052 public: 0053 /// Constructor. 0054 F04ElementField(const G4ThreeVector, G4LogicalVolume*); 0055 0056 /// the actual implementation constructs the F04ElementField 0057 void Construct(); 0058 0059 /// Destructor. 0060 virtual ~F04ElementField() = default; 0061 0062 /// SetMaxStep(G4double) sets the max. step size 0063 void SetMaxStep(G4double stp) 0064 { 0065 fMaxStep = stp; 0066 fUserLimits->SetMaxAllowedStep(fMaxStep); 0067 fVolume->SetUserLimits(fUserLimits); 0068 } 0069 0070 /// GetMaxStep() returns the max. step size 0071 G4double GetMaxStep() { return fMaxStep; } 0072 0073 /// SetColor(G4String) sets the color 0074 void SetColor(G4String c) 0075 { 0076 fColor = c; 0077 fVolume->SetVisAttributes(GetVisAttribute(fColor)); 0078 } 0079 0080 /// GetColor() returns the color 0081 G4String GetColor() { return fColor; } 0082 0083 /// GetVisAttribute() returns the appropriate G4VisAttributes. 0084 static G4VisAttributes* GetVisAttribute(G4String color); 0085 0086 /// SetGlobalPoint() ensures that the point is within the global 0087 /// bounding box of this ElementField's global coordinates. 0088 /// Normally called 8 times for the corners of the local bounding 0089 /// box, after a local->global coordinate transform. 0090 /// If never called, the global bounding box is infinite. 0091 /// BEWARE: if called only once, the bounding box is just a point. 0092 void SetGlobalPoint(const G4double point[4]) 0093 { 0094 if (fMinX == -DBL_MAX || fMinX > point[0]) fMinX = point[0]; 0095 if (fMinY == -DBL_MAX || fMinY > point[1]) fMinY = point[1]; 0096 if (fMinZ == -DBL_MAX || fMinZ > point[2]) fMinZ = point[2]; 0097 if (fMaxX == DBL_MAX || fMaxX < point[0]) fMaxX = point[0]; 0098 if (fMaxY == DBL_MAX || fMaxY < point[1]) fMaxY = point[1]; 0099 if (fMaxZ == DBL_MAX || fMaxZ < point[2]) fMaxZ = point[2]; 0100 } 0101 0102 /// IsInBoundingBox() returns true if the point is within the 0103 /// global bounding box - global coordinates. 0104 bool IsInBoundingBox(const G4double point[4]) const 0105 { 0106 if (point[2] < fMinZ || point[2] > fMaxZ) return false; 0107 if (point[0] < fMinX || point[0] > fMaxX) return false; 0108 if (point[1] < fMinY || point[1] > fMaxY) return false; 0109 return true; 0110 } 0111 0112 /// AddFieldValue() will add the field value for this element to field[]. 0113 /// Implementations must be sure to verify that point[] is within 0114 /// the field region, and do nothing if not. 0115 /// point[] is in global coordinates and geant4 units; x,y,z,t. 0116 /// field[] is in geant4 units; Bx,By,Bz,Ex,Ey,Ez. 0117 /// For efficiency, the caller may (but need not) call 0118 /// IsInBoundingBox(point), and only call this function if that 0119 /// returns true. 0120 virtual void AddFieldValue(const G4double point[4], G4double field[6]) const = 0; 0121 0122 virtual G4double GetLength() = 0; 0123 virtual G4double GetWidth() = 0; 0124 virtual G4double GetHeight() = 0; 0125 0126 protected: 0127 G4LogicalVolume* fVolume = nullptr; 0128 0129 G4AffineTransform fGlobal2local; 0130 0131 // F04ElementField(const F04ElementField&); 0132 0133 private: 0134 F04ElementField& operator=(const F04ElementField&); 0135 0136 static G4ThreadLocal G4Navigator* fNavigator; 0137 0138 G4String fColor = "1,1,1"; 0139 0140 G4ThreeVector fCenter; 0141 G4double fMinX = -DBL_MAX; 0142 G4double fMinY = -DBL_MAX; 0143 G4double fMinZ = -DBL_MAX; 0144 G4double fMaxX = DBL_MAX; 0145 G4double fMaxY = DBL_MAX; 0146 G4double fMaxZ = DBL_MAX; 0147 0148 G4double fMaxStep = 1. * CLHEP::mm; 0149 G4UserLimits* fUserLimits = nullptr; 0150 }; 0151 0152 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|