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) 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 "BDSBunchGauss.hh"
19#include "BDSBunchGaussSlowExtBase.hh"
20#include "BDSBunchSlowExt.hh"
21#include "BDSDebug.hh"
22#include "BDSWarning.hh"
23
24#include "parser/beam.h"
25
26BDSBunchGaussSlowExtBase::BDSBunchGaussSlowExtBase(const G4String& nameIn):
27 BDSBunch(nameIn),
28 gauss(nullptr),
29 slowext(new BDSBunchSlowExt())
30{;}
31
32BDSBunchGaussSlowExtBase::~BDSBunchGaussSlowExtBase()
33{
34 delete gauss;
35 delete slowext;
36}
37
39 const GMAD::Beam& beam,
40 const BDSBunchType& distrType,
41 G4Transform3D beamlineTransformIn,
42 const G4double beamlineSIn)
43{
44 BDSBunch::SetOptions(beamParticle, beam, distrType, beamlineTransformIn, beamlineSIn);
45
46 gauss->SetOptions(beamParticle, beam, distrType, beamlineTransformIn, beamlineSIn);
47 slowext->SetOptions(beamParticle, beam, distrType, beamlineTransformIn, beamlineSIn);
48
49 if (gauss->OffsetSampleMean())
50 {BDS::Warning(__METHOD_NAME__, "offsetSampleMean will only work for the Gaussian component of this slow extracted distribution");}
51}
52
58
60{
61 auto pGauss = gauss->GetNextParticleLocal();
62 G4double dtLocal, dELocal;
63 slowext->GetDeltas(dtLocal, dELocal);
64 pGauss.totalEnergy += dELocal;
65 pGauss.T += dtLocal;
66 return pGauss;
67}
68
70 G4bool batchMode)
71{
72 gauss->BeginOfRunAction(numberOfEvents, batchMode);
73}
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:46
virtual void SetOptions(const BDSParticleDefinition *beamParticle, const GMAD::Beam &beam, const BDSBunchType &distrType, G4Transform3D beamlineTransformIn=G4Transform3D::Identity, const G4double beamlineS=0)
Definition BDSBunch.cc:81
virtual void CheckParameters()
Definition BDSBunch.cc:222
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:43