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) Royal Holloway,
3University of London 2001 - 2024.
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 "BDSModulatorLinearT.hh"
22
23#include "G4String.hh"
24
25#include "CLHEP/Units/SystemOfUnits.h"
26
27#include <string>
28
29BDSModulatorLinearT::BDSModulatorLinearT(G4double T0In,
30 G4double T1In,
31 G4double slopeIn,
32 G4double yInterceptIn):
33 T0(T0In),
34 T1(T1In),
35 slope(slopeIn / CLHEP::s),
36 yIntercept(yInterceptIn)
37{
38 if (T1 < T0)
39 {
40 G4String msg = "T1 (" + std::to_string(T1) + ") must be greater equal than T0 (";
41 msg += std::to_string(T0) + ")";
42 throw BDSException(__METHOD_NAME__, msg);
43 }
44}
45
46G4double BDSModulatorLinearT::Factor(const G4ThreeVector& /*xyz*/,
47 G4double T) const
48{
49 return T <= T1 && T >= T0 ? yIntercept + slope * T : 0;
50}
51
53{
54 G4double dT = T1 - T0;
55 return dT / 20;
56}
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.