BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSBunchGaussSlowExtBase.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 "BDSBunchGauss.hh"
20#include "BDSBunchGaussSlowExtBase.hh"
21#include "BDSBunchSlowExt.hh"
22#include "BDSDebug.hh"
23#include "BDSWarning.hh"
24
25#include "parser/beam.h"
26
27BDSBunchGaussSlowExtBase::BDSBunchGaussSlowExtBase(const G4String& nameIn):
28 BDSBunch(nameIn),
29 gauss(nullptr),
30 slowext(new BDSBunchSlowExt())
31{;}
32
33BDSBunchGaussSlowExtBase::~BDSBunchGaussSlowExtBase()
34{
35 delete gauss;
36 delete slowext;
37}
38
40 const GMAD::Beam& beam,
41 const BDSBunchType& distrType,
42 G4Transform3D beamlineTransformIn,
43 const G4double beamlineSIn)
44{
45 BDSBunch::SetOptions(beamParticle, beam, distrType, beamlineTransformIn, beamlineSIn);
46
47 gauss->SetOptions(beamParticle, beam, distrType, beamlineTransformIn, beamlineSIn);
48 slowext->SetOptions(beamParticle, beam, distrType, beamlineTransformIn, beamlineSIn);
49
50 if (gauss->OffsetSampleMean())
51 {BDS::Warning(__METHOD_NAME__, "offsetSampleMean will only work for the Gaussian component of this slow extracted distribution");}
52}
53
59
61{
62 auto pGauss = gauss->GetNextParticleLocal();
63 G4double dtLocal, dELocal;
64 slowext->GetDeltas(dtLocal, dELocal);
65 pGauss.totalEnergy += dELocal;
66 pGauss.T += dtLocal;
67 return pGauss;
68}
69
71 G4bool batchMode)
72{
73 gauss->BeginOfRunAction(numberOfEvents, batchMode);
74}
virtual BDSParticleCoordsFull GetNextParticleLocal()
virtual void SetOptions(const BDSParticleDefinition *beamParticle, const GMAD::Beam &beam, const BDSBunchType &distrType, G4Transform3D beamlineTransformIn=G4Transform3D::Identity, const G4double beamlineS=0)
virtual void BeginOfRunAction(G4int numberOfEvents, G4bool batchMode)
virtual void SetOptions(const BDSParticleDefinition *beamParticle, const GMAD::Beam &beam, const BDSBunchType &distrType, G4Transform3D beamlineTransformIn=G4Transform3D::Identity, const G4double beamlineS=0)
virtual void BeginOfRunAction(G4int numberOfEvents, G4bool batchMode)
virtual BDSParticleCoordsFull GetNextParticleLocal()
A bunch distribution with a linear sweep in momentum in time.
virtual void CheckParameters()
virtual void SetOptions(const BDSParticleDefinition *beamParticle, const GMAD::Beam &beam, const BDSBunchType &distrType, G4Transform3D beamlineTransformIn=G4Transform3D::Identity, const G4double beamlineS=0)
void GetDeltas(G4double &dt, G4double &dE) const
The base class for bunch distribution generators.
Definition BDSBunch.hh:47
virtual void SetOptions(const BDSParticleDefinition *beamParticle, const GMAD::Beam &beam, const BDSBunchType &distrType, G4Transform3D beamlineTransformIn=G4Transform3D::Identity, const G4double beamlineS=0)
Definition BDSBunch.cc:82
virtual void CheckParameters()
Definition BDSBunch.cc:223
A set of particle coordinates including energy and weight.
Wrapper for particle definition.
Improve type-safety of native enum data type in C++.
Beam class.
Definition beam.h:44