BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSPrimaryVertexInformation.cc
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3University of London 2001 - 2023.
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 "BDSParticleCoordsFullGlobal.hh"
20#include "BDSParticleDefinition.hh"
21#include "BDSPrimaryVertexInformation.hh"
22
23#include "globals.hh"
24#include "G4ParticleDefinition.hh"
25
26#include "CLHEP/Units/PhysicalConstants.h"
27
28BDSPrimaryVertexInformation:: BDSPrimaryVertexInformation(const BDSParticleCoordsFullGlobal& primaryVertexIn,
29 const BDSParticleDefinition* particle):
30 primaryVertex(primaryVertexIn),
31 momentum(0),
32 charge(particle->Charge()),
33 rigidity(0),
34 mass(particle->Mass()),
35 pdgID(particle->ParticleDefinition()->GetPDGEncoding()),
36 nElectrons(particle->NElectrons())
37{
38 // temporarily construct one of our particle definitions to calculate momentum and rigidity
39 // for this particular particle. Note, "particle" is the general bunch particle, not the individual coords.
40 auto thisParticle = new BDSParticleDefinition(particle->ParticleDefinition(),
41 primaryVertexIn.local.totalEnergy, 0, 0,
42 particle->FFact(),
43 particle->IonDefinition());
44 momentum = thisParticle->Momentum();
45 rigidity = thisParticle->BRho();
46 delete thisParticle;
47}
48
49BDSPrimaryVertexInformation::BDSPrimaryVertexInformation(const BDSParticleCoordsFullGlobal& primaryVertexIn,
50 G4double momentumIn,
51 G4double chargeIn,
52 G4double rigidityIn,
53 G4double massIn,
54 G4int pdgIDIn,
55 G4int nElectronsIn):
56 primaryVertex(primaryVertexIn),
57 momentum(momentumIn),
58 charge(chargeIn),
59 rigidity(rigidityIn),
60 mass(massIn),
61 pdgID(pdgIDIn),
62 nElectrons(nElectronsIn)
63{;}
64
66{
67 G4cout << primaryVertex << G4endl;
68 G4cout << "Primary particle charge " << charge / CLHEP::eplus << G4endl;
69}
A set of particle coordinates in both local and global.
Wrapper for particle definition.
G4ParticleDefinition * ParticleDefinition() const
Accessor.
G4double FFact() const
Accessor.
BDSIonDefinition * IonDefinition() const
Accessor.
virtual void Print() const
Required implementation by virtual base class.
G4double charge
Effective charge of primary.
BDSParticleCoordsFullGlobal primaryVertex
Full set of coordinates.