Public Member Functions | |
BLCMDbeamlossntuple () | |
BLCMDbeamlossntuple (BLCMDbeamlossntuple &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 |
BLNTuple * | ntuple |
BLEvaluator * | eval |
BLCMDbeamlossntuple::BLCMDbeamlossntuple | ( | ) |
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().
00062 : BLCommand(), BLManager::TrackingAction() 00063 { 00064 registerCommand(BLCMDTYPE_DATA); 00065 setSynopsis("NTuple containing particle tracks when lost."); 00066 setDescription("The NTuple contains the same data as a virtualdetector:\n" 00067 "NTuple Variables:\n" 00068 " x,y,z (mm)\n" 00069 " Px,Py,Pz (MeV/c)\n" 00070 " t (ns)\n" 00071 " PDGid (11=e-, 13=mu-, 22=gamma, 211=pi+, 2212=proton, ...)\n" 00072 " EventID (may be inexact above 16,777,215)\n" 00073 " TrackID\n" 00074 " ParentID (0 => primary particle)\n" 00075 " Weight (defaults to 1.0)\n\n" 00076 "Valid Formats (ignore case): "); 00077 description += BLNTuple::getFormatList(); 00078 00079 name = ""; 00080 format = ""; 00081 filename = ""; 00082 require = ""; 00083 coordinates = "Centerline"; 00084 coordinateType = BLCOORD_CENTERLINE; 00085 ntuple = 0; 00086 eval = 0; 00087 }
BLCMDbeamlossntuple::BLCMDbeamlossntuple | ( | BLCMDbeamlossntuple & | r | ) |
References coordinates, coordinateType, eval, filename, format, name, ntuple, and require.
00089 : BLCommand(r), 00090 BLManager::TrackingAction(r) 00091 { 00092 name = r.name; 00093 format = r.format; 00094 filename = r.filename; 00095 require = r.require; 00096 coordinates = r.coordinates; 00097 coordinateType = r.coordinateType; 00098 ntuple = 0; 00099 eval = 0; 00100 }
G4String BLCMDbeamlossntuple::commandName | ( | ) | [inline, virtual] |
int BLCMDbeamlossntuple::command | ( | BLArgumentVector & | argv, | |
BLArgumentMap & | namedArgs | |||
) | [virtual] |
Implements BLCommand.
References BLCMDbeamlossntuple(), coordinates, coordinateType, BLNTuple::create(), eval, filename, format, BLCoordinates::getCoordinateType(), BLManager::getObject(), BLCommand::handleNamedArgs(), name, ntuple, BLCommand::print(), BLCommand::printError(), BLManager::registerTrackingAction(), require, and TrackFields.
00103 { 00104 if(argv.size() != 1) { 00105 printError("Invalid beamlossntuple command -- need name"); 00106 return -1; 00107 } 00108 00109 if(argv[0] == "default") { 00110 handleNamedArgs(namedArgs); 00111 return -1; 00112 } 00113 00114 BLCMDbeamlossntuple *t = new BLCMDbeamlossntuple(defaultBeamLossNTuple); 00115 int retval = t->handleNamedArgs(namedArgs); 00116 00117 // ascii->bltrackfile format, for accuracy and consistency of output 00118 for(unsigned i=0; i<t->format.size(); ++i) 00119 t->format[i] = tolower(t->format[i]); 00120 if(t->format == "ascii") 00121 t->format = "bltrackfile"; 00122 00123 t->name = argv[0]; 00124 t->ntuple = BLNTuple::create(t->format,"NTuple",t->name,TrackFields, 00125 t->filename); 00126 00127 t->coordinateType = BLCoordinates::getCoordinateType(t->coordinates); 00128 if(t->require != "") t->eval = new BLEvaluator(); 00129 00130 t->print(argv[0]); 00131 00132 BLManager::getObject()->registerTrackingAction(t); 00133 00134 return retval; 00135 }
void BLCMDbeamlossntuple::defineNamedArgs | ( | ) | [virtual] |
Reimplemented from BLCommand.
References BLCommand::argString(), coordinates, filename, format, and require.
00138 { 00139 argString(format,"format","The NTuple format (see above for list)."); 00140 argString(filename,"filename","The filename for the NTuple."); 00141 argString(filename,"file","Synonym for filename."); 00142 argString(require,"require","Expression which must be nonzero to include the track (default=1)",false); 00143 argString(coordinates,"coordinates","Coordinates: global, centerline, or reference (default=c)."); 00144 }
void BLCMDbeamlossntuple::PreUserTrackingAction | ( | const G4Track * | track | ) | [inline, virtual] |
void BLCMDbeamlossntuple::PostUserTrackingAction | ( | const G4Track * | track | ) | [virtual] |
PostUserTrackingAction() 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().
00147 { 00148 // omit tracks that were not tracked 00149 if(track->GetCurrentStepNumber() <= 0) 00150 return; 00151 00152 // only use reference coordinates when they are valid 00153 BLManagerState state = BLManager::getObject()->getState(); 00154 if(coordinateType == BLCOORD_REFERENCE && state != BEAM) return; 00155 00156 if(eval) { 00157 eval->setTrackVariables(track,coordinateType); 00158 G4double v = eval->evaluate(require); 00159 if(!eval->isOK()) { 00160 BLCommand::printError("beamlossntuple: invalid expression require='%s'\n", 00161 require.c_str()); 00162 delete eval; 00163 eval = 0; 00164 v = 1.0; 00165 } 00166 if(v == 0.0) return; 00167 } 00168 00169 G4RunManager* runmgr = G4RunManager::GetRunManager(); 00170 const G4Event* event = runmgr->GetCurrentEvent(); 00171 int evId = event->GetEventID(); 00172 G4ThreeVector position = track->GetPosition(); 00173 G4double time = track->GetGlobalTime(); 00174 G4ThreeVector momentum = track->GetMomentum(); 00175 00176 // transform to desired coordinates, if available 00177 BLCoordinates *c = (BLCoordinates *)track->GetUserInformation(); 00178 if(c && c->isValid()) { 00179 c->getCoords(coordinateType,position); 00180 momentum = c->getRotation() * momentum; 00181 } 00182 00183 float data[12]; 00184 data[0] = position[0]/mm; // x (mm) 00185 data[1] = position[1]/mm; // y (mm) 00186 data[2] = position[2]/mm; // z (mm) 00187 data[3] = momentum[0]/MeV; // Px (MeV/c) 00188 data[4] = momentum[1]/MeV; // Py (MeV/c) 00189 data[5] = momentum[2]/MeV; // Pz (MeV/c) 00190 data[6] = time/ns; // t (ns) 00191 data[7] = track->GetDefinition()->GetPDGEncoding(); 00192 data[8] = evId; // Event ID 00193 data[9] = 00194 BLManager::getObject()->getExternalTrackID(track); 00195 data[10] = 00196 BLManager::getObject()->getExternalParentID(track); 00197 data[11] = track->GetWeight(); // Weight 00198 00199 if(ntuple) ntuple->appendRow(data,NTrackFields); 00200 }
G4String BLCMDbeamlossntuple::name [private] |
Referenced by BLCMDbeamlossntuple(), and command().
G4String BLCMDbeamlossntuple::format [private] |
Referenced by BLCMDbeamlossntuple(), command(), and defineNamedArgs().
G4String BLCMDbeamlossntuple::filename [private] |
Referenced by BLCMDbeamlossntuple(), command(), and defineNamedArgs().
G4String BLCMDbeamlossntuple::require [private] |
Referenced by BLCMDbeamlossntuple(), command(), defineNamedArgs(), and PostUserTrackingAction().
G4String BLCMDbeamlossntuple::coordinates [private] |
Referenced by BLCMDbeamlossntuple(), command(), and defineNamedArgs().
Referenced by BLCMDbeamlossntuple(), command(), and PostUserTrackingAction().
BLNTuple* BLCMDbeamlossntuple::ntuple [private] |
Referenced by BLCMDbeamlossntuple(), command(), and PostUserTrackingAction().
BLEvaluator* BLCMDbeamlossntuple::eval [private] |
Referenced by BLCMDbeamlossntuple(), command(), and PostUserTrackingAction().