Public Member Functions | |
Entry (BLCMDzntuple *znt, G4double zpos, BLCoordinateType _coordinateType) | |
void | UserZSteppingAction (const G4Track *track) |
Public Attributes | |
BLCMDzntuple * | zntuple |
BLNTuple * | ntuple |
BLEvaluator * | eval |
BLCoordinateType | coordinateType |
int | nNTuples |
BLCMDzntuple::Entry::Entry | ( | BLCMDzntuple * | znt, | |
G4double | zpos, | |||
BLCoordinateType | _coordinateType | |||
) |
References coordinateType, BLNTuple::create(), eval, BLCMDzntuple::file, BLCMDzntuple::format, nNTuples, BLCMDzntuple::noSingles, ntuple, BLCMDzntuple::require, BLCMDntuple::setDetector(), snprintf, TrackFields, and zntuple.
00202 { 00203 char name[128]; 00204 snprintf(name,sizeof(name),"Z%.0f",floor(zpos+0.5)); 00205 00206 zntuple = znt; 00207 if(zntuple->noSingles == 0) 00208 ntuple = BLNTuple::create(zntuple->format,"NTuple",name, 00209 TrackFields,zntuple->file); 00210 else 00211 ntuple = 0; 00212 00213 eval = 0; 00214 if(zntuple->require != "") eval = new BLEvaluator(); 00215 coordinateType = _coordinateType; 00216 00217 // define this virtualdetector to the ntuple command 00218 nNTuples = BLCMDntuple::setDetector(this,name,TrackFields); 00219 }
void BLCMDzntuple::Entry::UserZSteppingAction | ( | const G4Track * | track | ) | [virtual] |
Implements BLManager::ZSteppingAction.
References BLCMDntuple::appendRow(), BLNTuple::appendRow(), B, BEAM, BLCOORD_REFERENCE, coordinateType, E, eval, BLEvaluator::evaluate(), BLCoordinates::getCoords(), BLManager::getExternalParentID(), BLManager::getExternalTrackID(), BLGlobalField::GetFieldValue(), BLNTuple::getNData(), BLGlobalField::getObject(), BLManager::getObject(), BLCoordinates::getRotation(), BLManager::getState(), BLEvaluator::isOK(), BLCoordinates::isValid(), nNTuples, NTrackFields, ntuple, BLCommand::printError(), BLCMDzntuple::require, BLEvaluator::setTrackVariables(), and zntuple.
00222 { 00223 // only use reference coordinates when they are valid 00224 BLManagerState state = BLManager::getObject()->getState(); 00225 if(coordinateType == BLCOORD_REFERENCE && state != BEAM) return; 00226 00227 if(eval) { 00228 eval->setTrackVariables(track,coordinateType); 00229 G4double v = eval->evaluate(zntuple->require); 00230 if(!eval->isOK()) { 00231 BLCommand::printError("beamlossntuple: invalid expression require='%s'\n", 00232 zntuple->require.c_str()); 00233 delete eval; 00234 eval = 0; 00235 v = 1.0; 00236 } 00237 if(v == 0.0) return; 00238 } 00239 00240 G4RunManager* runmgr = G4RunManager::GetRunManager(); 00241 const G4Event* event = runmgr->GetCurrentEvent(); 00242 int evId = event->GetEventID(); 00243 G4ThreeVector position = track->GetPosition(); 00244 G4double time = track->GetGlobalTime(); 00245 G4ThreeVector momentum = track->GetMomentum(); 00246 00247 // get # data fields, and get B and E if needed 00248 unsigned ndata = (ntuple ? ntuple->getNData() : NTrackFields); 00249 G4double field[6]; 00250 if(ndata > NTrackFields) { 00251 G4double point[4]; 00252 point[0] = position[0]; 00253 point[1] = position[1]; 00254 point[2] = position[2]; 00255 point[3] = time; 00256 BLGlobalField::getObject()->GetFieldValue(point,field); 00257 } 00258 00259 // transform to desired coordinates, if available 00260 BLCoordinates *c = (BLCoordinates *)track->GetUserInformation(); 00261 if(c && c->isValid()) { 00262 c->getCoords(coordinateType,position); 00263 momentum = c->getRotation() * momentum; 00264 } 00265 00266 00267 float data[18]; 00268 assert(ndata <= sizeof(data)/sizeof(data[0])); 00269 data[0] = position[0]/mm; // x (mm) 00270 data[1] = position[1]/mm; // y (mm) 00271 data[2] = position[2]/mm; // z (mm) 00272 data[3] = momentum[0]/MeV; // Px (MeV/c) 00273 data[4] = momentum[1]/MeV; // Py (MeV/c) 00274 data[5] = momentum[2]/MeV; // Pz (MeV/c) 00275 data[6] = time/ns; // t (ns) 00276 data[7] = track->GetDefinition()->GetPDGEncoding(); 00277 data[8] = evId; // Event ID 00278 data[9] = BLManager::getObject()->getExternalTrackID(track); 00279 data[10] = BLManager::getObject()->getExternalParentID(track); 00280 data[11] = track->GetWeight(); // Weight 00281 if(ndata > NTrackFields) { 00282 G4ThreeVector B(field[0],field[1],field[2]); 00283 G4ThreeVector E(field[3],field[4],field[5]); 00284 if(c && c->isValid()) { 00285 B = c->getRotation() * B; 00286 E = c->getRotation() * E; 00287 } 00288 data[12] = B[0]/tesla; 00289 data[13] = B[1]/tesla; 00290 data[14] = B[2]/tesla; 00291 data[15] = E[0]/(megavolt/meter); 00292 data[16] = E[1]/(megavolt/meter); 00293 data[17] = E[2]/(megavolt/meter); 00294 } 00295 00296 if(ntuple) ntuple->appendRow(data,ndata); 00297 00298 // insert data into BLCMDntuple-s 00299 if(nNTuples > 0) BLCMDntuple::appendRow(this,data,NTrackFields); 00300 }
Referenced by Entry(), and UserZSteppingAction().
Referenced by BLCMDzntuple::callback(), Entry(), and UserZSteppingAction().
Referenced by Entry(), and UserZSteppingAction().
Referenced by Entry(), and UserZSteppingAction().
Referenced by Entry(), and UserZSteppingAction().