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