Geant4 Cross Reference |
1 // 2 // ******************************************************************** 3 // * License and Disclaimer * 4 // * * 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. * 10 // * * 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitation of liability. * 17 // * * 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************************************** 25 // 26 /// \file 27 /// \brief Implementation of the G4SteppingVerboseWithUnits class 28 // 29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 30 // 31 // Stepping Verbose with units for all the applicable double values 32 // This class is ported from TestEm2 extended example 33 // Original author : Michel Maire (LAPP) 34 // Porting with addition of UI command : Makoto Asai (SLAC) Feb.23.2021 35 // 36 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 37 38 #include "G4SteppingVerboseWithUnits.hh" 39 40 #include "G4GenericMessenger.hh" 41 #include "G4SteppingManager.hh" 42 #include "G4UnitsTable.hh" 43 44 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 45 46 G4SteppingVerboseWithUnits::G4SteppingVerboseWithUnits(G4int prec) : fprec(prec) {} 47 48 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 49 50 G4SteppingVerboseWithUnits::~G4SteppingVerboseWithUnits() { delete fmessenger; } 51 52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 53 54 void G4SteppingVerboseWithUnits::SetManager(G4SteppingManager* const fMan) 55 { 56 fManager = fMan; 57 fmessenger = new G4GenericMessenger(this, "/tracking/", "precision of verbose output"); 58 auto& cmd = 59 fmessenger->DeclareProperty("setVerbosePrecision", fprec, "set precision of verbose output"); 60 cmd.SetStates(G4State_PreInit, G4State_Idle); 61 } 62 63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 64 65 void G4SteppingVerboseWithUnits::TrackingStarted() 66 { 67 CopyState(); 68 G4long oldprec = G4cout.precision(fprec); 69 70 // Step zero 71 // 72 if (verboseLevel > 0) { 73 G4cout << std::setw(5) << "Step#" 74 << " " << std::setw(fprec + 3) << "X" 75 << " " << std::setw(fprec + 3) << "Y" 76 << " " << std::setw(fprec + 3) << "Z" 77 << " " << std::setw(fprec + 6) << "KineE" 78 << " " << std::setw(fprec + 10) << "dEStep" 79 << " " << std::setw(fprec + 7) << "StepLeng" << std::setw(fprec + 7) << "TrakLeng" 80 << std::setw(10) << "Volume" 81 << " " << std::setw(10) << "Process" << G4endl; 82 83 G4cout << std::setw(5) << fTrack->GetCurrentStepNumber() << " " << std::setw(fprec + 3) 84 << G4BestUnit(fTrack->GetPosition().x(), "Length") << std::setw(fprec + 3) 85 << G4BestUnit(fTrack->GetPosition().y(), "Length") << std::setw(fprec + 3) 86 << G4BestUnit(fTrack->GetPosition().z(), "Length") << std::setw(fprec + 3) 87 << G4BestUnit(fTrack->GetKineticEnergy(), "Energy") << std::setw(fprec + 7) 88 << G4BestUnit(fStep->GetTotalEnergyDeposit(), "Energy") << std::setw(fprec + 3) 89 << G4BestUnit(fStep->GetStepLength(), "Length") << std::setw(fprec + 3) 90 << G4BestUnit(fTrack->GetTrackLength(), "Length") << std::setw(10) 91 << fTrack->GetVolume()->GetName() << std::setw(9) << " initStep" << G4endl; 92 } 93 G4cout.precision(oldprec); 94 } 95 96 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 97 98 void G4SteppingVerboseWithUnits::StepInfo() 99 { 100 CopyState(); 101 G4long oldprec = G4cout.precision(fprec); 102 103 if (verboseLevel >= 1) { 104 if (verboseLevel >= 4) VerboseTrack(); 105 if (verboseLevel >= 3) { 106 G4cout << G4endl; 107 G4cout << std::setw(5) << "#Step#" 108 << " " << std::setw(fprec + 3) << "X" 109 << " " << std::setw(fprec + 3) << "Y" 110 << " " << std::setw(fprec + 3) << "Z" 111 << " " << std::setw(fprec + 6) << "KineE" 112 << " " << std::setw(fprec + 10) << "dEStep" 113 << " " << std::setw(fprec + 7) << "StepLeng" << std::setw(fprec + 7) << "TrakLeng" 114 << std::setw(10) << "Volume" 115 << " " << std::setw(10) << "Process" << G4endl; 116 } 117 118 G4cout << std::setw(5) << fTrack->GetCurrentStepNumber() << " " << std::setw(fprec + 3) 119 << G4BestUnit(fTrack->GetPosition().x(), "Length") << std::setw(fprec + 3) 120 << G4BestUnit(fTrack->GetPosition().y(), "Length") << std::setw(fprec + 3) 121 << G4BestUnit(fTrack->GetPosition().z(), "Length") << std::setw(fprec + 3) 122 << G4BestUnit(fTrack->GetKineticEnergy(), "Energy") << std::setw(fprec + 7) 123 << G4BestUnit(fStep->GetTotalEnergyDeposit(), "Energy") << std::setw(fprec + 3) 124 << G4BestUnit(fStep->GetStepLength(), "Length") << std::setw(fprec + 3) 125 << G4BestUnit(fTrack->GetTrackLength(), "Length") << std::setw(10) 126 << fTrack->GetVolume()->GetName(); 127 128 const G4VProcess* process = fStep->GetPostStepPoint()->GetProcessDefinedStep(); 129 G4String procName = " UserLimit"; 130 if (process != nullptr) procName = process->GetProcessName(); 131 if (fStepStatus == fWorldBoundary) procName = "OutOfWorld"; 132 G4cout << " " << std::setw(9) << procName; 133 G4cout << G4endl; 134 135 if (verboseLevel == 2) { 136 const std::vector<const G4Track*>* secondary = fStep->GetSecondaryInCurrentStep(); 137 if (! secondary->empty()) { 138 G4cout << "\n :----- List of secondaries ----------------" << G4endl; 139 G4cout.precision(4); 140 for (auto lp : *secondary) { 141 G4cout << " " << std::setw(13) << lp->GetDefinition()->GetParticleName() 142 << ": energy =" << std::setw(6) << G4BestUnit(lp->GetKineticEnergy(), "Energy") 143 << " time =" << std::setw(6) << G4BestUnit(lp->GetGlobalTime(), "Time"); 144 G4cout << G4endl; 145 } 146 147 G4cout << " :------------------------------------------\n" << G4endl; 148 } 149 } 150 } 151 G4cout.precision(oldprec); 152 } 153 154 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 155 156 void G4SteppingVerboseWithUnits::AtRestDoItInvoked() 157 { 158 G4VProcess* ptProcManager; 159 CopyState(); 160 161 if (verboseLevel >= 3) { 162 G4int npt = 0; 163 G4cout << " **List of AtRestDoIt invoked:" << G4endl; 164 for (std::size_t np = 0; np < MAXofAtRestLoops; ++np) { 165 std::size_t npGPIL = MAXofAtRestLoops - np - 1; 166 if ((*fSelectedAtRestDoItVector)[npGPIL] == G4ForceCondition::Forced) { 167 ++npt; 168 ptProcManager = (*fAtRestDoItVector)[(G4int)np]; 169 G4cout << " # " << npt << " : " << ptProcManager->GetProcessName() << " (Forced)" 170 << G4endl; 171 } 172 else if ((*fSelectedAtRestDoItVector)[npGPIL] == G4ForceCondition::NotForced) { 173 ++npt; 174 ptProcManager = (*fAtRestDoItVector)[(G4int)np]; 175 G4cout << " # " << npt << " : " << ptProcManager->GetProcessName() << G4endl; 176 } 177 } 178 179 G4cout << " Generated secondaries = " << fN2ndariesAtRestDoIt << G4endl; 180 181 if (fN2ndariesAtRestDoIt > 0) { 182 G4cout << " -- List of secondaries generated : " 183 << "(x,y,z,kE,t,PID) --" << G4endl; 184 for (std::size_t lp1 = (*fSecondary).size() - fN2ndariesAtRestDoIt; 185 lp1 < (*fSecondary).size(); ++lp1) 186 { 187 G4cout << " " << std::setw(9) 188 << G4BestUnit((*fSecondary)[lp1]->GetPosition().x(), "Length") << " " << std::setw(9) 189 << G4BestUnit((*fSecondary)[lp1]->GetPosition().y(), "Length") << " " << std::setw(9) 190 << G4BestUnit((*fSecondary)[lp1]->GetPosition().z(), "Length") << " " << std::setw(9) 191 << G4BestUnit((*fSecondary)[lp1]->GetKineticEnergy(), "Energy") << " " 192 << std::setw(9) << G4BestUnit((*fSecondary)[lp1]->GetGlobalTime(), "Time") << " " 193 << std::setw(18) << (*fSecondary)[lp1]->GetDefinition()->GetParticleName() << G4endl; 194 } 195 } 196 } 197 198 if (verboseLevel >= 4) { 199 ShowStep(); 200 G4cout << G4endl; 201 } 202 } 203 204 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 205 206 void G4SteppingVerboseWithUnits::AlongStepDoItAllDone() 207 { 208 G4VProcess* ptProcManager; 209 210 CopyState(); 211 212 if (verboseLevel >= 3) { 213 G4cout << G4endl; 214 G4cout << " >>AlongStepDoIt (after all invocations):" << G4endl; 215 G4cout << " ++List of invoked processes " << G4endl; 216 217 for (std::size_t ci = 0; ci < MAXofAlongStepLoops; ++ci) { 218 ptProcManager = (*fAlongStepDoItVector)((G4int)ci); 219 G4cout << " " << ci + 1 << ") "; 220 if (ptProcManager != nullptr) { 221 G4cout << ptProcManager->GetProcessName() << G4endl; 222 } 223 } 224 225 ShowStep(); 226 G4cout << G4endl; 227 G4cout << " ++List of secondaries generated " 228 << "(x,y,z,kE,t,PID):" 229 << " No. of secondaries = " << (*fSecondary).size() << G4endl; 230 231 if (! (*fSecondary).empty()) { 232 for (auto& lp1 : *fSecondary) { 233 G4cout << " " << std::setw(9) << G4BestUnit(lp1->GetPosition().x(), "Length") << " " 234 << std::setw(9) << G4BestUnit(lp1->GetPosition().y(), "Length") << " " 235 << std::setw(9) << G4BestUnit(lp1->GetPosition().z(), "Length") << " " 236 << std::setw(9) << G4BestUnit(lp1->GetKineticEnergy(), "Energy") << " " 237 << std::setw(9) << G4BestUnit(lp1->GetGlobalTime(), "Time") << " " << std::setw(18) 238 << lp1->GetDefinition()->GetParticleName() << G4endl; 239 } 240 } 241 } 242 } 243 244 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 245 246 void G4SteppingVerboseWithUnits::PostStepDoItAllDone() 247 { 248 G4VProcess* ptProcManager; 249 250 CopyState(); 251 252 if ((static_cast<int>(fStepStatus == fPostStepDoItProc) | static_cast<int>(fCondition == Forced) | 253 static_cast<int>(fCondition == Conditionally) | 254 static_cast<int>(fCondition == ExclusivelyForced) | 255 static_cast<int>(fCondition == StronglyForced)) != 0) 256 { 257 if (verboseLevel >= 3) { 258 G4int npt = 0; 259 G4cout << G4endl; 260 G4cout << " **PostStepDoIt (after all invocations):" << G4endl; 261 G4cout << " ++List of invoked processes " << G4endl; 262 263 for (std::size_t np = 0; np < MAXofPostStepLoops; ++np) { 264 std::size_t npGPIL = MAXofPostStepLoops - np - 1; 265 if ((*fSelectedPostStepDoItVector)[npGPIL] == G4ForceCondition::Forced) { 266 ++npt; 267 ptProcManager = (*fPostStepDoItVector)[(G4int)np]; 268 G4cout << " " << npt << ") " << ptProcManager->GetProcessName() << " (Forced)" 269 << G4endl; 270 } 271 else if ((*fSelectedPostStepDoItVector)[npGPIL] == G4ForceCondition::NotForced) { 272 ++npt; 273 ptProcManager = (*fPostStepDoItVector)[(G4int)np]; 274 G4cout << " " << npt << ") " << ptProcManager->GetProcessName() << G4endl; 275 } 276 } 277 278 ShowStep(); 279 G4cout << G4endl; 280 G4cout << " ++List of secondaries generated " 281 << "(x,y,z,kE,t,PID):" 282 << " No. of secondaries = " << (*fSecondary).size() << G4endl; 283 G4cout << " [Note]Secondaries from AlongStepDoIt included." << G4endl; 284 285 if (! (*fSecondary).empty()) { 286 for (auto& lp1 : *fSecondary) { 287 G4cout << " " << std::setw(9) << G4BestUnit(lp1->GetPosition().x(), "Length") << " " 288 << std::setw(9) << G4BestUnit(lp1->GetPosition().y(), "Length") << " " 289 << std::setw(9) << G4BestUnit(lp1->GetPosition().z(), "Length") << " " 290 << std::setw(9) << G4BestUnit(lp1->GetKineticEnergy(), "Energy") << " " 291 << std::setw(9) << G4BestUnit(lp1->GetGlobalTime(), "Time") << " " << std::setw(18) 292 << lp1->GetDefinition()->GetParticleName() << G4endl; 293 } 294 } 295 } 296 } 297 } 298 299 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 300 301 void G4SteppingVerboseWithUnits::DPSLStarted() 302 { 303 CopyState(); 304 305 if (verboseLevel > 5) { 306 G4cout << G4endl << " >>DefinePhysicalStepLength (List of proposed StepLengths): " << G4endl; 307 } 308 } 309 310 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 311 312 void G4SteppingVerboseWithUnits::DPSLUserLimit() 313 { 314 CopyState(); 315 316 if (verboseLevel > 5) { 317 G4cout << G4endl << G4endl; 318 G4cout << "=== Defined Physical Step Length (DPSL)" << G4endl; 319 G4cout << " ++ProposedStep(UserLimit) = " << std::setw(9) 320 << G4BestUnit(physIntLength, "Length") 321 << " : ProcName = User defined maximum allowed Step" << G4endl; 322 } 323 } 324 325 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 326 327 void G4SteppingVerboseWithUnits::DPSLPostStep() 328 { 329 CopyState(); 330 331 if (verboseLevel > 5) { 332 G4cout << " ++ProposedStep(PostStep ) = " << std::setw(9) 333 << G4BestUnit(physIntLength, "Length") 334 << " : ProcName = " << fCurrentProcess->GetProcessName() << " ("; 335 if (fCondition == ExclusivelyForced) { 336 G4cout << "ExclusivelyForced)" << G4endl; 337 } 338 else if (fCondition == StronglyForced) { 339 G4cout << "StronglyForced)" << G4endl; 340 } 341 else if (fCondition == Conditionally) { 342 G4cout << "Conditionally)" << G4endl; 343 } 344 else if (fCondition == Forced) { 345 G4cout << "Forced)" << G4endl; 346 } 347 else { 348 G4cout << "No ForceCondition)" << G4endl; 349 } 350 } 351 } 352 353 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 354 355 void G4SteppingVerboseWithUnits::DPSLAlongStep() 356 { 357 CopyState(); 358 359 if (verboseLevel > 5) { 360 G4cout << " ++ProposedStep(AlongStep) = " << std::setw(9) 361 << G4BestUnit(physIntLength, "Length") 362 << " : ProcName = " << fCurrentProcess->GetProcessName() << " ("; 363 if (fGPILSelection == CandidateForSelection) { 364 G4cout << "CandidateForSelection)" << G4endl; 365 } 366 else if (fGPILSelection == NotCandidateForSelection) { 367 G4cout << "NotCandidateForSelection)" << G4endl; 368 } 369 else { 370 G4cout << "?!?)" << G4endl; 371 } 372 } 373 } 374 375 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 376 377 void G4SteppingVerboseWithUnits::AlongStepDoItOneByOne() 378 { 379 CopyState(); 380 381 if (verboseLevel >= 4) { 382 G4cout << G4endl; 383 G4cout << " >>AlongStepDoIt (process by process): " 384 << " Process Name = " << fCurrentProcess->GetProcessName() << G4endl; 385 386 ShowStep(); 387 G4cout << " " 388 << "!Note! Safety of PostStep is only valid " 389 << "after all DoIt invocations." << G4endl; 390 391 VerboseParticleChange(); 392 G4cout << G4endl; 393 394 G4cout << " ++List of secondaries generated " 395 << "(x,y,z,kE,t,PID):" 396 << " No. of secondaries = " << fN2ndariesAlongStepDoIt << G4endl; 397 398 if (fN2ndariesAlongStepDoIt > 0) { 399 for (std::size_t lp1 = (*fSecondary).size() - fN2ndariesAlongStepDoIt; 400 lp1 < (*fSecondary).size(); ++lp1) 401 { 402 G4cout << " " << std::setw(9) 403 << G4BestUnit((*fSecondary)[lp1]->GetPosition().x(), "Length") << " " << std::setw(9) 404 << G4BestUnit((*fSecondary)[lp1]->GetPosition().y(), "Length") << " " << std::setw(9) 405 << G4BestUnit((*fSecondary)[lp1]->GetPosition().z(), "Length") << " " << std::setw(9) 406 << G4BestUnit((*fSecondary)[lp1]->GetKineticEnergy(), "Energy") << " " 407 << std::setw(9) << G4BestUnit((*fSecondary)[lp1]->GetGlobalTime(), "Time") << " " 408 << std::setw(18) << (*fSecondary)[lp1]->GetDefinition()->GetParticleName() << G4endl; 409 } 410 } 411 } 412 } 413 414 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 415 416 void G4SteppingVerboseWithUnits::PostStepDoItOneByOne() 417 { 418 CopyState(); 419 420 if (verboseLevel >= 4) { 421 G4cout << G4endl; 422 G4cout << " >>PostStepDoIt (process by process): " 423 << " Process Name = " << fCurrentProcess->GetProcessName() << G4endl; 424 425 ShowStep(); 426 G4cout << G4endl; 427 VerboseParticleChange(); 428 G4cout << G4endl; 429 430 G4cout << " ++List of secondaries generated " 431 << "(x,y,z,kE,t,PID):" 432 << " No. of secondaries = " << fN2ndariesPostStepDoIt << G4endl; 433 434 if (fN2ndariesPostStepDoIt > 0) { 435 for (std::size_t lp1 = (*fSecondary).size() - fN2ndariesPostStepDoIt; 436 lp1 < (*fSecondary).size(); ++lp1) 437 { 438 G4cout << " " << std::setw(9) 439 << G4BestUnit((*fSecondary)[lp1]->GetPosition().x(), "Length") << " " << std::setw(9) 440 << G4BestUnit((*fSecondary)[lp1]->GetPosition().y(), "Length") << " " << std::setw(9) 441 << G4BestUnit((*fSecondary)[lp1]->GetPosition().z(), "Length") << " " << std::setw(9) 442 << G4BestUnit((*fSecondary)[lp1]->GetKineticEnergy(), "Energy") << " " 443 << std::setw(9) << G4BestUnit((*fSecondary)[lp1]->GetGlobalTime(), "Time") << " " 444 << std::setw(18) << (*fSecondary)[lp1]->GetDefinition()->GetParticleName() << G4endl; 445 } 446 } 447 } 448 } 449 450 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 451 452 void G4SteppingVerboseWithUnits::VerboseTrack() 453 { 454 CopyState(); 455 456 G4cout << G4endl; 457 G4cout << " ++G4Track Information " << G4endl; 458 G4long oldprec = G4cout.precision(fprec); 459 460 G4cout << " -----------------------------------------------" << G4endl; 461 G4cout << " G4Track Information " << std::setw(20) << G4endl; 462 G4cout << " -----------------------------------------------" << G4endl; 463 464 G4cout << " Step number : " << std::setw(20) << fTrack->GetCurrentStepNumber() 465 << G4endl; 466 G4cout << " Position - x : " << std::setw(20) 467 << G4BestUnit(fTrack->GetPosition().x(), "Length") << G4endl; 468 G4cout << " Position - y : " << std::setw(20) 469 << G4BestUnit(fTrack->GetPosition().y(), "Length") << G4endl; 470 G4cout << " Position - z : " << std::setw(20) 471 << G4BestUnit(fTrack->GetPosition().z(), "Length") << G4endl; 472 G4cout << " Global Time : " << std::setw(20) 473 << G4BestUnit(fTrack->GetGlobalTime(), "Time") << G4endl; 474 G4cout << " Local Time : " << std::setw(20) 475 << G4BestUnit(fTrack->GetLocalTime(), "Time") << G4endl; 476 G4cout << " Momentum Direct - x : " << std::setw(20) << fTrack->GetMomentumDirection().x() 477 << G4endl; 478 G4cout << " Momentum Direct - y : " << std::setw(20) << fTrack->GetMomentumDirection().y() 479 << G4endl; 480 G4cout << " Momentum Direct - z : " << std::setw(20) << fTrack->GetMomentumDirection().z() 481 << G4endl; 482 G4cout << " Kinetic Energy : " << std::setw(20) 483 << G4BestUnit(fTrack->GetKineticEnergy(), "Energy") << G4endl; 484 G4cout << " Polarization - x : " << std::setw(20) << fTrack->GetPolarization().x() 485 << G4endl; 486 G4cout << " Polarization - y : " << std::setw(20) << fTrack->GetPolarization().y() 487 << G4endl; 488 G4cout << " Polarization - z : " << std::setw(20) << fTrack->GetPolarization().z() 489 << G4endl; 490 G4cout << " Track Length : " << std::setw(20) 491 << G4BestUnit(fTrack->GetTrackLength(), "Length") << G4endl; 492 G4cout << " Track ID # : " << std::setw(20) << fTrack->GetTrackID() << G4endl; 493 G4cout << " Parent Track ID # : " << std::setw(20) << fTrack->GetParentID() << G4endl; 494 G4cout << " Next Volume : " << std::setw(20); 495 if (fTrack->GetNextVolume() != nullptr) 496 G4cout << fTrack->GetNextVolume()->GetName() << " "; 497 else 498 G4cout << "OutOfWorld" 499 << " "; 500 G4cout << G4endl; 501 G4cout << " Track Status : " << std::setw(20); 502 if (fTrack->GetTrackStatus() == fAlive) 503 G4cout << " Alive"; 504 else if (fTrack->GetTrackStatus() == fStopButAlive) 505 G4cout << " StopButAlive"; 506 else if (fTrack->GetTrackStatus() == fStopAndKill) 507 G4cout << " StopAndKill"; 508 else if (fTrack->GetTrackStatus() == fKillTrackAndSecondaries) 509 G4cout << " KillTrackAndSecondaries"; 510 else if (fTrack->GetTrackStatus() == fSuspend) 511 G4cout << " Suspend"; 512 else if (fTrack->GetTrackStatus() == fPostponeToNextEvent) 513 G4cout << " PostponeToNextEvent"; 514 G4cout << G4endl; 515 G4cout << " Vertex - x : " << std::setw(20) 516 << G4BestUnit(fTrack->GetVertexPosition().x(), "Length") << G4endl; 517 G4cout << " Vertex - y : " << std::setw(20) 518 << G4BestUnit(fTrack->GetVertexPosition().y(), "Length") << G4endl; 519 G4cout << " Vertex - z : " << std::setw(20) 520 << G4BestUnit(fTrack->GetVertexPosition().z(), "Length") << G4endl; 521 G4cout << " Vertex - Px (MomDir): " << std::setw(20) 522 << fTrack->GetVertexMomentumDirection().x() << G4endl; 523 G4cout << " Vertex - Py (MomDir): " << std::setw(20) 524 << fTrack->GetVertexMomentumDirection().y() << G4endl; 525 G4cout << " Vertex - Pz (MomDir): " << std::setw(20) 526 << fTrack->GetVertexMomentumDirection().z() << G4endl; 527 G4cout << " Vertex - KineE : " << std::setw(20) 528 << G4BestUnit(fTrack->GetVertexKineticEnergy(), "Energy") << G4endl; 529 530 G4cout << " Creator Process : " << std::setw(20); 531 if (fTrack->GetCreatorProcess() == nullptr) 532 G4cout << " Event Generator" << G4endl; 533 else 534 G4cout << fTrack->GetCreatorProcess()->GetProcessName() << G4endl; 535 536 G4cout << " -----------------------------------------------" << G4endl; 537 G4cout.precision(oldprec); 538 } 539 540 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 541 542 void G4SteppingVerboseWithUnits::VerboseParticleChange() 543 { 544 G4cout << G4endl; 545 G4cout << " ++G4ParticleChange Information " << G4endl; 546 fParticleChange->DumpInfo(); 547 } 548 549 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 550 551 void G4SteppingVerboseWithUnits::ShowStep() const 552 { 553 // Show header 554 G4cout << G4endl; 555 G4cout << " ++G4Step Information " << G4endl; 556 G4long oldprc = G4cout.precision(fprec); 557 558 // Show G4Step specific information 559 G4cout << " Address of G4Track : " << fStep->GetTrack() << G4endl; 560 G4cout << " Step Length : " 561 << G4BestUnit(fStep->GetTrack()->GetStepLength(), "Length") << G4endl; 562 G4cout << " Energy Deposit : " << G4BestUnit(fStep->GetTotalEnergyDeposit(), "Energy") 563 << G4endl; 564 565 // Show G4StepPoint specific information 566 G4cout << " -------------------------------------------------------" 567 << "----------------" << G4endl; 568 G4cout << " StepPoint Information " << std::setw(20) << "PreStep" << std::setw(20) 569 << "PostStep" << G4endl; 570 G4cout << " -------------------------------------------------------" 571 << "----------------" << G4endl; 572 G4cout << " Position - x : " << std::setw(17) 573 << G4BestUnit(fStep->GetPreStepPoint()->GetPosition().x(), "Length") << std::setw(17) 574 << G4BestUnit(fStep->GetPostStepPoint()->GetPosition().x(), "Length") << G4endl; 575 G4cout << " Position - y : " << std::setw(17) 576 << G4BestUnit(fStep->GetPreStepPoint()->GetPosition().y(), "Length") << std::setw(17) 577 << G4BestUnit(fStep->GetPostStepPoint()->GetPosition().y(), "Length") << G4endl; 578 G4cout << " Position - z : " << std::setw(17) 579 << G4BestUnit(fStep->GetPreStepPoint()->GetPosition().z(), "Length") << std::setw(17) 580 << G4BestUnit(fStep->GetPostStepPoint()->GetPosition().z(), "Length") << G4endl; 581 G4cout << " Global Time : " << std::setw(17) 582 << G4BestUnit(fStep->GetPreStepPoint()->GetGlobalTime(), "Time") << std::setw(17) 583 << G4BestUnit(fStep->GetPostStepPoint()->GetGlobalTime(), "Time") << G4endl; 584 G4cout << " Local Time : " << std::setw(17) 585 << G4BestUnit(fStep->GetPreStepPoint()->GetLocalTime(), "Time") << std::setw(17) 586 << G4BestUnit(fStep->GetPostStepPoint()->GetLocalTime(), "Time") << G4endl; 587 G4cout << " Proper Time : " << std::setw(17) 588 << G4BestUnit(fStep->GetPreStepPoint()->GetProperTime(), "Time") << std::setw(17) 589 << G4BestUnit(fStep->GetPostStepPoint()->GetProperTime(), "Time") << G4endl; 590 G4cout << " Momentum Direct - x : " << std::setw(20) 591 << fStep->GetPreStepPoint()->GetMomentumDirection().x() << std::setw(20) 592 << fStep->GetPostStepPoint()->GetMomentumDirection().x() << G4endl; 593 G4cout << " Momentum Direct - y : " << std::setw(20) 594 << fStep->GetPreStepPoint()->GetMomentumDirection().y() << std::setw(20) 595 << fStep->GetPostStepPoint()->GetMomentumDirection().y() << G4endl; 596 G4cout << " Momentum Direct - z : " << std::setw(20) 597 << fStep->GetPreStepPoint()->GetMomentumDirection().z() << std::setw(20) 598 << fStep->GetPostStepPoint()->GetMomentumDirection().z() << G4endl; 599 G4cout << " Momentum - x : " << std::setw(14) 600 << G4BestUnit(fStep->GetPreStepPoint()->GetMomentum().x(), "Momentum") << std::setw(14) 601 << G4BestUnit(fStep->GetPostStepPoint()->GetMomentum().x(), "Momentum") << G4endl; 602 G4cout << " Momentum - y : " << std::setw(14) 603 << G4BestUnit(fStep->GetPreStepPoint()->GetMomentum().y(), "Momentum") << std::setw(14) 604 << G4BestUnit(fStep->GetPostStepPoint()->GetMomentum().y(), "Momentum") << G4endl; 605 G4cout << " Momentum - z : " << std::setw(14) 606 << G4BestUnit(fStep->GetPreStepPoint()->GetMomentum().z(), "Momentum") << std::setw(14) 607 << G4BestUnit(fStep->GetPostStepPoint()->GetMomentum().z(), "Momentum") << G4endl; 608 G4cout << " Total Energy : " << std::setw(16) 609 << G4BestUnit(fStep->GetPreStepPoint()->GetTotalEnergy(), "Energy") << std::setw(16) 610 << G4BestUnit(fStep->GetPostStepPoint()->GetTotalEnergy(), "Energy") << G4endl; 611 G4cout << " Kinetic Energy : " << std::setw(16) 612 << G4BestUnit(fStep->GetPreStepPoint()->GetKineticEnergy(), "Energy") << std::setw(16) 613 << G4BestUnit(fStep->GetPostStepPoint()->GetKineticEnergy(), "Energy") << G4endl; 614 G4cout << " Velocity : " << std::setw(14) 615 << G4BestUnit(fStep->GetPreStepPoint()->GetVelocity(), "Velocity") << std::setw(14) 616 << G4BestUnit(fStep->GetPostStepPoint()->GetVelocity(), "Velocity") << G4endl; 617 G4cout << " Volume Name : " << std::setw(20) 618 << fStep->GetPreStepPoint()->GetPhysicalVolume()->GetName(); 619 G4String volName = "OutOfWorld"; 620 if (fStep->GetPostStepPoint()->GetPhysicalVolume() != nullptr) 621 volName = fStep->GetPostStepPoint()->GetPhysicalVolume()->GetName(); 622 G4cout << std::setw(20) << volName << G4endl; 623 G4cout << " Safety : " << std::setw(17) 624 << G4BestUnit(fStep->GetPreStepPoint()->GetSafety(), "Length") << std::setw(17) 625 << G4BestUnit(fStep->GetPostStepPoint()->GetSafety(), "Length") << G4endl; 626 G4cout << " Polarization - x : " << std::setw(20) 627 << fStep->GetPreStepPoint()->GetPolarization().x() << std::setw(20) 628 << fStep->GetPostStepPoint()->GetPolarization().x() << G4endl; 629 G4cout << " Polarization - y : " << std::setw(20) 630 << fStep->GetPreStepPoint()->GetPolarization().y() << std::setw(20) 631 << fStep->GetPostStepPoint()->GetPolarization().y() << G4endl; 632 G4cout << " Polarization - Z : " << std::setw(20) 633 << fStep->GetPreStepPoint()->GetPolarization().z() << std::setw(20) 634 << fStep->GetPostStepPoint()->GetPolarization().z() << G4endl; 635 G4cout << " Weight : " << std::setw(20) 636 << fStep->GetPreStepPoint()->GetWeight() << std::setw(20) 637 << fStep->GetPostStepPoint()->GetWeight() << G4endl; 638 G4cout << " Step Status : "; 639 G4StepStatus tStepStatus = fStep->GetPreStepPoint()->GetStepStatus(); 640 if (tStepStatus == fGeomBoundary) { 641 G4cout << std::setw(20) << "Geom Limit"; 642 } 643 else if (tStepStatus == fAlongStepDoItProc) { 644 G4cout << std::setw(20) << "AlongStep Proc."; 645 } 646 else if (tStepStatus == fPostStepDoItProc) { 647 G4cout << std::setw(20) << "PostStep Proc"; 648 } 649 else if (tStepStatus == fAtRestDoItProc) { 650 G4cout << std::setw(20) << "AtRest Proc"; 651 } 652 else if (tStepStatus == fUndefined) { 653 G4cout << std::setw(20) << "Undefined"; 654 } 655 656 tStepStatus = fStep->GetPostStepPoint()->GetStepStatus(); 657 if (tStepStatus == fGeomBoundary) { 658 G4cout << std::setw(20) << "Geom Limit"; 659 } 660 else if (tStepStatus == fAlongStepDoItProc) { 661 G4cout << std::setw(20) << "AlongStep Proc."; 662 } 663 else if (tStepStatus == fPostStepDoItProc) { 664 G4cout << std::setw(20) << "PostStep Proc"; 665 } 666 else if (tStepStatus == fAtRestDoItProc) { 667 G4cout << std::setw(20) << "AtRest Proc"; 668 } 669 else if (tStepStatus == fUndefined) { 670 G4cout << std::setw(20) << "Undefined"; 671 } 672 673 G4cout << G4endl; 674 G4cout << " Process defined Step: "; 675 if (fStep->GetPreStepPoint()->GetProcessDefinedStep() == nullptr) { 676 G4cout << std::setw(20) << "Undefined"; 677 } 678 else { 679 G4cout << std::setw(20) << fStep->GetPreStepPoint()->GetProcessDefinedStep()->GetProcessName(); 680 } 681 if (fStep->GetPostStepPoint()->GetProcessDefinedStep() == nullptr) { 682 G4cout << std::setw(20) << "Undefined"; 683 } 684 else { 685 G4cout << std::setw(20) << fStep->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName(); 686 } 687 G4cout.precision(oldprc); 688 689 G4cout << G4endl; 690 G4cout << " -------------------------------------------------------" 691 << "----------------" << G4endl; 692 } 693 694 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 695