25 #include <boost/regex.hpp>
32 "The \"FLEXIBLECOLLIMATOR\" element defines a slit."),
35 (
"FNAME",
"File name containing description of holes");
37 (
"DESCRIPTION",
"String describing the distribution of holes");
39 (
"OUTFN",
"File name of log file for deleted particles");
41 (
"DUMP",
"Save quadtree and holes of collimator",
false);
91 std::ifstream it(fname);
92 std::string str((std::istreambuf_iterator<char>(it)),
93 std::istreambuf_iterator<char>());
95 str = boost::regex_replace(str, boost::regex(
"//.*?\\n"), std::string(
""), boost::match_default | boost::format_all);
96 str = boost::regex_replace(str, boost::regex(
"\\s"), std::string(
""), boost::match_default | boost::format_all);
99 }
else if (desc !=
"") {
100 desc = boost::regex_replace(desc, boost::regex(
"[\\t ]"), std::string(
""), boost::match_default | boost::format_all);
102 }
else if (
getOpalName() !=
"FLEXIBLECOLLIMATOR") {
104 "A description for the holes has to be provided, either using DESCRIPTION or FNAME");
std::string getDescription() const
Representation for a collimator.
virtual ~OpalFlexibleCollimator()
static AttCell * registerStringAttribute(const std::string &name)
Register a ``string'' element attribute.
Interface for basic beam line object.
virtual void fillRegisteredAttributes(const ElementBase &, ValueFlag)
Fill in all registered attributes.
ValueFlag
Switch for value desired on ATTLIST command.
The base class for all OPAL exceptions.
virtual ElementBase * removeWrappers()
Return the design element.
ParticleMatterInteraction * partMatInt_m
virtual void setElementLength(double length)
Set design length.
std::vector< Attribute > itsAttr
The object attributes (see Attribute.hh).
virtual OpalFlexibleCollimator * clone(const std::string &name)
Make clone.
static ParticleMatterInteraction * find(const std::string &name)
Find named PARTICLEMATTERINTERACTION.
bool getBool(const Attribute &attr)
Return logical value.
ParticleMatterInteractionHandler * handler_m
static std::map< std::string, OwnPtr< AttCell > > attributeRegistry
The registry for named attributes.
const std::string & getOpalName() const
Return object name.
void setDescription(const std::string &desc)
void writeHolesAndQuadtree(const std::string &baseFilename) const
OpalFlexibleCollimator()
Exemplar constructor.
void initParticleMatterInteractionHandler(ElementBase &element)
virtual void update()
Update the embedded CLASSIC collimator.
void setOutputFN(const std::string &fn)
Base class for all beam line elements.
void setElement(ElementBase *)
Assign new CLASSIC element.
void registerOwnership() const
virtual void update()
Update the embedded CLASSIC element.
virtual void updateUnknown(ElementBase *)
Transmit the ``unknown'' (not known to OPAL) attributes to CLASSIC.
virtual void setParticleMatterInteraction(ParticleMatterInteractionHandler *spys)
ElementBase * getElement() const
Return the embedded CLASSIC element.
Attribute makeBool(const std::string &name, const std::string &help)
Make logical attribute.
double getReal(const Attribute &attr)
Return real value.
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute.
virtual void fillRegisteredAttributes(const ElementBase &, ValueFlag)
Fill in all registered attributes.
std::string getString(const Attribute &attr)
Get string value.