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.
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, BLCommand::description, file, format, BLNTuple::getFormatList(), noSingles, referenceParticle, BLCommand::registerCommand(), require, BLCommand::setDescription(), BLCommand::setSynopsis(), z, and zloop.

Referenced by command().

00088                            : BLCommand(), BLCallback() 
00089 {
00090         registerCommand(BLCMDTYPE_DATA);
00091         setSynopsis("Generate an NTuple for each of a list of Z positions.");
00092         setDescription("Generates an NTuple like a virtualdetector, but\n"
00093                         "without a physical volume. Tracks are forced to \n"
00094                         "take steps within 2mm surrounding each desired z\n"
00095                         "position, and they are interpolated to the desired\n"
00096                         "z position. Each z position generates a separate\n"
00097                         "NTuple named Z123 (etc.). z accepts a list of z\n"
00098                         "positions, and zloop can generate a set of equally\n"
00099                         "spaced z positions.\n\n"
00100                         "Each value in z and zloop can be an expression using "
00101                         "double constants and the usual C operators and "
00102                         "functions.\n\n"
00103                         "Valid Formats (ignore case): ");
00104         description += BLNTuple::getFormatList(); 
00105 
00106         z = "";
00107         zloop = "";
00108         noSingles = 0;
00109         format = "root";
00110         file = "";
00111         require = "";
00112         referenceParticle = 0;
00113         coordinates = "Centerline";
00114         coordinateType = BLCOORD_CENTERLINE;
00115 }

BLCMDzntuple::BLCMDzntuple ( BLCMDzntuple r  ) 

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

00117                                           : BLCommand(r), BLCallback(r)
00118 {
00119         z = r.z;
00120         zloop = r.zloop;
00121         noSingles = r.noSingles;
00122         format = r.format;
00123         file = r.file;
00124         require = r.require;
00125         referenceParticle = r.referenceParticle;
00126         coordinates = r.coordinates;
00127         coordinateType = r.coordinateType;
00128 }


Member Function Documentation

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

commandName() returns "zntuple".

Implements BLCommand.

00074 { return "zntuple"; }

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

command() implements the zntuple command.

Implements BLCommand.

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

00131 {
00132         BLCMDzntuple *p = new BLCMDzntuple(defaultZntuple);
00133 
00134         int retval = p->handleNamedArgs(namedArgs);
00135 
00136         p->coordinateType = BLCoordinates::getCoordinateType(p->coordinates);
00137 
00138         p->print("");
00139 
00140         // must defer creation of BLNTuple-s
00141         BLManager::getObject()->registerCallback(p,0);
00142 
00143         return retval;
00144 }

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.

00147 {
00148         argString(z,"z","Comma-separated list of Z positions (mm)");
00149         argString(zloop,"zloop","Loop in z, first:last:incr (mm)");
00150         argInt(noSingles,"noSingles","Set to 1 to omit the NTuple for singles.");
00151         argString(format,"format","NTuple format (see above for list)");
00152         argString(file,"file","Output filename ('' uses name to determine filename)");
00153         argString(file,"filename","Synonym for file");
00154         argString(require,"require","Expression which must be nonzero to include the track (default=1)",false);
00155         argInt(referenceParticle,"referenceParticle","Set to 1 to include the Reference Particle.");
00156         argString(coordinates,"coordinates","Coordinates: global, centerline, or reference (default=c).");
00157 }

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

callback from BLCallback.

Reimplemented from BLCallback.

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

00160 {
00161         if(type != 0) return;
00162 
00163         // register the z position(s) in the string z
00164         std::vector<G4double> vect = getList(z,",");
00165         if(vect.size() > 0) {
00166                 for(unsigned i=0; i<vect.size(); ++i) {
00167                         Entry *e = new Entry(this,vect[i],coordinateType);
00168                         int when = 4;
00169                         if(referenceParticle != 0 || 
00170                            (e->ntuple && e->ntuple->needsReference()))
00171                                 when |= 2;
00172                         BLManager::getObject()->registerZStep(vect[i],e,when);
00173                 }
00174         } else if(z.size() > 0) {
00175                 printError("printf: Syntax error in z");
00176         }
00177 
00178         // register the z position(s) in the string zloop
00179         vect = getList(zloop,",:");
00180         if(vect.size() == 3) {
00181                 if(vect[2] < 1.0*mm || vect[0] > vect[1]) {
00182                         printError("printf: invalid zloop '%s'",zloop.c_str());
00183                 } else {
00184                         while(vect[0] <= vect[1]) {
00185                             Entry *e = new Entry(this,vect[0],coordinateType);
00186                             int when = 4;
00187                             if(referenceParticle != 0 || 
00188                                (e->ntuple && e->ntuple->needsReference()))
00189                                 when |= 2;
00190                             BLManager::getObject()->registerZStep(vect[0],
00191                                                                 e,when);
00192                             vect[0] += vect[2];
00193                         }
00194                 }
00195         } else if(zloop.size() > 0) {
00196                 printError("printf: invalid zloop '%s'",zloop.c_str());
00197         }
00198 }


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