24#include <boost/regex.hpp>
28 "The \"FLEXIBLECOLLIMATOR\" element defines a flexible collimator."),
29 parmatint_m(nullptr) {
31 (
"FNAME",
"File name containing description of holes");
33 (
"DESCRIPTION",
"String describing the distribution of holes");
35 (
"DUMP",
"Save quadtree and holes of collimator",
false);
44 parmatint_m(nullptr) {
72 std::ifstream it(fname);
73 std::string str((std::istreambuf_iterator<char>(it)),
74 std::istreambuf_iterator<char>());
76 str = boost::regex_replace(str, boost::regex(
"//.*?\\n"), std::string(
""), boost::match_default | boost::format_all);
77 str = boost::regex_replace(str, boost::regex(
"\\s"), std::string(
""), boost::match_default | boost::format_all);
80 }
else if (!desc.empty()) {
81 desc = boost::regex_replace(desc, boost::regex(
"[\\t ]"), std::string(
""), boost::match_default | boost::format_all);
85 "A description for the holes has to be provided, either using DESCRIPTION or FNAME");
Attribute makeBool(const std::string &name, const std::string &help)
Make logical attribute.
double getReal(const Attribute &attr)
Return real value.
bool getBool(const Attribute &attr)
Return logical value.
std::string getString(const Attribute &attr)
Get string value.
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute.
ElementBase * getElement() const
Return the embedded CLASSIC element.
void setElement(ElementBase *)
Assign new CLASSIC element.
const std::string & getOpalName() const
Return object name.
std::vector< Attribute > itsAttr
The object attributes.
virtual void setElementLength(double length)
Set design length.
void setOutputFN(std::string fn)
Set output filename.
virtual void setParticleMatterInteraction(ParticleMatterInteractionHandler *spys)
void setDescription(const std::string &desc)
void writeHolesAndQuadtree(const std::string &baseFilename) const
@ PARTICLEMATTERINTERACTION
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 OpalFlexibleCollimator * clone(const std::string &name)
Make clone.
virtual void update()
Update the embedded CLASSIC collimator.
OpalFlexibleCollimator()
Exemplar constructor.
ParticleMatterInteraction * parmatint_m
virtual ~OpalFlexibleCollimator()
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)
The base class for all OPAL exceptions.