BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSFieldQueryRaw.cc
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) BDSIM Collaboration, 2001 - 2026.
3
4This file is part of BDSIM.
5
6BDSIM is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published
8by the Free Software Foundation version 3 of the License.
9
10BDSIM is distributed in the hope that it will be useful, but
11WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
17*/
18#include "BDSFieldQueryInfo.hh"
19#include "BDSFieldQueryRaw.hh"
20#include "BDSWarning.hh"
21
22#include "G4Field.hh"
23#include "G4String.hh"
24#include "G4ThreeVector.hh"
25#include "G4Types.hh"
26
27BDSFieldQueryRaw::BDSFieldQueryRaw():
28 field(nullptr)
29{;}
30
31BDSFieldQueryRaw::~BDSFieldQueryRaw()
32{;}
33
34void BDSFieldQueryRaw::QueryFieldRaw(G4Field* fieldIn,
35 const BDSFieldQueryInfo* query)
36{
37 field = fieldIn;
38 QueryField(query);
39}
40
41void BDSFieldQueryRaw::GetFieldValue(const G4ThreeVector& globalXYZ,
42 const G4ThreeVector& /*globalDirection*/,
43 G4double tGlobal,
44 G4double fieldValue[6])
45{
46 for (G4int i = 0; i < 6; i++)
47 {fieldValue[i] = 0;}
48 if (!field)
49 {return;}
50 G4double position[4] = {globalXYZ.x(), globalXYZ.y(),globalXYZ.z(), tGlobal};
51 field->GetFieldValue(position, fieldValue);
52}
53
55{
56 if (query->fieldObject.empty())
57 {
58 G4String msg = "\"fieldObject\" variable is empty in query definition \"" + query->name;
59 msg += "\" - it must have a value";
60 BDS::Warning(msg);
61 }
62}
Holder class for all information required for a field query.
G4String fieldObject
Optional for use in interpolator.
G4Field * field
The field object to query.
virtual void CheckIfFieldObjectSpecified(const BDSFieldQueryInfo *query) const
void QueryFieldRaw(G4Field *field, 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])
virtual void QueryField(const BDSFieldQueryInfo *query)
Query the field in the Geant4 model according to information in query.