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) 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 "BDSParticleCoordsFullGlobal.hh"
19#include "BDSParticleDefinition.hh"
20#include "BDSPrimaryVertexInformation.hh"
21
22#include "globals.hh"
23#include "G4ParticleDefinition.hh"
24
25#include "CLHEP/Units/PhysicalConstants.h"
26
27BDSPrimaryVertexInformation:: BDSPrimaryVertexInformation(const BDSParticleCoordsFullGlobal& primaryVertexIn,
28 const BDSParticleDefinition* particle):
29 primaryVertex(primaryVertexIn),
30 momentum(0),
31 charge(particle->Charge()),
32 rigidity(0),
33 mass(particle->Mass()),
34 pdgID(particle->ParticleDefinition()->GetPDGEncoding()),
35 nElectrons(particle->NElectrons())
36{
37 // temporarily construct one of our particle definitions to calculate momentum and rigidity
38 // for this particular particle. Note, "particle" is the general bunch particle, not the individual coords.
39 auto thisParticle = new BDSParticleDefinition(particle->ParticleDefinition(),
40 primaryVertexIn.local.totalEnergy, 0, 0,
41 particle->FFact(),
42 particle->IonDefinition());
43 momentum = thisParticle->Momentum();
44 rigidity = thisParticle->BRho();
45 delete thisParticle;
46}
47
48BDSPrimaryVertexInformation::BDSPrimaryVertexInformation(const BDSParticleCoordsFullGlobal& primaryVertexIn,
49 G4double momentumIn,
50 G4double chargeIn,
51 G4double rigidityIn,
52 G4double massIn,
53 G4int pdgIDIn,
54 G4int nElectronsIn):
55 primaryVertex(primaryVertexIn),
56 momentum(momentumIn),
57 charge(chargeIn),
58 rigidity(rigidityIn),
59 mass(massIn),
60 pdgID(pdgIDIn),
61 nElectrons(nElectronsIn)
62{;}
63
65{
66 G4cout << primaryVertex << G4endl;
67 G4cout << "Primary particle charge " << charge / CLHEP::eplus << G4endl;
68}
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.