BLCMDprobefield Class Reference

Inheritance diagram for BLCMDprobefield:

BLCommand BLCallback

List of all members.


Detailed Description

class BLCMDprobefield is a command to print fields at specified points


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


Constructor & Destructor Documentation

BLCMDprobefield::BLCMDprobefield (  ) 

References BLCMDTYPE_DATA, file, in, BLCommand::registerCommand(), BLCommand::setDescription(), and BLCommand::setSynopsis().

Referenced by command().

00056 {
00057         registerCommand(BLCMDTYPE_DATA);
00058         setSynopsis("Prints B and E fields at specified points.");
00059         setDescription("Intended primarily for debugging. Prints Bx,By,Bz "
00060                 "in Tesla, and Ex,Ey,Ez in MegaVolts/meter. "
00061                 "Each input line is x,y,z,t separated by spaces or commas; "
00062                 "omitted values are set to 0.0. "
00063                 "Runs after the reference particle is tracked. "
00064                 "Only global coordinates are used.");
00065         file = "-";
00066         in = 0;
00067 }

BLCMDprobefield::~BLCMDprobefield (  )  [inline]

00041 { }


Member Function Documentation

G4String BLCMDprobefield::commandName (  )  [inline, virtual]

Implements BLCommand.

00043 { return "probefield"; }

int BLCMDprobefield::command ( BLArgumentVector argv,
BLArgumentMap namedArgs 
) [virtual]

Implements BLCommand.

References BLCMDprobefield(), file, BLAsciiFile::fopen(), BLManager::getObject(), BLCommand::handleNamedArgs(), in, BLCommand::printError(), and BLManager::registerCallback().

00070 {
00071         if(argv.size() > 0) {
00072                 printError("probefield: Invalid argument\n");
00073                 return -1;
00074         }
00075 
00076         BLCMDprobefield *p = new BLCMDprobefield(defaultProbeField);
00077         int retval = p->handleNamedArgs(namedArgs);
00078 
00079         if(p->file == "-") {
00080                 p->in = stdin;
00081         } else {
00082                 p->in = BLAsciiFile::fopen(p->file);
00083                 if(!p->in)
00084                         printError("probefield cannot open '%s'",
00085                                                         p->file.c_str());
00086                 ++retval;
00087         }
00088 
00089         // register the object to be called back to do its print.
00090         // 1 => after reference particle is tracked.
00091         BLManager::getObject()->registerCallback(p,1);
00092 
00093         return retval;
00094 }

void BLCMDprobefield::defineNamedArgs (  )  [virtual]

Reimplemented from BLCommand.

References BLCommand::argString(), and file.

00097 {
00098         argString(file,"file","Filename for reading list of points (- = stdin)");
00099 }

void BLCMDprobefield::callback ( int  type  )  [virtual]

callback() from BLCallback.

Reimplemented from BLCallback.

References BLGlobalField::GetFieldValue(), BLGlobalField::getObject(), and in.

00102 {
00103         BLGlobalField *gf = BLGlobalField::getObject();
00104 
00105         printf("probefield is printing field values:\n");
00106         printf("#x y z t Bx By Bz Ex Ey Ez\n");
00107         for(;;) {
00108                 if(in == stdin) fprintf(stderr,"point: ");
00109                 char line[1024];
00110                 if(!fgets(line,sizeof(line),in)) break;
00111                 for(;;) {
00112                         char *p = strchr(line,',');
00113                         if(!p) break;
00114                         *p = ' ';
00115                 }
00116                 G4double pos[4];
00117                 pos[0] = pos[1] = pos[2] = pos[3] = 0.0;
00118                 sscanf(line,"%lf %lf %lf %lf",&pos[0],&pos[1],&pos[2],&pos[3]); 
00119                 pos[0] *= mm; pos[1] *= mm; pos[2] *= mm; pos[3] *= ns;
00120                 G4double field[6];
00121                 gf->GetFieldValue(pos,field);
00122                 printf("%.3f %.3f %.3f %.3f  %.6f %.6f %.6f  %.6f %.6f %.6f\n",
00123                         pos[0]/mm,pos[1]/mm,pos[2]/mm,pos[3]/ns,
00124                         field[0]/tesla,field[1]/tesla,field[2]/tesla,
00125                         field[3]/(megavolt/meter),field[4]/(megavolt/meter),
00126                         field[5]/(megavolt/meter));
00127                 fflush(stdout);
00128         }
00129 }


Member Data Documentation

G4String BLCMDprobefield::file [private]

FILE* BLCMDprobefield::in [private]

Reimplemented from BLCommand.

Referenced by BLCMDprobefield(), callback(), and command().


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