55                  "The \"SEQUENCE\" statement initiates parsing of an " 
   57                  "\t<label>: SEQUENCE,L=<length>,REFER=<reference>\n" 
   59                  "\t\t<object>: <class>,AT=<real>{,<attribute>=<value>}\n" 
   60                  "\t\t<object>: <class>,DRIFT=<real>{,<attribute>=<value>}\n" 
   64                     (
"TYPE", 
"The design type");
 
   66                       (
"L", 
"Total length of sequence in m");
 
   70                       "Reference position for members:\n" 
   71                       "\tENTRY | EXIT | CENTRE (default is CENTRE)", 
"CENTRE");
 
   74                        "Element giving reference position for this sequence" 
   75                        "\t(if given, this position is used instead of the centre, when the" 
   76                        "\tsequence is nested in another sequence with \"REFER=CENTRE\")");
 
  116         newLine->push_back(member);
 
  131             if(iter->getElement()->getName() == 
name) {
 
  134                 while(++test != line.end()) {
 
  135                     if(test->getElement()->getName() == 
name) {
 
  136                         throw OpalException(
"Sequence::findNamedPosition()", 
"Element \"" +
 
  137                                             name + 
"\" is not unique in sequence.");
 
  147                         "Element \"" + name + 
"\" not found in sequence.");
 
  162         return (- iter->itsPosition);
 
  173         return (
getLength() - iter->itsPosition);
 
  184     } 
else if(ref == 
"EXIT") {
 
  221     std::streamsize old_prec = os.precision(12);
 
  228             os << 
',' << i.getName()
 
  229                << (i.isExpression() ? 
":=" : 
"=") << i;
 
  235     for(TLine::const_iterator iter = line->begin();
 
  236         iter != line->end(); ++iter) {
 
  264     if(oldElement != 0  &&  newElement != 0) {
 
  287     line->erase(line->begin(), line->end());
 
  299             const std::string &name = i->getElement()->getName();
 
  303             i->OpalElement = elem;
 
  319     line.push_front(member);
 
  322     line.push_back(member);
 
  330     const std::string prev_name = prev->getElement()->getName();
 
  336     double prev_exit = prev->itsPosition + prev_elem->
getExit(
itsCode);
 
  340     const std::string next_name = next->getElement()->getName();
 
  348     double driftLength = next_entry - prev_exit;
 
  350     static double tolerance = 1.0e-8;
 
  351     if(
std::abs(driftLength) < tolerance) {
 
  353     } 
else if(driftLength < 0.0) {
 
  355         std::ostringstream os;
 
  356         os << 
"Inconsistent positions in sequence \"" << 
getOpalName() + 
"\";\n" 
  357            << 
"previous element:  \"" << prev_name + 
"\" at = " 
  358            << prev->itsPosition << 
",\n" 
  359            << 
"following element: \"" << next_name + 
"\" at = " 
  360            << next->itsPosition << 
"." << std::ends;
 
  361         throw OpalException(
"Sequence::findDriftLength()", os.str());
 
  373         if(i == line.end()) 
break;
 
  379         line.insert(i, member);
 
  390         if(iter == last) 
break;
 
  393             TLine *sub_line = 
dynamic_cast<TLine *
>(base);
 
  395                 const std::string &sub_name = sub_line->
getName();
 
  403         if(iter == last) 
break;
 
  405         iter->setLength(driftLength);
 
virtual double getExit(ReferenceType) const 
Return arc length from origin to exit (positive !). 
virtual bool isShared() const 
Shared flag. 
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
double findDriftLength(TLine::iterator drift) const 
virtual void print(std::ostream &) const 
Print sequence. 
Interface for basic beam line object. 
virtual TLine * fetchLine() const 
Return the embedded CLASSIC beam line. 
void parseTemplate(TokenStream &, Statement &)
Parse the sequence template. 
Abstract interface for a stream of input tokens. 
The base class for all OPAL exceptions. 
virtual void setName(const std::string &name)
Set element name. 
virtual ElementBase * removeWrappers()
Return the design element. 
Sequence()
Exemplar constructor. 
An ``archetype'' for a SEQUENCE with arguments. 
virtual const std::string & getName() const 
Get element name. 
std::vector< Attribute > itsAttr
The object attributes (see Attribute.hh). 
virtual void parse(Statement &)
Parse sequence. 
TLine::iterator findNamedPosition(TLine &, const std::string &) const 
double itsPosition
The position attribute ("AT" or "DRIFT"). 
void insertDrifts(TLine &line)
virtual double getEntrance(ReferenceType) const 
Return the arc length from origin to entrance. 
virtual void replace(Object *oldObject, Object *newObject)
Replace references to elements. 
void apply(const ObjectFunction &)
Apply a function to all objects. 
ReferenceType getReference() const 
Return the reference type flag. 
static OpalData * getInstance()
const std::string & getOpalName() const 
Return object name. 
MemberType itsType
Type word. 
Template class for beam lines. 
The base class for all OPAL elements. 
A representation of an Object attribute. 
ReferenceType
Reference for element positioning. 
void addEndMarkers(TLine &line) const 
Interface for statements. 
static void updateList(Sequence *, TLine *)
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const 
void storeLine(TLine &line)
Store sequence line. 
void setElement(ElementBase *)
Assign new CLASSIC element. 
virtual ElementBase * copyStructure()
Make a structural copy. 
The parser for SEQUENCE members. 
virtual Sequence * clone(const std::string &name)
Make clone. 
virtual ElementBase * clone() const =0
Return clone. 
virtual void execute()
Apply the algorithm to the top-level beamline. 
virtual double getExit(ReferenceType) const 
Return the arc length from origin to exit. 
TBeamline< SequenceMember > TLine
The type of a sequence line. 
ElementBase * getElement() const 
Return the embedded CLASSIC element. 
virtual void run() const 
Read current stream. 
The base class for all OPAL beam lines and sequences. 
static Element * find(const std::string &name)
Find named Element. 
virtual Sequence * copy(const std::string &name)
Make copy of the sequence line. 
virtual double getLength() const 
Return sequence length. 
Object * find(const std::string &name)
Find entry. 
The base class for all OPAL objects. 
int increment()
Increment and return the occurrence counter. 
PositionType itsFlag
Flag word. 
bool getReflectionFlag() const 
Get reflection flag. 
bool isSharable() const 
Test if the element can be shared. 
std::string::iterator iterator
virtual void parse(Statement &)
Parse the object. 
double getReal(const Attribute &attr)
Return real value. 
Replace all references to named element by a new version. 
virtual void update()
Update the embedded CLASSIC beam line. 
virtual Object * makeTemplate(const std::string &, TokenStream &, Statement &)
Make a sequence template. 
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute. 
ElementBase * getElement() const 
Get the element pointer. 
virtual double getEntrance(ReferenceType) const 
Return arc length from origin to entrance (negative !). 
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute. 
Representation for a drift space. 
Inform & endl(Inform &inf)
void setElement(ElementBase *)
Set the element pointer. 
std::string getString(const Attribute &attr)
Get string value.