OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
Tracker.cpp
Go to the documentation of this file.
1//
2// Class Tracker
3// Track particles or bunches.
4// An abstract base class for all visitors capable of tracking particles
5// through a beam element.
6// [P]
7// Phase space coordinates (in this order):
8// [DL]
9// [DT]x:[DD]
10// horizontal displacement (metres).
11// [DT]p_x/p_r:[DD]
12// horizontal canonical momentum (no dimension).
13// [DT]y:[DD]
14// vertical displacement (metres).
15// [DT]p_y/p_r:[DD]
16// vertical canonical momentum (no dimension).
17// [DT]delta_p/p_r:[DD]
18// relative momentum error (no dimension).
19// [DT]v*delta_t:[DD]
20// time difference delta_t w.r.t. the reference frame which moves with
21// uniform velocity
22// [P]
23// v_r = c*beta_r = p_r/m
24// [P]
25// along the design orbit, multiplied by the instantaneous velocity v of
26// the particle (metres).
27// [/DL]
28// Where
29// [DL]
30// [DT]p_r:[DD]
31// is the constant reference momentum defining the reference frame velocity.
32// [DT]m:[DD]
33// is the rest mass of the particles.
34// [/DL]
35// Other units used:
36// [DL]
37// [DT]reference momentum:[DD]
38// electron-volts.
39// [DT]accelerating voltage:[DD]
40// volts.
41// [DT]separator voltage:[DD]
42// volts.
43// [DT]frequencies:[DD]
44// hertz.
45// [DT]phase lags:[DD]
46// multiples of (2*pi).
47// [/DL]
48//
49// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
50// All rights reserved
51//
52// This file is part of OPAL.
53//
54// OPAL is free software: you can redistribute it and/or modify
55// it under the terms of the GNU General Public License as published by
56// the Free Software Foundation, either version 3 of the License, or
57// (at your option) any later version.
58//
59// You should have received a copy of the GNU General Public License
60// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
61//
62#include "Algorithms/Tracker.h"
65
66// FIXME Remove headers and dynamic_cast in readOneBunchFromFile
67#include "PartBunch/PartBunch.h"
68
69#include <cfloat>
70#include <cmath>
71#include <limits>
72
73// Class Tracker
74// ------------------------------------------------------------------------
75
76Tracker::Tracker(const Beamline& beamline, bool backBeam, bool backTrack)
77 : AbstractTracker(beamline, backBeam, backTrack),
78 itsBeamline_m(beamline),
79 itsBunch_m(nullptr) {}
80
81Tracker::Tracker(const Beamline& beamline, PartBunch_t& bunch, bool backBeam, bool backTrack)
82 : AbstractTracker(beamline, backBeam, backTrack), itsBeamline_m(beamline), itsBunch_m(&bunch) {}
83
85
87 if (itsBunch_m == nullptr) {
88 throw OpalException("Tracker::getBunch", "No particle bunch is attached to this tracker.");
89 }
90 return *itsBunch_m;
91}
92
93void Tracker::addToBunch(const OpalParticle& /*part*/) {
94 *gmsg << "passed OpalParticle argument not used in Tracker::addToBunch" << endl;
95}
96
97//~ void Tracker::setBunch(const PartBunch &bunch) {
98//~ itsBunch_m = &bunch;
99//~ }
100
102 if (itsBunch_m == nullptr || itsBunch_m->getParticleContainer() == nullptr
103 || itsBunch_m->getParticleContainer()->getReference() == nullptr) {
104 throw OpalException(
105 "Tracker::visitComponent",
106 "Missing particle reference data in active particle container.");
107 }
108 comp.trackBunch(
109 *itsBunch_m, *itsBunch_m->getParticleContainer()->getReference(), back_beam,
110 back_track);
111}
Inform * gmsg
Definition changes.cpp:7
Template PIC bunch: IPPL PicManager, shared field mesh/solver, and multiple particle containers.
Track particles or bunches.
An abstract sequence of beam line components.
Definition Beamline.h:34
virtual void trackBunch(PartBunch_t &bunch, const PartData &, bool revBeam, bool revTrack) const
Track a borrowed particle bunch through a non-standard component.
Definition Component.cpp:35
const PartData * getReference() const
Definition PartBunch.h:494
virtual ~Tracker()
Definition Tracker.cpp:84
virtual void visitComponent(const Component &)
Store the bunch.
Definition Tracker.cpp:101
void addToBunch(const OpalParticle &)
Add particle to bunch.
Definition Tracker.cpp:93
PartBunch_t & getBunch() const
Return the currently attached borrowed bunch.
Definition Tracker.cpp:86
PartBunch_t * itsBunch_m
The bunch of particles to be tracked. Borrowed; lifetime is managed by TrackRun.
Definition Tracker.h:119