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 |
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().
00084 : BLCommand(), BLCallback() 00085 { 00086 registerCommand(BLCMDTYPE_DATA); 00087 setSynopsis("Generate an NTuple for each of a list of Z positions."); 00088 setDescription("Generates an NTuple like a virtualdetector, but\n" 00089 "without a physical volume. Tracks are forced to \n" 00090 "take steps within 2mm surrounding each desired z\n" 00091 "position, and they are interpolated to the desired\n" 00092 "z position. Each z position generates a separate\n" 00093 "NTuple named Z123 (etc.). z accepts a list of z\n" 00094 "positions, and zloop can generate a set of equally\n" 00095 "spaced z positions.\n\n" 00096 "Each value in z and zloop can be an expression using " 00097 "double constants and the usual C operators and " 00098 "functions.\n\n" 00099 "NTuple Variables:\n" 00100 " x,y,z (mm)\n" 00101 " Px,Py,Pz (MeV/c)\n" 00102 " t (ns)\n" 00103 " PDGid (11=e-, 13=mu-, 22=gamma, 211=pi+, 2212=proton, ...)\n" 00104 " EventID (may be inexact above 16,777,215)\n" 00105 " TrackID\n" 00106 " ParentID (0 => primary particle)\n" 00107 " Weight (defaults to 1.0)\n\n" 00108 "Valid Formats (ignore case): "); 00109 description += BLNTuple::getFormatList(); 00110 00111 z = ""; 00112 zloop = ""; 00113 noSingles = 0; 00114 format = "root"; 00115 file = ""; 00116 require = ""; 00117 referenceParticle = 0; 00118 coordinates = "Centerline"; 00119 coordinateType = BLCOORD_CENTERLINE; 00120 }
BLCMDzntuple::BLCMDzntuple | ( | BLCMDzntuple & | r | ) |
References coordinates, coordinateType, file, format, noSingles, referenceParticle, require, z, and zloop.
00122 : BLCommand(r), BLCallback(r) 00123 { 00124 z = r.z; 00125 zloop = r.zloop; 00126 noSingles = r.noSingles; 00127 format = r.format; 00128 file = r.file; 00129 require = r.require; 00130 referenceParticle = r.referenceParticle; 00131 coordinates = r.coordinates; 00132 coordinateType = r.coordinateType; 00133 }
virtual G4String BLCMDzntuple::commandName | ( | ) | [inline, virtual] |
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().
00136 { 00137 BLCMDzntuple *p = new BLCMDzntuple(defaultZntuple); 00138 00139 int retval = p->handleNamedArgs(namedArgs); 00140 00141 p->coordinateType = BLCoordinates::getCoordinateType(p->coordinates); 00142 00143 p->print(""); 00144 00145 // must defer creation of BLNTuple-s 00146 BLManager::getObject()->registerCallback(p,0); 00147 00148 // ascii->bltrackfile format, for accuracy and consistency of output 00149 for(unsigned i=0; i<p->format.size(); ++i) 00150 p->format[i] = tolower(p->format[i]); 00151 if(p->format == "ascii") 00152 p->format = "bltrackfile"; 00153 00154 return retval; 00155 }
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.
00158 { 00159 argString(z,"z","Comma-separated list of Z positions (mm)"); 00160 argString(zloop,"zloop","Loop in z, first:last:incr (mm)"); 00161 argInt(noSingles,"noSingles","Set to 1 to omit the NTuple for singles."); 00162 argString(format,"format","NTuple format (see above for list)"); 00163 argString(file,"file","Output filename ('' uses name to determine filename)"); 00164 argString(file,"filename","Synonym for file"); 00165 argString(require,"require","Expression which must be nonzero to include the track (default=1)",false); 00166 argInt(referenceParticle,"referenceParticle","Set to 1 to include the Reference Particle."); 00167 argString(coordinates,"coordinates","Coordinates: global, centerline, or reference (default=c)."); 00168 }
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.
00171 { 00172 if(type != 0) return; 00173 00174 // register the z position(s) in the string z 00175 std::vector<G4double> vect = getList(z,","); 00176 if(vect.size() > 0) { 00177 for(unsigned i=0; i<vect.size(); ++i) { 00178 Entry *e = new Entry(this,vect[i],coordinateType); 00179 int when = 4; 00180 if(referenceParticle != 0 || 00181 (e->ntuple && e->ntuple->needsReference())) 00182 when |= 2; 00183 BLManager::getObject()->registerZStep(vect[i],e,when); 00184 } 00185 } else if(z.size() > 0) { 00186 printError("printf: Syntax error in z"); 00187 } 00188 00189 // register the z position(s) in the string zloop 00190 vect = getList(zloop,",:"); 00191 if(vect.size() == 3) { 00192 if(vect[2] < 1.0*mm || vect[0] > vect[1]) { 00193 printError("printf: invalid zloop '%s'",zloop.c_str()); 00194 } else { 00195 while(vect[0] <= vect[1]) { 00196 Entry *e = new Entry(this,vect[0],coordinateType); 00197 int when = 4; 00198 if(referenceParticle != 0 || 00199 (e->ntuple && e->ntuple->needsReference())) 00200 when |= 2; 00201 BLManager::getObject()->registerZStep(vect[0], 00202 e,when); 00203 vect[0] += vect[2]; 00204 } 00205 } 00206 } else if(zloop.size() > 0) { 00207 printError("printf: invalid zloop '%s'",zloop.c_str()); 00208 } 00209 }
G4String BLCMDzntuple::z [private] |
Referenced by BLCMDzntuple(), callback(), and defineNamedArgs().
G4String BLCMDzntuple::zloop [private] |
Referenced by BLCMDzntuple(), callback(), and defineNamedArgs().
G4int BLCMDzntuple::noSingles [private] |
Referenced by BLCMDzntuple(), defineNamedArgs(), and BLCMDzntuple::Entry::UserZSteppingAction().
G4String BLCMDzntuple::format [private] |
Referenced by BLCMDzntuple(), command(), defineNamedArgs(), and BLCMDzntuple::Entry::Entry().
G4String BLCMDzntuple::file [private] |
Referenced by BLCMDzntuple(), defineNamedArgs(), and BLCMDzntuple::Entry::Entry().
G4String BLCMDzntuple::require [private] |
G4int BLCMDzntuple::referenceParticle [private] |
Referenced by BLCMDzntuple(), callback(), and defineNamedArgs().
G4String BLCMDzntuple::coordinates [private] |
Referenced by BLCMDzntuple(), command(), and defineNamedArgs().
BLCoordinateType BLCMDzntuple::coordinateType [private] |
Referenced by BLCMDzntuple(), callback(), and command().