53 : fNDataPointsPerMaxHalfScene(nDataPointsPerMaxHalfScene)
55 fType =
"G4MagneticFieldModel";
57 std::ostringstream oss;
58 oss << fNDataPointsPerMaxHalfScene;
73 const G4double xHalfScene = 0.5 * (xMax - xMin);
74 const G4double yHalfScene = 0.5 * (yMax - yMin);
75 const G4double zHalfScene = 0.5 * (zMax - zMin);
81 if (maxHalfScene <= 0.) {
83 <<
"Extent non-positive."
101 <<
"Null global field pointer."
106 <<
"No global field exists."
111 <<
"No global field manager."
116 const G4double interval = maxHalfScene / fNDataPointsPerMaxHalfScene;
117 const G4int nDataPointsPerXHalfScene =
G4int(xHalfScene / interval);
118 const G4int nDataPointsPerYHalfScene =
G4int(yHalfScene / interval);
119 const G4int nDataPointsPerZHalfScene =
G4int(zHalfScene / interval);
120 const G4int nXSamples = 2 * nDataPointsPerXHalfScene + 1;
121 const G4int nYSamples = 2 * nDataPointsPerYHalfScene + 1;
122 const G4int nZSamples = 2 * nDataPointsPerZHalfScene + 1;
123 const G4int nSamples = nXSamples * nYSamples * nZSamples;
124 const G4int nSamples3 = nSamples * 3;
125 const G4double arrowLengthMax = 0.8 * interval;
126 const G4int nResults = 6;
129 double position_time[4] = {0,0,0,0};
133 std::vector<G4double> BField(nSamples3);
134 std::vector<G4double> BFieldMagnitude(nSamples);
135 std::vector<G4double> xyz(nSamples3);
139 for (
G4int i = 0; i < nXSamples; i++) {
140 G4double x = (i - nDataPointsPerXHalfScene) * interval;
141 position_time[0] =
x;
142 for (
G4int j = 0; j < nYSamples; j++) {
143 G4double y = (j - nDataPointsPerYHalfScene) * interval;
144 position_time[1] =
y;
145 for (
G4int k = 0; k < nZSamples; k++) {
146 G4double z = (k - nDataPointsPerZHalfScene) * interval;
147 position_time[2] =
z;
149 const G4int ijk = i * nYSamples * nZSamples + j * nZSamples + k;
150 const G4int ijk3 = ijk * 3;
155 const G4Field* field = globalField;
164 if (pRegionFieldMgr) {
188 for (
G4int l = 0; l < 3; l++) {
189 BField[ijk3 + l] = result[l];
193 (result[0]*result[0]+result[1]*result[1]+result[2]*result[2]);
194 BFieldMagnitude[ijk] = mag;
200 if (mag > BFieldMagnitudeMax) {
201 BFieldMagnitudeMax = mag;
208 if (BFieldMagnitudeMax <= 0) {
210 <<
"No field in this scene."
215 for (
G4int i = 0; i < nSamples; i++) {
216 if (BFieldMagnitude[i] > 0) {
217 const G4int i3 = i * 3;
221 const G4double B = BFieldMagnitude[i];
231 const G4double f = B / BFieldMagnitudeMax;
232 const G4double arrowLength = arrowLengthMax *
f;
236 blue = 2. * (0.5 -
f);
238 red = 2. * (f - 0.5);
239 green = 2. * (1.0 -
f);
244 x + arrowLength * BField[i3] / B,
245 y + arrowLength * BField[i3 + 1] / B,
246 z + arrowLength * BField[i3 + 2] / B,
virtual void GetFieldValue(const double Point[4], double *fieldArr) const =0
G4Navigator * GetNavigatorForTracking() const
G4double G4NeutronHPJENDLHEData::G4double result
G4Region * GetRegion() const
virtual ~G4MagneticFieldModel()
G4FieldManager * GetFieldManager() const
virtual void DescribeYourselfTo(G4VGraphicsScene &)
G4GLOB_DLL std::ostream G4cout
G4bool DoesFieldExist() const
G4String fGlobalDescription
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)
G4MagneticFieldModel(G4int nDataPointsPerHalfScene=10)
virtual void DescribeYourselfTo(G4VGraphicsScene &)
const G4Field * GetDetectorField() const