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