GenericBendField Class Reference

Inheritance diagram for GenericBendField:

BLElementField

List of all members.


Detailed Description

GenericBendField represents one placement of a generic bending magnet.

Public Member Functions

 GenericBendField (BLCoordinateTransform &_global2local, BLCMDgenericbend *bend)
 constructor.
void addFieldValue (const G4double point[4], G4double field[6]) const
 addFieldValue() adds the field for this solenoid into field[]. point[] is in global coordinates.

Private Attributes

G4double halfwidth
G4double halfheight
G4double halflength
G4double * By
BLCoordinateTransform global2local
G4RotationMatrix rotation
G4double fringeMaxZ
G4double fringeDepth
BLEngeFunction enge

Constructor & Destructor Documentation

GenericBendField::GenericBendField ( BLCoordinateTransform _global2local,
BLCMDgenericbend bend 
)

constructor.

References BLCMDgenericbend::By, By, enge, ENGE_BLOCK, BLCMDgenericbend::fieldHeight, BLCMDgenericbend::fieldLength, BLCMDgenericbend::fieldWidth, BLCMDgenericbend::fringe, FRINGE_ACCURACY, fringeDepth, BLCMDgenericbend::fringeFactor, fringeMaxZ, BLCoordinateTransform::getGlobal(), BLCommand::getList(), BLCoordinateTransform::getRotation(), BLEngeFunction::getType(), global2local, halfheight, halflength, halfwidth, BLCommand::printError(), rotation, BLEngeFunction::set(), and BLElementField::setGlobalPoint().

00351                                                         :
00352                                 BLElementField(), rotation(), enge(ENGE_BEND)
00353 {
00354         halfwidth = bend->fieldWidth/2.0;
00355         halfheight = bend->fieldHeight/2.0;
00356         halflength = bend->fieldLength/2.0;
00357         By = &bend->By;
00358         global2local = _global2local;
00359         rotation = global2local.getRotation().inverse();
00360         fringeDepth = bend->fringeFactor * halfheight * 2.0;
00361 
00362         if(bend->fringe != "") {
00363                 std::vector<G4double> v = BLCommand::getList(bend->fringe,',');
00364                 if(v.size() == 1 && v[0] == 0.0)
00365                         enge.set(0,0,0,0,0,0);
00366                 else if(v.size() == 6)
00367                         enge.set(v[0],v[1],v[2],v[3],v[4],v[5]);
00368                 else
00369                         BLCommand::printError("Invalid fringe value '%s'\n",
00370                                                 bend->fringe.c_str());
00371         }
00372 
00373         if(enge.getType() == ENGE_BLOCK) {
00374                 fringeMaxZ = halflength;
00375         } else {
00376                 for(int i=0; i<1000; ++i) {
00377                         fringeMaxZ = i*halfwidth/5.0 + halflength;
00378                         if(enge((fringeMaxZ-halflength)/fringeDepth) <
00379                                                         FRINGE_ACCURACY)
00380                                 break;
00381                 }
00382         }
00383 
00384         // set global bounding box
00385         G4double local[4], global[4];
00386         local[3] = 0.0;
00387         for(int i=0; i<2; ++i) {
00388                 local[0] = (i==0 ? -1.0 : 1.0) * halfwidth;
00389                 for(int j=0; j<2; ++j) {
00390                         local[1] = (j==0 ? -1.0 : 1.0) * halfheight;
00391                         for(int k=0; k<2; ++k) {
00392                                 local[2] = (k==0 ? -1.0 : 1.0) * fringeMaxZ;
00393                                 global2local.getGlobal(local,global);
00394                                 setGlobalPoint(global);
00395                         }
00396                 }
00397         }
00398 }


Member Function Documentation

void GenericBendField::addFieldValue ( const G4double  point[4],
G4double  field[6] 
) const [virtual]

addFieldValue() adds the field for this solenoid into field[]. point[] is in global coordinates.

Implements BLElementField.

