OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
MapIntegrator.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: MapIntegrator.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.1.1.1 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: MapIntegrator
10 // An abstract base class for integrators.
11 // A MapIntegrator propagates a single particle or particle bunch,
12 // as well as a truncated Taylor series map.
13 //
14 // ------------------------------------------------------------------------
15 // Class category: Algorithms
16 // ------------------------------------------------------------------------
17 //
18 // $Date: 2000/03/27 09:32:33 $
19 // $Author: fci $
20 //
21 // ------------------------------------------------------------------------
22 
27 #include "FixedAlgebra/FVps.h"
28 #include "FixedAlgebra/LinearMap.h"
29 
30 
31 // Class MapIntegrator
32 // ------------------------------------------------------------------------
33 
35  TrackIntegrator(elem)
36 {}
37 
38 
40  TrackIntegrator(rhs)
41 {}
42 
43 
45 {}
46 
47 
48 void MapIntegrator::accept(BeamlineVisitor &visitor) const {
49  visitor.visitMapIntegrator(*this);
50 }
51 
52 
54  bool backBeam, bool backTrack) const {
55  // Default behaviour: track particle using own map.
56  FVps<double, 6> ownMap;
57  getMap(ownMap, ref, backBeam, backTrack);
59  z[0] = part.x();
60  z[1] = part.px();
61  z[2] = part.x();
62  z[3] = part.py();
63  z[4] = part.x();
64  z[5] = part.pt();
65  z = ownMap.constantTerm(z);
66  part.x() = z[0];
67  part.px() = z[1];
68  part.y() = z[2];
69  part.py() = z[3];
70  part.y() = z[4];
71  part.pt() = z[5];
72 }
73 
74 
76  bool backBeam, bool backTrack) const {
77  // Default behaviour: track particle bunch using own map.
78  FVps<double, 6> ownMap;
79  getMap(ownMap, ref, backBeam, backTrack);
81 
82  // PartBunch::iterator last = bunch.end();
83  // for (PartBunch::iterator part = bunch.begin(); part != last; ++part) {
84  for(unsigned int i = 0; i < bunch->getLocalNum(); i++) {
85  const OpalParticle part = bunch->get_part(i);
86  z[0] = part[0];
87  z[1] = part[1];
88  z[2] = part[2];
89  z[3] = part[3];
90  z[4] = part[4];
91  z[5] = part[5];
92  z = ownMap.constantTerm(z);
93  bunch->set_part(z, i);
94  }
95 }
96 
97 
99  bool backBeam, bool backTrack) const {
100  // Default behaviour: track map using own map.
101  FVps<double, 6> ownMap;
102  getMap(ownMap, ref, backBeam, backTrack);
103  map = ownMap.substitute(map);
104 }
double & py()
Get reference to vertical momentum (no dimension).
Definition: OpalParticle.h:122
Interface for basic beam line object.
Definition: ElementBase.h:128
virtual void trackMap(FVps< double, 6 > &, const PartData &, bool revBeam, bool revTrack) const
Track a map.
double & x()
Get reference to horizontal position in m.
Definition: OpalParticle.h:110
virtual void visitMapIntegrator(const MapIntegrator &)=0
Apply the algorithm to an integrator capable of mapping.
Particle reference data.
Definition: PartData.h:38
FVector< T, N > constantTerm() const
Extract the constant part of the map.
Definition: FVps.hpp:540
OpalParticle get_part(int ii)
virtual void getMap(FVps< double, 6 > &, const PartData &, bool revBeam, bool revTrack) const =0
virtual void trackBunch(PartBunchBase< double, 3 > *, const PartData &, bool revBeam, bool revTrack) const
Track a particle bunch.
virtual void accept(BeamlineVisitor &visitor) const
Apply visitor.
Integrate particle.
size_t getLocalNum() const
void set_part(FVector< double, 6 > z, int ii)
double & pt()
Get reference to relative momentum error (no dimension).
Definition: OpalParticle.h:125
double & y()
Get reference to vertical displacement in m.
Definition: OpalParticle.h:113
double & px()
Get reference to horizontal momentum (no dimension).
Definition: OpalParticle.h:119
FVps substitute(const FMatrix< T, N, N > &M, int n) const
Substitute.
Definition: FVps.hpp:608
Abstract algorithm.
OpalParticle position.
Definition: OpalParticle.h:38
virtual ~MapIntegrator()
virtual void trackParticle(OpalParticle &part, const PartData &, bool revBeam, bool revTrack) const
Track a particle.
Integrate a map.
Definition: MapIntegrator.h:41