BLCMDzntuple Class Reference

Inheritance diagram for BLCMDzntuple:

BLCommand BLCallback

List of all members.


Detailed Description

class BLCMDzntuple will generate an NTuple for each of a list of Z positions.

Public Member Functions

 BLCMDzntuple ()
 Constructor.
 BLCMDzntuple (BLCMDzntuple &r)
virtual G4String commandName ()
 commandName() returns "zntuple".
virtual int command (BLArgumentVector &argv, BLArgumentMap &namedArgs)
 command() implements the zntuple command.
virtual void defineNamedArgs ()
 defineNamedArgs() defines the named arguments for this command.
void help (bool detailed)
 help() prints help text.
virtual void callback (int type)
 callback from BLCallback.

Private Attributes

G4String z
G4String zloop
G4int noSingles
G4String format
G4String file
G4String require
G4int referenceParticle
G4String coordinates
BLCoordinateType coordinateType

Classes

struct  Entry

Constructor & Destructor Documentation

BLCMDzntuple::BLCMDzntuple (  ) 

Constructor.

References BLCMDTYPE_DATA, BLCOORD_CENTERLINE, coordinates, coordinateType, file, format, noSingles, referenceParticle, BLCommand::registerCommand(), require, BLCommand::setDescription(), BLCommand::setSynopsis(), z, and zloop.

Referenced by command().

00090                            : BLCommand(), BLCallback() 
00091 {
00092         registerCommand(BLCMDTYPE_DATA);
00093         setSynopsis("Generate an NTuple for each of a list of Z positions.");
00094         setDescription("Generates an NTuple like a virtualdetector, but\n"
00095                 "without a physical volume. Tracks are forced to \n"
00096                 "take steps within 2mm surrounding each desired z\n"
00097                 "position, and they are interpolated to the desired\n"
00098                 "z position. Each z position generates a separate\n"
00099                 "NTuple named Z123 (etc.). z accepts a list of z\n"
00100                 "positions, and zloop can generate a set of equally\n"
00101                 "spaced z positions; both can be used.\n\n"
00102                 "Each value in z and zloop can be an expression using "
00103                 "double constants and the usual C operators and "
00104                 "functions.\n\n"
00105                 "The standard NTuple fields are:\n"
00106                 "    x,y,z (mm)\n"
00107                 "    Px,Py,Pz (MeV/c)\n"
00108                 "    t (ns)\n"
00109                 "    PDGid (11=e-, 13=mu-, 22=gamma, 211=pi+, 2212=proton, ...)\n"
00110                 "    EventID (may be inexact above 16,777,215)\n"
00111                 "    TrackID\n"
00112                 "    ParentID (0 => primary particle)\n"
00113                 "    Weight (defaults to 1.0)\n\n"
00114                 "The following additional fields are appended for "
00115                 "format=Extended, format=asciiExtended, and "
00116                 "format=rootExtended:\n"
00117                 "    Bx, By, Bz (Tesla)\n"
00118                 "    Ex, Ey, Ez (Megavolts/meter)\n"
00119                 "    ProperTime (ns)\n"
00120                 "    PathLength (mm)\n"
00121                 "    PolX, PolY, PolZ (polarization)\n"
00122                 "    InitialKE (MeV when track was created)\n\n"
00123                 "Valid Formats (ignore case): ");
00124 
00125         z = "";
00126         zloop = "";
00127         noSingles = 0;
00128         format = "";
00129         file = "";
00130         require = "";
00131         referenceParticle = 0;
00132         coordinates = "Centerline";
00133         coordinateType = BLCOORD_CENTERLINE;
00134 }

BLCMDzntuple::BLCMDzntuple ( BLCMDzntuple r  ) 

References coordinates, coordinateType, file, format, noSingles, referenceParticle, require, z, and zloop.

00136                                           : BLCommand(r), BLCallback(r)
00137 {
00138         z = r.z;
00139         zloop = r.zloop;
00140         noSingles = r.noSingles;
00141         format = r.format;
00142         file = r.file;
00143         require = r.require;
00144         referenceParticle = r.referenceParticle;
00145         coordinates = r.coordinates;
00146         coordinateType = r.coordinateType;
00147 }


Member Function Documentation

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

commandName() returns "zntuple".

Implements BLCommand.

00069 { return "zntuple"; }

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

command() implements the zntuple command.

Implements BLCommand.

References BLCMDzntuple(), coordinates, coordinateType, format, BLCoordinates::getCoordinateType(), BLManager::getObject(), BLCommand::handleNamedArgs(), BLCommand::print(), and BLManager::registerCallback().

