BLCMDnewparticlentuple Class Reference

Inheritance diagram for BLCMDnewparticlentuple:

BLCommand BLManager::TrackingAction

List of all members.


Detailed Description

class BLCMDnewparticlentuple - NTuple for tracks where they are created.

Public Member Functions

 BLCMDnewparticlentuple ()
 BLCMDnewparticlentuple (BLCMDnewparticlentuple &r)
G4String commandName ()
int command (BLArgumentVector &argv, BLArgumentMap &namedArgs)
void defineNamedArgs ()
void PreUserTrackingAction (const G4Track *track)
 PreUserTrackingAction() from BLManager::TrackingAction.
void PostUserTrackingAction (const G4Track *track)
 PostUserTrackingAction() from BLManager::TrackingAction.

Private Attributes

G4String name
G4String format
G4String filename
G4String require
G4String coordinates
BLCoordinateType coordinateType
BLNTuplentuple
BLEvaluatoreval

Constructor & Destructor Documentation

BLCMDnewparticlentuple::BLCMDnewparticlentuple (  ) 

References BLCMDTYPE_DATA, BLCOORD_CENTERLINE, coordinates, coordinateType, BLCommand::description, eval, filename, format, BLNTuple::getFormatList(), name, ntuple, BLCommand::registerCommand(), require, BLCommand::setDescription(), and BLCommand::setSynopsis().

Referenced by command().

00063                                                : BLCommand(),
00064                                                 BLManager::TrackingAction()
00065 {
00066         registerCommand(BLCMDTYPE_DATA);
00067         setSynopsis("NTuple containing particle tracks when created.");
00068         setDescription("Note that initial beam particles are included, unless "
00069                 "require is set to 'Parent>0'. "
00070                 "The NTuple contains the same data as a virtualdetector:\n"
00071                 "    x,y,z (mm)\n"
00072                 "    Px,Py,Pz (MeV/c)\n"
00073                 "    t (ns)\n"
00074                 "    PDGid (11=e-, 13=mu-, 22=gamma, 211=pi+, 2212=proton, ...)\n"
00075                 "    EvNum (inexact above 16,777,215)\n"
00076                 "    TrkId (1 is first track of event)\n"
00077                 "    Parent (0 => primary particle)\n"
00078                 "    wt (weight, defaults to 1.0)\n\n"
00079                 "Valid Formats (ignore case): ");
00080         description += BLNTuple::getFormatList(); 
00081 
00082         name = "";
00083         format = "";
00084         filename = "";
00085         require = "";
00086         coordinates = "Centerline";
00087         coordinateType = BLCOORD_CENTERLINE;
00088         ntuple = 0;
00089         eval = 0;
00090 }

BLCMDnewparticlentuple::BLCMDnewparticlentuple ( BLCMDnewparticlentuple r  ) 

References coordinates, coordinateType, eval, filename, format, name, ntuple, and require.

00092                                                                         : BLCommand(r), 
00093                                                 BLManager::TrackingAction(r)
00094 {
00095         name = r.name;
00096         format = r.format;
00097         filename = r.filename;
00098         require = r.require;
00099         coordinates = r.coordinates;
00100         coordinateType = r.coordinateType;
00101         ntuple = 0;
00102         eval = 0;
00103 }


Member Function Documentation

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

Implements BLCommand.

00047 { return "newparticlentuple"; }

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

Implements BLCommand.

References BLCMDnewparticlentuple(), coordinates, coordinateType, BLNTuple::create(), eval, filename, format, BLCoordinates::getCoordinateType(), BLManager::getObject(), BLCommand::handleNamedArgs(), name, ntuple, BLCommand::print(), BLCommand::printError(), BLManager::registerTrackingAction(), require, and TrackFields.

00106 {
00107         if(argv.size() != 1) {
00108                 printError("Invalid newparticlentuple command -- need name");
00109                 return -1;
00110         }
00111 
00112         if(argv[0] == "default") {
00113                 handleNamedArgs(namedArgs);
00114                 return -1;
00115         }
00116 
00117         BLCMDnewparticlentuple *t = new BLCMDnewparticlentuple(defaultNewParticleNTuple);
00118         int retval = t->handleNamedArgs(namedArgs);
00119 
00120         t->name = argv[0];
00121         t->ntuple = BLNTuple::create(t->format,"NTuple",t->name,TrackFields,
00122                                                         t->filename);
00123 
00124         t->coordinateType = BLCoordinates::getCoordinateType(t->coordinates);
00125         if(t->require != "") t->eval = new BLEvaluator();
00126 
00127         t->print(argv[0]);
00128 
00129         BLManager::getObject()->registerTrackingAction(t);
00130 
00131         return retval;
00132 }

