Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 // 27 // 28 // 29 // class G4TransportationLogger Implementation 30 // 31 // Author: J. Apostolakis, June 2018 32 // 33 // ------------------------------------------- 34 35 #include <iomanip> 36 37 #include "G4SystemOfUnits.hh" 38 #include "G4TransportationLogger.hh" 39 #include "G4Track.hh" 40 #include "G4Step.hh" 41 42 G4TransportationLogger::G4TransportationLogger 43 44 : fClassName(className), fVerbose(verbosity 45 fThldWarningEnergy(0.), fThldImportantEne 46 { 47 } 48 49 G4TransportationLogger::G4TransportationLogger 50 51 : fClassName(className), fVerbose(verbosity 52 fThldWarningEnergy(0.), fThldImportantEne 53 { 54 } 55 56 G4TransportationLogger::~G4TransportationLogge 57 { 58 } 59 60 // ******************************************* 61 // SetThresholds 62 // ******************************************* 63 void G4TransportationLogger:: 64 SetThresholds( G4double newEnWarn, G4double im 65 G4int newMaxTrials ) 66 { 67 SetThresholdWarningEnergy( newEnWarn ); 68 SetThresholdImportantEnergy( importantEnerg 69 SetThresholdTrials(newMaxTrials ); 70 } 71 72 ////////////////////////////////////////////// 73 // 74 void 75 G4TransportationLogger::ReportLooperThresholds 76 { 77 G4cout << className << ": Current values f 78 << " the killing of looping tracks: 79 << " Warning Energy = " << Get 80 << " ( below this tracks are kille 81 << " Important Energy = " << Get 82 << " ( above this tracks are given 83 << " Extra Trials = " << Get 84 << " 'important' tracks, i.e. those 85 << G4endl; 86 } 87 88 // ******************************************* 89 // ReportLoopingTrack 90 // ******************************************* 91 // 92 void G4TransportationLogger::ReportLoopingTrac 93 94 95 96 97 ) const 98 { 99 static std::atomic<unsigned int> numAdviceEx 100 constexpr double gramPerCm3 = gram / ( centi 101 std::ostringstream msg; 102 auto preStepPt= stepData.GetPreStepPoint(); 103 auto preStepEn= preStepPt ? preStepPt->GetKi 104 msg << " Transportation is killing track tha 105 << " Track is " 106 << track.GetParticleDefinition()->GetPar 107 << " and has " << track.GetKineticEnergy 108 << " MeV energy ( pre-Step = " << preSt 109 msg << " momentum = " << track.GetMomentum 110 << G4endl 111 << " position = " << track.GetPosition 112 auto physVolume= track.GetVolume(); 113 auto material= physVolume->GetLogicalVolume( 114 msg << " is in volume '" << physVolume->GetN 115 if( material ) 116 { 117 msg << " its material is '" << material-> 118 msg << " with density = " << material->Ge 119 << " g/cm^3 "; 120 } 121 else 122 { 123 msg << " unable to obtain material inform 124 } 125 msg << G4endl; 126 msg << " Total number of Steps by this track 127 << G4endl 128 << " Length of this step = " << stepData 129 << G4endl 130 << " Number of propagation trials = " << 131 << " ( vs maximum = " << GetThresholdTri 132 << G4endl; 133 134 if (noCalls) 135 msg << " ( Number of *calls* of Transpor 136 137 const G4int numPrints= 5; 138 if( numAdviceExcessSteps++ < numPrints ) 139 { 140 msg << " =============== Recommendations 141 msg << " Recommendations to address this 142 msg << " This warning is controlled by th 143 << " method of G4Transportation. " < 144 << " Current value of 'warning' thres 145 << GetThresholdWarningEnergy() / MeV 146 msg << " - If 'unimportant' particles (wi 147 << " application, then increase its 148 msg << " - If particles of high-enough en 149 << " killed, you can " << G4endl 150 << " a) Increase the trial steps us 151 << " Particles above the 'important' 152 << " will be given this many 'chance 153 << " The default value was 10, and t 154 << G4endl 155 << " b) Increase the energy which y 156 << " killed only after extra trials), 157 << " Note: this can incur a pote 158 << " if more tracks require very larg 159 << " c) investigate alternative int 160 << " e.g. Helical methods for uni 161 << " or else higher order RK methods 162 << G4endl; 163 msg << " This information is provided " < 164 << numAdviceExcessSteps << " / " << n 165 msg << " ================================ 166 } 167 const G4String fullMethodName= fClassName + 168 G4Exception( fullMethodName, "Transport-001- 169 } 170