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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 /run/src/G4ExceptionHandler.cc (Version 11.3.0) and /run/src/G4ExceptionHandler.cc (Version 9.6.p4)


  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 // G4ExceptionHandler implementation           << 
 27 //                                                 26 //
 28 // Author: M.Asai - August 2002                <<  27 // $Id$
 29 // ------------------------------------------- <<  28 //
                                                   >>  29 // 
                                                   >>  30 // ------------------------------------------------------------
                                                   >>  31 //      GEANT 4 class implementation file 
                                                   >>  32 //
                                                   >>  33 //      ---------------- G4ExceptionHandler ----------------
                                                   >>  34 //             by Makoto Asai (August 2002)
                                                   >>  35 // ------------------------------------------------------------
 30                                                    36 
 31 #include "G4ExceptionHandler.hh"                   37 #include "G4ExceptionHandler.hh"
 32                                                << 
 33 #include "G4EventManager.hh"                   << 
 34 #include "G4Material.hh"                       << 
 35 #include "G4ParticleDefinition.hh"             << 
 36 #include "G4RunManager.hh"                     << 
 37 #include "G4RunManagerKernel.hh"               << 
 38 #include "G4StateManager.hh"                       38 #include "G4StateManager.hh"
 39 #include "G4Step.hh"                           <<  39 #include "G4RunManager.hh"
 40 #include "G4StepPoint.hh"                      << 
 41 #include "G4SteppingManager.hh"                << 
 42 #include "G4String.hh"                         << 
 43 #include "G4Track.hh"                          << 
 44 #include "G4TrackingManager.hh"                << 
 45 #include "G4UnitsTable.hh"                     << 
 46 #include "G4VPhysicalVolume.hh"                << 
 47 #include "G4VProcess.hh"                       << 
 48 #include "G4ios.hh"                                40 #include "G4ios.hh"
                                                   >>  41 #include <stdlib.h>
                                                   >>  42 #include "G4String.hh"
 49                                                    43 
 50 #include <cstdlib>                             <<  44 G4ExceptionHandler::G4ExceptionHandler() 
                                                   >>  45 {
                                                   >>  46 }
 51                                                    47 
 52 // ------------------------------------------- <<  48 G4ExceptionHandler::~G4ExceptionHandler()
 53 G4bool G4ExceptionHandler::operator==(const G4 << 
 54 {                                                  49 {
 55   return (this == &right);                     << 
 56 }                                                  50 }
 57                                                    51 
 58 // ------------------------------------------- <<  52 G4ExceptionHandler::G4ExceptionHandler(const G4ExceptionHandler &)
 59 G4bool G4ExceptionHandler::operator!=(const G4 <<  53 :G4VExceptionHandler()
 60 {                                                  54 {
 61   return (this != &right);                     << 
 62 }                                                  55 }
 63                                                    56 
 64 // ------------------------------------------- <<  57 G4ExceptionHandler& G4ExceptionHandler::operator=(const G4ExceptionHandler &)
 65 G4bool G4ExceptionHandler::Notify(const char*  << 
 66                                   G4ExceptionS << 
 67 {                                                  58 {
 68   static const G4String es_banner =            <<  59    return *this;
 69     "\n-------- EEEE ------- G4Exception-START << 
 70   static const G4String ee_banner =            << 
 71     "\n-------- EEEE -------- G4Exception-END  << 
 72   static const G4String ws_banner =            << 
 73     "\n-------- WWWW ------- G4Exception-START << 
 74   static const G4String we_banner =            << 
 75     "\n-------- WWWW -------- G4Exception-END  << 
 76   std::ostringstream message;                  << 
 77   message << "*** G4Exception : " << exception << 
 78           << "      issued by : " << originOfE << 
 79   G4bool abortionForCoreDump = false;          << 
 80   G4ApplicationState aps = G4StateManager::Get << 
 81   switch (severity) {                          << 
 82     case FatalException:                       << 
 83       G4cerr << es_banner << message.str() <<  << 
 84       DumpTrackInfo();                         << 
 85       G4cerr << ee_banner << G4endl;           << 
 86       abortionForCoreDump = true;              << 
 87       break;                                   << 
 88     case FatalErrorInArgument:                 << 
 89       G4cerr << es_banner << message.str() <<  << 
 90              << G4endl;                        << 
 91       DumpTrackInfo();                         << 
 92       G4cerr << ee_banner << G4endl;           << 
 93       abortionForCoreDump = true;              << 
 94       break;                                   << 
 95     case RunMustBeAborted:                     << 
 96       if (aps == G4State_GeomClosed || aps ==  << 
 97         G4cerr << es_banner << message.str() < << 
 98         DumpTrackInfo();                       << 
 99         G4cerr << ee_banner << G4endl;         << 
100         G4RunManager::GetRunManager()->AbortRu << 
101       }                                        << 
102       abortionForCoreDump = false;             << 
103       break;                                   << 
104     case EventMustBeAborted:                   << 
105       if (aps == G4State_EventProc) {          << 
106         G4cerr << es_banner << message.str() < << 
107         DumpTrackInfo();                       << 
108         G4cerr << ee_banner << G4endl;         << 
109         G4RunManager::GetRunManager()->AbortEv << 
110       }                                        << 
111       abortionForCoreDump = false;             << 
112       break;                                   << 
113     case JustWarning:                          << 
114       G4cout << ws_banner << message.str() <<  << 
115              << G4endl;                        << 
116       abortionForCoreDump = false;             << 
117       break;                                   << 
118     default:                                   << 
119       abortionForCoreDump = false;             << 
120       break;                                   << 
121   }                                            << 
122   return abortionForCoreDump;                  << 
123 }                                                  60 }
124                                                    61 
125 // ------------------------------------------- <<  62 G4int G4ExceptionHandler::operator==(const G4ExceptionHandler &right) const
126 void G4ExceptionHandler::DumpTrackInfo()       << 
127 {                                                  63 {
128   const G4Track* theTrack = nullptr;           <<  64    return (this == &right);
129   const G4Step* theStep = nullptr;             <<  65 }
130   if (G4StateManager::GetStateManager()->GetCu << 
131     G4SteppingManager* steppingMgr =           << 
132       G4RunManagerKernel::GetRunManagerKernel( << 
133     theTrack = steppingMgr->GetfTrack();       << 
134     theStep = steppingMgr->GetfStep();         << 
135   }                                            << 
136                                                    66 
137   if (theTrack == nullptr) {                   <<  67 G4int G4ExceptionHandler::operator!=(const G4ExceptionHandler &right) const
138     G4cerr << " **** Track information is not  <<  68 {
139   }                                            <<  69    return (this != &right);
140   else {                                       <<  70 }
141     G4cerr << "G4Track (" << theTrack << ") -  << 
142            << ", parent ID = " << theTrack->Ge << 
143     G4cerr << " Particle type : " << theTrack- << 
144     if (theTrack->GetCreatorProcess() != nullp << 
145       G4cerr << " - creator process : " << the << 
146              << ", creator model : " << theTra << 
147     }                                          << 
148     else {                                     << 
149       G4cerr << " - creator process : not avai << 
150     }                                          << 
151     G4cerr << " Kinetic energy : " << G4BestUn << 
152            << " - Momentum direction : " << th << 
153   }                                            << 
154                                                    71 
155   if (theStep == nullptr) {                    <<  72 G4bool G4ExceptionHandler::Notify(const char* originOfException,
156     G4cerr << " **** Step information is not a <<  73                         const char* exceptionCode,
157   }                                            <<  74                         G4ExceptionSeverity severity,
158   else {                                       <<  75                         const char* description)
159     G4cerr << " Step length : " << G4BestUnit( <<  76 {
160            << " - total energy deposit : " <<  <<  77   static const G4String es_banner
161            << G4endl;                          <<  78     = "\n-------- EEEE ------- G4Exception-START -------- EEEE -------\n";
162     G4cerr << " Pre-step point : " << theStep- <<  79   static const G4String ee_banner
163     G4cerr << " - Physical volume : ";         <<  80     = "\n-------- EEEE -------- G4Exception-END --------- EEEE -------\n";
164     if (theStep->GetPreStepPoint()->GetPhysica <<  81   static const G4String ws_banner
165       G4cerr << theStep->GetPreStepPoint()->Ge <<  82     = "\n-------- WWWW ------- G4Exception-START -------- WWWW -------\n";
166       if (theStep->GetPreStepPoint()->GetMater <<  83   static const G4String we_banner
167         G4cerr << " (" << theStep->GetPreStepP <<  84     = "\n-------- WWWW -------- G4Exception-END --------- WWWW -------\n";
168       }                                        <<  85   std::ostringstream message;
169       else {                                   <<  86   message << "*** G4Exception : " << exceptionCode << G4endl
170         G4cerr << " (material not available)"; <<  87           << "      issued by : " << originOfException << G4endl
171       }                                        <<  88           << description << G4endl;
172     }                                          <<  89   G4bool abortionForCoreDump = false;
173     else {                                     <<  90   G4ApplicationState aps = G4StateManager::GetStateManager()->GetCurrentState();
174       G4cerr << "not available";               <<  91   switch(severity)
175     }                                          <<  92   {
176     G4cerr << G4endl;                          <<  93    case FatalException:
177     if (theStep->GetPreStepPoint()->GetProcess <<  94     G4cerr << es_banner << message.str() << "*** Fatal Exception *** core dump ***"
178       G4cerr << " - defined by : "             <<  95            << ee_banner << G4endl;
179              << theStep->GetPreStepPoint()->Ge <<  96     abortionForCoreDump = true;
180              << " - step status : " << theStep <<  97     break;
181     }                                          <<  98    case FatalErrorInArgument:
182     else {                                     <<  99     G4cerr << es_banner << message.str() << "*** Fatal Error In Argument *** core dump ***"
183       G4cerr << " - defined by : not available << 100            << ee_banner << G4endl;
184     }                                          << 101     abortionForCoreDump = true;
185     G4cerr << " Post-step point : " << theStep << 102     break;
186     G4cerr << " - Physical volume : ";         << 103    case RunMustBeAborted:
187     if (theStep->GetPostStepPoint()->GetPhysic << 104     if(aps==G4State_GeomClosed || aps==G4State_EventProc)
188       G4cerr << theStep->GetPostStepPoint()->G << 105     {
189       if (theStep->GetPostStepPoint()->GetMate << 106       G4cerr << es_banner << message.str() << "*** Run Must Be Aborted ***"
190         G4cerr << " (" << theStep->GetPostStep << 107              << ee_banner << G4endl;
191       }                                        << 108       G4RunManager::GetRunManager()->AbortRun(false);
192       else {                                   << 109     }
193         G4cerr << " (material not available)"; << 110     abortionForCoreDump = false;
194       }                                        << 111     break;
195     }                                          << 112    case EventMustBeAborted:
196     else {                                     << 113     if(aps==G4State_EventProc)
197       G4cerr << "not available";               << 114     {
198     }                                          << 115       G4cerr << es_banner << message.str() << "*** Event Must Be Aborted ***"
199     G4cerr << G4endl;                          << 116              << ee_banner << G4endl;
200     if (theStep->GetPostStepPoint()->GetProces << 117       G4RunManager::GetRunManager()->AbortEvent();
201       G4cerr << " - defined by : "             << 118     }
202              << theStep->GetPostStepPoint()->G << 119     abortionForCoreDump = false;
203              << " - step status : " << theStep << 120     break;
204     }                                          << 121    default:
205     else {                                     << 122     G4cout << ws_banner << message.str() << "*** This is just a warning message. ***"
206       G4cerr << " - defined by : not available << 123            << we_banner << G4endl;
207     }                                          << 124     abortionForCoreDump = false;
208     G4cerr << " *** Note: Step information mig << 125     break;
209   }                                               126   }
                                                   >> 127   return abortionForCoreDump;
210 }                                                 128 }
211                                                   129