Commit 28f2a31b authored by Jianjun Yang's avatar Jianjun Yang
Browse files

Add ZSTART and ZEND for modelling vertical beam probe in OPAL-cycl

parent a2247865
......@@ -93,6 +93,8 @@ Collimator::Collimator(const Collimator &right):
xend_m(right.xend_m),
ystart_m(right.ystart_m),
yend_m(right.yend_m),
zstart_m(right.zstart_m),
zend_m(right.zend_m),
width_m(right.width_m),
isAPepperPot_m(right.isAPepperPot_m),
isASlit_m(right.isASlit_m),
......@@ -131,6 +133,8 @@ Collimator::Collimator(const string &name):
xend_m(0.0),
ystart_m(0.0),
yend_m(0.0),
zstart_m(0.0),
zend_m(0.0),
width_m(0.0),
isAPepperPot_m(false),
isASlit_m(false),
......@@ -249,17 +253,19 @@ bool Collimator::checkCollimator(PartBunch &bunch, const int turnnumber, const d
double r_start = sqrt(xstart_m * xstart_m + ystart_m * ystart_m);
double r_end = sqrt(xend_m * xend_m + yend_m * yend_m);
double r1 = sqrt(rmax(0) * rmax(0) + rmax(1) * rmax(1));
if( r1 > r_start - 10.0 && r1 < r_end + 10.0 ){
size_t tempnum = bunch.getLocalNum();
int pflag = 0;
for(unsigned int i = 0; i < tempnum; ++i) {
if(bunch.PType[i] == 0) {
pflag = checkPoint(bunch.R[i](0), bunch.R[i](1));
if(pflag != 0) {
lossDs_m->addParticle(bunch.R[i], bunch.P[i], bunch.ID[i]);
bunch.Bin[i] = -1;
flagNeedUpdate = true;
if(rmax(2) >= zstart_m && rmin(2) <= zend_m) {
if( r1 > r_start - 10.0 && r1 < r_end + 10.0 ){
size_t tempnum = bunch.getLocalNum();
int pflag = 0;
for(unsigned int i = 0; i < tempnum; ++i) {
if(bunch.PType[i] == 0 && bunch.R[i](2) < zend_m && bunch.R[i](2) > zstart_m ) {
pflag = checkPoint(bunch.R[i](0), bunch.R[i](1));
if(pflag != 0) {
lossDs_m->addParticle(bunch.R[i], bunch.P[i], bunch.ID[i]);
bunch.Bin[i] = -1;
flagNeedUpdate = true;
}
}
}
}
......@@ -557,6 +563,14 @@ void Collimator::setYEnd(double yend) {
yend_m = yend;
}
void Collimator::setZStart(double zstart) {
zstart_m = zstart;
}
void Collimator::setZEnd(double zend) {
zend_m = zend;
}
void Collimator::setWidth(double width) {
width_m = width;
}
......@@ -577,6 +591,14 @@ double Collimator::getYEnd() {
return yend_m;
}
double Collimator::getZStart() {
return zstart_m;
}
double Collimator::getZEnd() {
return zend_m;
}
double Collimator::getWidth() {
return width_m;
}
......@@ -670,6 +692,12 @@ void Collimator::setGeom() {
geom_m[4].x = geom_m[0].x;
geom_m[4].y = geom_m[0].y;
if (zstart_m > zend_m){
double tempz = 0.0;
tempz = zstart_m;
zstart_m = zend_m;
zend_m = tempz;
}
}
......
......@@ -116,23 +116,19 @@ public:
// --------Cyclotron collimator
void setXStart(double xstart) ;
void setYStart(double ystart) ;
void setZStart(double zstart) ;
void setXEnd(double xend) ;
void setYEnd(double yend) ;
void setZEnd(double zend) ;
void setWidth(double width) ;
double getXStart() ;
double getYStart() ;
double getZStart() ;
double getXEnd() ;
double getYEnd() ;
double getZEnd() ;
double getWidth() ;
//-----------------
......@@ -176,6 +172,8 @@ private:
double xend_m;
double ystart_m;
double yend_m;
double zstart_m;
double zend_m;
double width_m;
......
......@@ -40,6 +40,8 @@ CollimatorPhysics::CollimatorPhysics(const string &name, ElementBase *element, c
xend_m(0.0),
ystart_m(0.0),
yend_m(0.0),
zstart_m(0.0),
zend_m(0.0),
width_m(0.0),
Begin_m(0.0),
End_m(0.0),
......@@ -66,8 +68,10 @@ CollimatorPhysics::CollimatorPhysics(const string &name, ElementBase *element, c
yp_m = coll->getYpos();
xstart_m = coll->getXStart();
ystart_m = coll->getYStart();
zstart_m = coll->getZStart();
xend_m = coll->getXEnd();
yend_m = coll->getYEnd();
zend_m = coll->getZEnd();
width_m = coll->getWidth();
setCColimatorGeom();
......@@ -138,11 +142,12 @@ void CollimatorPhysics::apply(PartBunch &bunch) {
Vector_t &P = Pincol_m[i];
if(collshape_m == "CCollimator") {
if( checkPoint(R(0), R(1)) == 1 )
incoll_m = true;
if(R(2) < zend_m && R(2) > zstart_m ) {
if(checkPoint(R(0), R(1)) == 1 )
incoll_m = true;
}
else
incoll_m = false;
} else {
if(collshape_m == "Slit") {
......@@ -235,12 +240,15 @@ void CollimatorPhysics::apply(PartBunch &bunch) {
Vector_t R = bunch.R[i];
Vector_t P = bunch.P[i];
if(collshape_m == "CCollimator") {
if( checkPoint(R(0), R(1)) == 1 )
incoll_m = true;
if(collshape_m == "CCollimator") {
if(R(2) < zend_m && R(2) > zstart_m ) {
if(checkPoint(R(0), R(1)) == 1 )
incoll_m = true;
}
else
incoll_m = false;
} else {
if(collshape_m == "Slit") {
if(a_m > 0) {
rr1 = -R(0) * scalefactor / std::fabs(a_m);
......@@ -338,11 +346,14 @@ void CollimatorPhysics::apply(PartBunch &bunch) {
Vector_t &P = Pincol_m[i];
if(collshape_m == "CCollimator") {
if( checkPoint(R(0), R(1)) == 1 )
incoll_m = true;
if(R(2) < zend_m && R(2) > zstart_m ) {
if(checkPoint(R(0), R(1)) == 1 )
incoll_m = true;
}
else
incoll_m = false;
} else {
if(collshape_m == "Slit") {
if(a_m > 0) {
rr1 = -R(0) * scalefactor / std::fabs(a_m);
......@@ -610,6 +621,12 @@ void CollimatorPhysics::setCColimatorGeom() {
geom_m[4].x = geom_m[0].x;
geom_m[4].y = geom_m[0].y;
if (zstart_m > zend_m){
double tempz = 0.0;
tempz = zstart_m;
zstart_m = zend_m;
zend_m = tempz;
}
}
......
......@@ -47,6 +47,8 @@ private:
double xend_m;
double ystart_m;
double yend_m;
double zstart_m;
double zend_m;
double width_m;
double Begin_m;
......
......@@ -355,6 +355,12 @@ void ParallelCyclotronTracker::visitCollimator(const Collimator &coll) {
double yend = elptr->getYEnd();
*gmsg << "Yend= " <<yend << " [mm]" << endl;
double zstart = elptr->getZStart();
*gmsg << "Zstart= " << zstart << " [mm]" << endl;
double zend = elptr->getZEnd();
*gmsg << "Zend= " <<zend << " [mm]" << endl;
double width = elptr->getWidth();
*gmsg << "Width= " << width << " [mm]" << endl;
......
......@@ -12,7 +12,7 @@
// ------------------------------------------------------------------------
//
// $Date: 2000/03/27 09:33:39 $
// $Author: Andreas Adelmann $
// $Author: Andreas Adelmann, Jianjun Yang $
//
// ------------------------------------------------------------------------
......@@ -39,6 +39,10 @@ OpalCCollimator::OpalCCollimator():
("YSTART", "Start of y coordinate, [mm]");
itsAttr[YEND] = Attributes::makeReal
("YEND", "End of y coordinate, [mm]");
itsAttr[ZSTART] = Attributes::makeReal
("ZSTART", "Start of vertical coordinate, [mm], default value: -100",-100.0);
itsAttr[ZEND] = Attributes::makeReal
("ZEND", "End of vertical coordinate, [mm], default value: 100", 100.0);
itsAttr[WIDTH] = Attributes::makeReal
("WIDTH", "Width of the collimator [mm]");
itsAttr[OUTFN] = Attributes::makeString
......@@ -48,6 +52,8 @@ OpalCCollimator::OpalCCollimator():
registerRealAttribute("XEND");
registerRealAttribute("YSTART");
registerRealAttribute("YEND");
registerRealAttribute("ZSTART");
registerRealAttribute("ZEND");
registerRealAttribute("WIDTH");
registerStringAttribute("OUTFN");
......@@ -86,12 +92,16 @@ void OpalCCollimator::update() {
double xend = Attributes::getReal(itsAttr[XEND]);
double ystart = Attributes::getReal(itsAttr[YSTART]);
double yend = Attributes::getReal(itsAttr[YEND]);
double zstart = Attributes::getReal(itsAttr[ZSTART]);
double zend = Attributes::getReal(itsAttr[ZEND]);
double width = Attributes::getReal(itsAttr[WIDTH]);
coll->setElementLength(length);
coll->setXStart(xstart);
coll->setXEnd(xend);
coll->setYStart(ystart);
coll->setYEnd(yend);
coll->setZStart(zstart);
coll->setZEnd(zend);
coll->setWidth(width);
coll->setOutputFN(Attributes::getString(itsAttr[OUTFN]));
coll->setCColl();
......
......@@ -14,7 +14,7 @@
// ------------------------------------------------------------------------
//
// $Date: 2000/03/27 09:33:39 $
// $Author: Andreas Adelmann $
// $Author: Andreas Adelmann, Jianjun Yang $
//
// ------------------------------------------------------------------------
......@@ -35,6 +35,8 @@ public:
XEND, // End of x coordinate
YSTART, // Start of y coordinate
YEND, // End of y coordinate
ZSTART, // Top boundary
ZEND, // Bottom boundary
WIDTH, //The width of collimator
OUTFN,
SIZE
......
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