Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/scoring/src/G4ParallelWorldProcess.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 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/scoring/src/G4ParallelWorldProcess.cc (Version 11.3.0) and /processes/scoring/src/G4ParallelWorldProcess.cc (Version 11.0.p2)


  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                                                    29 
                                                   >>  30 #include "G4ios.hh"
 30 #include "G4ParallelWorldProcess.hh"               31 #include "G4ParallelWorldProcess.hh"
 31                                                << 
 32 #include "G4FieldTrackUpdator.hh"              << 
 33 #include "G4Material.hh"                       << 
 34 #include "G4Navigator.hh"                      << 
 35 #include "G4ParallelWorldProcessStore.hh"          32 #include "G4ParallelWorldProcessStore.hh"
                                                   >>  33 #include "G4Step.hh"
                                                   >>  34 #include "G4StepPoint.hh"
                                                   >>  35 #include "G4Navigator.hh"
                                                   >>  36 #include "G4VTouchable.hh"
                                                   >>  37 #include "G4VPhysicalVolume.hh"
 36 #include "G4ParticleChange.hh"                     38 #include "G4ParticleChange.hh"
 37 #include "G4PathFinder.hh"                         39 #include "G4PathFinder.hh"
                                                   >>  40 #include "G4TransportationManager.hh"
                                                   >>  41 #include "G4ParticleChange.hh"
                                                   >>  42 #include "G4StepPoint.hh"
                                                   >>  43 #include "G4FieldTrackUpdator.hh"
                                                   >>  44 #include "G4Material.hh"
 38 #include "G4ProductionCuts.hh"                     45 #include "G4ProductionCuts.hh"
 39 #include "G4ProductionCutsTable.hh"                46 #include "G4ProductionCutsTable.hh"
 40 #include "G4SDManager.hh"                      << 
 41 #include "G4Step.hh"                           << 
 42 #include "G4StepPoint.hh"                      << 
 43 #include "G4TransportationManager.hh"          << 
 44 #include "G4TransportationProcessType.hh"          47 #include "G4TransportationProcessType.hh"
 45 #include "G4VPhysicalVolume.hh"                << 
 46 #include "G4VSensitiveDetector.hh"             << 
 47 #include "G4VTouchable.hh"                     << 
 48 #include "G4ios.hh"                            << 
 49                                                    48 
 50 G4ThreadLocal G4Step* G4ParallelWorldProcess:: <<  49 #include "G4SDManager.hh"
 51 G4ThreadLocal G4int G4ParallelWorldProcess::nP <<  50 #include "G4VSensitiveDetector.hh"
 52 G4ThreadLocal G4int G4ParallelWorldProcess::fN << 
 53                                                    51 
                                                   >>  52 G4ThreadLocal G4Step* G4ParallelWorldProcess::fpHyperStep = 0;
                                                   >>  53 G4ThreadLocal G4int   G4ParallelWorldProcess::nParallelWorlds = 0;
                                                   >>  54 G4ThreadLocal G4int   G4ParallelWorldProcess::fNavIDHyp = 0;
 54 const G4Step* G4ParallelWorldProcess::GetHyper     55 const G4Step* G4ParallelWorldProcess::GetHyperStep()
 55 {                                              <<  56 { return fpHyperStep; }
 56   return fpHyperStep;                          << 
 57 }                                              << 
 58                                                << 
 59 G4int G4ParallelWorldProcess::GetHypNavigatorI     57 G4int G4ParallelWorldProcess::GetHypNavigatorID()
 60 {                                              <<  58 { return fNavIDHyp; }
 61   return fNavIDHyp;                            << 
 62 }                                              << 
 63                                                    59 
 64 G4ParallelWorldProcess::G4ParallelWorldProcess <<  60 G4ParallelWorldProcess::
 65   : G4VProcess(processName, theType), fFieldTr <<  61 G4ParallelWorldProcess(const G4String& processName,G4ProcessType theType)
                                                   >>  62 :G4VProcess(processName,theType),fGhostWorld(nullptr),fGhostNavigator(nullptr),
                                                   >>  63  fNavigatorID(-1),fFieldTrack('0'),fGhostSafety(0.),fOnBoundary(false),
                                                   >>  64  layeredMaterialFlag(false)
 66 {                                                  65 {
 67   SetProcessSubType(PARALLEL_WORLD_PROCESS);       66   SetProcessSubType(PARALLEL_WORLD_PROCESS);
 68   if (fpHyperStep == nullptr) fpHyperStep = ne <<  67   if(!fpHyperStep) fpHyperStep = new G4Step();
 69   iParallelWorld = ++nParallelWorlds;              68   iParallelWorld = ++nParallelWorlds;
 70                                                    69 
 71   pParticleChange = &aDummyParticleChange;         70   pParticleChange = &aDummyParticleChange;
 72                                                    71 
 73   fGhostStep = new G4Step();                       72   fGhostStep = new G4Step();
 74   fGhostPreStepPoint = fGhostStep->GetPreStepP     73   fGhostPreStepPoint = fGhostStep->GetPreStepPoint();
 75   fGhostPostStepPoint = fGhostStep->GetPostSte     74   fGhostPostStepPoint = fGhostStep->GetPostStepPoint();
 76                                                    75 
 77   fTransportationManager = G4TransportationMan     76   fTransportationManager = G4TransportationManager::GetTransportationManager();
 78   fTransportationManager->GetNavigatorForTrack     77   fTransportationManager->GetNavigatorForTracking()->SetPushVerbosity(false);
 79   fPathFinder = G4PathFinder::GetInstance();       78   fPathFinder = G4PathFinder::GetInstance();
 80                                                    79 
 81   fGhostWorldName = "** NotDefined **";            80   fGhostWorldName = "** NotDefined **";
 82   G4ParallelWorldProcessStore::GetInstance()-> <<  81   G4ParallelWorldProcessStore::GetInstance()->SetParallelWorld(this,processName);
 83                                                    82 
 84   if (verboseLevel > 0) {                      <<  83   if (verboseLevel>0)
                                                   >>  84   {
 85     G4cout << GetProcessName() << " is created     85     G4cout << GetProcessName() << " is created " << G4endl;
 86   }                                                86   }
 87 }                                                  87 }
 88                                                    88 
 89 G4ParallelWorldProcess::~G4ParallelWorldProces     89 G4ParallelWorldProcess::~G4ParallelWorldProcess()
 90 {                                                  90 {
 91   delete fGhostStep;                               91   delete fGhostStep;
 92   nParallelWorlds--;                               92   nParallelWorlds--;
 93   if (nParallelWorlds == 0) {                  <<  93   if(nParallelWorlds==0)
                                                   >>  94   {
 94     delete fpHyperStep;                            95     delete fpHyperStep;
 95     fpHyperStep = nullptr;                     <<  96     fpHyperStep = 0;
 96   }                                                97   }
 97 }                                                  98 }
 98                                                    99 
 99 void G4ParallelWorldProcess::SetParallelWorld( << 100 void G4ParallelWorldProcess::
                                                   >> 101 SetParallelWorld(G4String parallelWorldName)
100 {                                                 102 {
101   fGhostWorldName = parallelWorldName;            103   fGhostWorldName = parallelWorldName;
102   fGhostWorld = fTransportationManager->GetPar    104   fGhostWorld = fTransportationManager->GetParallelWorld(fGhostWorldName);
103   fGhostNavigator = fTransportationManager->Ge    105   fGhostNavigator = fTransportationManager->GetNavigator(fGhostWorld);
104   fGhostNavigator->SetPushVerbosity(false);       106   fGhostNavigator->SetPushVerbosity(false);
105 }                                                 107 }
106                                                   108 
107 void G4ParallelWorldProcess::SetParallelWorld( << 109 void G4ParallelWorldProcess::
                                                   >> 110 SetParallelWorld(G4VPhysicalVolume* parallelWorld)
108 {                                                 111 {
109   fGhostWorldName = parallelWorld->GetName();     112   fGhostWorldName = parallelWorld->GetName();
110   fGhostWorld = parallelWorld;                    113   fGhostWorld = parallelWorld;
111   fGhostNavigator = fTransportationManager->Ge    114   fGhostNavigator = fTransportationManager->GetNavigator(fGhostWorld);
112   fGhostNavigator->SetPushVerbosity(false);       115   fGhostNavigator->SetPushVerbosity(false);
113 }                                                 116 }
114                                                   117 
115 void G4ParallelWorldProcess::StartTracking(G4T    118 void G4ParallelWorldProcess::StartTracking(G4Track* trk)
116 {                                                 119 {
117   if (fGhostNavigator != nullptr) {            << 120   if(fGhostNavigator)
118     fNavigatorID = fTransportationManager->Act << 121   { fNavigatorID = fTransportationManager->ActivateNavigator(fGhostNavigator); }
119   }                                            << 122   else
120   else {                                       << 123   {
121     G4Exception(                               << 124     G4Exception("G4ParallelWorldProcess::StartTracking",
122       "G4ParallelWorldProcess::StartTracking", << 125        "ProcParaWorld000",FatalException,
123       "G4ParallelWorldProcess is used for trac << 126        "G4ParallelWorldProcess is used for tracking without having a parallel world assigned");
124   }                                               127   }
125   fPathFinder->PrepareNewTrack(trk->GetPositio << 128   fPathFinder->PrepareNewTrack(trk->GetPosition(),trk->GetMomentumDirection());
126                                                   129 
127   fOldGhostTouchable = fPathFinder->CreateTouc    130   fOldGhostTouchable = fPathFinder->CreateTouchableHandle(fNavigatorID);
128   fGhostPreStepPoint->SetTouchableHandle(fOldG    131   fGhostPreStepPoint->SetTouchableHandle(fOldGhostTouchable);
129   fNewGhostTouchable = fOldGhostTouchable;        132   fNewGhostTouchable = fOldGhostTouchable;
130   fGhostPostStepPoint->SetTouchableHandle(fNew    133   fGhostPostStepPoint->SetTouchableHandle(fNewGhostTouchable);
131                                                   134 
132   fGhostSafety = -1.;                             135   fGhostSafety = -1.;
133   fOnBoundary = false;                            136   fOnBoundary = false;
134   fGhostPreStepPoint->SetStepStatus(fUndefined    137   fGhostPreStepPoint->SetStepStatus(fUndefined);
135   fGhostPostStepPoint->SetStepStatus(fUndefine    138   fGhostPostStepPoint->SetStepStatus(fUndefined);
136                                                   139 
                                                   >> 140 //  G4VPhysicalVolume* thePhys = fNewGhostTouchable->GetVolume();
                                                   >> 141 //  if(thePhys)
                                                   >> 142 //  {
                                                   >> 143 //    G4Material* ghostMaterial = thePhys->GetLogicalVolume()->GetMaterial();
                                                   >> 144 //    if(ghostMaterial)
                                                   >> 145 //    { G4cout << " --- Material : " << ghostMaterial->GetName() << G4endl; }
                                                   >> 146 //  }
                                                   >> 147 
137   *(fpHyperStep->GetPostStepPoint()) = *(trk->    148   *(fpHyperStep->GetPostStepPoint()) = *(trk->GetStep()->GetPostStepPoint());
138   if (layeredMaterialFlag) {                   << 149   if(layeredMaterialFlag)
                                                   >> 150   {
139     G4StepPoint* realWorldPostStepPoint = trk-    151     G4StepPoint* realWorldPostStepPoint = trk->GetStep()->GetPostStepPoint();
140     SwitchMaterial(realWorldPostStepPoint);       152     SwitchMaterial(realWorldPostStepPoint);
141     G4StepPoint* realWorldPreStepPoint = trk-> << 153     G4StepPoint *realWorldPreStepPoint = trk->GetStep()->GetPreStepPoint();
142     SwitchMaterial(realWorldPreStepPoint);        154     SwitchMaterial(realWorldPreStepPoint);
143     G4double velocity = trk->CalculateVelocity    155     G4double velocity = trk->CalculateVelocity();
144     realWorldPostStepPoint->SetVelocity(veloci    156     realWorldPostStepPoint->SetVelocity(velocity);
145     realWorldPreStepPoint->SetVelocity(velocit    157     realWorldPreStepPoint->SetVelocity(velocity);
146     trk->SetVelocity(velocity);                   158     trk->SetVelocity(velocity);
147   }                                               159   }
148   *(fpHyperStep->GetPreStepPoint()) = *(fpHype    160   *(fpHyperStep->GetPreStepPoint()) = *(fpHyperStep->GetPostStepPoint());
149 }                                                 161 }
150                                                   162 
151 G4double G4ParallelWorldProcess::AtRestGetPhys << 163 G4double 
152                                                << 164 G4ParallelWorldProcess::AtRestGetPhysicalInteractionLength(
153 {                                              << 165          const G4Track& /*track*/, 
154   //++++++++++++++++++++++++++++++++++++++++++ << 166          G4ForceCondition* condition)
155   // At Rest must be registered ONLY for the p << 167 {
156   // process(es).                              << 168 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
157   //++++++++++++++++++++++++++++++++++++++++++ << 169 // At Rest must be registered ONLY for the particle which has other At Rest
                                                   >> 170 // process(es).
                                                   >> 171 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
158   *condition = Forced;                            172   *condition = Forced;
159   return DBL_MAX;                                 173   return DBL_MAX;
160 }                                                 174 }
161                                                   175 
162 G4VParticleChange* G4ParallelWorldProcess::AtR << 176 G4VParticleChange* G4ParallelWorldProcess::AtRestDoIt(
163 {                                              << 177      const G4Track& track,
164   //++++++++++++++++++++++++++++++++++++++++++ << 178      const G4Step& step)
165   // At Rest must be registered ONLY for the p << 179 { 
166   // process(es).                              << 180 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
167   //++++++++++++++++++++++++++++++++++++++++++ << 181 // At Rest must be registered ONLY for the particle which has other At Rest
                                                   >> 182 // process(es).
                                                   >> 183 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
168   fOldGhostTouchable = fGhostPostStepPoint->Ge    184   fOldGhostTouchable = fGhostPostStepPoint->GetTouchableHandle();
169   G4VSensitiveDetector* aSD = nullptr;         << 185   G4VSensitiveDetector* aSD = 0;
170   if (fOldGhostTouchable->GetVolume() != nullp << 186   if(fOldGhostTouchable->GetVolume())
171     aSD = fOldGhostTouchable->GetVolume()->Get << 187   { aSD = fOldGhostTouchable->GetVolume()->GetLogicalVolume()->GetSensitiveDetector(); }
172   }                                            << 
173   fOnBoundary = false;                            188   fOnBoundary = false;
174   if (aSD != nullptr) {                        << 189   if(aSD)
                                                   >> 190   {
175     CopyStep(step);                               191     CopyStep(step);
176     fGhostPreStepPoint->SetSensitiveDetector(a    192     fGhostPreStepPoint->SetSensitiveDetector(aSD);
177                                                   193 
178     fNewGhostTouchable = fOldGhostTouchable;      194     fNewGhostTouchable = fOldGhostTouchable;
179                                                << 195   
180     fGhostPreStepPoint->SetTouchableHandle(fOl    196     fGhostPreStepPoint->SetTouchableHandle(fOldGhostTouchable);
181     fGhostPostStepPoint->SetTouchableHandle(fN    197     fGhostPostStepPoint->SetTouchableHandle(fNewGhostTouchable);
182     if (fNewGhostTouchable->GetVolume() != nul << 198     if(fNewGhostTouchable->GetVolume())
                                                   >> 199     {
183       fGhostPostStepPoint->SetSensitiveDetecto    200       fGhostPostStepPoint->SetSensitiveDetector(
184         fNewGhostTouchable->GetVolume()->GetLo    201         fNewGhostTouchable->GetVolume()->GetLogicalVolume()->GetSensitiveDetector());
185     }                                             202     }
186     else {                                     << 203     else
187       fGhostPostStepPoint->SetSensitiveDetecto << 204     { fGhostPostStepPoint->SetSensitiveDetector(0); }
188     }                                          << 
189                                                   205 
190     aSD->Hit(fGhostStep);                         206     aSD->Hit(fGhostStep);
191   }                                               207   }
192                                                   208 
193   pParticleChange->Initialize(track);             209   pParticleChange->Initialize(track);
194   return pParticleChange;                         210   return pParticleChange;
195 }                                                 211 }
196                                                   212 
197 G4double G4ParallelWorldProcess::PostStepGetPh << 213 G4double 
198                                                << 214 G4ParallelWorldProcess::PostStepGetPhysicalInteractionLength(
199                                                << 215          const G4Track& /*track*/, 
                                                   >> 216          G4double   /*previousStepSize*/, 
                                                   >> 217          G4ForceCondition* condition)
200 {                                                 218 {
201   *condition = StronglyForced;                    219   *condition = StronglyForced;
202   return DBL_MAX;                                 220   return DBL_MAX;
203 }                                                 221 }
204                                                   222 
205 G4VParticleChange* G4ParallelWorldProcess::Pos << 223 G4VParticleChange* G4ParallelWorldProcess::PostStepDoIt(
206 {                                              << 224      const G4Track& track,
                                                   >> 225      const G4Step& step)
                                                   >> 226 { 
207   fOldGhostTouchable = fGhostPostStepPoint->Ge    227   fOldGhostTouchable = fGhostPostStepPoint->GetTouchableHandle();
208   G4VSensitiveDetector* aSD = nullptr;         << 228   G4VSensitiveDetector* aSD = 0;
209   if (fOldGhostTouchable->GetVolume() != nullp << 229   if(fOldGhostTouchable->GetVolume())
210     aSD = fOldGhostTouchable->GetVolume()->Get << 230   { aSD = fOldGhostTouchable->GetVolume()->GetLogicalVolume()->GetSensitiveDetector(); }
211   }                                            << 
212   CopyStep(step);                                 231   CopyStep(step);
213   fGhostPreStepPoint->SetSensitiveDetector(aSD    232   fGhostPreStepPoint->SetSensitiveDetector(aSD);
214                                                   233 
215   if (fOnBoundary) {                           << 234   if(fOnBoundary)
                                                   >> 235   {
216     fNewGhostTouchable = fPathFinder->CreateTo    236     fNewGhostTouchable = fPathFinder->CreateTouchableHandle(fNavigatorID);
217   }                                               237   }
218   else {                                       << 238   else
                                                   >> 239   {
219     fNewGhostTouchable = fOldGhostTouchable;      240     fNewGhostTouchable = fOldGhostTouchable;
220   }                                               241   }
221                                                << 242     
222   fGhostPreStepPoint->SetTouchableHandle(fOldG    243   fGhostPreStepPoint->SetTouchableHandle(fOldGhostTouchable);
223   fGhostPostStepPoint->SetTouchableHandle(fNew    244   fGhostPostStepPoint->SetTouchableHandle(fNewGhostTouchable);
224                                                   245 
225   if (fNewGhostTouchable->GetVolume() != nullp << 246   if(fNewGhostTouchable->GetVolume())
                                                   >> 247   {
226     fGhostPostStepPoint->SetSensitiveDetector(    248     fGhostPostStepPoint->SetSensitiveDetector(
227       fNewGhostTouchable->GetVolume()->GetLogi    249       fNewGhostTouchable->GetVolume()->GetLogicalVolume()->GetSensitiveDetector());
228   }                                               250   }
229   else {                                       << 251   else
230     fGhostPostStepPoint->SetSensitiveDetector( << 252   { fGhostPostStepPoint->SetSensitiveDetector(0); }
231   }                                            << 
232                                                   253 
233   G4VSensitiveDetector* sd = fGhostPreStepPoin    254   G4VSensitiveDetector* sd = fGhostPreStepPoint->GetSensitiveDetector();
234   if (sd != nullptr) {                         << 255   if(sd)
                                                   >> 256   {
235     sd->Hit(fGhostStep);                          257     sd->Hit(fGhostStep);
236   }                                               258   }
237                                                   259 
238   pParticleChange->Initialize(track);          << 260   pParticleChange->Initialize(track); 
239   if (layeredMaterialFlag) {                   << 261   if(layeredMaterialFlag)
240     G4StepPoint* realWorldPostStepPoint = ((G4 << 262   {
                                                   >> 263     G4StepPoint* realWorldPostStepPoint =
                                                   >> 264      ((G4Step*)(track.GetStep()))->GetPostStepPoint();
241     SwitchMaterial(realWorldPostStepPoint);       265     SwitchMaterial(realWorldPostStepPoint);
242   }                                               266   }
243   return pParticleChange;                         267   return pParticleChange;
244 }                                                 268 }
245                                                   269 
246 G4double G4ParallelWorldProcess::AlongStepGetP << 270 G4double G4ParallelWorldProcess::AlongStepGetPhysicalInteractionLength(
247                                                << 271             const G4Track& track, G4double  previousStepSize, G4double  currentMinimumStep,
248                                                << 272             G4double& proposedSafety, G4GPILSelection* selection)
249                                                << 273 {
250                                                << 274   static G4ThreadLocal G4FieldTrack *endTrack_G4MT_TLS_ = 0 ; if (!endTrack_G4MT_TLS_) endTrack_G4MT_TLS_ = new  G4FieldTrack ('0') ;  G4FieldTrack &endTrack = *endTrack_G4MT_TLS_;
251 {                                              << 275   //static ELimited eLimited;
252   static G4ThreadLocal G4FieldTrack* endTrack_ << 
253   if (endTrack_G4MT_TLS_ == nullptr) endTrack_ << 
254   G4FieldTrack& endTrack = *endTrack_G4MT_TLS_ << 
255   // static ELimited eLimited;                 << 
256   ELimited eLimited;                              276   ELimited eLimited;
257   ELimited eLim = kUndefLimited;                  277   ELimited eLim = kUndefLimited;
258                                                << 278   
259   *selection = NotCandidateForSelection;          279   *selection = NotCandidateForSelection;
260   G4double returnedStep = DBL_MAX;                280   G4double returnedStep = DBL_MAX;
261                                                   281 
262   if (previousStepSize > 0.) {                 << 282   if (previousStepSize > 0.)
263     fGhostSafety -= previousStepSize;          << 283   { fGhostSafety -= previousStepSize; }
264   }                                            << 
265   if (fGhostSafety < 0.) fGhostSafety = 0.0;      284   if (fGhostSafety < 0.) fGhostSafety = 0.0;
266                                                << 285       
267   if (currentMinimumStep <= fGhostSafety && cu << 286   if (currentMinimumStep <= fGhostSafety && currentMinimumStep > 0.)
                                                   >> 287   {
268     // I have no chance to limit                  288     // I have no chance to limit
269     returnedStep = currentMinimumStep;            289     returnedStep = currentMinimumStep;
270     fOnBoundary = false;                          290     fOnBoundary = false;
271     proposedSafety = fGhostSafety - currentMin    291     proposedSafety = fGhostSafety - currentMinimumStep;
272     eLim = kDoNot;                                292     eLim = kDoNot;
273   }                                               293   }
274   else {                                       << 294   else 
275     G4FieldTrackUpdator::Update(&fFieldTrack,  << 295   {
276                                                << 296     G4FieldTrackUpdator::Update(&fFieldTrack,&track);
277 #ifdef G4DEBUG_PARALLEL_WORLD_PROCESS          << 297 
278     if (verboseLevel > 0) {                    << 298 #ifdef G4DEBUG_PARALLEL_WORLD_PROCESS    
279       int localVerb = verboseLevel - 1;        << 299     if( verboseLevel > 0 ){
280                                                << 300        int localVerb = verboseLevel-1; 
281       if (localVerb == 1) {                    << 301 
282         G4cout << " Pll Wrl  proc::AlongStepGP << 302        if( localVerb == 1 ) { 
283       }                                        << 303           G4cout << " Pll Wrl  proc::AlongStepGPIL " << this->GetProcessName() << G4endl;
284       else if (localVerb > 1) {                << 304        }else if( localVerb > 1 ) { 
285         G4cout << "--------------------------- << 305           G4cout << "----------------------------------------------" << G4endl;
286         G4cout << " ParallelWorldProcess: fiel << 306           G4cout << " ParallelWorldProcess: field Track set to : " << G4endl;
287         G4cout << "--------------------------- << 307           G4cout << "----------------------------------------------" << G4endl;
288         G4cout << fFieldTrack << G4endl;       << 308           G4cout << fFieldTrack << G4endl;
289         G4cout << "--------------------------- << 309           G4cout << "----------------------------------------------" << G4endl;
290       }                                        << 310        }
291     }                                             311     }
292 #endif                                            312 #endif
293                                                << 313     
294     returnedStep = fPathFinder->ComputeStep(fF << 314     returnedStep
295                                             tr << 315       = fPathFinder->ComputeStep(fFieldTrack,currentMinimumStep,fNavigatorID,
296                                             en << 316                      track.GetCurrentStepNumber(),fGhostSafety,eLimited,
297     if (eLimited == kDoNot) {                  << 317                      endTrack,track.GetVolume());
                                                   >> 318     if(eLimited == kDoNot)
                                                   >> 319     {
298       fOnBoundary = false;                        320       fOnBoundary = false;
299       fGhostSafety = fGhostNavigator->ComputeS << 321       fGhostSafety = fGhostNavigator->ComputeSafety(endTrack.GetPosition());      
300     }                                             322     }
301     else {                                     << 323     else
                                                   >> 324     {
302       fOnBoundary = true;                         325       fOnBoundary = true;
303       // fGhostSafetyEnd = 0.0;    // At end-p    326       // fGhostSafetyEnd = 0.0;    // At end-point of expected step only
304     }                                             327     }
305     proposedSafety = fGhostSafety;                328     proposedSafety = fGhostSafety;
306     if (eLimited == kUnique || eLimited == kSh << 329     if(eLimited == kUnique || eLimited == kSharedOther) {
307       *selection = CandidateForSelection;      << 330        *selection = CandidateForSelection;
308     }                                             331     }
309     else if (eLimited == kSharedTransport) {   << 332     else if (eLimited == kSharedTransport) { 
310       returnedStep *= (1.0 + 1.0e-9);          << 333        returnedStep *= (1.0 + 1.0e-9);  
311     }                                             334     }
312     eLim = eLimited;                              335     eLim = eLimited;
313   }                                               336   }
314                                                   337 
315   if (iParallelWorld == nParallelWorlds) fNavI << 338   if(iParallelWorld==nParallelWorlds) fNavIDHyp = 0;
316   if (eLim == kUnique || eLim == kSharedOther) << 339   if(eLim == kUnique || eLim == kSharedOther) fNavIDHyp = fNavigatorID;
317   return returnedStep;                            340   return returnedStep;
318 }                                                 341 }
319                                                   342 
320 G4VParticleChange* G4ParallelWorldProcess::Alo << 343 G4VParticleChange* G4ParallelWorldProcess::AlongStepDoIt(
                                                   >> 344     const G4Track& track, const G4Step& )
321 {                                                 345 {
322   pParticleChange->Initialize(track);             346   pParticleChange->Initialize(track);
323   return pParticleChange;                      << 347   return pParticleChange; 
324 }                                                 348 }
325                                                   349 
326 void G4ParallelWorldProcess::CopyStep(const G4 << 350 void G4ParallelWorldProcess::CopyStep(const G4Step & step)
327 {                                                 351 {
328   G4StepStatus prevStat = fGhostPostStepPoint-    352   G4StepStatus prevStat = fGhostPostStepPoint->GetStepStatus();
329                                                   353 
330   fGhostStep->SetTrack(step.GetTrack());          354   fGhostStep->SetTrack(step.GetTrack());
331   fGhostStep->SetStepLength(step.GetStepLength    355   fGhostStep->SetStepLength(step.GetStepLength());
332   fGhostStep->SetTotalEnergyDeposit(step.GetTo    356   fGhostStep->SetTotalEnergyDeposit(step.GetTotalEnergyDeposit());
333   fGhostStep->SetNonIonizingEnergyDeposit(step    357   fGhostStep->SetNonIonizingEnergyDeposit(step.GetNonIonizingEnergyDeposit());
334   fGhostStep->SetControlFlag(step.GetControlFl    358   fGhostStep->SetControlFlag(step.GetControlFlag());
335   fGhostStep->SetSecondary((const_cast<G4Step&    359   fGhostStep->SetSecondary((const_cast<G4Step&>(step)).GetfSecondary());
336                                                   360 
337   *fGhostPreStepPoint = *(step.GetPreStepPoint    361   *fGhostPreStepPoint = *(step.GetPreStepPoint());
338   *fGhostPostStepPoint = *(step.GetPostStepPoi    362   *fGhostPostStepPoint = *(step.GetPostStepPoint());
339                                                   363 
340   fGhostPreStepPoint->SetStepStatus(prevStat);    364   fGhostPreStepPoint->SetStepStatus(prevStat);
341   if (fOnBoundary) {                           << 365   if(fOnBoundary)
342     fGhostPostStepPoint->SetStepStatus(fGeomBo << 366   { fGhostPostStepPoint->SetStepStatus(fGeomBoundary); }
343   }                                            << 367   else if(fGhostPostStepPoint->GetStepStatus()==fGeomBoundary)
344   else if (fGhostPostStepPoint->GetStepStatus( << 368   { fGhostPostStepPoint->SetStepStatus(fPostStepDoItProc); }
345     fGhostPostStepPoint->SetStepStatus(fPostSt << 
346   }                                            << 
347                                                   369 
348   if (iParallelWorld == 1) {                   << 370   if(iParallelWorld==1)
                                                   >> 371   {
349     G4StepStatus prevStatHyp = fpHyperStep->Ge    372     G4StepStatus prevStatHyp = fpHyperStep->GetPostStepPoint()->GetStepStatus();
350                                                   373 
351     fpHyperStep->SetTrack(step.GetTrack());       374     fpHyperStep->SetTrack(step.GetTrack());
352     fpHyperStep->SetStepLength(step.GetStepLen    375     fpHyperStep->SetStepLength(step.GetStepLength());
353     fpHyperStep->SetTotalEnergyDeposit(step.Ge    376     fpHyperStep->SetTotalEnergyDeposit(step.GetTotalEnergyDeposit());
354     fpHyperStep->SetNonIonizingEnergyDeposit(s    377     fpHyperStep->SetNonIonizingEnergyDeposit(step.GetNonIonizingEnergyDeposit());
355     fpHyperStep->SetControlFlag(step.GetContro    378     fpHyperStep->SetControlFlag(step.GetControlFlag());
356                                                   379 
357     *(fpHyperStep->GetPreStepPoint()) = *(fpHy    380     *(fpHyperStep->GetPreStepPoint()) = *(fpHyperStep->GetPostStepPoint());
358     *(fpHyperStep->GetPostStepPoint()) = *(ste    381     *(fpHyperStep->GetPostStepPoint()) = *(step.GetPostStepPoint());
359                                                << 382   
360     fpHyperStep->GetPreStepPoint()->SetStepSta    383     fpHyperStep->GetPreStepPoint()->SetStepStatus(prevStatHyp);
361   }                                               384   }
362                                                   385 
363   if (fOnBoundary) {                           << 386   if(fOnBoundary)
364     fpHyperStep->GetPostStepPoint()->SetStepSt << 387   { fpHyperStep->GetPostStepPoint()->SetStepStatus(fGeomBoundary); }
365   }                                            << 
366 }                                                 388 }
367                                                   389 
368 void G4ParallelWorldProcess::SwitchMaterial(G4    390 void G4ParallelWorldProcess::SwitchMaterial(G4StepPoint* realWorldStepPoint)
369 {                                                 391 {
370   if (realWorldStepPoint->GetStepStatus() == f << 392   if(realWorldStepPoint->GetStepStatus()==fWorldBoundary) return;
371   G4VPhysicalVolume* thePhys = fNewGhostToucha    393   G4VPhysicalVolume* thePhys = fNewGhostTouchable->GetVolume();
372   if (thePhys != nullptr) {                    << 394   if(thePhys)
                                                   >> 395   {
373     G4Material* ghostMaterial = thePhys->GetLo    396     G4Material* ghostMaterial = thePhys->GetLogicalVolume()->GetMaterial();
374     if (ghostMaterial != nullptr) {            << 397     if(ghostMaterial)
                                                   >> 398     {
375       G4Region* ghostRegion = thePhys->GetLogi    399       G4Region* ghostRegion = thePhys->GetLogicalVolume()->GetRegion();
376       G4ProductionCuts* prodCuts = realWorldSt << 400       G4ProductionCuts* prodCuts =
377       if (ghostRegion != nullptr) {            << 401           realWorldStepPoint->GetMaterialCutsCouple()->GetProductionCuts();
                                                   >> 402       if(ghostRegion)
                                                   >> 403       {
378         G4ProductionCuts* ghostProdCuts = ghos    404         G4ProductionCuts* ghostProdCuts = ghostRegion->GetProductionCuts();
379         if (ghostProdCuts != nullptr) prodCuts << 405         if(ghostProdCuts) prodCuts = ghostProdCuts;
380       }                                           406       }
381       const G4MaterialCutsCouple* ghostMCCoupl    407       const G4MaterialCutsCouple* ghostMCCouple =
382         G4ProductionCutsTable::GetProductionCu << 408           G4ProductionCutsTable::GetProductionCutsTable()
383                                                << 409           ->GetMaterialCutsCouple(ghostMaterial,prodCuts);
384       if (ghostMCCouple != nullptr) {          << 410       if(ghostMCCouple)
                                                   >> 411       {
385         realWorldStepPoint->SetMaterial(ghostM    412         realWorldStepPoint->SetMaterial(ghostMaterial);
386         realWorldStepPoint->SetMaterialCutsCou    413         realWorldStepPoint->SetMaterialCutsCouple(ghostMCCouple);
387         *(fpHyperStep->GetPostStepPoint()) = *    414         *(fpHyperStep->GetPostStepPoint()) = *(fGhostPostStepPoint);
388         fpHyperStep->GetPostStepPoint()->SetMa    415         fpHyperStep->GetPostStepPoint()->SetMaterial(ghostMaterial);
389         fpHyperStep->GetPostStepPoint()->SetMa    416         fpHyperStep->GetPostStepPoint()->SetMaterialCutsCouple(ghostMCCouple);
390       }                                           417       }
391       else {                                   << 418       else
392         G4cout << "!!! MaterialCutsCouple is n << 419       {
393                << G4endl << "    Material in r << 420         G4cout << "!!! MaterialCutsCouple is not found for "
394                << realWorldStepPoint->GetMater << 421                << ghostMaterial->GetName() << "." << G4endl
                                                   >> 422                << "    Material in real world ("
                                                   >> 423                << realWorldStepPoint->GetMaterial()->GetName()
                                                   >> 424                << ") is used." << G4endl;
395       }                                           425       }
396     }                                             426     }
397   }                                               427   }
398 }                                                 428 }
399                                                   429 
400 G4bool G4ParallelWorldProcess::IsAtRestRequire    430 G4bool G4ParallelWorldProcess::IsAtRestRequired(G4ParticleDefinition* partDef)
401 {                                                 431 {
402   G4int pdgCode = partDef->GetPDGEncoding();      432   G4int pdgCode = partDef->GetPDGEncoding();
403   if (pdgCode == 0) {                          << 433   if(pdgCode==0)
                                                   >> 434   {
404     G4String partName = partDef->GetParticleNa    435     G4String partName = partDef->GetParticleName();
405     if (partName == "geantino") return false;  << 436     if(partName=="geantino") return false;
406     if (partName == "chargedgeantino") return  << 437     if(partName=="chargedgeantino") return false;
407   }                                               438   }
408   else {                                       << 439   else
409     if (pdgCode == 11 || pdgCode == 2212) retu << 440   {
                                                   >> 441     if(pdgCode==11 || pdgCode==2212) return false; // electrons and proton
410     pdgCode = std::abs(pdgCode);                  442     pdgCode = std::abs(pdgCode);
411     if (pdgCode == 22) return false;  // gamma << 443     if(pdgCode==22) return false; // gamma and optical photons
412     if (pdgCode == 12 || pdgCode == 14 || pdgC << 444     if(pdgCode==12 || pdgCode==14 || pdgCode==16) return false; // all neutronos
413   }                                               445   }
414   return true;                                    446   return true;
415 }                                                 447 }
                                                   >> 448 
416                                                   449