19#include "BDSFieldQueryForVis.hh"
20#include "BDSFieldQueryInfo.hh"
22#include "G4ThreeVector.hh"
32BDSFieldQueryForVis::BDSFieldQueryForVis():
35 drawZeroValuePoints(false)
38BDSFieldQueryForVis::~BDSFieldQueryForVis()
45 maxFieldB = -std::numeric_limits<G4double>::max();
46 maxFieldE = -std::numeric_limits<G4double>::max();
51 G4int totalNPoints = query->xInfo.n * query->yInfo.n * query->zInfo.n * query->tInfo.n;
52 values.reserve(totalNPoints);
53 drawZeroValuePoints = query->drawZeroValuePoints;
58 const G4ThreeVector& globalDirection,
60 G4double fieldValue[6])
63 G4double bFieldMag =
SimpleMag(fieldValue[0], fieldValue[1], fieldValue[2]);
64 G4double eFieldMag =
SimpleMag(fieldValue[3], fieldValue[4], fieldValue[5]);
65 maxFieldB = std::max(maxFieldB, bFieldMag);
66 maxFieldE = std::max(maxFieldE, eFieldMag);
67 if ( (bFieldMag == 0) && (eFieldMag == 0) && !drawZeroValuePoints)
69 values.emplace_back( std::array<G4double, 9>({globalXYZ.x(), globalXYZ.y(), globalXYZ.z(),
70 fieldValue[0], fieldValue[1], fieldValue[2],
71 fieldValue[3], fieldValue[4], fieldValue[5]}) );
76 return std::sqrt(x*x + y*y + z*z);
virtual void GetFieldValue(const G4ThreeVector &globalXYZ, const G4ThreeVector &globalDirection, G4double tGlobal, G4double fieldValue[6])
Call base class method but make a copy of the global position and fields in this class.
virtual void QueryField(const BDSFieldQueryInfo *query)
Reserve the vector size we need first, then proceed as normal. Avoids big copies.
virtual void CleanUp()
Call the base class method and also clear the vector of values in this class.
static G4double SimpleMag(G4double x, G4double y, G4double z)
Calculate magnitude of 3-vector without having to construct one.
Holder class for all information required for a field query.
virtual void CleanUp()
Reset any member variables used during a query. Closes any files if open.
virtual void QueryField(const BDSFieldQueryInfo *query)
Query the field in the Geant4 model according to information in query.
virtual void GetFieldValue(const G4ThreeVector &globalXYZ, const G4ThreeVector &globalDirection, G4double tGlobal, G4double fieldValue[6])