BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
modulator.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 MODULATOR_H
19#define MODULATOR_H
20
21#include <iomanip>
22#include <iostream>
23#include <string>
24
25#include "published.h"
26
27namespace GMAD
28{
35 class Modulator: public Published<Modulator>
36 {
37 public:
38 std::string name;
39 std::string type;
40 double frequency;
41 double phase;
42 double tOffset;
45
46 double T0;
47 double T1;
48
50 Modulator();
52 void clear();
54 void print()const;
56 template <typename T>
57 void set_value(std::string property, T value, bool bExit = true);
58
59 private:
61 void PublishMembers();
62 };
63
64 template <typename T>
65 void Modulator::set_value(std::string property, T value, bool bExit)
66 {
67#ifdef BDSDEBUG
68 std::cout << "modulator> setting value " << std::setw(25) << std::left << property << value << std::endl;
69#endif
70 // member method can throw runtime_error, catch and exit gracefully
71 try
72 {set(this,property,value);}
73 catch(const std::runtime_error&)
74 {
75 std::cerr << "Error: modulator> unknown parameter \"" << property << "\" with value " << value << std::endl;
76 if (bExit)
77 {exit(1);}
78 else
79 {std::rethrow_exception(std::current_exception());} // to be caught by python
80 }
81 }
82}
83
84#endif
Modulator class for parser.
Definition modulator.h:36
double tOffset
time offset used for phase calculation (ns) for modulator on top of rf cavity
Definition modulator.h:42
double T0
'on' time
Definition modulator.h:46
void clear()
Reset.
Definition modulator.cc:28
double amplitudeOffset
numerical value added to -1 -> 1 modulator as offset
Definition modulator.h:43
void set_value(std::string property, T value, bool bExit=true)
Set methods by property name and value.
Definition modulator.h:65
void print() const
Print some properties.
Definition modulator.cc:54
double frequency
frequency of modulation on top of rf cavity in Hz
Definition modulator.h:40
double T1
'off' time
Definition modulator.h:47
Modulator()
Constructor.
Definition modulator.cc:22
void PublishMembers()
publish members
Definition modulator.cc:41
double amplitudeScale
multiplier for amplitude of modulation
Definition modulator.h:44
double phase
phase of modulation oscillator on top of rf cavity
Definition modulator.h:41
Class that provides introspection to its members.
Definition published.h:48
void set(Modulator *instance, const std::string &name, double value)
Definition published.h:100
Parser namespace for GMAD language. Combination of Geant4 and MAD.