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) 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 "BDSDebug.hh"
20#include "BDSException.hh"
21#include "BDSScorerType.hh"
22#include "BDSUtilities.hh"
23
24#include "globals.hh"
25#include "G4String.hh"
26
27#include <map>
28#include <string>
29
31template<>
32std::map<BDSScorerType, std::string>* BDSScorerType::dictionary =
33 new std::map<BDSScorerType, std::string> ({
34 {BDSScorerType::cellcharge, "cellcharge"},
35 {BDSScorerType::cellcharge3d, "cellcharge3d"},
36 {BDSScorerType::depositeddose, "depositeddose"},
37 {BDSScorerType::depositeddose3d, "depositeddose3d"},
38 {BDSScorerType::depositedenergy, "depositedenergy"},
39 {BDSScorerType::depositedenergyblm, "depositedenergyblm"},
40 {BDSScorerType::depositedenergy, "depositedenergy3d"},
41 {BDSScorerType::population, "population"},
42 {BDSScorerType::population3d, "population3d"},
43 {BDSScorerType::populationscaled, "populationscaled"},
44 {BDSScorerType::cellflux, "cellflux"},
45 {BDSScorerType::cellflux3d, "cellflux3d"},
46 {BDSScorerType::cellfluxscaled, "cellfluxscaled"},
47 {BDSScorerType::cellfluxscaled3d, "cellfluxscaled3d"},
48 {BDSScorerType::cellfluxscaledperparticle, "cellfluxscaledperparticle"},
49 {BDSScorerType::cellfluxscaledperparticle3d, "cellfluxscaledperparticle3d"},
50 {BDSScorerType::cellflux4d,"cellflux4d"}
51 });
52
54{
55 std::map<G4String, BDSScorerType> types;
56 types["cellcharge"] = BDSScorerType::cellcharge;
57 types["cellcharge3d"] = BDSScorerType::cellcharge3d;
58 types["depositeddose"] = BDSScorerType::depositeddose;
59 types["depositeddose3d"] = BDSScorerType::depositeddose3d;
60 types["depositedenergy"] = BDSScorerType::depositedenergy;
61 types["depostiedenergyblm"] = BDSScorerType::depositedenergyblm;
62 types["depositedenergy3d"] = BDSScorerType::depositedenergy3d;
63 types["population"] = BDSScorerType::population;
64 types["population3d"] = BDSScorerType::population3d;
65 types["populationscaled"] = BDSScorerType::populationscaled;
66 types["cellflux"] = BDSScorerType::cellflux;
67 types["cellflux3d"] = BDSScorerType::cellflux3d;
68 types["cellfluxscaled"] = BDSScorerType::cellfluxscaled;
69 types["cellfluxscaled3d"] = BDSScorerType::cellfluxscaled3d;
70 types["cellfluxscaledperparticle"] = BDSScorerType::cellfluxscaledperparticle;
71 types["cellfluxscaledperparticle3d"] = BDSScorerType::cellfluxscaledperparticle3d;
72 types["cellflux4d"] = BDSScorerType::cellflux4d;
73
74 scorerType = BDS::LowerCase(scorerType);
75
76 auto result = types.find(scorerType);
77 if (result == types.end())
78 {// it's not a valid key
79 G4String msg = "\"" + scorerType + "\" is not a valid scorer type\n";
80 msg += "Available scorer types are:\n";
81 for (const auto& it : types)
82 {msg += "\"" + it.first + "\"\n";}
83 throw BDSException(__METHOD_NAME__, msg);
84 }
85
86#ifdef BDSDEBUG
87 G4cout << __METHOD_NAME__ << " determined scorer type to be " << result->second << G4endl;
88#endif
89 return result->second;
90}
General exception with possible name of object and message.
Definition: BDSException.hh:35
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.