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] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /processes/transportation/src/G4TransportationLogger.cc (Version 11.3.0) and /processes/transportation/src/G4TransportationLogger.cc (Version 11.1.3)


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