BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSIntegratorSetType.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 "BDSDebug.hh"
19#include "BDSException.hh"
20#include "BDSIntegratorSetType.hh"
21#include "BDSUtilities.hh"
22
23#include "globals.hh"
24#include "G4String.hh"
25
26#include <map>
27#include <string>
28
29template<>
30std::map<BDSIntegratorSetType, std::string>* BDSIntegratorSetType::dictionary =
31 new std::map<BDSIntegratorSetType, std::string> ({
32 {BDSIntegratorSetType::geant4, "geant4"},
33 {BDSIntegratorSetType::bdsimone, "bdsimone"},
34 {BDSIntegratorSetType::bdsimtwo, "bdsimtwo"},
35 {BDSIntegratorSetType::bdsimmatrix, "bdsimmatrix"},
36 {BDSIntegratorSetType::bdsimmatrixfringescaling, "bdsimmatrixfringescaling"}
37#if G4VERSION_NUMBER > 1039
38 ,
39 {BDSIntegratorSetType::geant4dp, "geant4dp"}
40#endif
41 });
42
44{
45 std::map<G4String, BDSIntegratorSetType> types;
46 types["bdsim"] = BDSIntegratorSetType::bdsimtwo; // alias for bdsim two the default
47 types["geant4"] = BDSIntegratorSetType::geant4;
48 types["bdsimone"] = BDSIntegratorSetType::bdsimone;
49 types["bdsimtwo"] = BDSIntegratorSetType::bdsimtwo;
50 types["bdsimmatrix"] = BDSIntegratorSetType::bdsimmatrix;
51 types["bdsimmatrixfringescaling"] = BDSIntegratorSetType::bdsimmatrixfringescaling;
52#if G4VERSION_NUMBER > 1039
53 types["geant4dp"] = BDSIntegratorSetType::geant4dp;
54#endif
55
56 integratorSet = BDS::LowerCase(integratorSet);
57
58 auto result = types.find(integratorSet);
59 if (result == types.end())
60 {// it's not a valid key
61 G4String msg = "\"" + integratorSet + "\" is not a valid integrator set\n";
62 msg += "Available sets are:\n";
63 for (const auto& it : types)
64 {msg += "\"" + it.first + "\"\n";}
65 throw BDSException(__METHOD_NAME__, msg);
66 }
67
68#ifdef BDSDEBUG
69 G4cout << __METHOD_NAME__ << "determined integrator set to be " << result->second << G4endl;
70#endif
71 return result->second;
72}
General exception with possible name of object and message.
static std::map< BDSTypeSafeEnum< integratorsettype_def, int >, std::string > * dictionary
BDSIntegratorSetType DetermineIntegratorSetType(G4String integratorSet)
Function that gives corresponding enum value for string (case-insensitive)
G4String LowerCase(const G4String &str)
Utility function to simplify lots of syntax changes for pedantic g4 changes.