BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
BDSIntegratorDrift.cc
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3University of London 2001 - 2022.
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 "BDSIntegratorDrift.hh"
20
21#include "G4ThreeVector.hh"
22
23BDSIntegratorDrift::BDSIntegratorDrift()
24{;}
25
26BDSIntegratorDrift::~BDSIntegratorDrift()
27{;}
28
29void BDSIntegratorDrift::AdvanceDriftMag(const G4double yIn[],
30 const G4double h,
31 G4double yOut[],
32 G4double yErr[]) const
33{
34 G4ThreeVector unitMomentum = G4ThreeVector(yIn[3],yIn[4],yIn[5]).unit();
35
36 AdvanceDriftMag(yIn, unitMomentum, h, yOut, yErr);
37}
38
39void BDSIntegratorDrift::AdvanceDriftMag(const G4double yIn[],
40 const G4ThreeVector& unitMomentum,
41 const G4double h,
42 G4double yOut[],
43 G4double yErr[]) const
44{
45 for (G4int i = 0; i < 3; i++)
46 {
47 yOut[i] = yIn[i] + h * unitMomentum[i]; // update position
48 yOut[i+3] = yIn[i+3]; // momentum doesn't change
49 yErr[i] = 0;
50 yErr[i+3] = 0;
51 }
52}
void AdvanceDriftMag(const G4double yIn[], const G4double h, G4double yOut[], G4double yErr[]) const
Error array [6] all 0.