BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSScorerType.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 "BDSScorerType.hh"
21#include "BDSUtilities.hh"
22
23#include "globals.hh"
24#include "G4String.hh"
25
26#include <map>
27#include <string>
28
30template<>
31std::map<BDSScorerType, std::string>* BDSScorerType::dictionary =
32 new std::map<BDSScorerType, std::string> ({
33 {BDSScorerType::cellcharge, "cellcharge"},
34 {BDSScorerType::cellcharge3d, "cellcharge3d"},
35 {BDSScorerType::depositeddose, "depositeddose"},
36 {BDSScorerType::depositeddose3d, "depositeddose3d"},
37 {BDSScorerType::depositedenergy, "depositedenergy"},
38 {BDSScorerType::depositedenergyblm, "depositedenergyblm"},
39 {BDSScorerType::depositedenergy, "depositedenergy3d"},
40 {BDSScorerType::population, "population"},
41 {BDSScorerType::population3d, "population3d"},
42 {BDSScorerType::populationscaled, "populationscaled"},
43 {BDSScorerType::cellflux, "cellflux"},
44 {BDSScorerType::cellflux3d, "cellflux3d"},
45 {BDSScorerType::cellfluxscaled, "cellfluxscaled"},
46 {BDSScorerType::cellfluxscaled3d, "cellfluxscaled3d"},
47 {BDSScorerType::cellfluxscaledperparticle, "cellfluxscaledperparticle"},
48 {BDSScorerType::cellfluxscaledperparticle3d, "cellfluxscaledperparticle3d"},
49 {BDSScorerType::cellflux4d,"cellflux4d"}
50 });
51
53{
54 std::map<G4String, BDSScorerType> types;
55 types["cellcharge"] = BDSScorerType::cellcharge;
56 types["cellcharge3d"] = BDSScorerType::cellcharge3d;
57 types["depositeddose"] = BDSScorerType::depositeddose;
58 types["depositeddose3d"] = BDSScorerType::depositeddose3d;
59 types["depositedenergy"] = BDSScorerType::depositedenergy;
60 types["depostiedenergyblm"] = BDSScorerType::depositedenergyblm;
61 types["depositedenergy3d"] = BDSScorerType::depositedenergy3d;
62 types["population"] = BDSScorerType::population;
63 types["population3d"] = BDSScorerType::population3d;
64 types["populationscaled"] = BDSScorerType::populationscaled;
65 types["cellflux"] = BDSScorerType::cellflux;
66 types["cellflux3d"] = BDSScorerType::cellflux3d;
67 types["cellfluxscaled"] = BDSScorerType::cellfluxscaled;
68 types["cellfluxscaled3d"] = BDSScorerType::cellfluxscaled3d;
69 types["cellfluxscaledperparticle"] = BDSScorerType::cellfluxscaledperparticle;
70 types["cellfluxscaledperparticle3d"] = BDSScorerType::cellfluxscaledperparticle3d;
71 types["cellflux4d"] = BDSScorerType::cellflux4d;
72
73 scorerType = BDS::LowerCase(scorerType);
74
75 auto result = types.find(scorerType);
76 if (result == types.end())
77 {// it's not a valid key
78 G4String msg = "\"" + scorerType + "\" is not a valid scorer type\n";
79 msg += "Available scorer types are:\n";
80 for (const auto& it : types)
81 {msg += "\"" + it.first + "\"\n";}
82 throw BDSException(__METHOD_NAME__, msg);
83 }
84
85#ifdef BDSDEBUG
86 G4cout << __METHOD_NAME__ << " determined scorer type to be " << result->second << G4endl;
87#endif
88 return result->second;
89}
General exception with possible name of object and message.
static std::map< BDSTypeSafeEnum< scorertype_def, int >, std::string > * dictionary
BDSScorerType DetermineScorerType(G4String scorerType)
function to determine the enum type of the cavity geometry (case-insensitive)
G4String LowerCase(const G4String &str)
Utility function to simplify lots of syntax changes for pedantic g4 changes.