53 (
G4int nDataPointsPerMaxHalfScene,
55 : fNDataPointsPerMaxHalfScene(nDataPointsPerMaxHalfScene)
56 , fRepresentation(representation)
58 fType =
"G4MagneticFieldModel";
60 std::ostringstream oss;
61 oss << fNDataPointsPerMaxHalfScene;
62 fGlobalDescription = fType +
':' + oss.str();
76 const G4double xHalfScene = 0.5 * (xMax - xMin);
77 const G4double yHalfScene = 0.5 * (yMax - yMin);
78 const G4double zHalfScene = 0.5 * (zMax - zMin);
79 const G4double xSceneCentre = 0.5 * (xMax + xMin);
80 const G4double ySceneCentre = 0.5 * (yMax + yMin);
81 const G4double zSceneCentre = 0.5 * (zMax + zMin);
84 if (maxHalfScene <= 0.) {
86 <<
"Extent non-positive."
99 const G4String intro =
"G4MagneticFieldModel::DescribeYourselfTo: ";
100 if (globalFieldMgr) {
104 static G4bool warned =
false;
107 <<
"Null global field pointer."
113 static G4bool warned =
false;
116 <<
"No global field exists."
122 static G4bool warned =
false;
125 <<
"No global field manager."
133 const G4int nDataPointsPerXHalfScene =
G4int(xHalfScene / interval);
134 const G4int nDataPointsPerYHalfScene =
G4int(yHalfScene / interval);
135 const G4int nDataPointsPerZHalfScene =
G4int(zHalfScene / interval);
136 const G4int nXSamples = 2 * nDataPointsPerXHalfScene + 1;
137 const G4int nYSamples = 2 * nDataPointsPerYHalfScene + 1;
138 const G4int nZSamples = 2 * nDataPointsPerZHalfScene + 1;
139 const G4int nSamples = nXSamples * nYSamples * nZSamples;
140 const G4int nSamples3 = nSamples * 3;
141 const G4double arrowLengthMax = 0.8 * interval;
142 const G4int nResults = 6;
145 double position_time[4] = {0,0,0,0};
146 double result[nResults];
149 std::vector<G4double> BField(nSamples3);
150 std::vector<G4double> BFieldMagnitude(nSamples);
151 std::vector<G4double> xyz(nSamples3);
155 for (
G4int i = 0; i < nXSamples; i++) {
156 G4double x = xSceneCentre + (i - nDataPointsPerXHalfScene) * interval;
157 position_time[0] = x;
158 for (
G4int j = 0; j < nYSamples; j++) {
159 G4double y = ySceneCentre + (j - nDataPointsPerYHalfScene) * interval;
160 position_time[1] = y;
161 for (
G4int k = 0; k < nZSamples; k++) {
162 G4double z = zSceneCentre + (k - nDataPointsPerZHalfScene) * interval;
163 position_time[2] = z;
165 const G4int ijk = i * nYSamples * nZSamples + j * nZSamples + k;
166 const G4int ijk3 = ijk * 3;
171 const G4Field* field = globalField;
180 if (pRegionFieldMgr) {
204 for (
G4int l = 0; l < 3; l++) {
205 BField[ijk3 + l] = result[l];
209 (result[0]*result[0]+result[1]*result[1]+result[2]*result[2]);
210 BFieldMagnitude[ijk] = mag;
216 if (mag > BFieldMagnitudeMax) {
217 BFieldMagnitudeMax = mag;
224 if (BFieldMagnitudeMax <= 0) {
226 <<
"No field in this scene."
232 for (
G4int i = 0; i < nSamples; i++) {
233 if (BFieldMagnitude[i] > 0) {
234 const G4int i3 = i * 3;
253 const G4double f = B / BFieldMagnitudeMax;
257 blue = 2. * (0.5 - f);
259 red = 2. * (f - 0.5);
260 green = 2. * (1.0 - f);
263 const G4double arrowLength = arrowLengthMax * f;
269 const G4double x2 = x1 + arrowLength * Bx /
B;
270 const G4double y2 = y1 + arrowLength * By /
B;
271 const G4double z2 = z1 + arrowLength * Bz /
B;
273 G4ArrowModel BArrow(x1,y1,z1,x2,y2,z2,arrowLength/5,arrowColour);
279 BArrowLite.push_back(
G4Point3D(x1,y1,z1));
280 BArrowLite.push_back(
G4Point3D(x2,y2,z2));
CLHEP::Hep3Vector G4ThreeVector
virtual void GetFieldValue(const double Point[4], double *fieldArr) const =0
Representation fRepresentation
G4Navigator * GetNavigatorForTracking() const
virtual void BeginPrimitives(const G4Transform3D &objectTransformation=G4Transform3D())=0
HepGeom::Point3D< G4double > G4Point3D
G4Region * GetRegion() const
double B(double temperature)
virtual ~G4MagneticFieldModel()
virtual void AddPrimitive(const G4Polyline &)=0
G4MagneticFieldModel(G4int nDataPointsPerHalfScene=10, Representation representation=Representation::fullArrow)
virtual void DescribeYourselfTo(G4VGraphicsScene &)
G4GLOB_DLL std::ostream G4cout
G4int fNDataPointsPerMaxHalfScene
G4bool DoesFieldExist() const
void SetVisAttributes(const G4VisAttributes *)
static G4TransportationManager * GetTransportationManager()
G4FieldManager * GetFieldManager() const
G4FieldManager * GetFieldManager() const
virtual const G4VisExtent & GetExtent() const
G4LogicalVolume * GetLogicalVolume() const
T max(const T t1, const T t2)
brief Return the largest of the two arguments
virtual G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=0, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true)
G4FieldManager * GetFieldManager() const
virtual void EndPrimitives()=0
virtual void DescribeYourselfTo(G4VGraphicsScene &)
const G4Field * GetDetectorField() const
static const G4double alpha
static const G4double pos