Commit 70f06d91 authored by adelmann's avatar adelmann 🎗
Browse files

add Degrader element

parent e756d1cf
......@@ -703,6 +703,8 @@ src/Elements/OpalCyclotron.cpp -text
src/Elements/OpalCyclotron.h -text
src/Elements/OpalCyclotronValley.cpp -text
src/Elements/OpalCyclotronValley.h -text
src/Elements/OpalDegrader.cpp -text
src/Elements/OpalDegrader.h -text
src/Elements/OpalDrift.cpp -text
src/Elements/OpalDrift.h -text
src/Elements/OpalECollimator.cpp -text
......
......@@ -22,6 +22,7 @@
#include "AbsBeamline/Collimator.h"
#include "AbsBeamline/Corrector.h"
#include "AbsBeamline/Degrader.h"
#include "AbsBeamline/Diagnostic.h"
#include "AbsBeamline/Drift.h"
#include "AbsBeamline/ElementBase.h"
......@@ -141,6 +142,11 @@ void LieMapper::visitCorrector(const Corrector &corr) {
}
void LieMapper::visitDegrader(const Degrader &deg) {
// The diagnostic has no effect on the map.
applyDrift(flip_s * deg.getElementLength());
}
void LieMapper::visitDiagnostic(const Diagnostic &diag) {
// The diagnostic has no effect on the map.
applyDrift(flip_s * diag.getElementLength());
......
......@@ -102,6 +102,9 @@ public:
/// Apply the algorithm to a Corrector.
virtual void visitCorrector(const Corrector &);
/// Apply the algorithm to a Degrader
virtual void visitDegrader(const Degrader &);
/// Apply the algorithm to a Diagnostic.
virtual void visitDiagnostic(const Diagnostic &);
......
......@@ -25,6 +25,7 @@
#include "AbsBeamline/Collimator.h"
#include "AbsBeamline/Corrector.h"
#include "AbsBeamline/Cyclotron.h"
#include "AbsBeamline/Degrader.h"
#include "AbsBeamline/Diagnostic.h"
#include "AbsBeamline/Drift.h"
#include "AbsBeamline/ElementBase.h"
......@@ -404,6 +405,18 @@ void ParallelCyclotronTracker::visitCorrector(const Corrector &corr) {
myElements.push_back(dynamic_cast<Corrector *>(corr.clone()));
}
/**
*
*
* @param degrader
*/
void ParallelCyclotronTracker::visitDegrader(const Degrader &deg) {
*gmsg << "In Degrader; L= " << deg.getElementLength() << endl;
myElements.push_back(dynamic_cast<Degrader *>(deg.clone()));
}
/**
*
*
......
......@@ -76,6 +76,9 @@ public:
/// Apply the algorithm to a Corrector.
virtual void visitCorrector(const Corrector &);
/// Apply the algorithm to a Degrader
virtual void visitDegrader(const Degrader &);
/// Apply the algorithm to a Diagnostic.
virtual void visitDiagnostic(const Diagnostic &);
......
......@@ -64,6 +64,7 @@ public:
virtual void visitBeamBeam(const BeamBeam &);
virtual void visitCollimator(const Collimator &);
virtual void visitCorrector(const Corrector &);
virtual void visitDegrader(const Degrader &);
virtual void visitDiagnostic(const Diagnostic &);
virtual void visitDrift(const Drift &);
virtual void visitLambertson(const Lambertson &);
......@@ -174,6 +175,9 @@ inline void ParallelSliceTracker::visitCorrector(const Corrector &corr) {
itsOpalBeamline_m->visit(corr, *this, itsBunch_m);
}
inline void ParallelSliceTracker::visitDegrader(const Degrader &deg) {
itsOpalBeamline_m->visit(deg, *this, itsBunch_m);
}
inline void ParallelSliceTracker::visitDiagnostic(const Diagnostic &diag) {
itsOpalBeamline_m->visit(diag, *this, itsBunch_m);
......
......@@ -31,6 +31,7 @@ class AlignWrapper;
class BeamBeam;
class Collimator;
class Corrector;
class Degrader;
class Diagnostic;
class Drift;
class ElementBase;
......@@ -133,9 +134,13 @@ public:
/// Apply the algorithm to a collimator.
virtual void visitCollimator(const Collimator &);
/// Apply the algorithm to a Corrector.
virtual void visitCorrector(const Corrector &);
/// Apply the algorithm to a Degrader.
virtual void visitDegrader(const Degrader &);
/// Apply the algorithm to a Diagnostic.
virtual void visitDiagnostic(const Diagnostic &);
......@@ -434,6 +439,11 @@ inline void ParallelTTracker::visitCorrector(const Corrector &corr) {
}
inline void ParallelTTracker::visitDegrader(const Degrader &deg) {
itsOpalBeamline_m.visit(deg, *this, itsBunch);
}
inline void ParallelTTracker::visitDiagnostic(const Diagnostic &diag) {
itsOpalBeamline_m.visit(diag, *this, itsBunch);
}
......
......@@ -22,6 +22,7 @@
#include "AbsBeamline/Collimator.h"
#include "AbsBeamline/Corrector.h"
#include "AbsBeamline/Degrader.h"
#include "AbsBeamline/Diagnostic.h"
#include "AbsBeamline/Drift.h"
#include "AbsBeamline/ElementBase.h"
......@@ -113,6 +114,9 @@ void ThickMapper::visitCorrector(const Corrector &corr) {
if(length != 0.0) applyDrift(length / 2.0);
}
void ThickMapper::visitDegrader(const Degrader &deg) {
applyDrift(flip_s * deg.getElementLength());
}
void ThickMapper::visitDiagnostic(const Diagnostic &diag) {
// The diagnostic has no effect on the map.
......
......@@ -104,6 +104,9 @@ public:
/// Apply the algorithm to a Corrector.
virtual void visitCorrector(const Corrector &);
/// Apply the algorithm to a Degrader.
virtual void visitDegrader(const Degrader &);
/// Apply the algorithm to a Diagnostic.
virtual void visitDiagnostic(const Diagnostic &);
......
......@@ -25,6 +25,7 @@
#include "AbsBeamline/Collimator.h"
#include "AbsBeamline/Corrector.h"
#include "AbsBeamline/Diagnostic.h"
#include "AbsBeamline/Degrader.h"
#include "AbsBeamline/Drift.h"
#include "AbsBeamline/ElementBase.h"
#include "AbsBeamline/Lambertson.h"
......@@ -135,6 +136,9 @@ void ThickTracker::visitCorrector(const Corrector &corr) {
if(length != 0.0) applyDrift(length / 2.0);
}
void ThickTracker::visitDegrader(const Degrader &deg) {
applyDrift(flip_s * deg.getElementLength());
}
void ThickTracker::visitDiagnostic(const Diagnostic &diag) {
// The diagnostic has no effect on particle tracking.
......
......@@ -96,6 +96,9 @@ public:
/// Apply the algorithm to a Corrector.
virtual void visitCorrector(const Corrector &);
/// Apply the algorithm to a Degrader.
virtual void visitDegrader(const Degrader &);
/// Apply the algorithm to a Diagnostic.
virtual void visitDiagnostic(const Diagnostic &);
......
......@@ -23,6 +23,7 @@
#include "AbsBeamline/Collimator.h"
#include "AbsBeamline/Corrector.h"
#include "AbsBeamline/Diagnostic.h"
#include "AbsBeamline/Degrader.h"
#include "AbsBeamline/Drift.h"
#include "AbsBeamline/ElementBase.h"
#include "AbsBeamline/Lambertson.h"
......@@ -146,6 +147,9 @@ void TransportMapper::visitCorrector(const Corrector &corr) {
if(length) applyDrift(length / 2.0);
}
void TransportMapper::visitDegrader(const Degrader &deg) {
applyDrift(flip_s * deg.getElementLength());
}
void TransportMapper::visitDiagnostic(const Diagnostic &diag) {
applyDrift(flip_s * diag.getElementLength());
......
......@@ -112,6 +112,9 @@ public:
/// Apply the algorithm to a Corrector.
virtual void visitCorrector(const Corrector &);
/// Apply the algorithm to a Degrader.
virtual void visitDegrader(const Degrader &);
/// Apply the algorithm to a Diagnostic.
virtual void visitDiagnostic(const Diagnostic &);
......
......@@ -9,6 +9,7 @@ set (_SRCS
OpalCyclotron.cpp
OpalDrift.cpp
OpalECollimator.cpp
OpalDegrader.cpp
OpalElement.cpp
OpalHKicker.cpp
OpalHMonitor.cpp
......
......@@ -10,6 +10,7 @@
#include "AbsBeamline/AlignWrapper.h"
#include "AbsBeamline/BeamBeam.h"
#include "AbsBeamline/Corrector.h"
#include "AbsBeamline/Degrader.h"
#include "AbsBeamline/Diagnostic.h"
#include "AbsBeamline/Lambertson.h"
#include "AbsBeamline/Marker.h"
......
// ------------------------------------------------------------------------
// $RCSfile: OpalDegrader.cpp,v $
// ------------------------------------------------------------------------
// $Revision: 1.1.1.1 $
// ------------------------------------------------------------------------
// Copyright: see Copyright.readme
// ------------------------------------------------------------------------
//
// Class: OpalDegrader
// The class of OPAL Degrader.
//
// ------------------------------------------------------------------------
//
// $Date: 2000/03/27 09:33:39 $
// $Author: Andreas Adelmann $
//
// ------------------------------------------------------------------------
#include "Elements/OpalDegrader.h"
#include "Attributes/Attributes.h"
#include "BeamlineCore/DegraderRep.h"
#include "Structure/SurfacePhysics.h"
// Class OpalDegrader
// ------------------------------------------------------------------------
OpalDegrader::OpalDegrader():
OpalElement(SIZE, "DEGRADER",
"The \"DEGRADER\" element defines a degrader."),
sphys_m(NULL) {
itsAttr[XSIZE] = Attributes::makeReal
("XSIZE", "Horizontal half-aperture in m");
itsAttr[YSIZE] = Attributes::makeReal
("YSIZE", "Vertical half-aperture in m");
itsAttr[OUTFN] = Attributes::makeString
("OUTFN", "Monitor output filename");
itsAttr[DX] = Attributes::makeReal
("DX", "Misalignment in x direction",0.0);
itsAttr[DY] = Attributes::makeReal
("DY", "Misalignment in y direction",0.0);
itsAttr[DZ] = Attributes::makeReal
("DZ", "Misalignment in z direction",0.0);
registerStringAttribute("OUTFN");
registerRealAttribute("XSIZE");
registerRealAttribute("YSIZE");
registerRealAttribute("DX");
registerRealAttribute("DY");
registerRealAttribute("DZ");
setElement((new DegraderRep("DEGRADER"))->makeAlignWrapper());
}
OpalDegrader::OpalDegrader(const string &name, OpalDegrader *parent):
OpalElement(name, parent),
sphys_m(NULL) {
setElement((new DegraderRep(name))->makeAlignWrapper());
}
OpalDegrader::~OpalDegrader() {
if(sphys_m)
delete sphys_m;
}
OpalDegrader *OpalDegrader::clone(const string &name) {
return new OpalDegrader(name, this);
}
void OpalDegrader::fillRegisteredAttributes(const ElementBase &base, ValueFlag flag) {
OpalElement::fillRegisteredAttributes(base, flag);
const DegraderRep *deg =
dynamic_cast<const DegraderRep *>(base.removeWrappers());
attributeRegistry["XSIZE"]->setReal(deg->getXsize());
attributeRegistry["YSIZE"]->setReal(deg->getYsize());
double dx, dy, dz;
deg->getMisalignment(dx, dy, dz);
attributeRegistry["DX"]->setReal(dx);
attributeRegistry["DY"]->setReal(dy);
attributeRegistry["DZ"]->setReal(dz);
}
void OpalDegrader::update() {
double dx = Attributes::getReal(itsAttr[DX]);
double dy = Attributes::getReal(itsAttr[DY]);
double dz = Attributes::getReal(itsAttr[DZ]);
DegraderRep *deg =
dynamic_cast<DegraderRep *>(getElement()->removeWrappers());
double length = Attributes::getReal(itsAttr[LENGTH]);
deg->setElementLength(length);
deg->setXsize(Attributes::getReal(itsAttr[XSIZE]));
deg->setYsize(Attributes::getReal(itsAttr[YSIZE]));
deg->setOutputFN(Attributes::getString(itsAttr[OUTFN]));
deg->setMisalignment(dx, dy, dz);
std::vector<double> apert = getApert();
double apert_major = -1., apert_minor = -1.;
if(apert.size() > 0) {
apert_major = apert[0];
if(apert.size() > 1) {
apert_minor = apert[1];
} else {
apert_minor = apert[0];
}
}
if(itsAttr[SURFACEPHYSICS] && sphys_m == NULL) {
sphys_m = (SurfacePhysics::find(Attributes::getString(itsAttr[SURFACEPHYSICS])))->clone(getOpalName() + string("_sphys"));
sphys_m->initSurfacePhysicsHandler(*deg, apert_major, apert_minor);
deg->setSurfacePhysics(sphys_m->handler_m);
}
// Transmit "unknown" attributes.
OpalElement::updateUnknown(deg);
}
#ifndef OPAL_OpalDegrader_HH
#define OPAL_OpalDegrader_HH
// ------------------------------------------------------------------------
// $RCSfile: OpalDegrader.h,v $
// ------------------------------------------------------------------------
// $Revision: 1.1.1.1 $
// ------------------------------------------------------------------------
// Copyright: see Copyright.readme
// ------------------------------------------------------------------------
//
// Class: OpalDegrader
//
// ------------------------------------------------------------------------
//
// $Date: 2000/03/27 09:33:39 $
// $Author: Andreas Adelmann $
//
// ------------------------------------------------------------------------
#include "Elements/OpalElement.h"
class SurfacePhysics;
// Class OpalDegrader
// ------------------------------------------------------------------------
/// The DEGRADER element.
class OpalDegrader: public OpalElement {
public:
/// The attributes of class OpalDegrader.
enum {
XSIZE = COMMON, // The horizontal half-size.
YSIZE, // The vertical half-size.
OUTFN,
DX, // Misalignment: translation in x direction
DY, // Misalignment: translation in y direction
DZ, // Misalignment: translation in z direction
SIZE
};
/// Exemplar constructor.
OpalDegrader();
virtual ~OpalDegrader();
/// Make clone.
virtual OpalDegrader *clone(const string &name);
/// Fill in all registered attributes.
virtual void fillRegisteredAttributes(const ElementBase &, ValueFlag);
/// Update the embedded CLASSIC collimator.
virtual void update();
private:
// Not implemented.
OpalDegrader(const OpalDegrader &);
void operator=(const OpalDegrader &);
// Clone constructor.
OpalDegrader(const string &name, OpalDegrader *parent);
SurfacePhysics *sphys_m;
};
#endif // OPAL_OpalDegrader_HH
......@@ -91,6 +91,7 @@
#include "Elements/OpalCyclotron.h"
#include "Elements/OpalDrift.h"
#include "Elements/OpalECollimator.h"
#include "Elements/OpalDegrader.h"
#include "Elements/OpalHKicker.h"
#include "Elements/OpalHMonitor.h"
#include "Elements/OpalInstrument.h"
......@@ -205,6 +206,7 @@ namespace Configure {
OPAL->create(new OpalCyclotron());
OPAL->create(new OpalDrift());
OPAL->create(new OpalECollimator());
OPAL->create(new OpalDegrader());
OPAL->create(new OpalHKicker());
OPAL->create(new OpalHMonitor());
OPAL->create(new OpalInstrument());
......
......@@ -127,7 +127,7 @@ void SurfacePhysics::initSurfacePhysicsHandler(ElementBase &element, const doubl
itsElement_m = &element;
material_m = Attributes::getString(itsAttr[MATERIAL]);
if(Attributes::getString(itsAttr[TYPE]) == "COLLIMATOR") {
if(Attributes::getString(itsAttr[TYPE]) == "COLLIMATOR" || Attributes::getString(itsAttr[TYPE]) == "DEGRADER") {
Inform m("sph ");
handler_m = new CollimatorPhysics(getOpalName(), itsElement_m, major, minor, material_m);
m << *this << endl;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment