blob: 911ae18ee56ec536074611e1e7680d26d6ec6cff (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
/*
* Quadrupole.cc
*
* Created on: Mar 29, 2011
* Author: jakob
*/
#include <iostream>
#include <sstream>
#include "Quadrupole.h"
namespace vhc {
Quadrupole::Quadrupole(const Vector3D& entry, const Vector3D& exit, double sectionRadius, double focalizingCoefficient, Element* next):
StraightElement(entry, exit, sectionRadius, next),
focalizingCoefficient(focalizingCoefficient)
{};
Quadrupole::~Quadrupole() {};
Vector3D Quadrupole::magneticFieldAt(const Vector3D& position) const {
Vector3D x = position - getEntryPosition();
Vector3D d = getDiagonal().unit();
Vector3D y = x - x.dot(d) * d;
Vector3D u = Vector3D::k.cross(d);
if ((x.dot(d) >= 0) && ((position - getExitPosition()).dot(-d) >= 0))
return focalizingCoefficient * (y.dot(u) * Vector3D::k + position.getZ() * u);
else
return Vector3D::Null;
}
double Quadrupole::getFocalizingCoefficient() const {
return focalizingCoefficient;
}
void Quadrupole::setFocalizingCoefficient(double value) {
focalizingCoefficient = value;
}
std::string Quadrupole::getType() const {return "Quadrupole";}
std::string Quadrupole::toString() const {
std::stringstream s;
s << Element::toString() << "\n";
s << "\tfocalizing coefficient: " << focalizingCoefficient;
return s.str();
}
void Quadrupole::accept(const ElementVisitor& v) const {v.visit(this);}
Quadrupole* Quadrupole::clone() const {return new Quadrupole(getEntryPosition(), getExitPosition(), getSectionRadius(), focalizingCoefficient);}
}
|