OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
OpalECollimator.cpp
Go to the documentation of this file.
1//
2// Class OpalECollimator
3// The ECOLLIMATOR element.
4//
5// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
6// All rights reserved
7//
8// This file is part of OPAL.
9//
10// OPAL is free software: you can redistribute it and/or modify
11// it under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// You should have received a copy of the GNU General Public License
16// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
17//
22
23#include <boost/regex.hpp>
24#include <cstdlib>
25
27 OpalElement(SIZE, "ECOLLIMATOR",
28 "The \"ECOLLIMATOR\" element defines an elliptic collimator."),
29 parmatint_m(nullptr) {
31 ("XSIZE", "Horizontal half-aperture in m");
33 ("YSIZE", "Vertical half-aperture in m");
34
36
37 setElement(new FlexibleCollimatorRep("ECOLLIMATOR"));
38}
39
40
42 OpalElement(name, parent),
43 parmatint_m(nullptr) {
45}
46
47
49 if (parmatint_m)
50 delete parmatint_m;
51}
52
53
55 return new OpalECollimator(name, this);
56}
57
58
61
63 dynamic_cast<FlexibleCollimatorRep*>(getElement());
64
65 double length = Attributes::getReal(itsAttr[LENGTH]);
66 coll->setElementLength(length);
67
68 if (getOpalName() != "ECOLLIMATOR") {
69 double width = 2 * Attributes::getReal(itsAttr[XSIZE]);
70 double height = 2 * Attributes::getReal(itsAttr[YSIZE]);
71 std::stringstream description;
72 description << "ellipse(" << width << "," << height << ")";
73 coll->setDescription(description.str());
74 }
75
77
79 const std::string matterDescriptor = Attributes::getString(itsAttr[PARTICLEMATTERINTERACTION]);
81 parmatint_m = orig->clone(matterDescriptor);
84 }
85
86 // Transmit "unknown" attributes.
88}
@ SIZE
Definition: IndexMap.cpp:174
const std::string name
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
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
const std::string & getOpalName() const
Return object name.
Definition: Object.cpp:310
std::vector< Attribute > itsAttr
The object attributes.
Definition: Object.h:216
virtual void setElementLength(double length)
Set design length.
Definition: ElementBase.h:418
void setOutputFN(std::string fn)
Set output filename.
virtual void setParticleMatterInteraction(ParticleMatterInteractionHandler *spys)
void setDescription(const std::string &desc)
virtual ~OpalECollimator()
virtual void update()
Update the embedded CLASSIC collimator.
virtual OpalECollimator * clone(const std::string &name)
Make clone.
OpalECollimator()
Exemplar constructor.
ParticleMatterInteraction * parmatint_m
@ PARTICLEMATTERINTERACTION
Definition: OpalElement.h:39
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 ParticleMatterInteraction * clone(const std::string &name)
Make clone.
static ParticleMatterInteraction * find(const std::string &name)
Find named PARTICLEMATTERINTERACTION.
ParticleMatterInteractionHandler * handler_m
void initParticleMatterInteractionHandler(ElementBase &element)