BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
scorer.h
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#ifndef SCORER_H
20#define SCORER_H
21
22#include <iomanip>
23#include <iostream>
24#include <string>
25
26#include "published.h"
27
28namespace GMAD
29{
36 class Scorer : public Published<Scorer>
37 {
38 public:
39 std::string name;
40 std::string type;
41 std::string particleName;
43 double minimumKineticEnergy;
44 double maximumKineticEnergy;
45 double minimumTime;
46 double maximumTime;
47 std::string conversionFactorFile;
48 std::string conversionFactorPath;
49 std::string materialToInclude;
50 std::string materialToExclude;
51 bool scoreWorldVolumeOnly;
52 bool scorePrimariesOnly;
53
55 Scorer();
57 void clear();
59 void print()const;
61 template <typename T>
62 void set_value(std::string property, T value);
63
64 private:
66 void PublishMembers();
67 };
68
69 template <typename T>
70 void Scorer::set_value(std::string property, T value)
71 {
72#ifdef BDSDEBUG
73 std::cout << "scorer> Setting value " << std::setw(25) << std::left << property << value << std::endl;
74#endif
75 // member method can throw runtime_error, catch and exit gracefully
76 try
77 {set(this,property,value);}
78 catch (const std::runtime_error&)
79 {
80 std::cerr << "Error: scorer> unknown option \"" << property << "\" with value \"" << value << "\"" << std::endl;
81 exit(1);
82 }
83 }
84}
85
86#endif
Class that provides introspection to its members.
Definition: published.h:47
void set(Scorer *instance, const std::string &name, double value)
Definition: published.h:99
Scorer class for parser.
Definition: scorer.h:37
std::string name
Name.
Definition: scorer.h:39
void set_value(std::string property, T value)
Set methods by property name and value.
Definition: scorer.h:70
void clear()
Reset.
Definition: scorer.cc:29
Scorer()
Constructor.
Definition: scorer.cc:23
void PublishMembers()
publish members
Definition: scorer.cc:46
int particlePDGID
PDG ID code for particle.
Definition: scorer.h:42
void print() const
Print some properties.
Definition: scorer.cc:64
std::string type
Type of the scorer, ie forumula.
Definition: scorer.h:40
std::string particleName
Particle name as a string.
Definition: scorer.h:41
Parser namespace for GMAD language. Combination of Geant4 and MAD.