53 (
G4int nDataPointsPerMaxHalfScene,
55 G4int arrow3DLineSegmentsPerCircle)
56 : fNDataPointsPerMaxHalfScene(nDataPointsPerMaxHalfScene)
57 , fRepresentation(representation)
58 , fArrow3DLineSegmentsPerCircle(arrow3DLineSegmentsPerCircle)
60 fType =
"G4MagneticFieldModel";
62 std::ostringstream oss;
63 oss <<
':' << fNDataPointsPerMaxHalfScene
64 <<
':' << fArrow3DLineSegmentsPerCircle;
65 fGlobalDescription = fType + oss.str();
79 const G4double xHalfScene = 0.5 * (xMax - xMin);
80 const G4double yHalfScene = 0.5 * (yMax - yMin);
81 const G4double zHalfScene = 0.5 * (zMax - zMin);
82 const G4double xSceneCentre = 0.5 * (xMax + xMin);
83 const G4double ySceneCentre = 0.5 * (yMax + yMin);
84 const G4double zSceneCentre = 0.5 * (zMax + zMin);
87 if (maxHalfScene <= 0.) {
89 <<
"Extent non-positive."
101 const G4Field* globalField = 0;
102 const G4String intro =
"G4MagneticFieldModel::DescribeYourselfTo: ";
103 if (globalFieldMgr) {
107 static G4bool warned =
false;
110 <<
"Null global field pointer."
117 static G4bool warned =
false;
120 <<
"No global field manager."
128 const G4int nDataPointsPerXHalfScene =
G4int(xHalfScene / interval);
129 const G4int nDataPointsPerYHalfScene =
G4int(yHalfScene / interval);
130 const G4int nDataPointsPerZHalfScene =
G4int(zHalfScene / interval);
131 const G4int nXSamples = 2 * nDataPointsPerXHalfScene + 1;
132 const G4int nYSamples = 2 * nDataPointsPerYHalfScene + 1;
133 const G4int nZSamples = 2 * nDataPointsPerZHalfScene + 1;
134 const G4int nSamples = nXSamples * nYSamples * nZSamples;
135 const G4int nSamples3 = nSamples * 3;
136 const G4double arrowLengthMax = 0.8 * interval;
137 const G4int nResults = 6;
140 double position_time[4] = {0,0,0,0};
144 std::vector<G4double> BField(nSamples3);
145 std::vector<G4double> BFieldMagnitude(nSamples);
146 std::vector<G4double> xyz(nSamples3);
150 for (
G4int i = 0; i < nXSamples; i++) {
151 G4double x = xSceneCentre + (i - nDataPointsPerXHalfScene) * interval;
152 position_time[0] =
x;
153 for (
G4int j = 0; j < nYSamples; j++) {
154 G4double y = ySceneCentre + (j - nDataPointsPerYHalfScene) * interval;
155 position_time[1] =
y;
156 for (
G4int k = 0; k < nZSamples; k++) {
157 G4double z = zSceneCentre + (k - nDataPointsPerZHalfScene) * interval;
158 position_time[2] =
z;
160 const G4int ijk = i * nYSamples * nZSamples + j * nZSamples + k;
161 const G4int ijk3 = ijk * 3;
166 const G4Field* field = globalField;
175 if (pRegionFieldMgr) {
199 for (
G4int l = 0; l < 3; l++) {
200 BField[ijk3 + l] = result[l];
204 (result[0]*result[0]+result[1]*result[1]+result[2]*result[2]);
205 BFieldMagnitude[ijk] = mag;
211 if (mag > BFieldMagnitudeMax) {
212 BFieldMagnitudeMax = mag;
219 if (BFieldMagnitudeMax <= 0) {
221 <<
"No field in this scene."
227 for (
G4int i = 0; i < nSamples; i++) {
228 if (BFieldMagnitude[i] > 0) {
229 const G4int i3 = i * 3;
248 const G4double f = B / BFieldMagnitudeMax;
252 blue = 2. * (0.5 -
f);
254 red = 2. * (f - 0.5);
255 green = 2. * (1.0 -
f);
258 const G4double arrowLength = arrowLengthMax *
f;
266 const G4double z2 = z1 + arrowLength * Bz /
B;
268 G4ArrowModel BArrow(x1,y1,z1,x2,y2,z2,arrowLength/5,arrowColour,
276 BArrowLite.push_back(
G4Point3D(x1,y1,z1));
277 BArrowLite.push_back(
G4Point3D(x2,y2,z2));
T max(const T t1, const T t2)
brief Return the largest of the two arguments
static const G4double pos
G4LogicalVolume * GetLogicalVolume() const
Float_t y1[n_points_granero]
G4MagneticFieldModel(G4int nDataPointsPerHalfScene=10, Representation representation=Representation::fullArrow, G4int arrow3DLineSegmentsPerCircle=6)
Float_t x1[n_points_granero]
virtual void EndPrimitives()=0
G4bool DoesFieldExist() const
virtual void GetFieldValue(const double Point[4], double *fieldArr) const =0
G4Navigator * GetNavigatorForTracking() const
virtual void BeginPrimitives(const G4Transform3D &objectTransformation=G4Transform3D())=0
G4FieldManager * GetFieldManager() const
Float_t y2[n_points_geant4]
virtual const G4VisExtent & GetExtent() const
G4FieldManager * GetFieldManager() const
G4int fNDataPointsPerMaxHalfScene
static const G4double alpha
const G4Field * GetDetectorField() const
virtual void DescribeYourselfTo(G4VGraphicsScene &)
virtual ~G4MagneticFieldModel()
virtual void AddPrimitive(const G4Polyline &)=0
virtual void DescribeYourselfTo(G4VGraphicsScene &)
G4double G4ParticleHPJENDLHEData::G4double result
static G4TransportationManager * GetTransportationManager()
Representation fRepresentation
G4int fArrow3DLineSegmentsPerCircle
G4GLOB_DLL std::ostream G4cout
G4FieldManager * GetFieldManager() const
virtual G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=0, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true)
Float_t x2[n_points_geant4]
double B(double temperature)
HepGeom::Point3D< G4double > G4Point3D
G4Region * GetRegion() const
void SetVisAttributes(const G4VisAttributes *)