00150 {
00151         if(argv.size() >= 1 && argv[0] == "default") {
00152                 return handleNamedArgs(namedArgs);
00153         }
00154 
00155         BLCMDzntuple *p = new BLCMDzntuple(defaultZntuple);
00156 
00157         int retval = p->handleNamedArgs(namedArgs);
00158 
00159         p->coordinateType = BLCoordinates::getCoordinateType(p->coordinates);
00160 
00161         p->print("");
00162 
00163         // must defer creation of BLTrackNTuple-s
00164         BLManager::getObject()->registerCallback(p,0);
00165 
00166         // ascii->bltrackfile format, for accuracy and consistency of output
00167         for(unsigned i=0; i<p->format.size(); ++i)
00168                 p->format[i] = tolower(p->format[i]);
00169         if(p->format == "ascii")
00170                 p->format = "bltrackfile";
00171 
00172         return retval;
00173 }

void BLCMDzntuple::defineNamedArgs (  )  [virtual]

defineNamedArgs() defines the named arguments for this command.

Reimplemented from BLCommand.

References BLCommand::argInt(), BLCommand::argString(), coordinates, file, format, noSingles, referenceParticle, require, z, and zloop.

00176 {
00177         argString(z,"z","Comma-separated list of Z positions (mm)");
00178         argString(zloop,"zloop","Loop in z, first:last:incr (mm)");
00179         argInt(noSingles,"noSingles","Set to 1 to omit the NTuple for singles.");
00180         argString(format,"format","NTuple format (see above for list)");
00181         argString(file,"file","Output filename ('' uses name to determine filename)");
00182         argString(file,"filename","Synonym for file");
00183         argString(require,"require","Expression which must be nonzero to include the track (default=1)",false);
00184         argInt(referenceParticle,"referenceParticle","Set to 1 to include the Reference Particle.");
00185         argString(coordinates,"coordinates","Coordinates: global, centerline, or reference (default=c).");
00186 }

void BLCMDzntuple::help ( bool  detailed  )  [inline, virtual]

help() prints help text.

Reimplemented from BLCommand.

References BLCommand::description, BLTrackNTuple::getFormatList(), and BLCommand::help().

00078                                  {
00079                 if(description[description.size()-2] == ':')
00080                         description += BLTrackNTuple::getFormatList(); 
00081                 BLCommand::help(detailed);
00082         }

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

callback from BLCallback.

Reimplemented from BLCallback.

References coordinateType, BLCommand::getList(), BLManager::getObject(), BLTrackNTuple::needsReference(), BLCMDzntuple::Entry::ntuple, BLCommand::printError(), referenceParticle, BLManager::registerZStep(), z, and zloop.

00189 {
00190         if(type != 0) return;
00191 
00192         // register the z position(s) in the string z
00193         std::vector<G4double> vect = getList(z,",");
00194         if(vect.size() > 0) {
00195                 for(unsigned i=0; i<vect.size(); ++i) {
00196                         Entry *e = new Entry(this,vect[i],coordinateType);
00197                         int when = 4;
00198                         if(referenceParticle != 0 || 
00199                            (e->ntuple && e->ntuple->needsReference()))
00200                                 when |= 2;
00201                         BLManager::getObject()->registerZStep(vect[i],e,when);
00202                 }
00203         } else if(z.size() > 0) {
00204                 printError("printf: Syntax error in z");
00205         }
00206 
00207         // register the z position(s) in the string zloop
00208         vect = getList(zloop,",:");
00209         if(vect.size() == 3) {
00210                 if(vect[2] < 1.0*mm || vect[0] > vect[1]) {
00211                         printError("printf: invalid zloop '%s'",zloop.c_str());
00212                 } else {
00213                         while(vect[0] <= vect[1]) {
00214                             Entry *e = new Entry(this,vect[0],coordinateType);
00215                             int when = 4;
00216                             if(referenceParticle != 0 || 
00217                                (e->ntuple && e->ntuple->needsReference()))
00218                                 when |= 2;
00219                             BLManager::getObject()->registerZStep(vect[0],
00220                                                                 e,when);
00221                             vect[0] += vect[2];
00222                         }
00223                 }
00224         } else if(zloop.size() > 0) {
00225                 printError("printf: invalid zloop '%s'",zloop.c_str());
00226         }
00227 }


Member Data Documentation

G4String BLCMDzntuple::z [private]

G4String BLCMDzntuple::zloop [private]

G4int BLCMDzntuple::noSingles [private]

G4String BLCMDzntuple::format [private]

G4String BLCMDzntuple::file [private]

G4String BLCMDzntuple::require [private]

G4String BLCMDzntuple::coordinates [private]

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


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