OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
OpalCCollimator.cpp
Go to the documentation of this file.
1 //
2 // Class OpalCCollimator
3 // The CCOLLIMATOR 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 //
19 #include "Attributes/Attributes.h"
22 #include "Physics/Physics.h"
23 
24 
26  OpalElement(SIZE, "CCOLLIMATOR",
27  "The \"CCOLLIMATOR\" element defines a rectangular-shape cyclotron collimator"),
28  parmatint_m(NULL) {
30  ("XSTART", " Start of x coordinate [mm]");
32  ("XEND", " End of x coordinate, [mm]");
34  ("YSTART", "Start of y coordinate, [mm]");
36  ("YEND", "End of y coordinate, [mm]");
38  ("ZSTART", "Start of vertical coordinate, [mm], default value: -100",-100.0);
40  ("ZEND", "End of vertical coordinate, [mm], default value: 100", 100.0);
42  ("WIDTH", "Width of the collimator [mm]");
43 
45 
46  setElement(new CCollimatorRep("CCOLLIMATOR"));
47 }
48 
49 
51  OpalElement(name, parent),
52  parmatint_m(NULL) {
54 }
55 
56 
58  if (parmatint_m)
59  delete parmatint_m;
60 }
61 
62 
64  return new OpalCCollimator(name, this);
65 }
66 
67 
70 
71  CCollimatorRep* coll =
72  dynamic_cast<CCollimatorRep*>(getElement());
73 
74  const double mm2m = 1e-3;
75  double xstart = mm2m * Attributes::getReal(itsAttr[XSTART]);
76  double xend = mm2m * Attributes::getReal(itsAttr[XEND]);
77  double ystart = mm2m * Attributes::getReal(itsAttr[YSTART]);
78  double yend = mm2m * Attributes::getReal(itsAttr[YEND]);
79  double zstart = mm2m * Attributes::getReal(itsAttr[ZSTART]);
80  double zend = mm2m * Attributes::getReal(itsAttr[ZEND]);
81  double width = mm2m * Attributes::getReal(itsAttr[WIDTH]);
82 
83  double length = Attributes::getReal(itsAttr[LENGTH]);
84 
85  coll->setElementLength(length);
86  coll->setDimensions(xstart, xend, ystart, yend, zstart, zend, width);
88 
90  const std::string matterDescriptor = Attributes::getString(itsAttr[PARTICLEMATTERINTERACTION]);
92  parmatint_m = orig->clone(matterDescriptor);
95  }
96 
97  // Transmit "unknown" attributes.
99 }
@ 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
constexpr double e
The value of.
Definition: Physics.h:39
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
void setDimensions(double xstart, double xend, double ystart, double yend, double zstart, double zend, double width)
Set dimensions and consistency checks.
virtual void setElementLength(double length)
Set design length.
Definition: ElementBase.h:436
void setOutputFN(std::string fn)
Set output filename.
virtual void setParticleMatterInteraction(ParticleMatterInteractionHandler *spys)
virtual void update()
Update the embedded CLASSIC collimator.
OpalCCollimator()
Exemplar constructor.
virtual OpalCCollimator * clone(const std::string &name)
Make clone.
virtual ~OpalCCollimator()
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)