Commit 7d535990 authored by snuverink_j's avatar snuverink_j

remove Tables actions: EIGEN, ENVELOPE, MATRIX, MICADO, THREADALL, THREADBPM, TWISS3

parent b0845329
......@@ -57,17 +57,10 @@
#include "Utilities/OpalFilter.h"
#include "TrimCoils/OpalTrimCoil.h"
#include "Tables/AttList.h"
#include "Tables/Eigen.h"
#include "Tables/Envelope.h"
#include "Tables/Insertion.h"
#include "Tables/List.h"
#include "Tables/MatrixCmd.h"
#include "Tables/Micado.h"
#include "Tables/Period.h"
#include "Tables/Survey.h"
#include "Tables/ThreadAll.h"
#include "Tables/ThreadBpm.h"
#include "Tables/Twiss3.h"
#include "Aperture/Aperture.h"
#include "Aperture/Split.h"
......@@ -162,13 +155,9 @@ namespace {
opal->create(new DumpFields());
opal->create(new DumpEMFields());
opal->create(new Echo());
opal->create(new Eigen());
opal->create(new Envelope());
opal->create(new Help());
opal->create(new List());
opal->create(new MatchCmd());
opal->create(new MatrixCmd());
opal->create(new Micado());
opal->create(new Option());
opal->create(new OptimizeCmd());
opal->create(new SampleCmd());
......@@ -179,11 +168,8 @@ namespace {
opal->create(new Quit());
opal->create(new PSystem());
opal->create(new System());
opal->create(new ThreadAll());
opal->create(new ThreadBpm());
opal->create(new Title());
opal->create(new TrackCmd());
opal->create(new Twiss3());
opal->create(new Aperture());
opal->create(new MSplit());
opal->create(new Value());
......
set (_SRCS
AttList.cpp
AttWriter.cpp
CorrectionBase.cpp
Eigen.cpp
Envelope.cpp
Insertion.cpp
List.cpp
MatrixCmd.cpp
Micado.cpp
Period.cpp
RangeSelector.cpp
Selector.cpp
Survey.cpp
ThreadAll.cpp
ThreadBpm.cpp
Twiss.cpp
Twiss3.cpp
)
include_directories (
......@@ -27,22 +18,13 @@ add_opal_sources(${_SRCS})
set (HDRS
AttList.h
AttWriter.h
CorrectionBase.h
Eigen.h
Envelope.h
Flatten.h
Insertion.h
List.h
MatrixCmd.h
Micado.h
Period.h
RangeSelector.h
Selector.h
Survey.h
ThreadAll.h
ThreadBpm.h
Twiss3.h
Twiss.h
)
install (FILES ${HDRS} DESTINATION "${CMAKE_INSTALL_PREFIX}/include/Tables")
......
// ------------------------------------------------------------------------
// $RCSfile: CorrectionBase.cpp,v $
// ------------------------------------------------------------------------
// $Revision: 1.3 $
// ------------------------------------------------------------------------
// Copyright: see Copyright.readme
// ------------------------------------------------------------------------
//
// Classes: CorrectionBase
//
// ------------------------------------------------------------------------
//
// $Date: 2001/08/13 15:25:21 $
// $Author: jowett $
//
// ------------------------------------------------------------------------
#include "Tables/CorrectionBase.h"
#include "AbsBeamline/Corrector.h"
#include "AbsBeamline/Monitor.h"
#include "AbstractObjects/Element.h"
#include "AbstractObjects/OpalData.h"
#include "Algorithms/IdealMapper.h"
#include "Attributes/Attributes.h"
#include "Elements/OpalHKicker.h"
#include "Elements/OpalKicker.h"
#include "Elements/OpalVKicker.h"
#include "Fields/BDipoleField.h"
#include "Physics/Physics.h"
#include "Utilities/OpalException.h"
// Nested class CorrectionBase::Row
// ------------------------------------------------------------------------
// Class CorrectionBase
// ------------------------------------------------------------------------
CorrectionBase::Row::Row(ElementBase *elem, int occur):
FlaggedElmPtr(elem, occur), orbit(), matrix()
{}
CorrectionBase::Row::Row(FlaggedElmPtr const &rhs):
FlaggedElmPtr(rhs), orbit(), matrix()
{}
CorrectionBase::Row::~Row(void)
{}
// Class CorrectionBase
// ------------------------------------------------------------------------
// Abstract base class for all orbit correction commands.
// Factors out all common behaviour for these algorithms.
CorrectionBase::CorrectionBase(int size, const char *name, const char *help):
Action(size, name, help) {
itsAttr[LINE] = Attributes::makeString
("LINE", "The beam line to be Micadoed");
itsAttr[BEAM] = Attributes::makeString
("BEAM", "The beam to be used", "UNNAMED_BEAM");
itsAttr[RANGE] = Attributes::makeRange
("RANGE", "The range in the lattice");
}
CorrectionBase::CorrectionBase(const std::string &name, CorrectionBase *parent):
Action(name, parent)
{}
CorrectionBase::~CorrectionBase()
{}
void CorrectionBase::addKick(int plane, Row &row, double kick) {
// Find object corresponding to current corrector.
const std::string &name = row.getElement()->getName();
Object *elem = OpalData::getInstance()->find(name);
// Decide on type of corrector.
if(dynamic_cast<OpalKicker *>(elem)) {
int attrNumber = (plane == 0) ? OpalKicker::HKICK : OpalKicker::VKICK;
kick += Attributes::getReal(elem->itsAttr[attrNumber]);
Attributes::setReal(elem->itsAttr[attrNumber], kick);
} else if(dynamic_cast<OpalHKicker *>(elem)) {
kick += Attributes::getReal(elem->itsAttr[OpalHKicker::KICK]);
Attributes::setReal(elem->itsAttr[OpalHKicker::KICK], kick);
} else if(dynamic_cast<OpalVKicker *>(elem)) {
kick += Attributes::getReal(elem->itsAttr[OpalVKicker::KICK]);
Attributes::setReal(elem->itsAttr[OpalVKicker::KICK], kick);
} else {
throw OpalException("CorrectionBase::addKick()",
"Orbit Corrector \"" + name + "\" not found.");
}
// Update the CLASSIC corrector.
elem->update();
}
void CorrectionBase::listCorrectors(bool list, int plane) {
double rms = 0.0;
double top = 0.0;
std::cout << "\nTotal corrector settings for plane "
<< (plane == 0 ? 'X' : 'Y') << '\n';
for(LocalIter iter = correctorTable[plane].begin();
iter != correctorTable[plane].end(); ++iter) {
ElementBase *design = (*iter)->getElement()->removeWrappers();
Corrector *corr = dynamic_cast<Corrector *>(design);
BDipoleField &field = corr->getField();
double setting = (plane == 0) ? - field.getBy() : field.getBx();
setting *= Physics::c / OpalData::getInstance()->getP0();
if(list) {
std::cout << std::setw(20) << corr->getName()
<< std::setw(12) << setting << '\n';
}
rms += setting * setting;
top = std::max(std::abs(setting), top);
}
rms = sqrt(rms / double(correctorTable[plane].size()));
std::cout << "R.m.s. : " << std::setw(20) << rms << '\n'
<< "Maximum: " << std::setw(20) << top << std::endl;
}
void CorrectionBase::listMonitors(bool list, int plane) {
double rms = 0.0;
double top = 0.0;
int q = 2 * plane;
std::cout << "\nFinal monitor readings for plane "
<< (plane == 0 ? 'X' : 'Y') << '\n';
for(LocalIter iter = monitorTable[plane].begin();
iter != monitorTable[plane].end(); ++iter) {
double reading = (*iter)->orbit[q];
if(list) {
std::cout << std::setw(20) << (*iter)->getElement()->getName()
<< std::setw(12) << reading << '\n';
}
rms += reading * reading;
top = std::max(std::abs(reading), top);
}
rms = sqrt(rms / double(monitorTable[plane].size()));
std::cout << "R.m.s. : " << std::setw(20) << rms << '\n'
<< "Maximum: " << std::setw(20) << top << std::endl;
}
void CorrectionBase::setupTables() {
IdealMapper mapper(itsLine, reference, false, false);
double arc = 0.0;
for(TLine::iterator iter = itsLine.begin();
iter != itsLine.end(); ++iter) {
// Build ideal matrix.
iter->accept(mapper);
mapper.getMatrix(iter->matrix);
iter->isUsed[0] = iter->isUsed[1] = false;
// Accumulate arc length.
ElementBase *elem = iter->getElement();
arc += elem->getElementLength();
iter->arc = arc;
// Put correctors and monitors in relevant table.
test(elem);
if(isCorr[0]) correctorTable[0].push_back(&*iter);
if(isCorr[1]) correctorTable[1].push_back(&*iter);
if(isMoni[0]) monitorTable[0].push_back(&*iter);
if(isMoni[1]) monitorTable[1].push_back(&*iter);
}
}
void CorrectionBase::test(ElementBase *base) {
ElementBase *design = base->removeWrappers();
isCorr[0] = isCorr[1] = isMoni[0] = isMoni[1] = false;
if(Corrector *corr = dynamic_cast<Corrector *>(design)) {
switch(corr->getPlane()) {
case Corrector::X:
isCorr[0] = true;
break;
case Corrector::Y:
isCorr[1] = true;
break;
case Corrector::XY:
isCorr[0] = isCorr[1] = true;
break;
default:
break;
}
} else if(Monitor *moni = dynamic_cast<Monitor *>(design)) {
switch(moni->getPlane()) {
case Monitor::X:
isMoni[0] = true;
break;
case Monitor::Y:
isMoni[1] = true;
break;
case Monitor::XY:
isMoni[0] = isMoni[1] = true;
break;
default:
break;
}
}
}
\ No newline at end of file
#ifndef OPAL_CorrectionBase_HH
#define OPAL_CorrectionBase_HH
// ------------------------------------------------------------------------
// $RCSfile: CorrectionBase.h,v $
// ------------------------------------------------------------------------
// $Revision: 1.2 $
// ------------------------------------------------------------------------
// Copyright: see Copyright.readme
// ------------------------------------------------------------------------
//
// Classes: CorrectionBase
//
// ------------------------------------------------------------------------
//
// $Date: 2001/08/13 15:25:22 $
// $Author: jowett $
//
// ------------------------------------------------------------------------
#include "AbstractObjects/Action.h"
#include "Algorithms/PartData.h"
#include "Beamlines/FlaggedElmPtr.h"
#include "Beamlines/TBeamline.h"
#include "FixedAlgebra/FMatrix.h"
#include "FixedAlgebra/FVector.h"
#include <list>
class ElementBase;
// Class CorrectionBase
// ------------------------------------------------------------------------
/// Abstract base class for all orbit correction commands.
// Factors out all common behaviour for these algorithms.
// A CorrectionBase contains a RBeamline<CorrectionBase::Row> which
// holds pointers to the elements in the line, together with the ideal
// transfer matrices from the beginning to the current position and the
// orbit computed from the algorithm. This information is used to find
// the required corrections. This class also contains a method to set
// the orbit corrector strength once it has been found.
class CorrectionBase: public Action {
public:
virtual ~CorrectionBase();
protected:
/// The comon attributes for orbit correction commands.
enum {
// User-definable attributes:
LINE, // The beam line for the table,
BEAM, // The beam to be used.
RANGE, // The range in the lattice.
SIZE
};
/// Structure for a row of the Twiss table.
struct Row: public FlaggedElmPtr {
Row(ElementBase *, int);
explicit Row(const FlaggedElmPtr &);
~Row();
/// The closed orbit after the element.
FVector<double, 6> orbit;
/// The transfer matrix up to and including the element.
FMatrix<double, 6, 6> matrix;
/// The accumulated arc length.
double arc;
/// Flag telling when observation has been used.
bool isUsed[2];
};
// The contained beamline type.
typedef TBeamline<Row> TLine;
/// Exemplar constructor.
CorrectionBase(int size, const char *name, const char *help);
/// Clone constructor.
CorrectionBase(const std::string &name, CorrectionBase *parent);
/// Add to kicker strength.
// Arguments:
// [ol]
// [li] The plane: (0 = x, 1 = y).
// [li] The position, given by an iterator into the Twiss table.
// [li] The kick change.
// [/ol]
void addKick(int plane, Row &, double kick);
/// List correctors before or after correction.
void listCorrectors(bool list, int plane);
/// List monitors before or after correction.
void listMonitors(bool list, int plane);
/// Set up the corrector and monitor tables.
void setupTables();
/// Routine to test for corrector or monitor.
void test(ElementBase *);
/// The flat beam line on which the correction is done.
TLine itsLine;
/// The particle reference data.
PartData reference;
/// The closed orbit guess.
FVector<double, 6> orbitGuess;
/// Flags telling wether a corrector exists.
bool isCorr[2];
/// Flag telling wether a monitor exists.
bool isMoni[2];
// Types used for corrector and monitor tables.
typedef std::list<Row *> LocalList;
typedef LocalList::iterator LocalIter;
// The table of correctors per plane.
LocalList correctorTable[2];
// The table of monitors per plane.
LocalList monitorTable[2];
private:
// Not implemented.
CorrectionBase();
CorrectionBase(const CorrectionBase &);
void operator=(const CorrectionBase &);
};
#endif // OPAL_CorrectionBase_HH
// ------------------------------------------------------------------------
// $RCSfile: Eigen.cpp,v $
// ------------------------------------------------------------------------
// $Revision: 1.2.4.1 $
// ------------------------------------------------------------------------
// Copyright: see Copyright.readme
// ------------------------------------------------------------------------
//
// Class: Eigen
// The class for OPAL EIGEN commands.
//
// ------------------------------------------------------------------------
//
// $Date: 2002/12/09 15:06:08 $
// $Author: jsberg $
//
// ------------------------------------------------------------------------
#include "Tables/Eigen.h"
#include "AbstractObjects/Attribute.h"
#include "AbstractObjects/OpalData.h"
#include "Attributes/Attributes.h"
#include "Tables/Twiss.h"
#include "Utilities/OpalException.h"
#include <fstream>
#include <iomanip>
#include <sstream>
#include <iostream>
// Class Eigen
// ------------------------------------------------------------------------
// The attributes of class Eigen.
namespace {
enum {
TABLE, // The name of the table to be listed.
FNAME, // The name of the file to be written.
SIZE
};
}
Eigen::Eigen():
Action(SIZE, "EIGEN",
"The \"EIGEN\" statement lists the eigenvectors for a named "
"\"TWISS\" table.") {
itsAttr[TABLE] = Attributes::makeString
("TABLE", "Name of table to be listed");
itsAttr[FNAME] = Attributes::makeString
("FILE", "Name of file to receive output", "EIGEN");
registerOwnership(AttributeHandler::STATEMENT);
}
Eigen::Eigen(const std::string &name, Eigen *parent):
Action(name, parent)
{}
Eigen::~Eigen()
{}
Eigen *Eigen::clone(const std::string &name) {
return new Eigen(name, this);
}
void Eigen::execute() {
std::string tableName = Attributes::getString(itsAttr[TABLE]);
Twiss *table = dynamic_cast<Twiss *>(OpalData::getInstance()->find(tableName));
if(table) {
std::string fileName = Attributes::getString(itsAttr[FNAME]);
if(fileName == "TERM") {
format(std::cout, table);
} else {
std::ofstream os(fileName.c_str());
if(os.good()) {
format(os, table);
} else {
throw OpalException("Eigen::execute()",
"Unable to open output stream \"" +
fileName + "\".");
}
}
} else {
throw OpalException("Eigen::execute()",
"Twiss table \"" + tableName + "\" not found.");
}
}
void Eigen::format(std::ostream &os, const Twiss *table) {
formatPrint(os, table);
}
void Eigen::formatPrint(std::ostream &os, const Twiss *table) const {
// Save the formatting flags.
std::streamsize old_prec = os.precision(6);
os.setf(std::ios::fixed, std::ios::floatfield);
// Print table specific header.
table->printTableTitle(os, "Eigenvectors");
os << std::string(118, '-') << '\n';
os << "Element" << std::string(24, ' ') << "S Orbit |"
<< std::string(25, ' ') << "E i g e n v e c t o r s\n";
os << std::string(118, '-') << '\n';
// Print table body.
for(Twiss::TLine::const_iterator row = table->begin();
row != table->end(); ++row) {
if(row->getSelectionFlag()) {
os << '\n';
std::string name = row->getElement()->getName();
if(int occur = row->getCounter()) {
std::ostringstream tos;
tos << name << '[' << occur << ']' << std::ends;
name = tos.str();
}
if(name.length() > 16) {
// Truncate the element name.
os << std::string(name, 0, 13) << ".. ";
} else {
// Left adjust the element name.
os << name << std::string(16 - name.length(), ' ');
}
os << std::setw(16) << table->getS(*row);
FMatrix<double, 6, 6> eigen = table->getCurlyA(*row);
FVector<double, 6> orbit = table->getOrbit(*row);
for(int i = 0; i < 6; ++i) {
if(i != 0) os << std::string(32, ' ');
os << std::setw(12) << orbit[i] << " |";
for(int j = 0; j < 6; ++j) {
os << std::setw(12) << eigen[i][j];
}
os << '\n';
}
}
}
os << std::string(118, '-') << std::endl;
// Restore the formatting flags.
os.precision(old_prec);
os.setf(std::ios::fixed, std::ios::floatfield);
}
#ifndef OPAL_Eigen_HH
#define OPAL_Eigen_HH
// ------------------------------------------------------------------------
// $RCSfile: Eigen.h,v $
// ------------------------------------------------------------------------
// $Revision: 1.1.1.1 $
// ------------------------------------------------------------------------
// Copyright: see Copyright.readme
// ------------------------------------------------------------------------
//
// Class: Eigen
//
// ------------------------------------------------------------------------
//
// $Date: 2000/03/27 09:33:45 $
// $Author: Andreas Adelmann $
//
// ------------------------------------------------------------------------
#include "AbstractObjects/Action.h"
#include "AbstractObjects/Attribute.h"
#include <iosfwd>
class Twiss;
// Class Eigen
// ------------------------------------------------------------------------
/// The EIGEN command.
class Eigen: public Action {
public:
/// Exemplar constructor.
Eigen();
virtual ~Eigen();
/// Make clone.
virtual Eigen *clone(const std::string &name);
/// Execute the command.
virtual void execute();
private:
// Not implemented.
Eigen(const Eigen &);
void operator=(const Eigen &);
// Clone constructor.
Eigen(const std::string &name, Eigen *parent);
// Do the listing.
void format(std::ostream &, const Twiss *);
/// Print Twiss table in eigenvector representation.
void formatPrint(std::ostream &, const Twiss *) const;
};
#endif // OPAL_Eigen_HH
// ------------------------------------------------------------------------
// $RCSfile: Envelope.cpp,v $
// ------------------------------------------------------------------------
// $Revision: 1.2.4.1 $