void BLCMDnewparticlentuple::defineNamedArgs (  )  [virtual]

Reimplemented from BLCommand.

References BLCommand::argString(), coordinates, filename, format, and require.

00135 {
00136         argString(format,"format","The NTuple format (see above for list).");
00137         argString(filename,"filename","The filename for the NTuple.");
00138         argString(filename,"file","Synonym for filename.");
00139         argString(require,"require","Expression which must be nonzero to include the track (default=1)",false);
00140         argString(coordinates,"coordinates","Coordinates: global, centerline, or reference (default=c).");
00141 }

void BLCMDnewparticlentuple::PreUserTrackingAction ( const G4Track *  track  )  [virtual]

PreUserTrackingAction() from BLManager::TrackingAction.

Implements BLManager::TrackingAction.

References BLNTuple::appendRow(), BEAM, BLCOORD_REFERENCE, coordinateType, eval, BLEvaluator::evaluate(), BLCoordinates::getCoords(), BLManager::getExternalParentID(), BLManager::getExternalTrackID(), BLManager::getObject(), BLCoordinates::getRotation(), BLManager::getState(), BLEvaluator::isOK(), BLCoordinates::isValid(), NTrackFields, ntuple, BLCommand::printError(), require, and BLEvaluator::setTrackVariables().

00144 {
00145         // only use reference coordinates when they are valid
00146         BLManagerState state = BLManager::getObject()->getState();
00147         if(coordinateType == BLCOORD_REFERENCE && state != BEAM) return;
00148 
00149         if(eval) {
00150                 eval->setTrackVariables(track,coordinateType);
00151                 G4double v = eval->evaluate(require);
00152                 if(!eval->isOK()) {
00153                         BLCommand::printError("newparticlentuple: invalid expression require='%s'\n",
00154                                 require.c_str());
00155                         delete eval;
00156                         eval = 0;
00157                         v = 1.0;
00158                 }
00159                 if(v == 0.0) return;
00160         }
00161 
00162         G4RunManager* runmgr = G4RunManager::GetRunManager();
00163         const G4Event* event = runmgr->GetCurrentEvent();
00164         int evId = event->GetEventID();
00165         G4ThreeVector position = track->GetPosition();
00166         G4double time = track->GetGlobalTime();
00167         G4ThreeVector momentum = track->GetMomentum();
00168 
00169         // transform to desired coordinates, if available
00170         BLCoordinates *c = (BLCoordinates *)track->GetUserInformation();
00171         if(c && c->isValid()) {
00172                 c->getCoords(coordinateType,position);
00173                 momentum = c->getRotation() * momentum;
00174         }
00175 
00176         float data[12];
00177         data[0] = position[0]/mm;               // x (mm)
00178         data[1] = position[1]/mm;               // y (mm)
00179         data[2] = position[2]/mm;               // z (mm)
00180         data[3] = momentum[0]/MeV;              // Px (MeV/c)
00181         data[4] = momentum[1]/MeV;              // Py (MeV/c)
00182         data[5] = momentum[2]/MeV;              // Pz (MeV/c)
00183         data[6] = time/ns;                      // t (ns)
00184         data[7] = track->GetDefinition()->GetPDGEncoding();
00185         data[8] = evId;                         // Event ID
00186         data[9] = 
00187             BLManager::getObject()->getExternalTrackID(track);
00188         data[10] = 
00189             BLManager::getObject()->getExternalParentID(track);
00190         data[11] = track->GetWeight();          // Weight
00191 
00192         if(ntuple) ntuple->appendRow(data,NTrackFields);
00193 }

void BLCMDnewparticlentuple::PostUserTrackingAction ( const G4Track *  track  )  [inline, virtual]


Member Data Documentation

G4String BLCMDnewparticlentuple::name [private]

Referenced by BLCMDnewparticlentuple(), and command().

G4String BLCMDnewparticlentuple::format [private]

G4String BLCMDnewparticlentuple::require [private]


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