Ideal means a block field with no fringes.
The sector axis is along Y, offset by fieldCenterRadius in the +X direction from the centerline, for angle>0. angle>0 means a left bend, while angle<0 means a right bend (toward -X).
The magnetic field is uniform throught the sector, along the local Y axis.
NOTE: the width of this object is not correct (too hard to compute). That's OK as long as some element is placed both before and after it.
Public Member Functions | |
BLCMDidealsectorbend () | |
Default constructor. Defines the command, args, etc. | |
virtual | ~BLCMDidealsectorbend () |
Destructor. | |
BLCMDidealsectorbend (const BLCMDidealsectorbend &r) | |
Copy constructor. | |
BLElement * | clone () |
clone() | |
G4String | commandName () |
commandName() returns "idealsectorbend". | |
int | command (BLArgumentVector &argv, BLArgumentMap &namedArgs) |
command() implements the idealsectorbend command. | |
void | defineNamedArgs () |
defineNamedArgs() defines the named arguments for the command. | |
void | construct (G4RotationMatrix *relativeRotation, G4ThreeVector relativePosition, G4LogicalVolume *parent, G4String parentName, G4RotationMatrix *parentRotation, G4ThreeVector parentPosition) |
construct() - construct the ideal sector bending magnet | |
G4double | getLength () |
getLength() returns the length along the Z axis | |
G4double | getWidth () |
getWidth() returns the width of the iron region (this is an overestimate on the inside) | |
G4double | getHeight () |
getHeight() returns the height of the iron region | |
G4bool | isOK () |
isOK() returns true. | |
bool | isOutside (G4ThreeVector &local, G4double tolerance) |
isOutside() from BLElement. | |
void | generatePoints (int npoints, std::vector< G4ThreeVector > &v) |
generatePoints() from BLElement. | |
Private Attributes | |
G4double | angle |
G4double | fieldCenterRadius |
G4double | fieldInnerRadius |
G4double | fieldOuterRadius |
G4double | fieldHeight |
G4double | ironInnerRadius |
G4double | ironOuterRadius |
G4double | ironHeight |
G4double | By |
G4String | fieldMaterial |
G4String | fieldColor |
G4String | ironMaterial |
G4String | ironColor |
G4int | kill |
G4double | maxStep |
G4Tubs * | fieldTubs |
G4Tubs * | ironTubs |
G4VSolid * | ironSolid |
Friends | |
class | IdealSectorBendField |
BLCMDidealsectorbend::BLCMDidealsectorbend | ( | ) |
Default constructor. Defines the command, args, etc.
References angle, BLCMDTYPE_ELEMENT, By, fieldCenterRadius, fieldColor, fieldHeight, fieldInnerRadius, fieldMaterial, fieldOuterRadius, fieldTubs, ironColor, ironHeight, ironInnerRadius, ironMaterial, ironOuterRadius, ironSolid, ironTubs, kill, maxStep, BLCommand::registerCommand(), BLCommand::setDescription(), and BLCommand::setSynopsis().
Referenced by clone(), and command().
00151 : BLElement() 00152 { 00153 // register the commandName(), and its synopsis and description. 00154 registerCommand(BLCMDTYPE_ELEMENT); 00155 setSynopsis("construct an ideal sector bending magnet."); 00156 setDescription("The field region is a sector with By specified.\n" 00157 "Unlike most Elements, the position of the idealsectorbend\n" 00158 "is the center of the front face of its field (aperture).\n" 00159 "angle>0 bends to the left around Y; angle<0 bends right.\n" 00160 "The only useful rotations are around the centerline Z.\n" 00161 "Should be followed immediately by a cornerarc. Note that " 00162 "-90<angle<90 degrees."); 00163 00164 // provide initial values for fields 00165 angle = 0.0; 00166 fieldCenterRadius = 0.0; 00167 fieldInnerRadius = 0.0; 00168 fieldOuterRadius = 0.0; 00169 fieldHeight = 0.0; 00170 ironInnerRadius = 0.0; 00171 ironOuterRadius = 0.0; 00172 ironHeight = 0.0; 00173 By = 0.0; 00174 fieldMaterial = "Vacuum"; 00175 fieldColor = ""; 00176 ironMaterial = "Fe"; 00177 ironColor = ""; 00178 kill = 0; 00179 maxStep = -1.0; 00180 fieldTubs = 0; 00181 ironTubs = 0; 00182 ironSolid = 0; 00183 }
BLCMDidealsectorbend::BLCMDidealsectorbend | ( | const BLCMDidealsectorbend & | r | ) |
Copy constructor.
References angle, By, BLTune::copyTunableArg(), fieldCenterRadius, fieldColor, fieldHeight, fieldInnerRadius, fieldMaterial, fieldOuterRadius, fieldTubs, ironColor, ironHeight, ironInnerRadius, ironMaterial, ironOuterRadius, ironSolid, ironTubs, kill, and maxStep.
00186 : BLElement(r) 00187 { 00188 // copy fields one at a time (transfers default values from the 00189 // default object to this new object). 00190 angle = r.angle; 00191 fieldCenterRadius = r.fieldCenterRadius; 00192 fieldInnerRadius = r.fieldInnerRadius; 00193 fieldOuterRadius = r.fieldOuterRadius; 00194 fieldHeight = r.fieldHeight; 00195 ironInnerRadius = r.ironInnerRadius; 00196 ironOuterRadius = r.ironOuterRadius; 00197 ironHeight = r.ironHeight; 00198 BLTune::copyTunableArg(&By,&r.By); 00199 fieldMaterial = r.fieldMaterial; 00200 fieldColor = r.fieldColor; 00201 ironMaterial = r.ironMaterial; 00202 ironColor = r.ironColor; 00203 kill = r.kill; 00204 maxStep = r.maxStep; 00205 fieldTubs = r.fieldTubs; 00206 ironTubs = r.ironTubs; 00207 ironSolid = r.ironSolid; 00208 }
BLElement* BLCMDidealsectorbend::clone | ( | ) | [inline, virtual] |
Implements BLElement.
References BLCMDidealsectorbend().
00083 { return new BLCMDidealsectorbend(*this); }
G4String BLCMDidealsectorbend::commandName | ( | ) | [inline, virtual] |
int BLCMDidealsectorbend::command | ( | BLArgumentVector & | argv, | |
BLArgumentMap & | namedArgs | |||
) | [virtual] |
command() implements the idealsectorbend command.
Implements BLCommand.
References angle, BLCMDidealsectorbend(), fieldMaterial, BLParam::getDouble(), BLCommand::getMaterial(), BLCommand::handleNamedArgs(), ironMaterial, maxStep, Param, BLCommand::print(), BLCommand::printError(), and BLElement::setName().
00211 { 00212 if(argv.size() != 1) { 00213 printError("idealsectorbend: Invalid command, must have name"); 00214 return -1; 00215 } 00216 00217 if(argv[0] == "default") { 00218 return defaultIdealSectorBend.handleNamedArgs(namedArgs); 00219 } 00220 00221 BLCMDidealsectorbend *t = new BLCMDidealsectorbend(defaultIdealSectorBend); 00222 t->setName(argv[0]); 00223 int retval = t->handleNamedArgs(namedArgs); 00224 00225 if(t->maxStep < 0.0) t->maxStep = Param.getDouble("maxStep"); 00226 00227 if(fabs(t->angle) > 90.0) 00228 printError("idealsectorbend: -90<=angle<=90 degrees."); 00229 00230 // check material exists 00231 getMaterial(t->fieldMaterial,false); 00232 getMaterial(t->ironMaterial,false); 00233 00234 t->print(argv[0]); 00235 00236 return retval; 00237 }
void BLCMDidealsectorbend::defineNamedArgs | ( | ) | [virtual] |
defineNamedArgs() defines the named arguments for the command.
Reimplemented from BLCommand.
References angle, BLCommand::argDouble(), BLCommand::argInt(), BLCommand::argString(), BLCommand::argTunable(), By, fieldCenterRadius, fieldColor, fieldHeight, fieldInnerRadius, fieldMaterial, fieldOuterRadius, ironColor, ironHeight, ironInnerRadius, ironMaterial, ironOuterRadius, kill, and maxStep.
00240 { 00241 argDouble(angle,"angle","Angle of bend (degrees).",deg); 00242 argDouble(fieldCenterRadius,"fieldCenterRadius","Center radius of field (mm)."); 00243 argDouble(fieldInnerRadius,"fieldInnerRadius","Inner radius of field (mm)."); 00244 argDouble(fieldOuterRadius,"fieldOuterRadius","Outer radius of field (mm)."); 00245 argDouble(fieldHeight,"fieldHeight","Height of field (mm)."); 00246 argDouble(ironInnerRadius,"ironInnerRadius","Inner radius of iron (mm)."); 00247 argDouble(ironOuterRadius,"ironOuterRadius","Outer radius of iron (mm)."); 00248 argDouble(ironHeight,"ironHeight","Height of iron (mm)."); 00249 argTunable(By,"By","Magnetic field (Tesla).",tesla); 00250 argString(fieldMaterial,"fieldMaterial","Material of field."); 00251 argString(fieldColor,"fieldColor","Color of field."); 00252 argString(ironMaterial,"ironMaterial","Material of iron."); 00253 argString(ironColor,"ironColor","Color of iron."); 00254 argDouble(maxStep,"maxStep","The maximum stepsize in the element (mm)"); 00255 argInt(kill,"kill","Set nonzero to kill particles hitting the iron."); 00256 }
void BLCMDidealsectorbend::construct | ( | G4RotationMatrix * | relativeRotation, | |
G4ThreeVector | relativePosition, | |||
G4LogicalVolume * | parent, | |||
G4String | parentName, | |||
G4RotationMatrix * | parentRotation, | |||
G4ThreeVector | parentPosition | |||
) | [virtual] |
construct() - construct the ideal sector bending magnet
Implements BLElement.
References BLGlobalField::addElementField(), angle, fieldCenterRadius, fieldColor, fieldHeight, fieldInnerRadius, fieldMaterial, fieldOuterRadius, fieldTubs, BLParam::getDouble(), BLCommand::getMaterial(), BLElement::getName(), BLGlobalField::getObject(), BLManager::getObject(), BLCommand::getVisAttrib(), IdealSectorBendField, ironColor, ironHeight, ironInnerRadius, ironMaterial, ironOuterRadius, ironSolid, ironTubs, kill, maxStep, Param, and BLCommand::stringToRotationMatrix().
00265 { 00266 G4String thisname = parentName+getName(); 00267 00268 // values for right bend (angle <0) 00269 G4double phi = angle; // start angle for iron Tubs 00270 G4double dphi = -angle; // end-start angle for iron Tubs 00271 G4double xOffset = -fieldCenterRadius; 00272 G4RotationMatrix *g4rot = stringToRotationMatrix("X90"); 00273 00274 // angle>0 bends to the left 00275 if(angle >= 0) { 00276 phi = pi; 00277 dphi = angle; 00278 xOffset = fieldCenterRadius; 00279 } 00280 00281 if(!fieldTubs) { 00282 G4double extra = 0.1*mm/fieldCenterRadius; 00283 fieldTubs = new G4Tubs(thisname+"IdealSectorBendField", 00284 fieldInnerRadius,fieldOuterRadius, 00285 fieldHeight/2.0,phi-extra,dphi+extra*2.0); 00286 } 00287 G4Material *mat = getMaterial(fieldMaterial); 00288 G4LogicalVolume *lvfield = new G4LogicalVolume(fieldTubs,mat, 00289 thisname+"LogVol"); 00290 lvfield->SetVisAttributes(getVisAttrib(fieldColor)); 00291 if(maxStep <= 0.0) maxStep = Param.getDouble("maxStep"); 00292 lvfield->SetUserLimits(new G4UserLimits(maxStep)); 00293 00294 if(!ironTubs) 00295 ironTubs = new G4Tubs(thisname+"IdealSectorBendIron", 00296 ironInnerRadius,ironOuterRadius, 00297 ironHeight/2.0,phi,dphi); 00298 if(!ironSolid) 00299 ironSolid = new G4SubtractionSolid(thisname+"IdealSectorBendSolid", 00300 ironTubs, fieldTubs); 00301 mat = getMaterial(ironMaterial); 00302 G4LogicalVolume *lviron = new G4LogicalVolume(ironSolid,mat, 00303 thisname+"LogVol"); 00304 lviron->SetVisAttributes(getVisAttrib(ironColor)); 00305 lviron->SetUserLimits(new G4UserLimits(maxStep)); 00306 00307 // (geant4 rotation convention is backwards from g4beamline) 00308 if(relativeRotation) 00309 *g4rot = *g4rot * relativeRotation->inverse(); 00310 00311 G4ThreeVector pos(xOffset,0.0,0.0); 00312 if(relativeRotation) 00313 pos = *relativeRotation * pos; 00314 00315 pos += relativePosition; 00316 00317 new G4PVPlacement(g4rot,pos,lvfield,thisname, 00318 parent,false,0); 00319 G4PVPlacement *pv = new G4PVPlacement(g4rot,pos,lviron, 00320 thisname, parent,false,0); 00321 if(kill) 00322 BLManager::getObject()-> 00323 registerSteppingAction(pv,new BLKillTrack(thisname)); 00324 00325 // get globalRotation and globalPosition 00326 G4RotationMatrix *globalRotation = 0; 00327 if(relativeRotation && parentRotation) { 00328 globalRotation = 00329 new G4RotationMatrix(*parentRotation * *relativeRotation); 00330 } else if(relativeRotation) { 00331 globalRotation = relativeRotation; 00332 } else if(parentRotation) { 00333 globalRotation = parentRotation; 00334 } 00335 G4ThreeVector globalPosition(pos + parentPosition); 00336 if(parentRotation) 00337 globalPosition = *parentRotation * relativePosition + 00338 parentPosition; 00339 00340 BLCoordinateTransform global2local(globalRotation,globalPosition); 00341 00342 IdealSectorBendField *p = new IdealSectorBendField(global2local,this); 00343 BLGlobalField::getObject()->addElementField(p); 00344 00345 printf("BLCMDidealsectorbend::Construct %s parent=%s relZ=%.1f globZ=%.1f\n", 00346 thisname.c_str(),parentName.c_str(),relativePosition[2], 00347 globalPosition[2]); 00348 }
G4double BLCMDidealsectorbend::getLength | ( | ) | [inline, virtual] |
getLength() returns the length along the Z axis
Implements BLElement.
References angle, and ironOuterRadius.
00103 { return ironOuterRadius*sin(fabs(angle))*2.0; }
G4double BLCMDidealsectorbend::getWidth | ( | ) | [inline, virtual] |
getWidth() returns the width of the iron region (this is an overestimate on the inside)
Implements BLElement.
References fieldCenterRadius, and ironOuterRadius.
00107 { return std::max<double>(fieldCenterRadius, 00108 ironOuterRadius-fieldCenterRadius)*2.0; }
G4double BLCMDidealsectorbend::getHeight | ( | ) | [inline, virtual] |
getHeight() returns the height of the iron region
Implements BLElement.
References ironHeight.
00111 { return ironHeight; }
G4bool BLCMDidealsectorbend::isOK | ( | ) | [inline, virtual] |
bool BLCMDidealsectorbend::isOutside | ( | G4ThreeVector & | local, | |
G4double | tolerance | |||
) | [inline, virtual] |
void BLCMDidealsectorbend::generatePoints | ( | int | npoints, | |
std::vector< G4ThreeVector > & | v | |||
) | [inline, virtual] |
friend class IdealSectorBendField [friend] |
Referenced by construct().
G4double BLCMDidealsectorbend::angle [private] |
Referenced by BLCMDidealsectorbend(), command(), construct(), defineNamedArgs(), getLength(), and IdealSectorBendField::IdealSectorBendField().
G4double BLCMDidealsectorbend::fieldCenterRadius [private] |
Referenced by BLCMDidealsectorbend(), construct(), defineNamedArgs(), and getWidth().
G4double BLCMDidealsectorbend::fieldInnerRadius [private] |
Referenced by BLCMDidealsectorbend(), construct(), defineNamedArgs(), and IdealSectorBendField::IdealSectorBendField().
G4double BLCMDidealsectorbend::fieldOuterRadius [private] |
Referenced by BLCMDidealsectorbend(), construct(), defineNamedArgs(), and IdealSectorBendField::IdealSectorBendField().
G4double BLCMDidealsectorbend::fieldHeight [private] |
Referenced by BLCMDidealsectorbend(), construct(), defineNamedArgs(), and IdealSectorBendField::IdealSectorBendField().
G4double BLCMDidealsectorbend::ironInnerRadius [private] |
Referenced by BLCMDidealsectorbend(), construct(), and defineNamedArgs().
G4double BLCMDidealsectorbend::ironOuterRadius [private] |
Referenced by BLCMDidealsectorbend(), construct(), defineNamedArgs(), getLength(), and getWidth().
G4double BLCMDidealsectorbend::ironHeight [private] |
Referenced by BLCMDidealsectorbend(), construct(), defineNamedArgs(), and getHeight().
G4double BLCMDidealsectorbend::By [private] |
Referenced by BLCMDidealsectorbend(), defineNamedArgs(), and IdealSectorBendField::IdealSectorBendField().
G4String BLCMDidealsectorbend::fieldMaterial [private] |
Referenced by BLCMDidealsectorbend(), command(), construct(), and defineNamedArgs().
G4String BLCMDidealsectorbend::fieldColor [private] |
Referenced by BLCMDidealsectorbend(), construct(), and defineNamedArgs().
G4String BLCMDidealsectorbend::ironMaterial [private] |
Referenced by BLCMDidealsectorbend(), command(), construct(), and defineNamedArgs().
G4String BLCMDidealsectorbend::ironColor [private] |
Referenced by BLCMDidealsectorbend(), construct(), and defineNamedArgs().
G4int BLCMDidealsectorbend::kill [private] |
Referenced by BLCMDidealsectorbend(), construct(), and defineNamedArgs().
G4double BLCMDidealsectorbend::maxStep [private] |
Referenced by BLCMDidealsectorbend(), command(), construct(), and defineNamedArgs().
G4Tubs* BLCMDidealsectorbend::fieldTubs [private] |
Referenced by BLCMDidealsectorbend(), and construct().
G4Tubs* BLCMDidealsectorbend::ironTubs [private] |
Referenced by BLCMDidealsectorbend(), and construct().
G4VSolid* BLCMDidealsectorbend::ironSolid [private] |
Referenced by BLCMDidealsectorbend(), and construct().