Geant4  10.00.p03
G4RunManagerKernel.cc
Go to the documentation of this file.
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 //
27 // $Id: G4RunManagerKernel.cc 84741 2014-10-20 10:22:35Z gcosmo $
28 //
29 //
30 
31 #include "G4RunManagerKernel.hh"
32 
33 #include <vector>
34 
35 #include "G4StateManager.hh"
36 #include "G4ApplicationState.hh"
37 #include "G4ExceptionHandler.hh"
38 #include "G4PrimaryTransformer.hh"
39 #include "G4GeometryManager.hh"
41 #include "G4VPhysicalVolume.hh"
42 #include "G4LogicalVolume.hh"
43 #include "G4VUserPhysicsList.hh"
44 
45 #include "G4ParticleTable.hh"
46 #include "G4Region.hh"
47 #include "G4RegionStore.hh"
48 #include "G4ProductionCuts.hh"
49 #include "G4ProductionCutsTable.hh"
50 #include "G4SDManager.hh"
51 #include "G4UImanager.hh"
52 #include "G4VVisManager.hh"
53 #include "G4UnitsTable.hh"
54 #include "G4Version.hh"
55 #include "G4ios.hh"
56 
57 #include "G4MTRunManager.hh"
58 #include "G4AllocatorList.hh"
59 
60 #include "G4AutoLock.hh"
61 
62 #ifdef G4FPE_DEBUG
63  #include "G4FPEDetection.hh"
64 #endif
65 
66 //The following lines are needed since G4VUserPhysicsList uses a #define theParticleIterator
67 #ifdef theParticleIterator
68 #undef theParticleIterator
69 #endif
70 
72 
74 { return fRunManagerKernel; }
75 
77 : physicsList(0),currentWorld(0),
78  geometryInitialized(false),physicsInitialized(false),
79  geometryToBeOptimized(true),
80  physicsNeedsToBeReBuilt(true),verboseLevel(0),
81  numberOfParallelWorld(0),geometryNeedsToBeClosed(true),
82  numberOfStaticAllocators(0)
83 {
84 #ifdef G4FPE_DEBUG
86 #endif
88  if(allocList) numberOfStaticAllocators = allocList->Size();
91  {
92  G4Exception("G4RunManagerKernel::G4RunManagerKernel()","Run0001",
93  FatalException,"More than one G4RunManagerKernel is constructed.");
94  }
95  fRunManagerKernel = this;
96 
98  if(particleTable->entries()>0)
99  {
100  // No particle should be registered beforehand
102  ED<<"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"<<G4endl;
103  ED<<" G4RunManagerKernel fatal exception"<<G4endl;
104  ED<<" -- Following particles have already been registered"<<G4endl;
105  ED<<" before G4RunManagerKernel is instantiated."<<G4endl;
106  for(int i=0;i<particleTable->entries();i++)
107  { ED<<" "<<particleTable->GetParticle(i)->GetParticleName()<<G4endl; }
108  ED<<"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"<<G4endl;
109  G4Exception("G4RunManagerKernel::G4RunManagerKernel()","Run0002",
110  FatalException,ED);
111  }
112 
113  // construction of Geant4 kernel classes
115 
116  defaultRegion = new G4Region("DefaultRegionForTheWorld"); // deleted by store
117  defaultRegionForParallelWorld = new G4Region("DefaultRegionForParallelWorld"); // deleted by store
119  G4ProductionCutsTable::GetProductionCutsTable()->GetDefaultProductionCuts());
121  G4ProductionCutsTable::GetProductionCutsTable()->GetDefaultProductionCuts());
122 
124  // set the initial application state
126 
127  // version banner
128  G4String vs = G4Version;
129  vs = vs.substr(1,vs.size()-2);
130  versionString = " Geant4 version ";
131  versionString += vs;
132  versionString += " ";
134  G4cout << G4endl
135  << "*************************************************************" << G4endl
136  << versionString << G4endl
137  << " Copyright : Geant4 Collaboration" << G4endl
138  << " Reference : NIM A 506 (2003), 250-303" << G4endl
139  << " WWW : http://cern.ch/geant4" << G4endl
140  << "*************************************************************" << G4endl
141  << G4endl;
142 }
143 
145 : physicsList(0),currentWorld(0),
146 geometryInitialized(false),physicsInitialized(false),
147 geometryToBeOptimized(true),
148 physicsNeedsToBeReBuilt(true),verboseLevel(0),
149 numberOfParallelWorld(0),geometryNeedsToBeClosed(true),
150  numberOfStaticAllocators(0)
151 {
152 //This version of the constructor should never be called in sequential mode!
153 #ifndef G4MULTITHREADED
155  msg<<"Geant4 code is compiled without multi-threading support (-DG4MULTITHREADED is set to off).";
156  msg<<" This type of RunManagerKernel can only be used in mult-threaded applications.";
157  G4Exception("G4RunManagerKernel::G4RunManagerKernel(G4bool)","Run0035",FatalException,msg);
158 #endif
159 
160 #ifdef G4FPE_DEBUG
162 #endif
163 
166  {
167  G4Exception("G4RunManagerKernel::G4RunManagerKernel()","Run0001",
168  FatalException,"More than one G4RunManagerKernel is constructed.");
169  }
170  fRunManagerKernel = this;
171  // construction of Geant4 kernel classes
173 
174  switch(rmkType)
175  {
176  case masterRMK:
177  //Master thread behvior
178  defaultRegion = new G4Region("DefaultRegionForTheWorld"); // deleted by store
179  defaultRegionForParallelWorld = new G4Region("DefaultRegionForParallelWorld"); // deleted by store
181  G4ProductionCutsTable::GetProductionCutsTable()->GetDefaultProductionCuts());
183  G4ProductionCutsTable::GetProductionCutsTable()->GetDefaultProductionCuts());
184  break;
185  case workerRMK:
186  //Worker thread behavior
187  defaultRegion = G4RegionStore::GetInstance()->GetRegion("DefaultRegionForTheWorld", true);
189  = G4RegionStore::GetInstance()->GetRegion("DefaultRegionForParallelWorld", true);
190  break;
191  default:
193  msgx<<" This type of RunManagerKernel can only be used in mult-threaded applications.";
194  G4Exception("G4RunManagerKernel::G4RunManagerKernel(G4bool)","Run0035",FatalException,msgx);
195  }
196  runManagerKernelType = rmkType;
197 
198  // set the initial application state
200 
201  // version banner
202  G4String vs = G4Version;
203  vs = vs.substr(1,vs.size()-2);
204  switch(rmkType)
205  {
206  case masterRMK:
207  versionString = " Geant4 version ";
208  versionString += vs;
209  versionString += " ";
211  G4cout << G4endl
212  << "*************************************************************" << G4endl
213  << versionString << G4endl
214  << " << in Multi-threaded mode >> " << G4endl
215  << " Copyright : Geant4 Collaboration" << G4endl
216  << " Reference : NIM A 506 (2003), 250-303" << G4endl
217  << " WWW : http://cern.ch/geant4" << G4endl
218  << "*************************************************************" << G4endl
219  << G4endl;
220  break;
221  default:
222  versionString = " Local thread RunManagerKernel version ";
223  versionString += vs;
224  G4cout << G4endl
225  << "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" << G4endl
226  << versionString << G4endl
227  << "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" << G4endl
228  << G4endl;
229  }
230 }
231 
233 {
234  if(runManagerKernelType==workerRMK) return;
235 
236  // Remove old world logical volume from the default region, if exist
238  {
239  if(defaultRegion->GetNumberOfRootVolumes()>size_t(1))
240  {
241  G4Exception("G4RunManager::SetupDefaultRegion",
242  "Run0005",
244  "Default world region should have a unique logical volume.");
245  }
246  std::vector<G4LogicalVolume*>::iterator lvItr
248  defaultRegion->RemoveRootLogicalVolume(*lvItr,false);
249  if(verboseLevel>1) G4cout
250  << "Obsolete world logical volume is removed from the default region." << G4endl;
251  }
252 
253 }
254 
256 {
258  // set the application state to the quite state
259  if(pStateManager->GetCurrentState()!=G4State_Quit)
260  {
261  if(verboseLevel>0) G4cout << "G4 kernel has come to Quit state." << G4endl;
262  pStateManager->SetNewState(G4State_Quit);
263  }
264 
265  // open geometry for deletion
267 
268  // deletion of Geant4 kernel classes
270  if(fSDM)
271  {
272  delete fSDM;
273  if(verboseLevel>1) G4cout << "G4SDManager deleted." << G4endl;
274  }
275  delete eventManager;
276  if(verboseLevel>1) G4cout << "EventManager deleted." << G4endl;
277 
279  if(verboseLevel>1) G4cout << "Units table cleared." << G4endl;
281  if(allocList)
282  {
284  delete allocList;
285  if(verboseLevel>1) G4cout << "G4Allocator objects are deleted." << G4endl;
286  }
287 
288  G4UImanager* pUImanager = G4UImanager::GetUIpointer();
290  {
291  G4cout << "Thread-local UImanager is to be deleted." << G4endl
292  << "There should not be any thread-local G4cout/G4cerr hereafter."
293  << G4endl;
294  verboseLevel = 0;
295  }
296  if(pUImanager) delete pUImanager;
297  if(verboseLevel>1) G4cout << "UImanager deleted." << G4endl;
298 
299  delete pStateManager;
300  if(verboseLevel>1) G4cout << "StateManager deleted." << G4endl;
302  if(verboseLevel>0) G4cout << "RunManagerKernel is deleted. Good bye :)" << G4endl;
303  fRunManagerKernel = 0;
304 }
305 
307 {
310  G4MTRunManager::masterWorlds_t masterWorlds= masterRM->GetMasterWorlds();
311  G4MTRunManager::masterWorlds_t::iterator itrMW = masterWorlds.begin();
312  for(;itrMW!=masterWorlds.end();itrMW++)
313  {
314  G4VPhysicalVolume* wv = (*itrMW).second;
315  G4VPhysicalVolume* pWorld
317  ->IsWorldExisting(wv->GetName());
318  if(!pWorld)
319  { transM->RegisterWorld(wv); }
320  }
321 }
322 
324  G4bool topologyIsChanged)
325 {
327  G4ApplicationState currentState = stateManager->GetCurrentState();
328  if(!(currentState==G4State_Idle||currentState==G4State_PreInit))
329  {
330  G4Exception("G4RunManagerKernel::DefineWorldVolume",
331  "DefineWorldVolumeAtIncorrectState",
332  JustWarning,
333  "Geant4 kernel is not PreInit or Idle state : Method ignored.");
334  if(verboseLevel>1) G4cerr << "Current application state is "
335  << stateManager->GetStateString(currentState) << G4endl;
336  return;
337  }
338 
339  currentWorld = worldVol;
342  G4MTRunManager::masterWorlds_t masterWorlds= masterRM->GetMasterWorlds();
343  G4MTRunManager::masterWorlds_t::iterator itrMW = masterWorlds.begin();
344  for(;itrMW!=masterWorlds.end();itrMW++)
345  {
346  if((*itrMW).first == 0)
347  {
348  if((*itrMW).second != currentWorld)
349  {
350  G4Exception("G4RunManagerKernel::WorkerDefineWorldVolume","RUN3091",
351  FatalException,"Mass world is inconsistent");
352  }
353  transM->SetWorldForTracking((*itrMW).second);
354  }
355  else
356  {
357  transM->RegisterWorld((*itrMW).second);
358  }
359  }
360 
361  if(topologyIsChanged) geometryNeedsToBeClosed = true;
362 
363  // Notify the VisManager as well
365  {
367  if(pVVisManager) pVVisManager->GeometryHasChanged();
368  }
369 
370  geometryInitialized = true;
371  if(physicsInitialized && currentState!=G4State_Idle)
372  { stateManager->SetNewState(G4State_Idle); }
373 }
374 
376  G4bool topologyIsChanged)
377 {
379  G4ApplicationState currentState = stateManager->GetCurrentState();
380  if(!(currentState==G4State_Idle||currentState==G4State_PreInit))
381  {
382  G4Exception("G4RunManagerKernel::DefineWorldVolume",
383  "Run00031",
384  JustWarning,
385  "Geant4 kernel is not PreInit or Idle state : Method ignored.");
386  return;
387  }
388 
389  // The world volume MUST NOT have a region defined by the user
390  if(worldVol->GetLogicalVolume()->GetRegion())
391  {
392  if(worldVol->GetLogicalVolume()->GetRegion()!=defaultRegion)
393  {
395  ED << "The world volume has a user-defined region <"
396  << worldVol->GetLogicalVolume()->GetRegion()->GetName()
397  << ">." << G4endl;
398  ED << "World would have a default region assigned by RunManagerKernel."
399  << G4endl;
400  G4Exception("G4RunManager::DefineWorldVolume",
401  "Run0004", FatalException, ED);
402  }
403  }
404 
406 
407  // Accept the world volume
408  currentWorld = worldVol;
409 
410  // Set the default region to the world
411 
413  worldLog->SetRegion(defaultRegion);
415  if(verboseLevel>1) G4cout << worldLog->GetName()
416  << " is registered to the default region." << G4endl;
417 
418  // Set the world volume, notify the Navigator and reset its state
421  if(topologyIsChanged) geometryNeedsToBeClosed = true;
422 
423  // Notify the VisManager as well
425  {
427  if(pVVisManager) pVVisManager->GeometryHasChanged();
428  }
429 
430  geometryInitialized = true;
431  if(physicsInitialized && currentState!=G4State_Idle)
432  { stateManager->SetNewState(G4State_Idle); }
433 }
434 
436 {
437  physicsList = uPhys;
438 
439  if(runManagerKernelType==workerRMK) return;
440 
441  SetupPhysics();
443  if(verboseLevel>1)
444  {
445  G4cout << "List of instantiated particles ============================================" << G4endl;
447  for(G4int i=0;i<nPtcl;i++)
448  {
450  G4cout << pd->GetParticleName() << " ";
451  if(i%10==9) G4cout << G4endl;
452  }
453  G4cout << G4endl;
454  }
455 }
456 
457 #include "G4IonTable.hh"
459 #include "G4IonConstructor.hh"
460 #include "G4Geantino.hh"
461 
463 {
465 
467 
468  // For sanity reason
471  if(gion)
474 
476  pItr->reset();
477  while( (*pItr)() )
478  {
479  G4ParticleDefinition* particle = pItr->value();
480  if(!(particle->IsGeneralIon())) particle->SetParticleDefinitionID();
481  }
482 
483  if(gion)
484  {
485  G4int gionId = gion->GetParticleDefinitionID();
486  pItr->reset(false);
487  while( (*pItr)() )
488  {
489  G4ParticleDefinition* particle = pItr->value();
490  if(particle->IsGeneralIon()) particle->SetParticleDefinitionID(gionId);
491  }
492  }
493 }
494 
495 namespace {
496  G4Mutex initphysicsmutex = G4MUTEX_INITIALIZER;
497 }
498 
500 {
502  G4ApplicationState currentState = stateManager->GetCurrentState();
503  if(!(currentState==G4State_Idle||currentState==G4State_PreInit))
504  {
505  G4Exception("G4RunManagerKernel::InitializePhysics",
506  "Run0011", JustWarning,
507  "Geant4 kernel is not PreInit or Idle state : Method ignored.");
508  return;
509  }
510 
511  if(!physicsList)
512  {
513  G4Exception("G4RunManagerKernel::InitializePhysics",
514  "Run0012", FatalException,
515  "G4VUserPhysicsList is not defined");
516  return;
517  }
518 
519  if(verboseLevel>1) G4cout << "physicsList->Construct() start." << G4endl;
522 
523  if(verboseLevel>1) G4cout << "physicsList->CheckParticleList() start." << G4endl;
525  //Cannot assume that SetCuts and CheckRegions are thread safe. We need to mutex
526  //Report from valgrind --tool=drd
527  if(verboseLevel>1) G4cout << "physicsList->setCut() start." << G4endl;
528  G4AutoLock l(&initphysicsmutex);
529  physicsList->SetCuts();
530  CheckRegions();
531  l.unlock();
532 
533  static G4bool createIsomerOnlyOnce = false;
535  {
536  if(!createIsomerOnlyOnce)
537  {
538  createIsomerOnlyOnce = true;
540  if(gion)
541  {
543  G4int gionId = gion->GetParticleDefinitionID();
545  pItr->reset(false);
546  while( (*pItr)() )
547  {
548  G4ParticleDefinition* particle = pItr->value();
549  if(particle->IsGeneralIon()) particle->SetParticleDefinitionID(gionId);
550  }
551  }
552  }
553  }
554 
555  physicsInitialized = true;
556  if(geometryInitialized && currentState!=G4State_Idle)
557  { stateManager->SetNewState(G4State_Idle); }
558 }
559 
561 {
563  G4ApplicationState currentState = stateManager->GetCurrentState();
564 
565  if(!geometryInitialized)
566  {
567  G4Exception("G4RunManagerKernel::RunInitialization",
568  "Run0021",
569  JustWarning,
570  "Geometry has not yet initialized : method ignored.");
571  return false;
572  }
573 
574  if(!physicsInitialized)
575  {
576  G4Exception("G4RunManagerKernel::RunInitialization",
577  "Run0022",
578  JustWarning,
579  "Physics has not yet initialized : method ignored.");
580  return false;
581  }
582 
583  if( currentState != G4State_Idle )
584  {
585  G4Exception("G4RunManagerKernel::RunInitialization",
586  "Run0023",
587  JustWarning,
588  "Geant4 kernel not in Idle state : method ignored.");
589  return false;
590  }
591 
593 
595  UpdateRegion();
596  BuildPhysicsTables(fakeRun);
597 
599  {
600  ResetNavigator();
601  // CheckRegularGeometry();
602  // Notify the VisManager as well
604  {
606  if(pVVisManager) pVVisManager->GeometryHasChanged();
607  }
608  }
609 
611 
612  stateManager->SetNewState(G4State_GeomClosed);
613  return true;
614 }
615 
617 {
620 }
621 
623 {
625  { geometryNeedsToBeClosed = false; return; }
626 
627  // We have to tweak the navigator's state in case a geometry has been
628  // modified between runs. By the following calls we ensure that navigator's
629  // state is reset properly. It is required the geometry to be closed
630  // and previous optimisations to be cleared.
631 
633  if(verboseLevel>1) G4cout << "Start closing geometry." << G4endl;
634 
635  geomManager->OpenGeometry();
637 
638  geometryNeedsToBeClosed = false;
639 }
640 
642 {
644  G4ApplicationState currentState = stateManager->GetCurrentState();
645  if( currentState != G4State_Idle )
646  {
647  G4Exception("G4RunManagerKernel::UpdateRegion",
648  "Run0024",
649  JustWarning,
650  "Geant4 kernel not in Idle state : method ignored.");
651  return;
652  }
653 
654  if(runManagerKernelType==workerRMK) return;
655 
656  CheckRegions();
657 
659 
661 }
662 
664 {
667  {
668 #ifdef G4MULTITHREADED
670  {
671  // make sure workers also rebuild physics tables
672  G4UImanager* pUImanager = G4UImanager::GetUIpointer();
673  pUImanager->ApplyCommand("/run/physicsModified");
674  }
675 #endif
678  physicsNeedsToBeReBuilt = false;
679  }
680 
681  if(!fakeRun && verboseLevel>1) DumpRegion();
682  if(!fakeRun && verboseLevel>0) physicsList->DumpCutValuesTable();
684 }
685 
687 {
689  size_t nWorlds = transM->GetNoWorlds();
690  std::vector<G4VPhysicalVolume*>::iterator wItr;
691  for(size_t i=0;i<G4RegionStore::GetInstance()->size();i++)
692  {
693  G4Region* region = (*(G4RegionStore::GetInstance()))[i];
694 
695  //Let each region have a pointer to the world volume where it belongs to.
696  //G4Region::SetWorld() checks if the region belongs to the given world and set it
697  //only if it does. Thus, here we go through all the registered world volumes.
698  region->SetWorld(0); // reset
699  region->UsedInMassGeometry(false);
700  region->UsedInParallelGeometry(false);
701  wItr = transM->GetWorldsIterator();
702  for(size_t iw=0;iw<nWorlds;iw++)
703  {
704  if(region->BelongsTo(*wItr))
705  {
706  if(*wItr==currentWorld)
707  { region->UsedInMassGeometry(true); }
708  else
709  { region->UsedInParallelGeometry(true); }
710  }
711  region->SetWorld(*wItr);
712  wItr++;
713  }
714 
715  G4ProductionCuts* cuts = region->GetProductionCuts();
716  if(!cuts)
717  {
718  if(region->IsInMassGeometry())
719  {
720  G4cerr << "Warning : Region <" << region->GetName()
721  << "> does not have specific production cuts," << G4endl
722  << "even though it appears in the current tracking world." << G4endl;
723  G4cerr << "Default cuts are used for this region." << G4endl;
724  }
725 
726  if(region->IsInMassGeometry()||region->IsInParallelGeometry())
727  {
728  region->SetProductionCuts(
730  ->GetDefaultProductionCuts());
731  }
732  }
733  }
734 
735  //
736  // If a parallel world has no region, set default region for parallel world
737  //
738 
739  wItr = transM->GetWorldsIterator();
740  for(size_t iw=0;iw<nWorlds;iw++)
741  {
742  //G4cout << "+++ " << (*wItr)->GetName() << G4endl;
743  if(*wItr!=currentWorld)
744  {
745  G4LogicalVolume* pwLogical = (*wItr)->GetLogicalVolume();
746  if(!(pwLogical->GetRegion()))
747  {
750  //G4cout << "+++++ defaultRegionForParallelWorld is set to "
751  // << (*wItr)->GetName() << " +++++" << G4endl;
752  }
753  }
754  wItr++;
755  }
756 
757 }
758 
759 void G4RunManagerKernel::DumpRegion(const G4String& rname) const
760 {
761  G4Region* region = G4RegionStore::GetInstance()->GetRegion(rname);
762  if(region) DumpRegion(region);
763 }
764 
766 {
767  if(!region)
768  {
769  for(size_t i=0;i<G4RegionStore::GetInstance()->size();i++)
770  { DumpRegion((*(G4RegionStore::GetInstance()))[i]); }
771  }
772  else
773  {
774  if(G4Threading::IsWorkerThread()) return;
775  G4cout << G4endl;
776  G4cout << "Region <" << region->GetName() << "> -- ";
777  if(region->GetWorldPhysical())
778  {
779  G4cout << " -- appears in <"
780  << region->GetWorldPhysical()->GetName() << "> world volume";
781  }
782  else
783  { G4cout << " -- is not associated to any world."; }
784  G4cout << G4endl;
785  if(region->IsInMassGeometry())
786  { G4cout << " This region is in the mass world." << G4endl; }
787  if(region->IsInParallelGeometry())
788  { G4cout << " This region is in the parallel world." << G4endl; }
789 
790  G4cout << " Root logical volume(s) : ";
791  size_t nRootLV = region->GetNumberOfRootVolumes();
792  std::vector<G4LogicalVolume*>::iterator lvItr = region->GetRootLogicalVolumeIterator();
793  for(size_t j=0;j<nRootLV;j++)
794  { G4cout << (*lvItr)->GetName() << " "; lvItr++; }
795  G4cout << G4endl;
796 
797  G4cout << " Pointers : G4VUserRegionInformation[" << region->GetUserInformation()
798  << "], G4UserLimits[" << region->GetUserLimits()
799  << "], G4FastSimulationManager[" << region->GetFastSimulationManager()
800  << "], G4UserSteppingAction[" << region->GetRegionalSteppingAction() << "]" << G4endl;
801 
802  G4cout << " Materials : ";
803  std::vector<G4Material*>::const_iterator mItr = region->GetMaterialIterator();
804  size_t nMaterial = region->GetNumberOfMaterials();
805  for(size_t iMate=0;iMate<nMaterial;iMate++)
806  {
807  G4cout << (*mItr)->GetName() << " ";
808  mItr++;
809  }
810  G4cout << G4endl;
811  G4ProductionCuts* cuts = region->GetProductionCuts();
812  if(!cuts && region->IsInMassGeometry())
813  {
814  G4cerr << "Warning : Region <" << region->GetName()
815  << "> does not have specific production cuts." << G4endl;
816  G4cerr << "Default cuts are used for this region." << G4endl;
817  region->SetProductionCuts(
818  G4ProductionCutsTable::GetProductionCutsTable()->GetDefaultProductionCuts());
819  }
820  else if(cuts)
821  {
822  G4cout << " Production cuts : "
823  << " gamma "
824  << G4BestUnit(cuts->GetProductionCut("gamma"),"Length")
825  << " e- "
826  << G4BestUnit(cuts->GetProductionCut("e-"),"Length")
827  << " e+ "
828  << G4BestUnit(cuts->GetProductionCut("e+"),"Length")
829  << " proton "
830  << G4BestUnit(cuts->GetProductionCut("proton"),"Length")
831  << G4endl;
832  }
833  }
834 }
835 
836 #include "G4LogicalVolumeStore.hh"
838 {
840  for(G4LogicalVolumeStore::iterator pos=store->begin(); pos!=store->end(); pos++)
841  {
842  if((*pos)&&((*pos)->GetNoDaughters()==1))
843  {
844  if((*pos)->GetDaughter(0)->IsRegularStructure())
845  {
847  return;
848  }
849  }
850  }
851 }
852 
853 #include "G4ParticleTable.hh"
854 #include "G4ParticleDefinition.hh"
855 #include "G4ProcessManager.hh"
856 #include "G4ProcessVector.hh"
857 #include "G4VProcess.hh"
859 {
862  theParticleIterator->reset();
863  while((*theParticleIterator)())
864  {
865  G4ParticleDefinition* pd = theParticleIterator->value();
867  if(pm)
868  {
870  G4VProcess* p = (*pv)[0];
871  return ( (p->GetProcessName()) == "CoupledTransportation" );
872  }
873  }
874  return false;
875 }
876 
879 {
883 
884  // Ensure that Process is added only once to the particles' process managers
885  static G4ThreadLocal bool InitSplitter=false;
886  if( ! InitSplitter ) {
887  InitSplitter = true;
888 
889  theParticleIterator->reset();
890  while( (*theParticleIterator)() )
891  {
892  G4ParticleDefinition* particle = theParticleIterator->value();
893  G4ProcessManager* pmanager = particle->GetProcessManager();
894  if(pmanager)
895  { pmanager->AddDiscreteProcess(pSplitter); }
896  }
897 
898  if(verboseLevel>0)
899  {
900  G4cout << "G4RunManagerKernel -- G4ScoreSplittingProcess is appended to all particles." << G4endl;
901  }
902  }
903 }
904 
906 {
909  theParticleIterator->reset();
910  //loop on particles and get process manager from there list of processes
911  while((*theParticleIterator)())
912  {
913  G4ParticleDefinition* pd = theParticleIterator->value();
915  if(pm)
916  {
917  G4ProcessVector& procs = *(pm->GetProcessList());
918  for ( G4int idx = 0 ; idx<procs.size() ; ++idx)
919  {
920  const G4VProcess* masterP = procs[idx]->GetMasterProcess();
921  if ( ! masterP )
922  {
923  //Process does not have an associated shadow master process
924  //We are in master mode or sequential
925  procs[idx]->SetMasterProcess(const_cast<G4VProcess*>(procs[idx]));
926  }
927  }
928  }
929  }
930 }
virtual void GeometryHasChanged()=0
G4bool ConfirmCoupledTransportation()
static G4Geantino * GeantinoDefinition()
Definition: G4Geantino.cc:82
G4VPhysicalVolume * IsWorldExisting(const G4String &worldName)
G4int GetParticleDefinitionID() const
G4Region * defaultRegionForParallelWorld
void InitializeLightIons()
Definition: G4IonTable.cc:177
G4ProductionCuts * GetProductionCuts() const
std::vector< G4Material * >::const_iterator GetMaterialIterator() const
std::map< G4int, G4VPhysicalVolume * > masterWorlds_t
virtual void SetupShadowProcess() const
G4Region * GetRegion(const G4String &name, G4bool verbose=true) const
const G4String & GetName() const
void SetPhysics(G4VUserPhysicsList *uPhys)
void SetParticleDefinitionID(G4int id=-1)
void UpdateMaterialList(G4VPhysicalVolume *currentWorld=0)
G4VPhysicalVolume * currentWorld
void DumpTable(const G4String &particle_name="ALL")
G4EventManager * eventManager
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4String GetName() const
void AddRootLogicalVolume(G4LogicalVolume *lv)
Definition: G4Region.cc:254
void UsedInParallelGeometry(G4bool val=true)
G4int Size() const
static G4VVisManager * GetConcreteInstance()
static G4AllocatorList * GetAllocatorListIfExist()
std::vector< G4VPhysicalVolume * >::iterator GetWorldsIterator()
G4double GetProductionCut(G4int index) const
G4VUserRegionInformation * GetUserInformation() const
G4int AddDiscreteProcess(G4VProcess *aProcess, G4int ord=ordDefault)
static masterWorlds_t & GetMasterWorlds()
void SetReadiness(G4bool val=true)
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
G4Region * GetRegion() const
G4ParticleDefinition * GetGenericIon() const
#define G4ThreadLocal
Definition: tls.hh:52
G4ProcessManager * GetProcessManager() const
int G4int
Definition: G4Types.hh:78
static G4RunManagerKernel * GetRunManagerKernel()
#define G4MUTEX_INITIALIZER
Definition: G4Threading.hh:158
G4bool RunInitialization(G4bool fakeRun=false)
const G4String & GetParticleName() const
void WorkerDefineWorldVolume(G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)
G4bool IsGeneralIon() const
static void ConstructParticle()
G4ExceptionHandler * defaultExceptionHandler
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
static G4RegionStore * GetInstance()
void CreateAllIsomer()
Definition: G4IonTable.cc:1521
static G4StateManager * GetStateManager()
void SetRegion(G4Region *reg)
G4VPhysicalVolume * GetWorldPhysical() const
G4ParticleDefinition * GetParticle(G4int index) const
G4IonTable * GetIonTable() const
void DumpCutValuesTable(G4int flag=1)
G4GLOB_DLL std::ostream G4cout
G4bool SetNewState(G4ApplicationState requestedState)
void reset(G4bool ifSkipIon=true)
const G4String & GetName() const
static void InvalidOperationDetection()
void DumpRegion(const G4String &rname) const
bool G4bool
Definition: G4Types.hh:79
static G4MTRunManager * GetMasterRunManager()
void UsedInMassGeometry(G4bool val=true)
static const G4String G4Version
Definition: G4Version.hh:63
static G4LogicalVolumeStore * GetInstance()
static const G4String G4Date
Definition: G4Version.hh:65
G4ApplicationState GetCurrentState() const
static G4GeometryManager * GetInstance()
const G4String & GetProcessName() const
Definition: G4VProcess.hh:408
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4bool IsWorkerThread()
Definition: G4Threading.cc:104
static G4TransportationManager * GetTransportationManager()
static void ClearUnitsTable()
G4int size() const
static G4ProductionCutsTable * GetProductionCutsTable()
G4bool BelongsTo(G4VPhysicalVolume *thePhys) const
Definition: G4Region.cc:362
void UseCoupledTransportation(G4bool vl=true)
G4int G4Mutex
Definition: G4Threading.hh:156
G4LogicalVolume * GetLogicalVolume() const
void SetWorld(G4VPhysicalVolume *wp)
Definition: G4Region.cc:346
static G4ParticleTable * GetParticleTable()
G4PrimaryTransformer * GetPrimaryTransformer() const
G4bool IsInMassGeometry() const
G4FastSimulationManager * GetFastSimulationManager() const
G4VUserPhysicsList * physicsList
static G4ThreadLocal G4RunManagerKernel * fRunManagerKernel
size_t GetNoWorlds() const
void Destroy(G4int nStat=0, G4int verboseLevel=0)
#define G4endl
Definition: G4ios.hh:61
void SetProductionCuts(G4ProductionCuts *cut)
void OpenGeometry(G4VPhysicalVolume *vol=0)
void UpdateCoupleTable(G4VPhysicalVolume *currentWorld)
virtual void ConstructParticle()=0
G4bool RegisterWorld(G4VPhysicalVolume *aWorld)
size_t GetNumberOfMaterials() const
void SetWorldForTracking(G4VPhysicalVolume *theWorld)
void BuildPhysicsTables(G4bool fakeRun)
G4ProcessVector * GetAlongStepProcessVector(G4ProcessVectorTypeIndex typ=typeGPIL) const
size_t GetNumberOfRootVolumes() const
void RemoveRootLogicalVolume(G4LogicalVolume *lv, G4bool scan=true)
Definition: G4Region.cc:283
G4bool IsInParallelGeometry() const
G4PTblDicIterator * GetIterator() const
G4int entries() const
G4UserLimits * GetUserLimits() const
static const G4double pos
G4UserSteppingAction * GetRegionalSteppingAction() const
G4bool CloseGeometry(G4bool pOptimise=true, G4bool verbose=false, G4VPhysicalVolume *vol=0)
#define theParticleIterator
G4ApplicationState
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:432
G4ProcessVector * GetProcessList() const
G4GLOB_DLL std::ostream G4cerr
void DefineWorldVolume(G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)
G4String GetStateString(G4ApplicationState aState) const
static G4SDManager * GetSDMpointerIfExist()
Definition: G4SDManager.cc:49
std::vector< G4LogicalVolume * >::iterator GetRootLogicalVolumeIterator()