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().

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

BLCMDfieldntuple::~BLCMDfieldntuple (  )  [inline]

00057 { }

BLCMDfieldntuple::BLCMDfieldntuple ( const BLCMDfieldntuple r  ) 

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

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


Member Function Documentation

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

Implements BLCommand.

00061 { return "fieldntuple"; }

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

Implements BLCommand.

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

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

void BLCMDfieldntuple::defineNamedArgs (  )  [virtual]

Reimplemented from BLCommand.

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

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

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.

00146 {
00147         BLGlobalField *gf = BLGlobalField::getObject();
00148 
00149         assert(ns == 1.0 && mm == 1.0); // units in point[]
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                         float 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                 extern void g4bl_exit(int);
00188                 g4bl_exit(0);
00189         }
00190 }


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