References B, By, enge, BLEngeFunction::fifth(), BLEngeFunction::fourth(), fringeDepth, fringeMaxZ, BLCoordinateTransform::getLocal(), global2local, halfheight, halflength, halfwidth, BLCoordinateTransform::isRotated(), BLEngeFunction::prime(), rotation, BLEngeFunction::second(), and BLEngeFunction::third().

00402 {
00403         G4ThreeVector global(point[0],point[1],point[2]);
00404         G4ThreeVector local;
00405 
00406         global2local.getLocal(local,global);
00407         if(fabs(local[0]) > halfwidth || fabs(local[1]) > halfheight ||
00408            fabs(local[2]) > fringeMaxZ)
00409                 return;
00410 
00411         /* Enge function as applied in Cosy Infinity */
00412         double fringeZ = (fabs(local[2])-halflength)/fringeDepth;
00413         G4double e = enge(fringeZ);
00414         G4double e1 = enge.prime(fringeZ)/fringeDepth;
00415         G4double y = local[1];
00416         G4double B0 = *By;
00417 /* 1,2,3 makes almost no visible difference in tracking; 
00418    the fields do differ visibly. */
00419 #define COMPUTE_TERMS 1
00420 #if COMPUTE_TERMS==1
00421         G4ThreeVector B(0.0,B0*e,B0*e1*y);
00422 #elif COMPUTE_TERMS==2
00423         G4double e2 = enge.second(fringeZ)/fringeDepth/fringeDepth;
00424         G4double e3 = enge.third(fringeZ)/fringeDepth/fringeDepth/fringeDepth;
00425         G4double y2 = y*y;
00426         G4double y3 = y*y2;
00427         G4ThreeVector B(0.0,B0*(e-0.5*e2*y2),B0*(e1*y-y3*e3/6.0));
00428 #elif COMPUTE_TERMS==3
00429         G4double e2 = enge.second(fringeZ)/fringeDepth/fringeDepth;
00430         G4double e3 = enge.third(fringeZ)/fringeDepth/fringeDepth/fringeDepth;
00431         G4double e4 = enge.fourth(fringeZ)/fringeDepth/fringeDepth/fringeDepth/fringeDepth;
00432         G4double e5 = enge.fifth(fringeZ)/fringeDepth/fringeDepth/fringeDepth/fringeDepth/fringeDepth;
00433         G4double y2 = y*y;
00434         G4double y3 = y*y2;
00435         G4double y4 = y*y3;
00436         G4double y5 = y*y4;
00437         G4ThreeVector B(0.0,B0*(e-0.5*e2*y2+y4*e4/24.0),
00438                                         B0*(e1*y-y3*e3/6.0+y5*e5/120.0));
00439 #else
00440 #error invalid value of COMPUTE_TERMS
00441 #endif
00442         if(local[2] < 0.0) B[2] = -B[2];
00443 
00444         if(global2local.isRotated())
00445                 B = rotation * B;
00446 
00447         field[0] += B[0];
00448         field[1] += B[1];
00449         field[2] += B[2];
00450 }


Member Data Documentation

G4double GenericBendField::halfwidth [private]

Referenced by addFieldValue(), and GenericBendField().

G4double GenericBendField::halfheight [private]

Referenced by addFieldValue(), and GenericBendField().

G4double GenericBendField::halflength [private]

Referenced by addFieldValue(), and GenericBendField().

G4double* GenericBendField::By [private]

Referenced by addFieldValue(), and GenericBendField().

Referenced by addFieldValue(), and GenericBendField().

G4RotationMatrix GenericBendField::rotation [private]

Referenced by addFieldValue(), and GenericBendField().

G4double GenericBendField::fringeMaxZ [private]

Referenced by addFieldValue(), and GenericBendField().

G4double GenericBendField::fringeDepth [private]

Referenced by addFieldValue(), and GenericBendField().

Referenced by addFieldValue(), and GenericBendField().


The documentation for this class was generated from the following file:
g4beamline