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 // s 27 /// \file VG01SteppingVerboseWithDir.cc 28 /// \brief Implementation of the VG01SteppingVerboseWithDir class 29 30 // Author : J. Apostolakis, (EP/SFT CERN) 2019-21 31 // 32 // Refines the existing G4SteppingVerbose, adding: 33 // - direction of particle 34 // - safety (at step's start point) 35 36 #include "VG01SteppingVerboseWithDir.hh" 37 38 #include "G4SteppingManager.hh" 39 #include "G4UnitsTable.hh" 40 41 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 42 43 VG01SteppingVerboseWithDir::VG01SteppingVerboseWithDir() : G4SteppingVerbose() {} 44 45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 46 47 VG01SteppingVerboseWithDir::~VG01SteppingVerboseWithDir() {} 48 49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 50 51 void VG01SteppingVerboseWithDir::Banner() 52 { 53 G4cout << G4endl; 54 G4cout << std::setw(5) << "Step#" 55 << " " << std::setw(9) << "X (mm)" 56 << " " << std::setw(9) << "Y (mm)" 57 << " " << std::setw(9) << "Z (mm)" 58 << " " << std::setw(11) << "Ek (MeV)" 59 << " " << std::setw(8) << "dE (MeV)" 60 << " " << std::setw(7) << "Step(mm)" 61 << " " << std::setw(12) << "Track(mm)" 62 << " " << std::setw(7) << "Safety(mm)" 63 << " | " << std::setw(11) << " Dir.x " 64 << " " << std::setw(11) << " Dir.y " 65 << " " << std::setw(11) << " Dir.z " 66 << " | " << std::setw(15) << "Material" << std::setw(14) << "Process" << std::setw(15) 67 << "NextVolu" << G4endl; 68 } 69 70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 71 72 void VG01SteppingVerboseWithDir::StepInfo() 73 { 74 CopyState(); 75 76 G4int prec = G4cout.precision(6); 77 78 if (verboseLevel >= 1) { 79 if (verboseLevel >= 4) VerboseTrack(); 80 if (verboseLevel >= 3) { 81 Banner(); 82 } 83 84 G4cout << std::setw(5) << fTrack->GetCurrentStepNumber() << " " << std::setw(9) 85 << fTrack->GetPosition().x() / CLHEP::mm << " " << std::setw(9) 86 << fTrack->GetPosition().y() / CLHEP::mm << " " << std::setw(9) 87 << fTrack->GetPosition().z() / CLHEP::mm << " " // << " Ek = " 88 << std::setw(11) << fTrack->GetKineticEnergy() / CLHEP::MeV << " "; 89 G4cout.precision(3); 90 G4cout << std::setw(8) << fStep->GetTotalEnergyDeposit() / CLHEP::MeV << " " << std::setw(7) 91 << fStep->GetStepLength() / CLHEP::mm << " "; 92 G4cout.precision(6); 93 G4cout << std::setw(12) << fTrack->GetTrackLength() / CLHEP::mm << " "; 94 95 G4cout.precision(5); 96 G4StepPoint* preStepPt = fTrack->GetStep()->GetPreStepPoint(); 97 if (preStepPt != nullptr) { 98 G4double safety = preStepPt->GetSafety(); 99 G4cout << std::setw(8) << ((safety > 1.0e-9) ? safety : 0.0) << " "; 100 } 101 else { 102 G4cout << std::setw(8) << "-0.0_(N/A)" 103 << " "; 104 } 105 106 G4cout << "| "; 107 G4cout << std::setw(11) << fTrack->GetMomentumDirection().x() << " " << std::setw(11) 108 << fTrack->GetMomentumDirection().y() << " " << std::setw(11) 109 << fTrack->GetMomentumDirection().z() << " | "; 110 111 G4cout << std::setw(15) << fTrack->GetMaterial()->GetName() << " "; 112 G4VProcess const* pds = fStep->GetPostStepPoint()->GetProcessDefinedStep(); 113 G4cout << std::setw(14) << ((pds != nullptr) ? pds->GetProcessName() : G4String("User Limit")) 114 << " "; 115 // if( fStepStatus != fWorldBoundary){ 116 if (fTrack->GetNextVolume() != nullptr) { 117 G4cout << std::setw(10) << fTrack->GetNextVolume()->GetName(); 118 G4cout << std::setw(4) << fTrack->GetNextVolume()->GetCopyNo(); 119 } 120 else { 121 G4cout << std::setw(10) << "OutOfWorld"; 122 } 123 124 G4cout << " "; 125 126 G4cout << G4endl; 127 128 if (verboseLevel == 2) { 129 G4int tN2ndariesTot = fN2ndariesAtRestDoIt + fN2ndariesAlongStepDoIt + fN2ndariesPostStepDoIt; 130 if (tN2ndariesTot > 0) { 131 G4cout << " :----- List of 2ndaries - " 132 << "#SpawnInStep=" << std::setw(3) << tN2ndariesTot << "(Rest=" << std::setw(2) 133 << fN2ndariesAtRestDoIt << ",Along=" << std::setw(2) << fN2ndariesAlongStepDoIt 134 << ",Post=" << std::setw(2) << fN2ndariesPostStepDoIt << "), " 135 << "#SpawnTotal=" << std::setw(3) << (*fSecondary).size() << " ---------------" 136 << G4endl; 137 138 for (size_t lp1 = (*fSecondary).size() - tN2ndariesTot; lp1 < (*fSecondary).size(); lp1++) { 139 G4cout << " : " << std::setw(8) << (*fSecondary)[lp1]->GetPosition().x() / CLHEP::mm 140 << " " << std::setw(8) << (*fSecondary)[lp1]->GetPosition().y() / CLHEP::mm << " " 141 << std::setw(8) << (*fSecondary)[lp1]->GetPosition().z() / CLHEP::mm << " " 142 << std::setw(8) << (*fSecondary)[lp1]->GetKineticEnergy() / CLHEP::MeV << " " 143 << std::setw(10) << (*fSecondary)[lp1]->GetDefinition()->GetParticleName() << " "; 144 G4cout << G4endl; 145 } 146 147 G4cout << " :-----------------------------" 148 << "----------------------------------" 149 << "-- EndOf2ndaries Info ---------------" << G4endl; 150 } 151 } 152 } 153 G4cout.precision(prec); 154 // G4cout<< "exit VG01SteppingVerboseWithDir::StepInfo " <<G4endl; 155 } 156 157 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 158 159 void VG01SteppingVerboseWithDir::TrackingStarted() 160 { 161 CopyState(); 162 G4int prec = G4cout.precision(6); 163 if (verboseLevel > 0) { 164 Banner(); 165 166 G4cout << std::setw(5) << fTrack->GetCurrentStepNumber() << " " << std::setw(9) 167 << fTrack->GetPosition().x() / CLHEP::mm << " " << std::setw(9) 168 << fTrack->GetPosition().y() / CLHEP::mm << " " << std::setw(9) 169 << fTrack->GetPosition().z() / CLHEP::mm << " " // << " E_0 = " 170 << std::setw(11) << fTrack->GetKineticEnergy() / CLHEP::MeV << " "; 171 // << " ( = " << std::setw(8) << G4BestUnit(fTrack->GetKineticEnergy(),"Energy") << " ) " 172 G4cout.precision(3); 173 G4cout << std::setw(8) << fStep->GetTotalEnergyDeposit() / CLHEP::MeV << " " << std::setw(7) 174 << fStep->GetStepLength() / CLHEP::mm << " "; 175 G4cout.precision(6); 176 G4cout << std::setw(12) << fTrack->GetTrackLength() / CLHEP::mm << " "; 177 178 G4Step const* step = fTrack->GetStep(); 179 G4StepPoint const* preStepPt = nullptr; 180 if (step != nullptr) preStepPt = fTrack->GetStep()->GetPreStepPoint(); 181 if (preStepPt != nullptr) { 182 G4double safety = preStepPt->GetSafety(); 183 G4cout << std::setw(8) << ((safety > 1.0e-9) ? safety : 0.0) << " "; 184 } 185 else { 186 G4cout << std::setw(8) << "N/A" 187 << " "; 188 } 189 G4cout << "| "; 190 G4cout << std::setw(11) << fTrack->GetMomentumDirection().x() << " " << std::setw(11) 191 << fTrack->GetMomentumDirection().y() << " " << std::setw(11) 192 << fTrack->GetMomentumDirection().z() << " | "; 193 194 // Material and volume name 195 if (fTrack->GetVolume()) { 196 G4Material* material = fTrack->GetVolume()->GetLogicalVolume()->GetMaterial(); 197 if (material != nullptr) { 198 G4cout << std::setw(15) << material->GetName() << " "; 199 } 200 else { 201 G4cout << std::setw(15) << "No-Material" 202 << " "; 203 } 204 G4cout << std::setw(14) << "initStep" 205 << " "; 206 G4cout << std::setw(10) << fTrack->GetVolume()->GetName(); 207 G4cout << std::setw(4) << fTrack->GetVolume()->GetCopyNo() << " (initial Volume)"; 208 } 209 else { 210 G4cout << std::setw(10) << "No-Material" 211 << " "; 212 G4cout << std::setw(14) << "initStep" 213 << " "; 214 G4cout << std::setw(10) << "OutOfWorld" 215 << " "; 216 } 217 // fTrack->GetMaterial() fails at track start !!!! 218 G4cout << G4endl; 219 } 220 G4cout.precision(prec); 221 } 222