Loading...
Searching...
No Matches
F04ElementField.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27/// \file field/field04/include/F04ElementField.hh
28/// \brief Definition of the F04ElementField class
29//
30
31#ifndef F04ElementField_h
32#define F04ElementField_h 1
33
34#include "globals.hh"
35
36#include "G4Navigator.hh"
37#include "G4TransportationManager.hh"
38
39#include "G4UserLimits.hh"
40#include "G4VisAttributes.hh"
41
42#include "CLHEP/Units/SystemOfUnits.h"
43
44// class F04ElementField - interface for the EM field of one element
45
46// This is the interface class used by GlobalField to compute the field
47// value at a given point[].
48
49// An element that represents an element with an EM field will
50// derive a class from this one and implement the computation for the
51// element. The Construct() function will add the derived object into
52// GlobalField.
53
55{
56
57 public:
58
59 /// Constructor.
60 F04ElementField(const G4ThreeVector, G4LogicalVolume*);
61
62 /// the actual implementation constructs the F04ElementField
63 void Construct();
64
65 /// Destructor.
66 virtual ~F04ElementField() = default;
67
68 /// SetMaxStep(G4double) sets the max. step size
69 void SetMaxStep(G4double stp)
70 {
71 fMaxStep = stp;
72 fUserLimits->SetMaxAllowedStep(fMaxStep);
73 fVolume->SetUserLimits(fUserLimits);
74 }
75
76 /// GetMaxStep() returns the max. step size
77 G4double GetMaxStep() { return fMaxStep; }
78
79 /// SetColor(G4String) sets the color
81 {
82 fColor = c;
83 fVolume->SetVisAttributes(GetVisAttribute(fColor));
84 }
85
86 /// GetColor() returns the color
87 G4String GetColor() { return fColor; }
88
89 /// GetVisAttribute() returns the appropriate G4VisAttributes.
91
92 /// SetGlobalPoint() ensures that the point is within the global
93 /// bounding box of this ElementField's global coordinates.
94 /// Normally called 8 times for the corners of the local bounding
95 /// box, after a local->global coordinate transform.
96 /// If never called, the global bounding box is infinite.
97 /// BEWARE: if called only once, the bounding box is just a point.
98 void SetGlobalPoint(const G4double point[4])
99 {
100 if(fMinX == -DBL_MAX || fMinX > point[0]) fMinX = point[0];
101 if(fMinY == -DBL_MAX || fMinY > point[1]) fMinY = point[1];
102 if(fMinZ == -DBL_MAX || fMinZ > point[2]) fMinZ = point[2];
103 if(fMaxX == DBL_MAX || fMaxX < point[0]) fMaxX = point[0];
104 if(fMaxY == DBL_MAX || fMaxY < point[1]) fMaxY = point[1];
105 if(fMaxZ == DBL_MAX || fMaxZ < point[2]) fMaxZ = point[2];
106 }
107
108 /// IsInBoundingBox() returns true if the point is within the
109 /// global bounding box - global coordinates.
110 bool IsInBoundingBox(const G4double point[4]) const
111 {
112 if(point[2] < fMinZ || point[2] > fMaxZ) return false;
113 if(point[0] < fMinX || point[0] > fMaxX) return false;
114 if(point[1] < fMinY || point[1] > fMaxY) return false;
115 return true;
116 }
117
118 /// AddFieldValue() will add the field value for this element to field[].
119 /// Implementations must be sure to verify that point[] is within
120 /// the field region, and do nothing if not.
121 /// point[] is in global coordinates and geant4 units; x,y,z,t.
122 /// field[] is in geant4 units; Bx,By,Bz,Ex,Ey,Ez.
123 /// For efficiency, the caller may (but need not) call
124 /// IsInBoundingBox(point), and only call this function if that
125 /// returns true.
126 virtual void
127 AddFieldValue(const G4double point[4], G4double field[6]) const = 0;
128
129 virtual G4double GetLength() = 0;
130 virtual G4double GetWidth() = 0;
131 virtual G4double GetHeight() = 0;
132
133 protected:
134
136
138
139// F04ElementField(const F04ElementField&);
140
141 private:
143
144 static G4ThreadLocal G4Navigator* fNavigator;
145
146 G4String fColor = "1,1,1";
147
148 G4ThreeVector fCenter;
149 G4double fMinX = -DBL_MAX;
150 G4double fMinY = -DBL_MAX;
151 G4double fMinZ = -DBL_MAX;
152 G4double fMaxX = DBL_MAX;
153 G4double fMaxY = DBL_MAX;
154 G4double fMaxZ = DBL_MAX;
155
156 G4double fMaxStep = 1. * CLHEP::mm;
158
159};
160
161#endif
bool IsInBoundingBox(const G4double point[4]) const
IsInBoundingBox() returns true if the point is within the global bounding box - global coordinates.
F04ElementField & operator=(const F04ElementField &)
G4String GetColor()
GetColor() returns the color.
G4AffineTransform fGlobal2local
virtual G4double GetLength()=0
void SetMaxStep(G4double stp)
SetMaxStep(G4double) sets the max. step size.
G4ThreeVector fCenter
static G4VisAttributes * GetVisAttribute(G4String color)
GetVisAttribute() returns the appropriate G4VisAttributes.
static G4ThreadLocal G4Navigator * fNavigator
G4LogicalVolume * fVolume
G4double GetMaxStep()
GetMaxStep() returns the max. step size.
G4UserLimits * fUserLimits
void Construct()
the actual implementation constructs the F04ElementField
virtual ~F04ElementField()=default
Destructor.
virtual void AddFieldValue(const G4double point[4], G4double field[6]) const =0
AddFieldValue() will add the field value for this element to field[].
void SetColor(G4String c)
SetColor(G4String) sets the color.
void SetGlobalPoint(const G4double point[4])
SetGlobalPoint() ensures that the point is within the global bounding box of this ElementField's glob...
virtual G4double GetWidth()=0
virtual G4double GetHeight()=0

Applications | User Support | Publications | Collaboration