Geant4  10.00.p01
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 79223 2014-02-20 15:01:29Z 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  SetupPhysics();
441  if(verboseLevel>1)
442  {
443  G4cout << "List of instantiated particles ============================================" << G4endl;
445  for(G4int i=0;i<nPtcl;i++)
446  {
448  G4cout << pd->GetParticleName() << " ";
449  if(i%10==9) G4cout << G4endl;
450  }
451  G4cout << G4endl;
452  }
453 }
454 
455 #include "G4IonTable.hh"
457 #include "G4IonConstructor.hh"
458 #include "G4Geantino.hh"
459 
461 {
463  if(runManagerKernelType==workerRMK) return;
464 
466 
467  // For sanity reason
470  if(gion)
473 
475  pItr->reset();
476  while( (*pItr)() )
477  {
478  G4ParticleDefinition* particle = pItr->value();
479  if(!(particle->IsGeneralIon())) particle->SetParticleDefinitionID();
480  }
481 
482  if(gion)
483  {
484  G4int gionId = gion->GetParticleDefinitionID();
485  pItr->reset(false);
486  while( (*pItr)() )
487  {
488  G4ParticleDefinition* particle = pItr->value();
489  if(particle->IsGeneralIon()) particle->SetParticleDefinitionID(gionId);
490  }
491  }
492 }
493 
494 namespace {
495  G4Mutex initphysicsmutex = G4MUTEX_INITIALIZER;
496 }
497 
499 {
501  G4ApplicationState currentState = stateManager->GetCurrentState();
502  if(!(currentState==G4State_Idle||currentState==G4State_PreInit))
503  {
504  G4Exception("G4RunManagerKernel::InitializePhysics",
505  "Run0011", JustWarning,
506  "Geant4 kernel is not PreInit or Idle state : Method ignored.");
507  return;
508  }
509 
510  if(!physicsList)
511  {
512  G4Exception("G4RunManagerKernel::InitializePhysics",
513  "Run0012", FatalException,
514  "G4VUserPhysicsList is not defined");
515  return;
516  }
517 
518  if(verboseLevel>1) G4cout << "physicsList->Construct() start." << G4endl;
521 
522  if(verboseLevel>1) G4cout << "physicsList->CheckParticleList() start." << G4endl;
524  //Cannot assume that SetCuts and CheckRegions are thread safe. We need to mutex
525  //Report from valgrind --tool=drd
526  if(verboseLevel>1) G4cout << "physicsList->setCut() start." << G4endl;
527  G4AutoLock l(&initphysicsmutex);
528  physicsList->SetCuts();
529  CheckRegions();
530  l.unlock();
531 
532  static G4bool createIsomerOnlyOnce = false;
534  {
535  if(!createIsomerOnlyOnce)
536  {
537  createIsomerOnlyOnce = true;
539  if(gion)
540  {
542  G4int gionId = gion->GetParticleDefinitionID();
544  pItr->reset(false);
545  while( (*pItr)() )
546  {
547  G4ParticleDefinition* particle = pItr->value();
548  if(particle->IsGeneralIon()) particle->SetParticleDefinitionID(gionId);
549  }
550  }
551  }
552  }
553 
554  physicsInitialized = true;
555  if(geometryInitialized && currentState!=G4State_Idle)
556  { stateManager->SetNewState(G4State_Idle); }
557 }
558 
560 {
562  G4ApplicationState currentState = stateManager->GetCurrentState();
563 
564  if(!geometryInitialized)
565  {
566  G4Exception("G4RunManagerKernel::RunInitialization",
567  "Run0021",
568  JustWarning,
569  "Geometry has not yet initialized : method ignored.");
570  return false;
571  }
572 
573  if(!physicsInitialized)
574  {
575  G4Exception("G4RunManagerKernel::RunInitialization",
576  "Run0022",
577  JustWarning,
578  "Physics has not yet initialized : method ignored.");
579  return false;
580  }
581 
582  if( currentState != G4State_Idle )
583  {
584  G4Exception("G4RunManagerKernel::RunInitialization",
585  "Run0023",
586  JustWarning,
587  "Geant4 kernel not in Idle state : method ignored.");
588  return false;
589  }
590 
592 
594  UpdateRegion();
595  BuildPhysicsTables(fakeRun);
596 
598  {
599  ResetNavigator();
600  // CheckRegularGeometry();
601  // Notify the VisManager as well
603  {
605  if(pVVisManager) pVVisManager->GeometryHasChanged();
606  }
607  }
608 
610 
611  stateManager->SetNewState(G4State_GeomClosed);
612  return true;
613 }
614 
616 {
619 }
620 
622 {
624  { geometryNeedsToBeClosed = false; return; }
625 
626  // We have to tweak the navigator's state in case a geometry has been
627  // modified between runs. By the following calls we ensure that navigator's
628  // state is reset properly. It is required the geometry to be closed
629  // and previous optimisations to be cleared.
630 
632  if(verboseLevel>1) G4cout << "Start closing geometry." << G4endl;
633 
634  geomManager->OpenGeometry();
636 
637  geometryNeedsToBeClosed = false;
638 }
639 
641 {
643  G4ApplicationState currentState = stateManager->GetCurrentState();
644  if( currentState != G4State_Idle )
645  {
646  G4Exception("G4RunManagerKernel::UpdateRegion",
647  "Run0024",
648  JustWarning,
649  "Geant4 kernel not in Idle state : method ignored.");
650  return;
651  }
652 
653  if(runManagerKernelType==workerRMK) return;
654 
655  CheckRegions();
656 
658 
660 }
661 
663 {
666  {
667 #ifdef G4MULTITHREADED
669  {
670  // make sure workers also rebuild physics tables
671  G4UImanager* pUImanager = G4UImanager::GetUIpointer();
672  pUImanager->ApplyCommand("/run/physicsModified");
673  }
674 #endif
677  physicsNeedsToBeReBuilt = false;
678  }
679 
680  if(!fakeRun && verboseLevel>1) DumpRegion();
681  if(!fakeRun && verboseLevel>0) physicsList->DumpCutValuesTable();
683 }
684 
686 {
688  size_t nWorlds = transM->GetNoWorlds();
689  std::vector<G4VPhysicalVolume*>::iterator wItr;
690  for(size_t i=0;i<G4RegionStore::GetInstance()->size();i++)
691  {
692  G4Region* region = (*(G4RegionStore::GetInstance()))[i];
693 
694  //Let each region have a pointer to the world volume where it belongs to.
695  //G4Region::SetWorld() checks if the region belongs to the given world and set it
696  //only if it does. Thus, here we go through all the registered world volumes.
697  region->SetWorld(0); // reset
698  region->UsedInMassGeometry(false);
699  region->UsedInParallelGeometry(false);
700  wItr = transM->GetWorldsIterator();
701  for(size_t iw=0;iw<nWorlds;iw++)
702  {
703  if(region->BelongsTo(*wItr))
704  {
705  if(*wItr==currentWorld)
706  { region->UsedInMassGeometry(true); }
707  else
708  { region->UsedInParallelGeometry(true); }
709  }
710  region->SetWorld(*wItr);
711  wItr++;
712  }
713 
714  G4ProductionCuts* cuts = region->GetProductionCuts();
715  if(!cuts)
716  {
717  if(region->IsInMassGeometry())
718  {
719  G4cerr << "Warning : Region <" << region->GetName()
720  << "> does not have specific production cuts," << G4endl
721  << "even though it appears in the current tracking world." << G4endl;
722  G4cerr << "Default cuts are used for this region." << G4endl;
723  }
724 
725  if(region->IsInMassGeometry()||region->IsInParallelGeometry())
726  {
727  region->SetProductionCuts(
729  ->GetDefaultProductionCuts());
730  }
731  }
732  }
733 
734  //
735  // If a parallel world has no region, set default region for parallel world
736  //
737 
738  wItr = transM->GetWorldsIterator();
739  for(size_t iw=0;iw<nWorlds;iw++)
740  {
741  //G4cout << "+++ " << (*wItr)->GetName() << G4endl;
742  if(*wItr!=currentWorld)
743  {
744  G4LogicalVolume* pwLogical = (*wItr)->GetLogicalVolume();
745  if(!(pwLogical->GetRegion()))
746  {
749  //G4cout << "+++++ defaultRegionForParallelWorld is set to "
750  // << (*wItr)->GetName() << " +++++" << G4endl;
751  }
752  }
753  wItr++;
754  }
755 
756 }
757 
758 void G4RunManagerKernel::DumpRegion(const G4String& rname) const
759 {
760  G4Region* region = G4RegionStore::GetInstance()->GetRegion(rname);
761  if(region) DumpRegion(region);
762 }
763 
765 {
766  if(!region)
767  {
768  for(size_t i=0;i<G4RegionStore::GetInstance()->size();i++)
769  { DumpRegion((*(G4RegionStore::GetInstance()))[i]); }
770  }
771  else
772  {
773  if(G4Threading::IsWorkerThread()) return;
774  G4cout << G4endl;
775  G4cout << "Region <" << region->GetName() << "> -- ";
776  if(region->GetWorldPhysical())
777  {
778  G4cout << " -- appears in <"
779  << region->GetWorldPhysical()->GetName() << "> world volume";
780  }
781  else
782  { G4cout << " -- is not associated to any world."; }
783  G4cout << G4endl;
784  if(region->IsInMassGeometry())
785  { G4cout << " This region is in the mass world." << G4endl; }
786  if(region->IsInParallelGeometry())
787  { G4cout << " This region is in the parallel world." << G4endl; }
788 
789  G4cout << " Root logical volume(s) : ";
790  size_t nRootLV = region->GetNumberOfRootVolumes();
791  std::vector<G4LogicalVolume*>::iterator lvItr = region->GetRootLogicalVolumeIterator();
792  for(size_t j=0;j<nRootLV;j++)
793  { G4cout << (*lvItr)->GetName() << " "; lvItr++; }
794  G4cout << G4endl;
795 
796  G4cout << " Pointers : G4VUserRegionInformation[" << region->GetUserInformation()
797  << "], G4UserLimits[" << region->GetUserLimits()
798  << "], G4FastSimulationManager[" << region->GetFastSimulationManager()
799  << "], G4UserSteppingAction[" << region->GetRegionalSteppingAction() << "]" << G4endl;
800 
801  G4cout << " Materials : ";
802  std::vector<G4Material*>::const_iterator mItr = region->GetMaterialIterator();
803  size_t nMaterial = region->GetNumberOfMaterials();
804  for(size_t iMate=0;iMate<nMaterial;iMate++)
805  {
806  G4cout << (*mItr)->GetName() << " ";
807  mItr++;
808  }
809  G4cout << G4endl;
810  G4ProductionCuts* cuts = region->GetProductionCuts();
811  if(!cuts && region->IsInMassGeometry())
812  {
813  G4cerr << "Warning : Region <" << region->GetName()
814  << "> does not have specific production cuts." << G4endl;
815  G4cerr << "Default cuts are used for this region." << G4endl;
816  region->SetProductionCuts(
817  G4ProductionCutsTable::GetProductionCutsTable()->GetDefaultProductionCuts());
818  }
819  else if(cuts)
820  {
821  G4cout << " Production cuts : "
822  << " gamma "
823  << G4BestUnit(cuts->GetProductionCut("gamma"),"Length")
824  << " e- "
825  << G4BestUnit(cuts->GetProductionCut("e-"),"Length")
826  << " e+ "
827  << G4BestUnit(cuts->GetProductionCut("e+"),"Length")
828  << " proton "
829  << G4BestUnit(cuts->GetProductionCut("proton"),"Length")
830  << G4endl;
831  }
832  }
833 }
834 
835 #include "G4LogicalVolumeStore.hh"
837 {
839  for(G4LogicalVolumeStore::iterator pos=store->begin(); pos!=store->end(); pos++)
840  {
841  if((*pos)&&((*pos)->GetNoDaughters()==1))
842  {
843  if((*pos)->GetDaughter(0)->IsRegularStructure())
844  {
846  return;
847  }
848  }
849  }
850 }
851 
852 #include "G4ParticleTable.hh"
853 #include "G4ParticleDefinition.hh"
854 #include "G4ProcessManager.hh"
855 #include "G4ProcessVector.hh"
856 #include "G4VProcess.hh"
858 {
861  theParticleIterator->reset();
862  while((*theParticleIterator)())
863  {
864  G4ParticleDefinition* pd = theParticleIterator->value();
866  if(pm)
867  {
869  G4VProcess* p = (*pv)[0];
870  return ( (p->GetProcessName()) == "CoupledTransportation" );
871  }
872  }
873  return false;
874 }
875 
878 {
882 
883  // Ensure that Process is added only once to the particles' process managers
884  static G4ThreadLocal bool InitSplitter=false;
885  if( ! InitSplitter ) {
886  InitSplitter = true;
887 
888  theParticleIterator->reset();
889  while( (*theParticleIterator)() )
890  {
891  G4ParticleDefinition* particle = theParticleIterator->value();
892  G4ProcessManager* pmanager = particle->GetProcessManager();
893  if(pmanager)
894  { pmanager->AddDiscreteProcess(pSplitter); }
895  }
896 
897  if(verboseLevel>0)
898  {
899  G4cout << "G4RunManagerKernel -- G4ScoreSplittingProcess is appended to all particles." << G4endl;
900  }
901  }
902 }
903 
905 {
908  theParticleIterator->reset();
909  //loop on particles and get process manager from there list of processes
910  while((*theParticleIterator)())
911  {
912  G4ParticleDefinition* pd = theParticleIterator->value();
914  if(pm)
915  {
916  G4ProcessVector& procs = *(pm->GetProcessList());
917  for ( G4int idx = 0 ; idx<procs.size() ; ++idx)
918  {
919  const G4VProcess* masterP = procs[idx]->GetMasterProcess();
920  if ( ! masterP )
921  {
922  //Process does not have an associated shadow master process
923  //We are in master mode or sequential
924  procs[idx]->SetMasterProcess(const_cast<G4VProcess*>(procs[idx]));
925  }
926  }
927  }
928  }
929 }
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:1508
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:419
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()