This command has no volumes, logical or physical. it just implements a field (E and/or B) from an input file based on BLFieldMap.
Public Member Functions | |
BLCMDfieldmap () | |
Default constructor. Defines the command, args, etc. | |
virtual | ~BLCMDfieldmap () |
Destructor. | |
BLCMDfieldmap (const BLCMDfieldmap &r) | |
Copy constructor. | |
BLElement * | clone () |
clone() | |
G4String | commandName () |
commandName() returns "fieldmap". | |
int | command (BLArgumentVector &argv, BLArgumentMap &namedArgs) |
command() implements the fieldmap 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 fieldmap | |
G4double | getLength () |
getLength() returns 0 (no physical volume here) | |
G4double | getWidth () |
getWidth() returns 0 (no physical volume nere) | |
G4double | getHeight () |
getHeight() returns 0 (no physical volume nere) | |
G4bool | isOK () |
isOK() returns true. | |
bool | isOutside (G4ThreeVector &local, G4double tolerance) |
isOutside() from BLElement. (no volume => every point is "outside") | |
void | generatePoints (int npoints, std::vector< G4ThreeVector > &v) |
generatePoints() from BLElement. (no volume => no generate) | |
Private Attributes | |
BLFieldMap * | map |
G4String | filename |
G4double | current |
G4double | gradient |
G4double | timeOffset |
BLCMDfieldmap::BLCMDfieldmap | ( | ) |
Default constructor. Defines the command, args, etc.
References BLCMDTYPE_ELEMENT, current, gradient, map, BLCommand::registerCommand(), BLCommand::setDescription(), BLCommand::setSynopsis(), and timeOffset.
Referenced by clone(), and command().
00115 : BLElement() 00116 { 00117 // register the commandName(), and its synopsis and description. 00118 registerCommand(BLCMDTYPE_ELEMENT); 00119 setSynopsis("implements a field map, E and/or B, from a file."); 00120 setDescription("Reads an input file in BLFieldMap format to define " 00121 "E and/or B fields, optionally with time dependence. " 00122 "See the Users Guide for a description of the BLFieldMap " 00123 "format." 00124 ""); 00125 00126 // provide initial values for fields 00127 map = 0; 00128 current = 1.0; 00129 gradient = 1.0; 00130 timeOffset = 0.0; 00131 }
BLCMDfieldmap::BLCMDfieldmap | ( | const BLCMDfieldmap & | r | ) |
Copy constructor.
References BLTune::copyTunableArg(), current, gradient, map, and timeOffset.
00134 : BLElement(r) 00135 { 00136 // copy fields one at a time (transfers default values from the 00137 // default object to this new object). 00138 map = r.map; 00139 BLTune::copyTunableArg(¤t,&r.current); 00140 BLTune::copyTunableArg(&gradient,&r.gradient); 00141 timeOffset = r.timeOffset; 00142 }
BLElement* BLCMDfieldmap::clone | ( | ) | [inline, virtual] |
G4String BLCMDfieldmap::commandName | ( | ) | [inline, virtual] |
int BLCMDfieldmap::command | ( | BLArgumentVector & | argv, | |
BLArgumentMap & | namedArgs | |||
) | [virtual] |
command() implements the fieldmap command.
Implements BLCommand.
References BLCMDfieldmap(), filename, BLCommand::handleNamedArgs(), map, BLCommand::print(), BLCommand::printError(), BLFieldMap::readFile(), and BLElement::setName().
00145 { 00146 if(argv.size() != 1) { 00147 BLCommand::printError("fieldmap: Invalid command, must have name"); 00148 return -1; 00149 } 00150 00151 if(argv[0] == "default") { 00152 return defaultFieldMapCmd.handleNamedArgs(namedArgs); 00153 } 00154 00155 BLCMDfieldmap *t = new BLCMDfieldmap(defaultFieldMapCmd); 00156 t->setName(argv[0]); 00157 int retval = t->handleNamedArgs(namedArgs); 00158 00159 t->map = new BLFieldMap(); 00160 t->map->readFile(t->filename); 00161 00162 t->print(argv[0]); 00163 00164 return retval; 00165 }
void BLCMDfieldmap::defineNamedArgs | ( | ) | [virtual] |
defineNamedArgs() defines the named arguments for the command.
Reimplemented from BLCommand.
References BLCommand::argDouble(), BLCommand::argString(), BLCommand::argTunable(), current, filename, gradient, and timeOffset.
00168 { 00169 argString(filename,"filename","Filename for the Field Map.",false); 00170 argString(filename,"file","Synonym for filename.",false); 00171 argTunable(current,"current","Current of the B-field."); 00172 argTunable(gradient,"gradient","Gradient of the E-field."); 00173 argDouble(timeOffset,"timeOffset","Time offset (ns)."); 00174 }
void BLCMDfieldmap::construct | ( | G4RotationMatrix * | relativeRotation, | |
G4ThreeVector | relativePosition, | |||
G4LogicalVolume * | parent, | |||
G4String | parentName, | |||
G4RotationMatrix * | parentRotation, | |||
G4ThreeVector | parentPosition | |||
) | [virtual] |
construct() - construct the fieldmap
Implements BLElement.
References BLGlobalField::addElementField(), current, BLElement::getName(), BLGlobalField::getObject(), gradient, map, and timeOffset.
00183 { 00184 G4String thisname = parentName+getName(); 00185 00186 // get globalRotation and globalPosition 00187 G4RotationMatrix *globalRotation = 0; 00188 if(relativeRotation && parentRotation) { 00189 globalRotation = 00190 new G4RotationMatrix(*parentRotation * *relativeRotation); 00191 } else if(relativeRotation) { 00192 globalRotation = relativeRotation; 00193 } else if(parentRotation) { 00194 globalRotation = parentRotation; 00195 } 00196 G4ThreeVector globalPosition(relativePosition + parentPosition); 00197 if(parentRotation) 00198 globalPosition = *parentRotation * relativePosition + 00199 parentPosition; 00200 00201 FieldMapPlacement *p = new FieldMapPlacement(map,globalRotation, 00202 globalPosition,current,gradient,timeOffset); 00203 BLGlobalField::getObject()->addElementField(p); 00204 00205 printf("BLMappedMagnet::Construct %s parent=%s relZ=%.1f\n", 00206 thisname.c_str(),parentName.c_str(),relativePosition[2]); 00207 }
G4double BLCMDfieldmap::getLength | ( | ) | [inline, virtual] |
G4double BLCMDfieldmap::getWidth | ( | ) | [inline, virtual] |
G4double BLCMDfieldmap::getHeight | ( | ) | [inline, virtual] |
G4bool BLCMDfieldmap::isOK | ( | ) | [inline, virtual] |
bool BLCMDfieldmap::isOutside | ( | G4ThreeVector & | local, | |
G4double | tolerance | |||
) | [inline, virtual] |
void BLCMDfieldmap::generatePoints | ( | int | npoints, | |
std::vector< G4ThreeVector > & | v | |||
) | [inline, virtual] |
BLFieldMap* BLCMDfieldmap::map [private] |
Referenced by BLCMDfieldmap(), command(), and construct().
G4String BLCMDfieldmap::filename [private] |
Referenced by command(), and defineNamedArgs().
G4double BLCMDfieldmap::current [private] |
Referenced by BLCMDfieldmap(), construct(), and defineNamedArgs().
G4double BLCMDfieldmap::gradient [private] |
Referenced by BLCMDfieldmap(), construct(), and defineNamedArgs().
G4double BLCMDfieldmap::timeOffset [private] |
Referenced by BLCMDfieldmap(), construct(), and defineNamedArgs().