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