OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
OpalPepperPot.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: OpalPepperPot.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.1.1.1 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: OpalPepperPot
10 // The class of OPAL elliptic collimators.
11 //
12 // ------------------------------------------------------------------------
13 //
14 // $Date: 2000/03/27 09:33:39 $
15 // $Author: Andreas Adelmann $
16 //
17 // ------------------------------------------------------------------------
18 
19 #include "Elements/OpalPepperPot.h"
20 #include "Attributes/Attributes.h"
23 
24 
25 // Class OpalPepperPot
26 // ------------------------------------------------------------------------
27 
29  OpalElement(SIZE, "PEPPERPOT",
30  "The \"PEPPERPOT\" element defines an elliptic collimator."),
31  parmatint_m(NULL) {
33  ("XSIZE", "Size in x of the pepperpot in m");
35  ("YSIZE", "Size in y of the pepperpot in m");
37  ("OUTFN", "Pepperpot output filename");
39  ("NHOLX", "Number of holes in x");
41  ("NHOLY", "Number of holes in y");
43  ("R", "Radios of a holes in m");
44 
45  registerStringAttribute("OUTFN");
46  registerRealAttribute("XSIZE");
47  registerRealAttribute("YSIZE");
49  registerRealAttribute("NHOLX");
50  registerRealAttribute("NHOLY");
51 
53 
54  setElement((new FlexibleCollimatorRep("PEPPERPOT"))->makeAlignWrapper());
55 }
56 
57 
58 OpalPepperPot::OpalPepperPot(const std::string &name, OpalPepperPot *parent):
59  OpalElement(name, parent),
60  parmatint_m(NULL) {
61  setElement((new FlexibleCollimatorRep(name))->makeAlignWrapper());
62 }
63 
64 
66  if(parmatint_m)
67  delete parmatint_m;
68 }
69 
70 
71 OpalPepperPot *OpalPepperPot::clone(const std::string &name) {
72  return new OpalPepperPot(name, this);
73 }
74 
75 
78 
79 
80  // const FlexibleCollimatorRep *ppo =
81  // dynamic_cast<const FlexibleCollimatorRep *>(base.removeWrappers());
82  // attributeRegistry["XSIZE"]->setReal(ppo->getXsize());
83  // attributeRegistry["YSIZE"]->setReal(ppo->getYsize());
84 
85 }
86 
89 
91  dynamic_cast<FlexibleCollimatorRep *>(getElement()->removeWrappers());
92  double length = Attributes::getReal(itsAttr[LENGTH]);
93  ppo->setElementLength(length);
95 
96  if (getOpalName() != "PEPPERPOT") {
97  double xsize = Attributes::getReal(itsAttr[XSIZE]);
98  double ysize = Attributes::getReal(itsAttr[YSIZE]);
99  double diameter = 2 * Attributes::getReal(itsAttr[R]);
100  int repX = Attributes::getReal(itsAttr[NHOLX]) - 1;
101  int repY = Attributes::getReal(itsAttr[NHOLY]) - 1;
102 
103  double shiftx = (xsize - diameter) / repX;
104  double shifty = (ysize - diameter) / repY;
105 
106  std::stringstream description;
107  description << "repeat(repeat(translate(ellipse("
108  << diameter << "," << diameter << "),"
109  << -shiftx * 0.5 * repX << "," << -shifty * 0.5 * repY << "),"
110  << repX << "," << shiftx << ",0.0),"
111  << repY << ",0.0," << shifty << ")";
112 
113  std::cout << "OpalPepperPot.cpp: " << __LINE__ << "\t"
114  << description.str() << std::endl;
115  ppo->setDescription(description.str());
116  exit(1);
117  }
118 
123  }
124 
125  // Transmit "unknown" attributes.
127 }
OpalPepperPot()
Exemplar constructor.
Representation for a collimator.
static AttCell * registerStringAttribute(const std::string &name)
Register a ``string&#39;&#39; element attribute.
Interface for basic beam line object.
Definition: ElementBase.h:128
virtual void fillRegisteredAttributes(const ElementBase &, ValueFlag)
Fill in all registered attributes.
ValueFlag
Switch for value desired on ATTLIST command.
Definition: OpalElement.h:71
virtual ElementBase * removeWrappers()
Return the design element.
virtual void update()
Update the embedded CLASSIC collimator.
virtual void setElementLength(double length)
Set design length.
Definition: ElementBase.h:515
std::vector< Attribute > itsAttr
The object attributes (see Attribute.hh).
Definition: Object.h:214
ParticleMatterInteraction * parmatint_m
Definition: OpalPepperPot.h:68
static ParticleMatterInteraction * find(const std::string &name)
Find named PARTICLEMATTERINTERACTION.
ParticleMatterInteractionHandler * handler_m
const std::string & getOpalName() const
Return object name.
Definition: Object.cpp:284
void setDescription(const std::string &desc)
void initParticleMatterInteractionHandler(ElementBase &element)
void setOutputFN(const std::string &fn)
Base class for all beam line elements.
Definition: OpalElement.h:41
void setElement(ElementBase *)
Assign new CLASSIC element.
Definition: Element.h:133
void registerOwnership() const
virtual void update()
Update the embedded CLASSIC element.
virtual void updateUnknown(ElementBase *)
Transmit the ``unknown&#39;&#39; (not known to OPAL) attributes to CLASSIC.
virtual void setParticleMatterInteraction(ParticleMatterInteractionHandler *spys)
ElementBase * getElement() const
Return the embedded CLASSIC element.
Definition: Element.h:128
virtual OpalPepperPot * clone(const std::string &name)
Make clone.
const std::string name
double getReal(const Attribute &attr)
Return real value.
Definition: Attributes.cpp:217
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute.
Definition: Attributes.cpp:296
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
Definition: Attributes.cpp:205
static AttCell * registerRealAttribute(const std::string &name)
Register a ``real&#39;&#39; element attribute.
virtual ~OpalPepperPot()
Inform & endl(Inform &inf)
Definition: Inform.cpp:42
virtual void fillRegisteredAttributes(const ElementBase &, ValueFlag)
Fill in all registered attributes.
std::string getString(const Attribute &attr)
Get string value.
Definition: Attributes.cpp:307