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 // G4SteppingVerbose class implementation 27 // 28 // Contact: 29 // Questions and comments to this code should be sent to 30 // Katsuya Amako (e-mail: Katsuya.Amako@kek.jp) 31 // Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp) 32 // -------------------------------------------------------------------- 33 34 #include "G4SteppingVerbose.hh" 35 36 #include "G4StepStatus.hh" // Include from 'tracking' 37 #include "G4SteppingManager.hh" 38 #include "G4SystemOfUnits.hh" 39 #include "G4VSensitiveDetector.hh" // Include from 'hits/digi' 40 41 // #define G4_USE_G4BESTUNIT_FOR_VERBOSE 1 42 43 #ifdef G4_USE_G4BESTUNIT_FOR_VERBOSE 44 # include "G4UnitsTable.hh" 45 #else 46 # define G4BestUnit(a, b) a 47 #endif 48 49 G4int G4SteppingVerbose::useBestUnitPrecision = -1; 50 51 ////////////////////////////////////////////////// 52 void G4SteppingVerbose::NewStep() 53 ////////////////////////////////////////////////// 54 {} 55 56 ////////////////////////////////////////////////// 57 void G4SteppingVerbose::AtRestDoItInvoked() 58 ////////////////////////////////////////////////// 59 { 60 if (Silent == 1) { 61 return; 62 } 63 64 G4VProcess* ptProcManager; 65 CopyState(); 66 67 if (verboseLevel >= 3) { 68 G4int npt = 0; 69 G4cout << " **List of AtRestDoIt invoked:" << G4endl; 70 for (std::size_t np = 0; np < MAXofAtRestLoops; ++np) { 71 std::size_t npGPIL = MAXofAtRestLoops - np - 1; 72 if ((*fSelectedAtRestDoItVector)[npGPIL] == G4ForceCondition::Forced) { 73 ++npt; 74 ptProcManager = (*fAtRestDoItVector)[(G4int)np]; 75 G4cout << " # " << npt << " : " << ptProcManager->GetProcessName() << " (Forced)" 76 << G4endl; 77 } 78 else if ((*fSelectedAtRestDoItVector)[npGPIL] == G4ForceCondition::NotForced) { 79 ++npt; 80 ptProcManager = (*fAtRestDoItVector)[(G4int)np]; 81 G4cout << " # " << npt << " : " << ptProcManager->GetProcessName() << G4endl; 82 } 83 } 84 85 G4cout << " Generated secondries # : " << fN2ndariesAtRestDoIt << G4endl; 86 87 if (fN2ndariesAtRestDoIt > 0) { 88 G4cout << " -- List of secondaries generated : " 89 << "(x,y,z,kE,t,PID) --" << G4endl; 90 for (std::size_t lp1 = (*fSecondary).size() - fN2ndariesAtRestDoIt; 91 lp1 < (*fSecondary).size(); ++lp1) 92 { 93 G4cout << " " << std::setw(9) 94 << G4BestUnit((*fSecondary)[lp1]->GetPosition().x(), "Length") << " " << std::setw(9) 95 << G4BestUnit((*fSecondary)[lp1]->GetPosition().y(), "Length") << " " << std::setw(9) 96 << G4BestUnit((*fSecondary)[lp1]->GetPosition().z(), "Length") << " " << std::setw(9) 97 << G4BestUnit((*fSecondary)[lp1]->GetKineticEnergy(), "Energy") << " " 98 << std::setw(9) << G4BestUnit((*fSecondary)[lp1]->GetGlobalTime(), "Time") << " " 99 << std::setw(18) << (*fSecondary)[lp1]->GetDefinition()->GetParticleName() << G4endl; 100 } 101 } 102 } 103 104 if (verboseLevel >= 4) { 105 ShowStep(); 106 G4cout << G4endl; 107 } 108 } 109 110 ///////////////////////////////////////////////////// 111 void G4SteppingVerbose::AlongStepDoItAllDone() 112 ///////////////////////////////////////////////////// 113 { 114 if (Silent == 1) { 115 return; 116 } 117 118 G4VProcess* ptProcManager; 119 120 CopyState(); 121 122 if (verboseLevel >= 3) { 123 G4cout << G4endl; 124 G4cout << " >>AlongStepDoIt (after all invocations):" << G4endl; 125 G4cout << " ++List of invoked processes " << G4endl; 126 127 for (std::size_t ci = 0; ci < MAXofAlongStepLoops; ++ci) { 128 ptProcManager = (*fAlongStepDoItVector)((G4int)ci); 129 G4cout << " " << ci + 1 << ") "; 130 if (ptProcManager != nullptr) { 131 G4cout << ptProcManager->GetProcessName() << G4endl; 132 } 133 } 134 135 ShowStep(); 136 G4cout << G4endl; 137 G4cout << " ++List of secondaries generated " 138 << "(x,y,z,kE,t,PID):" 139 << " No. of secondaries = " << (*fSecondary).size() << G4endl; 140 141 if (! (*fSecondary).empty()) { 142 for (auto& lp1 : *fSecondary) { 143 G4cout << " " << std::setw(9) << G4BestUnit(lp1->GetPosition().x(), "Length") << " " 144 << std::setw(9) << G4BestUnit(lp1->GetPosition().y(), "Length") << " " 145 << std::setw(9) << G4BestUnit(lp1->GetPosition().z(), "Length") << " " 146 << std::setw(9) << G4BestUnit(lp1->GetKineticEnergy(), "Energy") << " " 147 << std::setw(9) << G4BestUnit(lp1->GetGlobalTime(), "Time") << " " << std::setw(18) 148 << lp1->GetDefinition()->GetParticleName() << G4endl; 149 } 150 } 151 } 152 } 153 154 //////////////////////////////////////////////////// 155 void G4SteppingVerbose::PostStepDoItAllDone() 156 //////////////////////////////////////////////////// 157 { 158 if (Silent == 1) { 159 return; 160 } 161 162 G4VProcess* ptProcManager; 163 164 CopyState(); 165 166 if ((fStepStatus == fPostStepDoItProc) || (fCondition == Forced) || 167 (fCondition == Conditionally) || (fCondition == ExclusivelyForced) || 168 (fCondition == StronglyForced)) 169 { 170 if (verboseLevel >= 3) { 171 G4int npt = 0; 172 G4cout << G4endl; 173 G4cout << " **PostStepDoIt (after all invocations):" << G4endl; 174 G4cout << " ++List of invoked processes " << G4endl; 175 176 for (std::size_t np = 0; np < MAXofPostStepLoops; ++np) { 177 std::size_t npGPIL = MAXofPostStepLoops - np - 1; 178 if ((*fSelectedPostStepDoItVector)[npGPIL] == G4ForceCondition::Forced) { 179 ++npt; 180 ptProcManager = (*fPostStepDoItVector)[(G4int)np]; 181 G4cout << " " << npt << ") " << ptProcManager->GetProcessName() << " (Forced)" 182 << G4endl; 183 } 184 else if ((*fSelectedPostStepDoItVector)[npGPIL] == G4ForceCondition::NotForced) { 185 ++npt; 186 ptProcManager = (*fPostStepDoItVector)[(G4int)np]; 187 G4cout << " " << npt << ") " << ptProcManager->GetProcessName() << G4endl; 188 } 189 } 190 191 ShowStep(); 192 G4cout << G4endl; 193 G4cout << " ++List of secondaries generated " 194 << "(x,y,z,kE,t,PID):" 195 << " No. of secodaries = " << (*fSecondary).size() << G4endl; 196 G4cout << " [Note]Secondaries from AlongStepDoIt included." << G4endl; 197 198 if (! (*fSecondary).empty()) { 199 for (auto& lp1 : *fSecondary) { 200 G4cout << " " << std::setw(9) << G4BestUnit(lp1->GetPosition().x(), "Length") << " " 201 << std::setw(9) << G4BestUnit(lp1->GetPosition().y(), "Length") << " " 202 << std::setw(9) << G4BestUnit(lp1->GetPosition().z(), "Length") << " " 203 << std::setw(9) << G4BestUnit(lp1->GetKineticEnergy(), "Energy") << " " 204 << std::setw(9) << G4BestUnit(lp1->GetGlobalTime(), "Time") << " " << std::setw(18) 205 << lp1->GetDefinition()->GetParticleName() << G4endl; 206 } 207 } 208 } 209 } 210 } 211 212 ///////////////////////////////////////// 213 void G4SteppingVerbose::StepInfo() 214 ///////////////////////////////////////// 215 { 216 if (Silent == 1) { 217 return; 218 } 219 if (SilentStepInfo == 1) { 220 return; 221 } 222 223 CopyState(); 224 G4cout.precision(16); 225 G4long prec = G4cout.precision(3); 226 227 if (verboseLevel >= 1) { 228 if (verboseLevel >= 4) VerboseTrack(); 229 if (verboseLevel >= 3) { 230 G4cout << G4endl; 231 #ifdef G4_USE_G4BESTUNIT_FOR_VERBOSE 232 G4cout << std::setw(5) << "#Step#" 233 << " " << std::setw(8) << "X" 234 << " " << std::setw(8) << "Y" 235 << " " << std::setw(8) << "Z" 236 << " " << std::setw(9) << "KineE" 237 << " " << std::setw(8) << "dE" 238 << " " << std::setw(12) << "StepLeng" 239 << " " << std::setw(12) << "TrackLeng" 240 << " " << std::setw(12) << "NextVolume" 241 << " " << std::setw(8) << "ProcName" << G4endl; 242 #else 243 G4cout << std::setw(5) << "#Step#" 244 << " " << std::setw(8) << "X(mm)" 245 << " " << std::setw(8) << "Y(mm)" 246 << " " << std::setw(8) << "Z(mm)" 247 << " " << std::setw(9) << "KinE(MeV)" 248 << " " << std::setw(8) << "dE(MeV)" 249 << " " << std::setw(8) << "StepLeng" 250 << " " << std::setw(9) << "TrackLeng" 251 << " " << std::setw(11) << "NextVolume" 252 << " " << std::setw(8) << "ProcName" << G4endl; 253 #endif 254 } 255 G4cout << std::setw(5) << fTrack->GetCurrentStepNumber() << " " << std::setw(8) 256 << G4BestUnit(fTrack->GetPosition().x(), "Length") << " " << std::setw(8) 257 << G4BestUnit(fTrack->GetPosition().y(), "Length") << " " << std::setw(8) 258 << G4BestUnit(fTrack->GetPosition().z(), "Length") << " " << std::setw(9) 259 << G4BestUnit(fTrack->GetKineticEnergy(), "Energy") << " " << std::setw(8) 260 << G4BestUnit(fStep->GetTotalEnergyDeposit(), "Energy") << " " << std::setw(8) 261 << G4BestUnit(fStep->GetStepLength(), "Length") << " " << std::setw(9) 262 << G4BestUnit(fTrack->GetTrackLength(), "Length") << " "; 263 264 if (fTrack->GetNextVolume() != nullptr) { 265 G4cout << std::setw(11) << fTrack->GetNextVolume()->GetName() << " "; 266 } 267 else { 268 G4cout << std::setw(11) << "OutOfWorld" 269 << " "; 270 } 271 if (fStep->GetPostStepPoint()->GetProcessDefinedStep() != nullptr) { 272 G4cout << fStep->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName(); 273 } 274 else { 275 G4cout << "User Limit"; 276 } 277 G4cout << G4endl; 278 if (verboseLevel == 2) { 279 G4int tN2ndariesTot = fN2ndariesAtRestDoIt + fN2ndariesAlongStepDoIt + fN2ndariesPostStepDoIt; 280 if (tN2ndariesTot > 0) { 281 G4cout << " :----- List of 2ndaries - " 282 << "#SpawnInStep=" << std::setw(3) << tN2ndariesTot << "(Rest=" << std::setw(2) 283 << fN2ndariesAtRestDoIt << ",Along=" << std::setw(2) << fN2ndariesAlongStepDoIt 284 << ",Post=" << std::setw(2) << fN2ndariesPostStepDoIt << "), " 285 << "#SpawnTotal=" << std::setw(3) << (*fSecondary).size() << " ---------------" 286 << G4endl; 287 288 for (std::size_t lp1 = (*fSecondary).size() - tN2ndariesTot; lp1 < (*fSecondary).size(); 289 ++lp1) 290 { 291 G4cout << " : " << std::setw(9) 292 << G4BestUnit((*fSecondary)[lp1]->GetPosition().x(), "Length") << " " 293 << std::setw(9) << G4BestUnit((*fSecondary)[lp1]->GetPosition().y(), "Length") 294 << " " << std::setw(9) 295 << G4BestUnit((*fSecondary)[lp1]->GetPosition().z(), "Length") << " " 296 << std::setw(9) << G4BestUnit((*fSecondary)[lp1]->GetKineticEnergy(), "Energy") 297 << " " << std::setw(18) << (*fSecondary)[lp1]->GetDefinition()->GetParticleName() 298 << G4endl; 299 } 300 G4cout << " :-----------------------------" 301 << "----------------------------------" 302 << "-- EndOf2ndaries Info ---------------" << G4endl; 303 } 304 } 305 } 306 G4cout.precision(prec); 307 } 308 309 //////////////////////////////////////////// 310 void G4SteppingVerbose::DPSLStarted() 311 //////////////////////////////////////////// 312 { 313 if (Silent == 1) { 314 return; 315 } 316 CopyState(); 317 318 if (verboseLevel > 5) { 319 G4cout << G4endl << " >>DefinePhysicalStepLength (List of proposed StepLengths): " << G4endl; 320 } 321 } 322 323 ////////////////////////////////////////////// 324 void G4SteppingVerbose::DPSLUserLimit() 325 ////////////////////////////////////////////// 326 { 327 if (Silent == 1) { 328 return; 329 } 330 CopyState(); 331 332 if (verboseLevel > 5) { 333 G4cout << G4endl << G4endl; 334 G4cout << "=== Defined Physical Step Length (DPSL)" << G4endl; 335 G4cout << " ++ProposedStep(UserLimit) = " << std::setw(9) << physIntLength 336 << " : ProcName = User defined maximum allowed Step" << G4endl; 337 } 338 } 339 340 ///////////////////////////////////////////// 341 void G4SteppingVerbose::DPSLPostStep() 342 ///////////////////////////////////////////// 343 { 344 if (Silent == 1) { 345 return; 346 } 347 CopyState(); 348 349 if (verboseLevel > 5) { 350 G4cout << " ++ProposedStep(PostStep ) = " << std::setw(9) << physIntLength 351 << " : ProcName = " << fCurrentProcess->GetProcessName() << " ("; 352 if (fCondition == ExclusivelyForced) { 353 G4cout << "ExclusivelyForced)" << G4endl; 354 } 355 else if (fCondition == StronglyForced) { 356 G4cout << "StronglyForced)" << G4endl; 357 } 358 else if (fCondition == Conditionally) { 359 G4cout << "Conditionally)" << G4endl; 360 } 361 else if (fCondition == Forced) { 362 G4cout << "Forced)" << G4endl; 363 } 364 else { 365 G4cout << "No ForceCondition)" << G4endl; 366 } 367 } 368 } 369 370 ///////////////////////////////////////////// 371 void G4SteppingVerbose::DPSLAlongStep() 372 ///////////////////////////////////////////// 373 { 374 if (Silent == 1) { 375 return; 376 } 377 CopyState(); 378 379 if (verboseLevel > 5) { 380 G4cout << " ++ProposedStep(AlongStep) = " << std::setw(9) 381 << G4BestUnit(physIntLength, "Length") 382 << " : ProcName = " << fCurrentProcess->GetProcessName() << " ("; 383 if (fGPILSelection == CandidateForSelection) { 384 G4cout << "CandidateForSelection)" << G4endl; 385 } 386 else if (fGPILSelection == NotCandidateForSelection) { 387 G4cout << "NotCandidateForSelection)" << G4endl; 388 } 389 else { 390 G4cout << "?!?)" << G4endl; 391 } 392 } 393 } 394 395 //////////////////////////////////////////////// 396 void G4SteppingVerbose::TrackingStarted() 397 //////////////////////////////////////////////// 398 { 399 if (Silent == 1) { 400 return; 401 } 402 403 CopyState(); 404 405 G4long prec = G4cout.precision(3); 406 if (verboseLevel > 0) { 407 #ifdef G4_USE_G4BESTUNIT_FOR_VERBOSE 408 G4cout << std::setw(5) << "Step#" 409 << " " << std::setw(8) << "X" 410 << " " << std::setw(8) << "Y" 411 << " " << std::setw(8) << "Z" 412 << " " << std::setw(9) << "KineE" 413 << " " << std::setw(8) << "dE" 414 << " " << std::setw(12) << "StepLeng" 415 << " " << std::setw(12) << "TrackLeng" 416 << " " << std::setw(12) << "NextVolume" 417 << " " << std::setw(8) << "ProcName" << G4endl; 418 #else 419 G4cout << std::setw(5) << "Step#" 420 << " " << std::setw(8) << "X(mm)" 421 << " " << std::setw(8) << "Y(mm)" 422 << " " << std::setw(8) << "Z(mm)" 423 << " " << std::setw(9) << "KinE(MeV)" 424 << " " << std::setw(8) << "dE(MeV)" 425 << " " << std::setw(8) << "StepLeng" 426 << " " << std::setw(9) << "TrackLeng" 427 << " " << std::setw(11) << "NextVolume" 428 << " " << std::setw(8) << "ProcName" << G4endl; 429 #endif 430 431 G4cout << std::setw(5) << fTrack->GetCurrentStepNumber() << " " << std::setw(8) 432 << G4BestUnit(fTrack->GetPosition().x(), "Length") << " " << std::setw(8) 433 << G4BestUnit(fTrack->GetPosition().y(), "Length") << " " << std::setw(8) 434 << G4BestUnit(fTrack->GetPosition().z(), "Length") << " " << std::setw(9) 435 << G4BestUnit(fTrack->GetKineticEnergy(), "Energy") << " " << std::setw(8) 436 << G4BestUnit(fStep->GetTotalEnergyDeposit(), "Energy") << " " << std::setw(8) 437 << G4BestUnit(fStep->GetStepLength(), "Length") << " " << std::setw(9) 438 << G4BestUnit(fTrack->GetTrackLength(), "Length") << " "; 439 440 if (fTrack->GetNextVolume() != nullptr) { 441 G4cout << std::setw(11) << fTrack->GetNextVolume()->GetName() << " "; 442 } 443 else { 444 G4cout << std::setw(11) << "OutOfWorld" 445 << " "; 446 } 447 G4cout << "initStep" << G4endl; 448 } 449 G4cout.precision(prec); 450 } 451 452 ////////////////////////////////////////////////////// 453 void G4SteppingVerbose::AlongStepDoItOneByOne() 454 ////////////////////////////////////////////////////// 455 { 456 if (Silent == 1) { 457 return; 458 } 459 460 CopyState(); 461 462 if (verboseLevel >= 4) { 463 G4cout << G4endl; 464 G4cout << " >>AlongStepDoIt (process by process): " 465 << " Process Name = " << fCurrentProcess->GetProcessName() << G4endl; 466 467 ShowStep(); 468 G4cout << " " 469 << "!Note! Safety of PostStep is only valid " 470 << "after all DoIt invocations." << G4endl; 471 472 VerboseParticleChange(); 473 G4cout << G4endl; 474 475 G4cout << " ++List of secondaries generated " 476 << "(x,y,z,kE,t,PID):" 477 << " No. of secodaries = " << fN2ndariesAlongStepDoIt << G4endl; 478 479 if (fN2ndariesAlongStepDoIt > 0) { 480 for (std::size_t lp1 = (*fSecondary).size() - fN2ndariesAlongStepDoIt; 481 lp1 < (*fSecondary).size(); ++lp1) 482 { 483 G4cout << " " << std::setw(9) 484 << G4BestUnit((*fSecondary)[lp1]->GetPosition().x(), "Length") << " " << std::setw(9) 485 << G4BestUnit((*fSecondary)[lp1]->GetPosition().y(), "Length") << " " << std::setw(9) 486 << G4BestUnit((*fSecondary)[lp1]->GetPosition().z(), "Length") << " " << std::setw(9) 487 << G4BestUnit((*fSecondary)[lp1]->GetKineticEnergy(), "Energy") << " " 488 << std::setw(9) << G4BestUnit((*fSecondary)[lp1]->GetGlobalTime(), "Time") << " " 489 << std::setw(18) << (*fSecondary)[lp1]->GetDefinition()->GetParticleName() << G4endl; 490 } 491 } 492 } 493 } 494 495 ////////////////////////////////////////////////////// 496 void G4SteppingVerbose::PostStepDoItOneByOne() 497 ////////////////////////////////////////////////////// 498 { 499 if (Silent == 1) { 500 return; 501 } 502 503 CopyState(); 504 505 if (verboseLevel >= 4) { 506 G4cout << G4endl; 507 G4cout << " >>PostStepDoIt (process by process): " 508 << " Process Name = " << fCurrentProcess->GetProcessName() << G4endl; 509 510 ShowStep(); 511 G4cout << G4endl; 512 VerboseParticleChange(); 513 G4cout << G4endl; 514 515 G4cout << " ++List of secondaries generated " 516 << "(x,y,z,kE,t,PID):" 517 << " No. of secodaries = " << fN2ndariesPostStepDoIt << G4endl; 518 519 if (fN2ndariesPostStepDoIt > 0) { 520 for (std::size_t lp1 = (*fSecondary).size() - fN2ndariesPostStepDoIt; 521 lp1 < (*fSecondary).size(); ++lp1) 522 { 523 G4cout << " " << std::setw(9) 524 << G4BestUnit((*fSecondary)[lp1]->GetPosition().x(), "Length") << " " << std::setw(9) 525 << G4BestUnit((*fSecondary)[lp1]->GetPosition().y(), "Length") << " " << std::setw(9) 526 << G4BestUnit((*fSecondary)[lp1]->GetPosition().z(), "Length") << " " << std::setw(9) 527 << G4BestUnit((*fSecondary)[lp1]->GetKineticEnergy(), "Energy") << " " 528 << std::setw(9) << G4BestUnit((*fSecondary)[lp1]->GetGlobalTime(), "Time") << " " 529 << std::setw(18) << (*fSecondary)[lp1]->GetDefinition()->GetParticleName() << G4endl; 530 } 531 } 532 } 533 } 534 535 ////////////////////////////////////// 536 void G4SteppingVerbose::VerboseTrack() 537 ////////////////////////////////////// 538 { 539 if (Silent == 1) { 540 return; 541 } 542 543 CopyState(); 544 545 G4cout << G4endl; 546 G4cout << " ++G4Track Information " << G4endl; 547 G4long prec = G4cout.precision(3); 548 549 G4cout << " -----------------------------------------------" << G4endl; 550 G4cout << " G4Track Information " << std::setw(20) << G4endl; 551 G4cout << " -----------------------------------------------" << G4endl; 552 553 G4cout << " Step number : " << std::setw(20) << fTrack->GetCurrentStepNumber() 554 << G4endl; 555 #ifdef G4_USE_G4BESTUNIT_FOR_VERBOSE 556 G4cout << " Position - x : " << std::setw(20) 557 << G4BestUnit(fTrack->GetPosition().x(), "Length") << G4endl; 558 G4cout << " Position - y : " << std::setw(20) 559 << G4BestUnit(fTrack->GetPosition().y(), "Length") << G4endl; 560 G4cout << " Position - z : " << std::setw(20) 561 << G4BestUnit(fTrack->GetPosition().z(), "Length") << G4endl; 562 G4cout << " Global Time : " << std::setw(20) 563 << G4BestUnit(fTrack->GetGlobalTime(), "Time") << G4endl; 564 G4cout << " Local Time : " << std::setw(20) 565 << G4BestUnit(fTrack->GetLocalTime(), "Time") << G4endl; 566 #else 567 G4cout << " Position - x (mm) : " << std::setw(20) << fTrack->GetPosition().x() / mm 568 << G4endl; 569 G4cout << " Position - y (mm) : " << std::setw(20) << fTrack->GetPosition().y() / mm 570 << G4endl; 571 G4cout << " Position - z (mm) : " << std::setw(20) << fTrack->GetPosition().z() / mm 572 << G4endl; 573 G4cout << " Global Time (ns) : " << std::setw(20) << fTrack->GetGlobalTime() / ns 574 << G4endl; 575 G4cout << " Local Time (ns) : " << std::setw(20) << fTrack->GetLocalTime() / ns 576 << G4endl; 577 #endif 578 G4cout << " Momentum Direct - x : " << std::setw(20) << fTrack->GetMomentumDirection().x() 579 << G4endl; 580 G4cout << " Momentum Direct - y : " << std::setw(20) << fTrack->GetMomentumDirection().y() 581 << G4endl; 582 G4cout << " Momentum Direct - z : " << std::setw(20) << fTrack->GetMomentumDirection().z() 583 << G4endl; 584 #ifdef G4_USE_G4BESTUNIT_FOR_VERBOSE 585 G4cout << " Kinetic Energy : " 586 #else 587 G4cout << " Kinetic Energy (MeV): " 588 #endif 589 << std::setw(20) << G4BestUnit(fTrack->GetKineticEnergy(), "Energy") << G4endl; 590 G4cout << " Polarization - x : " << std::setw(20) << fTrack->GetPolarization().x() 591 << G4endl; 592 G4cout << " Polarization - y : " << std::setw(20) << fTrack->GetPolarization().y() 593 << G4endl; 594 G4cout << " Polarization - z : " << std::setw(20) << fTrack->GetPolarization().z() 595 << G4endl; 596 G4cout << " Track Length : " << std::setw(20) 597 << G4BestUnit(fTrack->GetTrackLength(), "Length") << G4endl; 598 G4cout << " Track ID # : " << std::setw(20) << fTrack->GetTrackID() << G4endl; 599 G4cout << " Parent Track ID # : " << std::setw(20) << fTrack->GetParentID() << G4endl; 600 G4cout << " Next Volume : " << std::setw(20); 601 if (fTrack->GetNextVolume() != nullptr) { 602 G4cout << fTrack->GetNextVolume()->GetName() << " "; 603 } 604 else { 605 G4cout << "OutOfWorld" 606 << " "; 607 } 608 G4cout << G4endl; 609 G4cout << " Track Status : " << std::setw(20); 610 if (fTrack->GetTrackStatus() == fAlive) { 611 G4cout << " Alive"; 612 } 613 else if (fTrack->GetTrackStatus() == fStopButAlive) { 614 G4cout << " StopButAlive"; 615 } 616 else if (fTrack->GetTrackStatus() == fStopAndKill) { 617 G4cout << " StopAndKill"; 618 } 619 else if (fTrack->GetTrackStatus() == fKillTrackAndSecondaries) { 620 G4cout << " KillTrackAndSecondaries"; 621 } 622 else if (fTrack->GetTrackStatus() == fSuspend) { 623 G4cout << " Suspend"; 624 } 625 else if (fTrack->GetTrackStatus() == fPostponeToNextEvent) { 626 G4cout << " PostponeToNextEvent"; 627 } 628 G4cout << G4endl; 629 #ifdef G4_USE_G4BESTUNIT_FOR_VERBOSE 630 G4cout << " Vertex - x : " << std::setw(20) 631 << G4BestUnit(fTrack->GetVertexPosition().x(), "Length") << G4endl; 632 G4cout << " Vertex - y : " << std::setw(20) 633 << G4BestUnit(fTrack->GetVertexPosition().y(), "Length") << G4endl; 634 G4cout << " Vertex - z : " << std::setw(20) 635 << G4BestUnit(fTrack->GetVertexPosition().z(), "Length") << G4endl; 636 #else 637 G4cout << " Vertex - x (mm) : " << std::setw(20) 638 << fTrack->GetVertexPosition().x() / mm << G4endl; 639 G4cout << " Vertex - y (mm) : " << std::setw(20) 640 << fTrack->GetVertexPosition().y() / mm << G4endl; 641 G4cout << " Vertex - z (mm) : " << std::setw(20) 642 << fTrack->GetVertexPosition().z() / mm << G4endl; 643 #endif 644 G4cout << " Vertex - Px (MomDir): " << std::setw(20) 645 << fTrack->GetVertexMomentumDirection().x() << G4endl; 646 G4cout << " Vertex - Py (MomDir): " << std::setw(20) 647 << fTrack->GetVertexMomentumDirection().y() << G4endl; 648 G4cout << " Vertex - Pz (MomDir): " << std::setw(20) 649 << fTrack->GetVertexMomentumDirection().z() << G4endl; 650 #ifdef G4_USE_G4BESTUNIT_FOR_VERBOSE 651 G4cout << " Vertex - KineE : " 652 #else 653 G4cout << " Vertex - KineE (MeV): " 654 #endif 655 << std::setw(20) << G4BestUnit(fTrack->GetVertexKineticEnergy(), "Energy") << G4endl; 656 657 G4cout << " Creator Process : " << std::setw(20); 658 if (fTrack->GetCreatorProcess() == nullptr) { 659 G4cout << " Event Generator" << G4endl; 660 } 661 else { 662 G4cout << fTrack->GetCreatorProcess()->GetProcessName() << G4endl; 663 } 664 665 G4cout << " -----------------------------------------------" << G4endl; 666 G4cout.precision(prec); 667 } 668 669 /////////////////////////////////////////////// 670 void G4SteppingVerbose::VerboseParticleChange() 671 /////////////////////////////////////////////// 672 { 673 if (Silent == 1) { 674 return; 675 } 676 677 G4cout << G4endl; 678 G4cout << " ++G4ParticleChange Information " << G4endl; 679 fParticleChange->DumpInfo(); 680 } 681 682 ///////////////////////////////////////// 683 void G4SteppingVerbose::ShowStep() const 684 //////////////////////////////////////// 685 { 686 if (Silent == 1) { 687 return; 688 } 689 G4String volName; 690 G4long oldprc; 691 692 // Show header 693 G4cout << G4endl; 694 G4cout << " ++G4Step Information " << G4endl; 695 oldprc = G4cout.precision(16); 696 697 // Show G4Step specific information 698 G4cout << " Address of G4Track : " << fStep->GetTrack() << G4endl; 699 G4cout << " Step Length (mm) : " << fStep->GetTrack()->GetStepLength() << G4endl; 700 G4cout << " Energy Deposit (MeV) : " << fStep->GetTotalEnergyDeposit() << G4endl; 701 702 // Show G4StepPoint specific information 703 G4cout << " -------------------------------------------------------" 704 << "----------------" << G4endl; 705 G4cout << " StepPoint Information " << std::setw(20) << "PreStep" << std::setw(20) 706 << "PostStep" << G4endl; 707 G4cout << " -------------------------------------------------------" 708 << "----------------" << G4endl; 709 G4cout << " Position - x (mm) : " << std::setw(20) 710 << fStep->GetPreStepPoint()->GetPosition().x() << std::setw(20) 711 << fStep->GetPostStepPoint()->GetPosition().x() << G4endl; 712 G4cout << " Position - y (mm) : " << std::setw(20) 713 << fStep->GetPreStepPoint()->GetPosition().y() << std::setw(20) 714 << fStep->GetPostStepPoint()->GetPosition().y() << G4endl; 715 G4cout << " Position - z (mm) : " << std::setw(20) 716 << fStep->GetPreStepPoint()->GetPosition().z() << std::setw(20) 717 << fStep->GetPostStepPoint()->GetPosition().z() << G4endl; 718 G4cout << " Global Time (ns) : " << std::setw(20) 719 << fStep->GetPreStepPoint()->GetGlobalTime() << std::setw(20) 720 << fStep->GetPostStepPoint()->GetGlobalTime() << G4endl; 721 G4cout << " Local Time (ns) : " << std::setw(20) 722 << fStep->GetPreStepPoint()->GetLocalTime() << std::setw(20) 723 << fStep->GetPostStepPoint()->GetLocalTime() << G4endl; 724 G4cout << " Proper Time (ns) : " << std::setw(20) 725 << fStep->GetPreStepPoint()->GetProperTime() << std::setw(20) 726 << fStep->GetPostStepPoint()->GetProperTime() << G4endl; 727 G4cout << " Momentum Direct - x : " << std::setw(20) 728 << fStep->GetPreStepPoint()->GetMomentumDirection().x() << std::setw(20) 729 << fStep->GetPostStepPoint()->GetMomentumDirection().x() << G4endl; 730 G4cout << " Momentum Direct - y : " << std::setw(20) 731 << fStep->GetPreStepPoint()->GetMomentumDirection().y() << std::setw(20) 732 << fStep->GetPostStepPoint()->GetMomentumDirection().y() << G4endl; 733 G4cout << " Momentum Direct - z : " << std::setw(20) 734 << fStep->GetPreStepPoint()->GetMomentumDirection().z() << std::setw(20) 735 << fStep->GetPostStepPoint()->GetMomentumDirection().z() << G4endl; 736 G4cout << " Momentum - x (MeV/c): " << std::setw(20) 737 << fStep->GetPreStepPoint()->GetMomentum().x() << std::setw(20) 738 << fStep->GetPostStepPoint()->GetMomentum().x() << G4endl; 739 G4cout << " Momentum - y (MeV/c): " << std::setw(20) 740 << fStep->GetPreStepPoint()->GetMomentum().y() << std::setw(20) 741 << fStep->GetPostStepPoint()->GetMomentum().y() << G4endl; 742 G4cout << " Momentum - z (MeV/c): " << std::setw(20) 743 << fStep->GetPreStepPoint()->GetMomentum().z() << std::setw(20) 744 << fStep->GetPostStepPoint()->GetMomentum().z() << G4endl; 745 G4cout << " Total Energy (MeV) : " << std::setw(20) 746 << fStep->GetPreStepPoint()->GetTotalEnergy() << std::setw(20) 747 << fStep->GetPostStepPoint()->GetTotalEnergy() << G4endl; 748 G4cout << " Kinetic Energy (MeV): " << std::setw(20) 749 << fStep->GetPreStepPoint()->GetKineticEnergy() << std::setw(20) 750 << fStep->GetPostStepPoint()->GetKineticEnergy() << G4endl; 751 G4cout << " Velocity (mm/ns) : " << std::setw(20) 752 << fStep->GetPreStepPoint()->GetVelocity() << std::setw(20) 753 << fStep->GetPostStepPoint()->GetVelocity() << G4endl; 754 G4cout << " Volume Name : " << std::setw(20) 755 << fStep->GetPreStepPoint()->GetPhysicalVolume()->GetName(); 756 if (fStep->GetPostStepPoint()->GetPhysicalVolume() != nullptr) { 757 volName = fStep->GetPostStepPoint()->GetPhysicalVolume()->GetName(); 758 } 759 else { 760 volName = "OutOfWorld"; 761 } 762 G4cout << std::setw(20) << volName << G4endl; 763 G4cout << " Safety (mm) : " << std::setw(20) 764 << fStep->GetPreStepPoint()->GetSafety() << std::setw(20) 765 << fStep->GetPostStepPoint()->GetSafety() << G4endl; 766 G4cout << " Polarization - x : " << std::setw(20) 767 << fStep->GetPreStepPoint()->GetPolarization().x() << std::setw(20) 768 << fStep->GetPostStepPoint()->GetPolarization().x() << G4endl; 769 G4cout << " Polarization - y : " << std::setw(20) 770 << fStep->GetPreStepPoint()->GetPolarization().y() << std::setw(20) 771 << fStep->GetPostStepPoint()->GetPolarization().y() << G4endl; 772 G4cout << " Polarization - Z : " << std::setw(20) 773 << fStep->GetPreStepPoint()->GetPolarization().z() << std::setw(20) 774 << fStep->GetPostStepPoint()->GetPolarization().z() << G4endl; 775 G4cout << " Weight : " << std::setw(20) 776 << fStep->GetPreStepPoint()->GetWeight() << std::setw(20) 777 << fStep->GetPostStepPoint()->GetWeight() << G4endl; 778 G4cout << " Step Status : "; 779 G4StepStatus tStepStatus = fStep->GetPreStepPoint()->GetStepStatus(); 780 if (tStepStatus == fGeomBoundary) { 781 G4cout << std::setw(20) << "Geom Limit"; 782 } 783 else if (tStepStatus == fAlongStepDoItProc) { 784 G4cout << std::setw(20) << "AlongStep Proc."; 785 } 786 else if (tStepStatus == fPostStepDoItProc) { 787 G4cout << std::setw(20) << "PostStep Proc"; 788 } 789 else if (tStepStatus == fAtRestDoItProc) { 790 G4cout << std::setw(20) << "AtRest Proc"; 791 } 792 else if (tStepStatus == fUndefined) { 793 G4cout << std::setw(20) << "Undefined"; 794 } 795 796 tStepStatus = fStep->GetPostStepPoint()->GetStepStatus(); 797 if (tStepStatus == fGeomBoundary) { 798 G4cout << std::setw(20) << "Geom Limit"; 799 } 800 else if (tStepStatus == fAlongStepDoItProc) { 801 G4cout << std::setw(20) << "AlongStep Proc."; 802 } 803 else if (tStepStatus == fPostStepDoItProc) { 804 G4cout << std::setw(20) << "PostStep Proc"; 805 } 806 else if (tStepStatus == fAtRestDoItProc) { 807 G4cout << std::setw(20) << "AtRest Proc"; 808 } 809 else if (tStepStatus == fUndefined) { 810 G4cout << std::setw(20) << "Undefined"; 811 } 812 813 G4cout << G4endl; 814 G4cout << " Process defined Step: "; 815 if (fStep->GetPreStepPoint()->GetProcessDefinedStep() == nullptr) { 816 G4cout << std::setw(20) << "Undefined"; 817 } 818 else { 819 G4cout << std::setw(20) << fStep->GetPreStepPoint()->GetProcessDefinedStep()->GetProcessName(); 820 } 821 if (fStep->GetPostStepPoint()->GetProcessDefinedStep() == nullptr) { 822 G4cout << std::setw(20) << "Undefined"; 823 } 824 else { 825 G4cout << std::setw(20) << fStep->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName(); 826 } 827 G4cout.precision(oldprc); 828 829 G4cout << G4endl; 830 G4cout << " -------------------------------------------------------" 831 << "----------------" << G4endl; 832 } 833 834 ////////////////////////////////////////////////// 835 void G4SteppingVerbose::UseBestUnit(G4int prec) 836 ////////////////////////////////////////////////// 837 { 838 useBestUnitPrecision = prec; 839 } 840 841 ////////////////////////////////////////////////// 842 G4int G4SteppingVerbose::BestUnitPrecision() 843 ////////////////////////////////////////////////// 844 { 845 return useBestUnitPrecision; 846 } 847