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().
00113 : BLElement() 00114 { 00115 // register the commandName(), and its synopsis and description. 00116 registerCommand(BLCMDTYPE_ELEMENT); 00117 setSynopsis("implements a field map, E and/or B, from a file."); 00118 setDescription("Reads an input file in BLFieldMap format to define " 00119 "E and/or B fields, optionally with time dependence. " 00120 "See the Users Guide for a description of the BLFieldMap " 00121 "format." 00122 ""); 00123 00124 // provide initial values for fields 00125 map = 0; 00126 current = 1.0; 00127 gradient = 1.0; 00128 timeOffset = 0.0; 00129 }
BLCMDfieldmap::BLCMDfieldmap | ( | const BLCMDfieldmap & | r | ) |
Copy constructor.
References BLTune::copyTunableArg(), current, gradient, map, and timeOffset.
00132 : BLElement(r) 00133 { 00134 // copy fields one at a time (transfers default values from the 00135 // default object to this new object). 00136 map = r.map; 00137 BLTune::copyTunableArg(¤t,&r.current); 00138 BLTune::copyTunableArg(&gradient,&r.gradient); 00139 timeOffset = r.timeOffset; 00140 }
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().
00143 { 00144 if(argv.size() != 1) { 00145 BLCommand::printError("fieldmap: Invalid command, must have name"); 00146 return -1; 00147 } 00148 00149 if(argv[0] == "default") { 00150 return defaultFieldMapCmd.handleNamedArgs(namedArgs); 00151 } 00152 00153 BLCMDfieldmap *t = new BLCMDfieldmap(defaultFieldMapCmd); 00154 t->setName(argv[0]); 00155 int retval = t->handleNamedArgs(namedArgs); 00156 00157 t->map = new BLFieldMap(); 00158 t->map->readFile(t->filename); 00159 00160 t->print(argv[0]); 00161 00162 return retval; 00163 }
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.
00166 { 00167 argString(filename,"filename","Filename for the Field Map.",false); 00168 argString(filename,"file","Synonym for filename.",false); 00169 argTunable(current,"current","Current of the B-field."); 00170 argTunable(gradient,"gradient","Gradient of the E-field."); 00171 argDouble(timeOffset,"timeOffset","Time offset (ns)."); 00172 }
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.
00181 { 00182 G4String thisname = parentName+getName(); 00183 00184 // get globalRotation and globalPosition 00185 G4RotationMatrix *globalRotation = 0; 00186 if(relativeRotation && parentRotation) { 00187 globalRotation = 00188 new G4RotationMatrix(*parentRotation * *relativeRotation); 00189 } else if(relativeRotation) { 00190 globalRotation = relativeRotation; 00191 } else if(parentRotation) { 00192 globalRotation = parentRotation; 00193 } 00194 G4ThreeVector globalPosition(relativePosition + parentPosition); 00195 if(parentRotation) 00196 globalPosition = *parentRotation * relativePosition + 00197 parentPosition; 00198 00199 FieldMapPlacement *p = new FieldMapPlacement(map,globalRotation, 00200 globalPosition,current,gradient,timeOffset); 00201 BLGlobalField::getObject()->addElementField(p); 00202 00203 printf("BLMappedMagnet::Construct %s parent=%s relZ=%.1f\n", 00204 thisname.c_str(),parentName.c_str(),relativePosition[2]); 00205 }
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().