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