Geant4  10.01
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 87128 2014-11-25 09:00:59Z 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"
42 #include "G4VPhysicalVolume.hh"
43 #include "G4LogicalVolume.hh"
44 #include "G4VUserPhysicsList.hh"
45 
46 #include "G4ParticleTable.hh"
47 #include "G4Region.hh"
48 #include "G4RegionStore.hh"
49 #include "G4ProductionCuts.hh"
50 #include "G4ProductionCutsTable.hh"
51 #include "G4SDManager.hh"
53 #include "G4UImanager.hh"
54 #include "G4VVisManager.hh"
55 #include "G4UnitsTable.hh"
56 #include "G4Version.hh"
57 #include "G4ios.hh"
58 
59 #include "G4MTRunManager.hh"
60 #include "G4AllocatorList.hh"
61 
62 #include "G4AutoLock.hh"
63 
64 #ifdef G4FPE_DEBUG
65  #include "G4FPEDetection.hh"
66 #endif
67 
68 //The following lines are needed since G4VUserPhysicsList uses a #define theParticleIterator
69 #ifdef theParticleIterator
70 #undef theParticleIterator
71 #endif
72 
74 
76 { return fRunManagerKernel; }
77 
79 : physicsList(0),currentWorld(0),
80  geometryInitialized(false),physicsInitialized(false),
81  geometryToBeOptimized(true),
82  physicsNeedsToBeReBuilt(true),verboseLevel(0),
83  numberOfParallelWorld(0),geometryNeedsToBeClosed(true),
84  numberOfStaticAllocators(0)
85 {
86 #ifdef G4FPE_DEBUG
88 #endif
90  if(allocList) numberOfStaticAllocators = allocList->Size();
93  {
94  G4Exception("G4RunManagerKernel::G4RunManagerKernel()","Run0001",
95  FatalException,"More than one G4RunManagerKernel is constructed.");
96  }
97  fRunManagerKernel = this;
98 
100  if(particleTable->entries()>0)
101  {
102  // No particle should be registered beforehand
104  ED<<"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"<<G4endl;
105  ED<<" G4RunManagerKernel fatal exception"<<G4endl;
106  ED<<" -- Following particles have already been registered"<<G4endl;
107  ED<<" before G4RunManagerKernel is instantiated."<<G4endl;
108  for(int i=0;i<particleTable->entries();i++)
109  { ED<<" "<<particleTable->GetParticle(i)->GetParticleName()<<G4endl; }
110  ED<<"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"<<G4endl;
111  G4Exception("G4RunManagerKernel::G4RunManagerKernel()","Run0002",
112  FatalException,ED);
113  }
114 
115  // construction of Geant4 kernel classes
117 
118  defaultRegion = new G4Region("DefaultRegionForTheWorld"); // deleted by store
119  defaultRegionForParallelWorld = new G4Region("DefaultRegionForParallelWorld"); // deleted by store
121  G4ProductionCutsTable::GetProductionCutsTable()->GetDefaultProductionCuts());
123  G4ProductionCutsTable::GetProductionCutsTable()->GetDefaultProductionCuts());
124 
126  // set the initial application state
128 
129  // version banner
130  G4String vs = G4Version;
131  vs = vs.substr(1,vs.size()-2);
132  versionString = " Geant4 version ";
133  versionString += vs;
134  versionString += " ";
136  G4cout << G4endl
137  << "*************************************************************" << G4endl
138  << versionString << G4endl
139  << " Copyright : Geant4 Collaboration" << G4endl
140  << " Reference : NIM A 506 (2003), 250-303" << G4endl
141  << " WWW : http://cern.ch/geant4" << G4endl
142  << "*************************************************************" << G4endl
143  << G4endl;
144 }
145 
147 : physicsList(0),currentWorld(0),
148 geometryInitialized(false),physicsInitialized(false),
149 geometryToBeOptimized(true),
150 physicsNeedsToBeReBuilt(true),verboseLevel(0),
151 numberOfParallelWorld(0),geometryNeedsToBeClosed(true),
152  numberOfStaticAllocators(0)
153 {
154 //This version of the constructor should never be called in sequential mode!
155 #ifndef G4MULTITHREADED
157  msg<<"Geant4 code is compiled without multi-threading support (-DG4MULTITHREADED is set to off).";
158  msg<<" This type of RunManagerKernel can only be used in mult-threaded applications.";
159  G4Exception("G4RunManagerKernel::G4RunManagerKernel(G4bool)","Run0035",FatalException,msg);
160 #endif
161 
162 #ifdef G4FPE_DEBUG
163  if ( ! G4Threading::IsWorkerThread() ) {
165  }
166 #endif
167 
170  {
171  G4Exception("G4RunManagerKernel::G4RunManagerKernel()","Run0001",
172  FatalException,"More than one G4RunManagerKernel is constructed.");
173  }
174  fRunManagerKernel = this;
175  // construction of Geant4 kernel classes
177 
178  switch(rmkType)
179  {
180  case masterRMK:
181  //Master thread behvior
182  defaultRegion = new G4Region("DefaultRegionForTheWorld"); // deleted by store
183  defaultRegionForParallelWorld = new G4Region("DefaultRegionForParallelWorld"); // deleted by store
185  G4ProductionCutsTable::GetProductionCutsTable()->GetDefaultProductionCuts());
187  G4ProductionCutsTable::GetProductionCutsTable()->GetDefaultProductionCuts());
188  break;
189  case workerRMK:
190  //Worker thread behavior
191  defaultRegion = G4RegionStore::GetInstance()->GetRegion("DefaultRegionForTheWorld", true);
193  = G4RegionStore::GetInstance()->GetRegion("DefaultRegionForParallelWorld", true);
194  break;
195  default:
196  defaultRegion = 0;
199  msgx<<" This type of RunManagerKernel can only be used in mult-threaded applications.";
200  G4Exception("G4RunManagerKernel::G4RunManagerKernel(G4bool)","Run0035",FatalException,msgx);
201  }
202  runManagerKernelType = rmkType;
203 
204  // set the initial application state
206 
207  // version banner
208  G4String vs = G4Version;
209  vs = vs.substr(1,vs.size()-2);
210  switch(rmkType)
211  {
212  case masterRMK:
213  versionString = " Geant4 version ";
214  versionString += vs;
215  versionString += " ";
217  G4cout << G4endl
218  << "*************************************************************" << G4endl
219  << versionString << G4endl
220  << " << in Multi-threaded mode >> " << G4endl
221  << " Copyright : Geant4 Collaboration" << G4endl
222  << " Reference : NIM A 506 (2003), 250-303" << G4endl
223  << " WWW : http://cern.ch/geant4" << G4endl
224  << "*************************************************************" << G4endl
225  << G4endl;
226  break;
227  default:
228  versionString = " Local thread RunManagerKernel version ";
229  versionString += vs;
230  G4cout << G4endl
231  << "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" << G4endl
232  << versionString << G4endl
233  << "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" << G4endl
234  << G4endl;
235  }
236 }
237 
239 {
240  if(runManagerKernelType==workerRMK) return;
241 
242  // Remove old world logical volume from the default region, if exist
244  {
245  if(defaultRegion->GetNumberOfRootVolumes()>size_t(1))
246  {
247  G4Exception("G4RunManager::SetupDefaultRegion",
248  "Run0005",
250  "Default world region should have a unique logical volume.");
251  }
252  std::vector<G4LogicalVolume*>::iterator lvItr
254  defaultRegion->RemoveRootLogicalVolume(*lvItr,false);
255  if(verboseLevel>1) G4cout
256  << "Obsolete world logical volume is removed from the default region." << G4endl;
257  }
258 
259 }
260 
262 {
264  // set the application state to the quite state
265  if(pStateManager->GetCurrentState()!=G4State_Quit)
266  {
267  if(verboseLevel>0) G4cout << "G4 kernel has come to Quit state." << G4endl;
268  pStateManager->SetNewState(G4State_Quit);
269  }
270 
271  // open geometry for deletion
273 
274  // deletion of Geant4 kernel classes
276  if(pwps) delete pwps;
278  if(fSDM)
279  {
280  delete fSDM;
281  if(verboseLevel>1) G4cout << "G4SDManager deleted." << G4endl;
282  }
283  delete eventManager;
284  if(verboseLevel>1) G4cout << "EventManager deleted." << G4endl;
285 
287  if(verboseLevel>1) G4cout << "Units table cleared." << G4endl;
288 
289  // deletion of navigation levels
291 
292  // deletion of allocators
294  if(allocList)
295  {
297  delete allocList;
298  if(verboseLevel>1) G4cout << "G4Allocator objects are deleted." << G4endl;
299  }
300 
301  G4UImanager* pUImanager = G4UImanager::GetUIpointer();
303  {
304  G4cout << "Thread-local UImanager is to be deleted." << G4endl
305  << "There should not be any thread-local G4cout/G4cerr hereafter."
306  << G4endl;
307  verboseLevel = 0;
308  }
309  if(pUImanager) delete pUImanager;
310  if(verboseLevel>1) G4cout << "UImanager deleted." << G4endl;
311 
312  delete pStateManager;
313  if(verboseLevel>1) G4cout << "StateManager deleted." << G4endl;
315  if(verboseLevel>0) G4cout << "RunManagerKernel is deleted. Good bye :)" << G4endl;
316  fRunManagerKernel = 0;
317 }
318 
320 {
323  G4MTRunManager::masterWorlds_t masterWorlds= masterRM->GetMasterWorlds();
324  G4MTRunManager::masterWorlds_t::iterator itrMW = masterWorlds.begin();
325  for(;itrMW!=masterWorlds.end();itrMW++)
326  {
327  G4VPhysicalVolume* wv = (*itrMW).second;
328  G4VPhysicalVolume* pWorld
330  ->IsWorldExisting(wv->GetName());
331  if(!pWorld)
332  { transM->RegisterWorld(wv); }
333  }
334 }
335 
337  G4bool topologyIsChanged)
338 {
340  G4ApplicationState currentState = stateManager->GetCurrentState();
341  if(!(currentState==G4State_Idle||currentState==G4State_PreInit))
342  {
343  G4Exception("G4RunManagerKernel::DefineWorldVolume",
344  "DefineWorldVolumeAtIncorrectState",
345  JustWarning,
346  "Geant4 kernel is not PreInit or Idle state : Method ignored.");
347  if(verboseLevel>1) G4cerr << "Current application state is "
348  << stateManager->GetStateString(currentState) << G4endl;
349  return;
350  }
351 
352  currentWorld = worldVol;
355  G4MTRunManager::masterWorlds_t masterWorlds= masterRM->GetMasterWorlds();
356  G4MTRunManager::masterWorlds_t::iterator itrMW = masterWorlds.begin();
357  for(;itrMW!=masterWorlds.end();itrMW++)
358  {
359  if((*itrMW).first == 0)
360  {
361  if((*itrMW).second != currentWorld)
362  {
363  G4Exception("G4RunManagerKernel::WorkerDefineWorldVolume","RUN3091",
364  FatalException,"Mass world is inconsistent");
365  }
366  transM->SetWorldForTracking((*itrMW).second);
367  }
368  else
369  {
370  transM->RegisterWorld((*itrMW).second);
371  }
372  }
373 
374  if(topologyIsChanged) geometryNeedsToBeClosed = true;
375 
376  // Notify the VisManager as well
378  {
380  if(pVVisManager) pVVisManager->GeometryHasChanged();
381  }
382 
383  geometryInitialized = true;
384  if(physicsInitialized && currentState!=G4State_Idle)
385  { stateManager->SetNewState(G4State_Idle); }
386 }
387 
389  G4bool topologyIsChanged)
390 {
392  G4ApplicationState currentState = stateManager->GetCurrentState();
393  if(!(currentState==G4State_Idle||currentState==G4State_PreInit))
394  {
395  G4Exception("G4RunManagerKernel::DefineWorldVolume",
396  "Run00031",
397  JustWarning,
398  "Geant4 kernel is not PreInit or Idle state : Method ignored.");
399  return;
400  }
401 
402  // The world volume MUST NOT have a region defined by the user
403  if(worldVol->GetLogicalVolume()->GetRegion())
404  {
405  if(worldVol->GetLogicalVolume()->GetRegion()!=defaultRegion)
406  {
408  ED << "The world volume has a user-defined region <"
409  << worldVol->GetLogicalVolume()->GetRegion()->GetName()
410  << ">." << G4endl;
411  ED << "World would have a default region assigned by RunManagerKernel."
412  << G4endl;
413  G4Exception("G4RunManager::DefineWorldVolume",
414  "Run0004", FatalException, ED);
415  }
416  }
417 
419 
420  // Accept the world volume
421  currentWorld = worldVol;
422 
423  // Set the default region to the world
424 
426  worldLog->SetRegion(defaultRegion);
428  if(verboseLevel>1) G4cout << worldLog->GetName()
429  << " is registered to the default region." << G4endl;
430 
431  // Set the world volume, notify the Navigator and reset its state
434  if(topologyIsChanged) geometryNeedsToBeClosed = true;
435 
436  // Notify the VisManager as well
438  {
440  if(pVVisManager) pVVisManager->GeometryHasChanged();
441  }
442 
443  geometryInitialized = true;
444  if(physicsInitialized && currentState!=G4State_Idle)
445  { stateManager->SetNewState(G4State_Idle); }
446 }
447 
449 {
450  physicsList = uPhys;
451 
452  if(runManagerKernelType==workerRMK) return;
453 
454  SetupPhysics();
456  if(verboseLevel>1)
457  {
458  G4cout << "List of instantiated particles ============================================" << G4endl;
460  for(G4int i=0;i<nPtcl;i++)
461  {
463  G4cout << pd->GetParticleName() << " ";
464  if(i%10==9) G4cout << G4endl;
465  }
466  G4cout << G4endl;
467  }
468 }
469 
470 #include "G4IonTable.hh"
472 #include "G4IonConstructor.hh"
473 #include "G4Geantino.hh"
474 
476 {
478 
480 
481  // For sanity reason
484  if(gion)
487 
489  pItr->reset();
490  while( (*pItr)() )
491  {
492  G4ParticleDefinition* particle = pItr->value();
493  if(!(particle->IsGeneralIon())) particle->SetParticleDefinitionID();
494  }
495 
496  if(gion)
497  {
498  G4int gionId = gion->GetParticleDefinitionID();
499  pItr->reset(false);
500  while( (*pItr)() )
501  {
502  G4ParticleDefinition* particle = pItr->value();
503  if(particle->IsGeneralIon()) particle->SetParticleDefinitionID(gionId);
504  }
505  }
506 }
507 
508 namespace {
509  G4Mutex initphysicsmutex = G4MUTEX_INITIALIZER;
510 }
511 
513 {
515  G4ApplicationState currentState = stateManager->GetCurrentState();
516  if(!(currentState==G4State_Idle||currentState==G4State_PreInit))
517  {
518  G4Exception("G4RunManagerKernel::InitializePhysics",
519  "Run0011", JustWarning,
520  "Geant4 kernel is not PreInit or Idle state : Method ignored.");
521  return;
522  }
523 
524  if(!physicsList)
525  {
526  G4Exception("G4RunManagerKernel::InitializePhysics",
527  "Run0012", FatalException,
528  "G4VUserPhysicsList is not defined");
529  return;
530  }
531 
532  if(verboseLevel>1) G4cout << "physicsList->Construct() start." << G4endl;
535 
536  if(verboseLevel>1) G4cout << "physicsList->CheckParticleList() start." << G4endl;
538  //Cannot assume that SetCuts and CheckRegions are thread safe. We need to mutex
539  //Report from valgrind --tool=drd
540  G4AutoLock l(&initphysicsmutex);
541  if ( !G4Threading::IsWorkerThread() ) {
542  if(verboseLevel>1) G4cout << "physicsList->setCut() start." << G4endl;
543  physicsList->SetCuts();
544 
545  }
546  CheckRegions();
547  l.unlock();
548 
549 /*******************
550 // static G4bool createIsomerOnlyOnce = false;
551 // if(G4Threading::IsMultithreadedApplication() && !G4Threading::IsWorkerThread())
552 // {
553 // if(!createIsomerOnlyOnce)
554 // {
555 // createIsomerOnlyOnce = true;
556 // G4ParticleDefinition* gion = G4ParticleTable::GetParticleTable()->GetGenericIon();
557 // if(gion)
558 // {
559 // G4ParticleTable::GetParticleTable()->GetIonTable()->CreateAllIsomer();
560 // PropagateGenericIonID();
561 // }
562 // }
563 // }
564 *********************/
565 
566  physicsInitialized = true;
567  if(geometryInitialized && currentState!=G4State_Idle)
568  { stateManager->SetNewState(G4State_Idle); }
569 }
570 
572 {
574  G4ApplicationState currentState = stateManager->GetCurrentState();
575 
576  if(!geometryInitialized)
577  {
578  G4Exception("G4RunManagerKernel::RunInitialization",
579  "Run0021",
580  JustWarning,
581  "Geometry has not yet initialized : method ignored.");
582  return false;
583  }
584 
585  if(!physicsInitialized)
586  {
587  G4Exception("G4RunManagerKernel::RunInitialization",
588  "Run0022",
589  JustWarning,
590  "Physics has not yet initialized : method ignored.");
591  return false;
592  }
593 
594  if( currentState != G4State_Idle )
595  {
596  G4Exception("G4RunManagerKernel::RunInitialization",
597  "Run0023",
598  JustWarning,
599  "Geant4 kernel not in Idle state : method ignored.");
600  return false;
601  }
602 
604 
607  UpdateRegion();
608  BuildPhysicsTables(fakeRun);
609 
611  {
612  ResetNavigator();
613  // CheckRegularGeometry();
614  // Notify the VisManager as well
616  {
618  if(pVVisManager) pVVisManager->GeometryHasChanged();
619  }
620  }
621 
623 
624  stateManager->SetNewState(G4State_GeomClosed);
625  return true;
626 }
627 
629 {
631  if(gion)
632  {
633  //G4ParticleTable::GetParticleTable()->GetIonTable()->CreateAllIsomer();
634  G4int gionId = gion->GetParticleDefinitionID();
636  pItr->reset(false);
637  while( (*pItr)() )
638  {
639  G4ParticleDefinition* particle = pItr->value();
640  if(particle->IsGeneralIon()) particle->SetParticleDefinitionID(gionId);
641  }
642  }
643 }
644 
646 {
650 }
651 
653 {
655  { geometryNeedsToBeClosed = false; return; }
656 
657  // We have to tweak the navigator's state in case a geometry has been
658  // modified between runs. By the following calls we ensure that navigator's
659  // state is reset properly. It is required the geometry to be closed
660  // and previous optimisations to be cleared.
661 
663  if(verboseLevel>1) G4cout << "Start closing geometry." << G4endl;
664 
665  geomManager->OpenGeometry();
667 
668  geometryNeedsToBeClosed = false;
669 }
670 
672 {
674  G4ApplicationState currentState = stateManager->GetCurrentState();
675  if( currentState != G4State_Idle )
676  {
677  G4Exception("G4RunManagerKernel::UpdateRegion",
678  "Run0024",
679  JustWarning,
680  "Geant4 kernel not in Idle state : method ignored.");
681  return;
682  }
683 
684  if(runManagerKernelType==workerRMK) return;
685 
686  CheckRegions();
687 
689 
691 }
692 
694 {
697  {
698 #ifdef G4MULTITHREADED
700  {
701  // make sure workers also rebuild physics tables
702  G4UImanager* pUImanager = G4UImanager::GetUIpointer();
703  pUImanager->ApplyCommand("/run/physicsModified");
704  }
705 #endif
708  physicsNeedsToBeReBuilt = false;
709  }
710 
711  if(!fakeRun && verboseLevel>1) DumpRegion();
712  if(!fakeRun && verboseLevel>0) physicsList->DumpCutValuesTable();
714 }
715 
717 {
719  size_t nWorlds = transM->GetNoWorlds();
720  std::vector<G4VPhysicalVolume*>::iterator wItr;
721  for(size_t i=0;i<G4RegionStore::GetInstance()->size();i++)
722  {
723  G4Region* region = (*(G4RegionStore::GetInstance()))[i];
724 
725  //Let each region have a pointer to the world volume where it belongs to.
726  //G4Region::SetWorld() checks if the region belongs to the given world and set it
727  //only if it does. Thus, here we go through all the registered world volumes.
728  region->SetWorld(0); // reset
729  region->UsedInMassGeometry(false);
730  region->UsedInParallelGeometry(false);
731  wItr = transM->GetWorldsIterator();
732  for(size_t iw=0;iw<nWorlds;iw++)
733  {
734  if(region->BelongsTo(*wItr))
735  {
736  if(*wItr==currentWorld)
737  { region->UsedInMassGeometry(true); }
738  else
739  { region->UsedInParallelGeometry(true); }
740  }
741  region->SetWorld(*wItr);
742  wItr++;
743  }
744 
745  G4ProductionCuts* cuts = region->GetProductionCuts();
746  if(!cuts)
747  {
748  if(region->IsInMassGeometry())
749  {
750  G4cout << "Warning : Region <" << region->GetName()
751  << "> does not have specific production cuts," << G4endl
752  << "even though it appears in the current tracking world." << G4endl;
753  G4cout << "Default cuts are used for this region." << G4endl;
754  }
755 
756  if(region->IsInMassGeometry()||region->IsInParallelGeometry())
757  {
758  region->SetProductionCuts(
760  ->GetDefaultProductionCuts());
761  }
762  }
763  }
764 
765  //
766  // If a parallel world has no region, set default region for parallel world
767  //
768 
769  wItr = transM->GetWorldsIterator();
770  for(size_t iw=0;iw<nWorlds;iw++)
771  {
772  //G4cout << "+++ " << (*wItr)->GetName() << G4endl;
773  if(*wItr!=currentWorld)
774  {
775  G4LogicalVolume* pwLogical = (*wItr)->GetLogicalVolume();
776  if(!(pwLogical->GetRegion()))
777  {
780  //G4cout << "+++++ defaultRegionForParallelWorld is set to "
781  // << (*wItr)->GetName() << " +++++" << G4endl;
782  }
783  }
784  wItr++;
785  }
786 
787 }
788 
789 void G4RunManagerKernel::DumpRegion(const G4String& rname) const
790 {
791  G4Region* region = G4RegionStore::GetInstance()->GetRegion(rname);
792  if(region) DumpRegion(region);
793 }
794 
796 {
797  if(!region)
798  {
799  for(size_t i=0;i<G4RegionStore::GetInstance()->size();i++)
800  { DumpRegion((*(G4RegionStore::GetInstance()))[i]); }
801  }
802  else
803  {
804  if(G4Threading::IsWorkerThread()) return;
805  G4cout << G4endl;
806  G4cout << "Region <" << region->GetName() << "> -- ";
807  if(region->GetWorldPhysical())
808  {
809  G4cout << " -- appears in <"
810  << region->GetWorldPhysical()->GetName() << "> world volume";
811  }
812  else
813  { G4cout << " -- is not associated to any world."; }
814  G4cout << G4endl;
815  if(region->IsInMassGeometry())
816  { G4cout << " This region is in the mass world." << G4endl; }
817  if(region->IsInParallelGeometry())
818  { G4cout << " This region is in the parallel world." << G4endl; }
819 
820  G4cout << " Root logical volume(s) : ";
821  size_t nRootLV = region->GetNumberOfRootVolumes();
822  std::vector<G4LogicalVolume*>::iterator lvItr = region->GetRootLogicalVolumeIterator();
823  for(size_t j=0;j<nRootLV;j++)
824  { G4cout << (*lvItr)->GetName() << " "; lvItr++; }
825  G4cout << G4endl;
826 
827  G4cout << " Pointers : G4VUserRegionInformation[" << region->GetUserInformation()
828  << "], G4UserLimits[" << region->GetUserLimits()
829  << "], G4FastSimulationManager[" << region->GetFastSimulationManager()
830  << "], G4UserSteppingAction[" << region->GetRegionalSteppingAction() << "]" << G4endl;
831 
832  G4cout << " Materials : ";
833  std::vector<G4Material*>::const_iterator mItr = region->GetMaterialIterator();
834  size_t nMaterial = region->GetNumberOfMaterials();
835  for(size_t iMate=0;iMate<nMaterial;iMate++)
836  {
837  G4cout << (*mItr)->GetName() << " ";
838  mItr++;
839  }
840  G4cout << G4endl;
841  G4ProductionCuts* cuts = region->GetProductionCuts();
842  if(!cuts && region->IsInMassGeometry())
843  {
844  G4cerr << "Warning : Region <" << region->GetName()
845  << "> does not have specific production cuts." << G4endl;
846  G4cerr << "Default cuts are used for this region." << G4endl;
847  region->SetProductionCuts(
848  G4ProductionCutsTable::GetProductionCutsTable()->GetDefaultProductionCuts());
849  }
850  else if(cuts)
851  {
852  G4cout << " Production cuts : "
853  << " gamma "
854  << G4BestUnit(cuts->GetProductionCut("gamma"),"Length")
855  << " e- "
856  << G4BestUnit(cuts->GetProductionCut("e-"),"Length")
857  << " e+ "
858  << G4BestUnit(cuts->GetProductionCut("e+"),"Length")
859  << " proton "
860  << G4BestUnit(cuts->GetProductionCut("proton"),"Length")
861  << G4endl;
862  }
863  }
864 }
865 
866 #include "G4LogicalVolumeStore.hh"
868 {
870  for(G4LogicalVolumeStore::iterator pos=store->begin(); pos!=store->end(); pos++)
871  {
872  if((*pos)&&((*pos)->GetNoDaughters()==1))
873  {
874  if((*pos)->GetDaughter(0)->IsRegularStructure())
875  {
877  return;
878  }
879  }
880  }
881 }
882 
883 #include "G4ParticleTable.hh"
884 #include "G4ParticleDefinition.hh"
885 #include "G4ProcessManager.hh"
886 #include "G4ProcessVector.hh"
887 #include "G4VProcess.hh"
889 {
892  theParticleIterator->reset();
893  while((*theParticleIterator)())
894  {
895  G4ParticleDefinition* pd = theParticleIterator->value();
897  if(pm)
898  {
900  G4VProcess* p = (*pv)[0];
901  return ( (p->GetProcessName()) == "CoupledTransportation" );
902  }
903  }
904  return false;
905 }
906 
909 {
913 
914  // Ensure that Process is added only once to the particles' process managers
915  static G4ThreadLocal bool InitSplitter=false;
916  if( ! InitSplitter ) {
917  InitSplitter = true;
918 
919  theParticleIterator->reset();
920  while( (*theParticleIterator)() )
921  {
922  G4ParticleDefinition* particle = theParticleIterator->value();
923  G4ProcessManager* pmanager = particle->GetProcessManager();
924  if(pmanager)
925  { pmanager->AddDiscreteProcess(pSplitter); }
926  }
927 
928  if(verboseLevel>0)
929  {
930  G4cout << "G4RunManagerKernel -- G4ScoreSplittingProcess is appended to all particles." << G4endl;
931  }
932  }
933 }
934 
936 {
939  theParticleIterator->reset();
940  //loop on particles and get process manager from there list of processes
941  while((*theParticleIterator)())
942  {
943  G4ParticleDefinition* pd = theParticleIterator->value();
945  if(pm)
946  {
947  G4ProcessVector& procs = *(pm->GetProcessList());
948  for ( G4int idx = 0 ; idx<procs.size() ; ++idx)
949  {
950  const G4VProcess* masterP = procs[idx]->GetMasterProcess();
951  if ( ! masterP )
952  {
953  //Process does not have an associated shadow master process
954  //We are in master mode or sequential
955  procs[idx]->SetMasterProcess(const_cast<G4VProcess*>(procs[idx]));
956  }
957  }
958  }
959  }
960 }
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:178
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:84
G4ProcessManager * GetProcessManager() const
int G4int
Definition: G4Types.hh:78
static G4RunManagerKernel * GetRunManagerKernel()
#define G4MUTEX_INITIALIZER
Definition: G4Threading.hh:163
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 G4ParallelWorldProcessStore * GetInstanceIfExist()
static G4RegionStore * GetInstance()
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:128
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:161
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
static G4NavigationHistoryPool * GetInstance()
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()