BLCMDfieldntuple Class Reference

Inheritance diagram for BLCMDfieldntuple:

BLCommand BLCallback

List of all members.


Detailed Description

class BLCMDfieldntuple is a command to generate an NTuple from field values at specified points.

Public Member Functions

 BLCMDfieldntuple ()
 ~BLCMDfieldntuple ()
 BLCMDfieldntuple (const BLCMDfieldntuple &r)
G4String commandName ()
int command (BLArgumentVector &argv, BLArgumentMap &namedArgs)
void defineNamedArgs ()
void callback (int type)
 callback() from BLCallback.

Private Attributes

G4String name
G4String category
G4String format
G4String filename
G4String x
G4String y
G4String z
G4String t
G4int exit

Classes

class  Loop

Constructor & Destructor Documentation

BLCMDfieldntuple::BLCMDfieldntuple (  ) 

References BLCMDTYPE_DATA, category, exit, filename, format, name, BLCommand::registerCommand(), BLCommand::setDescription(), BLCommand::setSynopsis(), t, x, y, and z.

Referenced by command().

00075                                    : BLCommand(), BLCallback()
00076 {
00077         registerCommand(BLCMDTYPE_DATA);
00078         setSynopsis("Generates an NTuple from B and E fields at specified points.");
00079         setDescription("Intended primarily for debugging. "
00080                 "This command makes it easy to plot fields as a function of "
00081                 "position and time, using existing NTuple plotting tools. "
00082                 "Outputs x,y,z,t,Bx,By,Bz,Ex,Ey,Ez into an NTuple. "
00083                 "Units are mm, ns, Tesla, and MegaVolts/meter. "
00084                 "Runs after the reference particle is tracked. "
00085                 "Only global coordinates are used.\n\n"
00086                 "The single positional argument is the name of the NTuple. "
00087                 "Named arguments {x,y,z,t} are of two forms specifying "
00088                 "coordinate values: "
00089                 "x=Xmin,Xmax,dX or x=X1:X2:X3:... which generate the obvious "
00090                 "loops (single value is OK). Expressions can be used. "
00091                 "Omitted coordinates are held fixed at 0.0.");
00092         name = "";
00093         category = "";
00094         format = "";
00095         filename = "";
00096         x = "0.0";
00097         y = "0.0";
00098         z = "0.0";
00099         t = "0.0";
00100         exit = 0;
00101 }

BLCMDfieldntuple::~BLCMDfieldntuple (  )  [inline]

00059 { }

BLCMDfieldntuple::BLCMDfieldntuple ( const BLCMDfieldntuple r  ) 

References category, exit, filename, format, name, t, x, y, and z.

00103                                                             : BLCommand(), BLCallback()
00104 {
00105         name = r.name;
00106         category = r.category;
00107         format = r.format;
00108         filename = r.filename;
00109         x = r.x;
00110         y = r.y;
00111         z = r.z;
00112         t = r.t;
00113         exit = r.exit;
00114 }


Member Function Documentation

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

Implements BLCommand.

00063 { return "fieldntuple"; }

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

Implements BLCommand.

References BLCMDfieldntuple(), BLManager::getObject(), BLCommand::handleNamedArgs(), name, BLCommand::printError(), and BLManager::registerCallback().

00117 {
00118         if(argv.size() != 1) {
00119                 printError("fieldntuple: Invalid name\n");
00120                 return -1;
00121         }
00122 
00123         BLCMDfieldntuple *p = new BLCMDfieldntuple(defaultFieldntuple);
00124         p->name = argv[0];
00125         int retval = p->handleNamedArgs(namedArgs);
00126 
00127         // register the object to be called back to do its work.
00128         // 1 => after reference particle is tracked.
00129         BLManager::getObject()->registerCallback(p,1);
00130 
00131         return retval;
00132 }

void BLCMDfieldntuple::defineNamedArgs (  )  [virtual]

Reimplemented from BLCommand.

References BLCommand::argInt(), BLCommand::argString(), category, exit, filename, format, t, x, y, and z.

00135 {
00136         argString(category,"category","The category of the NTuple.");
00137         argString(format,"format","NTuple format (see above for list).");
00138         argString(filename,"filename","Name of file.");
00139         argString(x,"x","Loop for x values: Xmin,Xmaz,dX or X1:X2:... (mm)");
00140         argString(y,"y","Loop for y values: Ymin,Ymaz,dY or Y1:Y2:... (mm)");
00141         argString(z,"z","Loop for z values: Zmin,Zmaz,dZ or Z1:Z2:... (mm)");
00142         argString(t,"t","Loop for t values: Tmin,Tmaz,dT or T1:T2:... (ns)");
00143         argInt(exit,"exit","Set nonzero to exit after generating NTuple (0).");
00144         argString(filename,"file","Synonym for filename.");
00145 }

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

callback() from BLCallback.

Reimplemented from BLCallback.

References BLNTuple::appendRow(), category, BLNTuple::closeAll(), BLNTuple::create(), exit, filename, BLNTuple::flush(), format, g4bl_exit(), BLGlobalField::GetFieldValue(), BLGlobalField::getObject(), name, BLCMDfieldntuple::Loop::next(), BLCMDfieldntuple::Loop::start(), t, x, y, and z.

00148 {
00149         BLGlobalField *gf = BLGlobalField::getObject();
00150 
00151         double point[4], field[6];
00152         Loop loopX(point[0],x);
00153         Loop loopY(point[1],y);
00154         Loop loopZ(point[2],z);
00155         Loop loopT(point[3],t);
00156 
00157         BLNTuple *ntuple=BLNTuple::create(format,category,name,
00158                                         "x:y:z:t:Bx:By:Bz:Ex:Ey:Ez",filename);
00159 
00160         for(loopX.start(); loopX.next(); ) {
00161             for(loopY.start(); loopY.next(); ) {
00162                 for(loopZ.start(); loopZ.next(); ) {
00163                     for(loopT.start(); loopT.next(); ) {
00164                         gf->GetFieldValue(point,field);
00165                         double data[10];
00166                         data[0] = point[0]/mm;
00167                         data[1] = point[1]/mm;
00168                         data[2] = point[2]/mm;
00169                         data[3] = point[3]/ns;
00170                         data[4] = field[0]/tesla;
00171                         data[5] = field[1]/tesla;
00172                         data[6] = field[2]/tesla;
00173                         data[7] = field[3]/(megavolt/meter);
00174                         data[8] = field[4]/(megavolt/meter);
00175                         data[9] = field[5]/(megavolt/meter);
00176                         ntuple->appendRow(data,10);
00177                     }
00178                 }
00179             }
00180         }
00181 
00182         ntuple->flush();
00183 
00184         if(exit != 0) {
00185                 printf("fieldntuple: exit\n");
00186                 BLNTuple::closeAll();
00187                 g4bl_exit(0);
00188         }
00189 }


Member Data Documentation

G4String BLCMDfieldntuple::name [private]

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

G4String BLCMDfieldntuple::category [private]

G4String BLCMDfieldntuple::format [private]

G4String BLCMDfieldntuple::filename [private]

G4String BLCMDfieldntuple::x [private]

G4String BLCMDfieldntuple::y [private]

G4String BLCMDfieldntuple::z [private]

G4String BLCMDfieldntuple::t [private]

G4int BLCMDfieldntuple::exit [private]


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