OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
OpalStripper.cpp
Go to the documentation of this file.
1 //
2 // Class OpalStripper
3 // The Stripper element
4 //
5 // Copyright (c) 2011, Jianjun Yang, Paul Scherrer Institut, Villigen PSI, Switzerland
6 // Copyright (c) 2014, 2017-2018, Paul Scherrer Institut, Villigen PSI, Switzerland
7 // All rights reserved
8 //
9 // Implemented as part of the PhD thesis
10 // "Beam dynamics in high intensity cyclotrons including neighboring bunch effects"
11 // and the paper
12 // "Beam dynamics in high intensity cyclotrons including neighboring bunch effects:
13 // Model, implementation, and application"
14 // (https://journals.aps.org/prab/pdf/10.1103/PhysRevSTAB.13.064201)
15 //
16 // This file is part of OPAL.
17 //
18 // OPAL is free software: you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation, either version 3 of the License, or
21 // (at your option) any later version.
22 //
23 // You should have received a copy of the GNU General Public License
24 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
25 //
26 #include "Elements/OpalStripper.h"
28 #include "Attributes/Attributes.h"
30 #include "Physics/Physics.h"
31 
32 
34  OpalElement(SIZE, "STRIPPER",
35  "The \"STRIPPER\" element defines a Stripper.") {
36 
38  ("XSTART", " Start of x coordinate [mm]");
40  ("XEND", " End of x coordinate, [mm]");
42  ("YSTART", "Start of y coordinate, [mm]");
44  ("YEND", "End of y coordinate, [mm]");
46  ("WIDTH", "Width of the stripper [mm], NOT used");
48  ("OPCHARGE", "Charge number of the outcome particle");
50  ("OPMASS", "Mass of the outcome particle [GeV/c^2]");
52  ("OPYIELD", "Yield (Particle number of the outcome particle) per income particle");
54  ("STOP", "Option Whether stop tracking at the stripper. Default: true", true);
55 
57 
58  setElement(new StripperRep("STRIPPER"));
59 }
60 
61 
62 OpalStripper::OpalStripper(const std::string &name, OpalStripper *parent):
63  OpalElement(name, parent) {
65 }
66 
67 
69 {}
70 
71 
72 OpalStripper *OpalStripper::clone(const std::string &name) {
73  return new OpalStripper(name, this);
74 }
75 
76 
79 
80  StripperRep *strp = dynamic_cast<StripperRep *>(getElement());
81 
82  const double mm2m = 0.001;
83  double xstart = mm2m * Attributes::getReal(itsAttr[XSTART]);
84  double xend = mm2m * Attributes::getReal(itsAttr[XEND]);
85  double ystart = mm2m * Attributes::getReal(itsAttr[YSTART]);
86  double yend = mm2m * Attributes::getReal(itsAttr[YEND]);
87 
88  double length = Attributes::getReal(itsAttr[LENGTH]);
89  double opcharge = Attributes::getReal(itsAttr[OPCHARGE]);
90  double opmass = Attributes::getReal(itsAttr[OPMASS]);
91  double opyield = Attributes::getReal(itsAttr[OPYIELD]);
92  bool stop = Attributes::getBool(itsAttr[STOP]);
93 
94  strp->setElementLength(length);
95  strp->setDimensions(xstart, xend, ystart, yend);
96  strp->setOPCharge(opcharge);
97  strp->setOPMass(opmass);
98  strp->setOPYield(opyield);
99  strp->setStop(stop);
101 
102  // Transmit "unknown" attributes.
104 }
@ SIZE
Definition: IndexMap.cpp:174
const std::string name
Attribute makeBool(const std::string &name, const std::string &help)
Make logical attribute.
Definition: Attributes.cpp:90
double getReal(const Attribute &attr)
Return real value.
Definition: Attributes.cpp:252
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
Definition: Attributes.cpp:240
bool getBool(const Attribute &attr)
Return logical value.
Definition: Attributes.cpp:100
std::string getString(const Attribute &attr)
Get string value.
Definition: Attributes.cpp:343
ElementBase * getElement() const
Return the embedded CLASSIC element.
Definition: Element.h:120
void setElement(ElementBase *)
Assign new CLASSIC element.
Definition: Element.h:125
std::vector< Attribute > itsAttr
The object attributes.
Definition: Object.h:216
virtual void setElementLength(double length)
Set design length.
Definition: ElementBase.h:436
void setOutputFN(std::string fn)
Set output filename.
void setDimensions(double xstart, double xend, double ystart, double yend)
Set dimensions and consistency checks.
void setOPCharge(double charge)
Member variable access.
Definition: Stripper.cpp:64
void setStop(bool stopflag)
Definition: Stripper.cpp:76
void setOPYield(double yield)
Definition: Stripper.cpp:72
void setOPMass(double mass)
Definition: Stripper.cpp:68
virtual void updateUnknown(ElementBase *)
Transmit the `‘unknown’' (not known to OPAL) attributes to CLASSIC.
virtual void update()
Update the embedded CLASSIC element.
void registerOwnership() const
virtual OpalStripper * clone(const std::string &name)
Make clone.
virtual void update()
Update the embedded CLASSIC septum.
virtual ~OpalStripper()