Public Member Functions | |
BLCMDprobefield () | |
~BLCMDprobefield () | |
G4String | commandName () |
int | command (BLArgumentVector &argv, BLArgumentMap &namedArgs) |
void | defineNamedArgs () |
void | callback (int type) |
callback() from BLCallback. | |
Private Attributes | |
G4String | file |
FILE * | in |
BLCMDprobefield::BLCMDprobefield | ( | ) |
References BLCMDTYPE_DATA, file, in, BLCommand::registerCommand(), BLCommand::setDescription(), and BLCommand::setSynopsis().
Referenced by command().
00055 { 00056 registerCommand(BLCMDTYPE_DATA); 00057 setSynopsis("Prints B and E fields at specified points."); 00058 setDescription("Intended primarily for debugging. Prints Bx,By,Bz " 00059 "in Tesla, and Ex,Ey,Ez in MegaVolts/meter. " 00060 "Each input line is x,y,z,t separated by spaces or commas; " 00061 "omitted values are set to 0.0. " 00062 "Runs after the reference particle is tracked. " 00063 "Only global coordinates are used."); 00064 file = "-"; 00065 in = 0; 00066 }
G4String BLCMDprobefield::commandName | ( | ) | [inline, virtual] |
int BLCMDprobefield::command | ( | BLArgumentVector & | argv, | |
BLArgumentMap & | namedArgs | |||
) | [virtual] |
Implements BLCommand.
References BLCMDprobefield(), file, BLManager::getObject(), BLCommand::handleNamedArgs(), in, BLCommand::printError(), and BLManager::registerCallback().
00069 { 00070 if(argv.size() > 0) { 00071 printError("probefield: Invalid argument\n"); 00072 return -1; 00073 } 00074 00075 BLCMDprobefield *p = new BLCMDprobefield(defaultProbeField); 00076 int retval = p->handleNamedArgs(namedArgs); 00077 00078 if(p->file == "-") { 00079 p->in = stdin; 00080 } else { 00081 p->in = fopen(p->file.c_str(),"r"); 00082 if(!p->in) 00083 printError("probefield cannot open '%s'", 00084 p->file.c_str()); 00085 ++retval; 00086 } 00087 00088 // register the object to be called back to do its print. 00089 // 1 => after reference particle is tracked. 00090 BLManager::getObject()->registerCallback(p,1); 00091 00092 return retval; 00093 }
void BLCMDprobefield::defineNamedArgs | ( | ) | [virtual] |
void BLCMDprobefield::callback | ( | int | type | ) | [virtual] |
callback() from BLCallback.
Reimplemented from BLCallback.
References BLGlobalField::GetFieldValue(), BLGlobalField::getObject(), and in.
00101 { 00102 BLGlobalField *gf = BLGlobalField::getObject(); 00103 00104 printf("probefield is printing field values:\n"); 00105 printf("#x y z t Bx By Bz Ex Ey Ez\n"); 00106 for(;;) { 00107 if(in == stdin) fprintf(stderr,"point: "); 00108 char line[1024]; 00109 if(!fgets(line,sizeof(line),in)) break; 00110 for(;;) { 00111 char *p = strchr(line,','); 00112 if(!p) break; 00113 *p = ' '; 00114 } 00115 G4double pos[4]; 00116 pos[0] = pos[1] = pos[2] = pos[3] = 0.0; 00117 sscanf(line,"%lf %lf %lf %lf",&pos[0],&pos[1],&pos[2],&pos[3]); 00118 pos[0] *= mm; pos[1] *= mm; pos[2] *= mm; pos[3] *= ns; 00119 G4double field[6]; 00120 gf->GetFieldValue(pos,field); 00121 printf("%.3f %.3f %.3f %.3f %.6f %.6f %.6f %.6f %.6f %.6f\n", 00122 pos[0]/mm,pos[1]/mm,pos[2]/mm,pos[3]/ns, 00123 field[0]/tesla,field[1]/tesla,field[2]/tesla, 00124 field[3]/(megavolt/meter),field[4]/(megavolt/meter), 00125 field[5]/(megavolt/meter)); 00126 fflush(stdout); 00127 } 00128 }
G4String BLCMDprobefield::file [private] |
Referenced by BLCMDprobefield(), command(), and defineNamedArgs().
FILE* BLCMDprobefield::in [private] |