BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSModulatorTopHatT.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 "BDSModulatorTopHatT.hh"
22
23#include "G4String.hh"
24
25#include <string>
26
27BDSModulatorTopHatT::BDSModulatorTopHatT(G4double T0In,
28 G4double T1In,
29 G4double amplitudeScaleIn):
30 T0(T0In),
31 T1(T1In),
32 scale(amplitudeScaleIn)
33{
34 if (T1 < T0)
35 {
36 G4String msg = "T1 (" + std::to_string(T1) + ") must be greater equal than T0 (";
37 msg += std::to_string(T0) + ")";
38 throw BDSException(__METHOD_NAME__, msg);
39 }
40}
41
42G4double BDSModulatorTopHatT::Factor(const G4ThreeVector& /*xyz*/,
43 G4double T) const
44{
45 return T <= T1 && T >= T0 ? scale : 0;
46}
47
49{
50 G4double dT = T1 - T0;
51 return dT / 20;
52}
General exception with possible name of object and message.
Definition: BDSException.hh:35
virtual G4double RecommendedMaxStepLength() const
Return difference in T0, T1 / 20.
virtual G4double Factor(const G4ThreeVector &xyz, G4double T) const
Returns value of equation in brief at the top of this file.