4.7.  Parallel Geometries

4.7.1.  A parallel world

Occasionally, it is not straightforward to define geometries for sensitive detectors, importance geometries or envelopes for shower parameterization to be coherently assigned to volumes in the tracking (mass) geometry. The parallel navigation functionality introduced since release 8.2 of Geant4, allows the user to define more than one worlds simultaneously. The G4Transportation process will see all worlds simultaneously; steps will be limited by both boundaries of the mass and parallel geometries.

In a parallel world, the user can define volumes in arbitrary manner with sensitivity, regions, shower parameterization setups, and/or importance weight for biasing. Volumes in different worlds can overlap.

Here are restrictions to be considered for the parallel geometry:

  • Materials, production thresholds and EM field are used only from the mass geometry. Even if such physical quantities are defined in a parallel world, they do not affect to the simulation.

  • Although all worlds will be comprehensively taken care by the G4Transportation process for the navigation, each parallel world must have its own process assigned to achieve its purpose. For example: in case the user defines a sensitive detector to a parallel world, a process dedicated to the parallel world is responsible to invoke this detector. The G4SteppingManager treats only the detectors in the mass geometry. For this case of detector sensitivity defined in a parallel world, a G4ParallelWorldScoringProcess process must be defined in the physics list (see Section 4.7.3).

4.7.2.  Defining a parallel world

A parallel world should be defined in the Construct() virtual method of the user's class derived from the abstract base class G4VUserParallelWorld.

Example 4.17.  An example header file of a concrete user parallel world class.

#ifndef MyParallelWorld_h
#define MyParallelWorld_h 1

#include "globals.hh"
#include "G4VUserParallelWorld.hh"

class MyParallelWorld : public G4VUserParallelWorld
{
  public:
    MyParallelWorld(G4String worldName);
    virtual ~MyParallelWorld();

  public:
    virtual void Construct();
};

#endif


A parallel world must have its unique name, which should be set to the G4VUserParallelWorld base class as an argument of the base class constructor.

The world physical volume of the parallel world is provided by the G4RunManager as a clone of the mass geometry. In the Construct() virtual method of the user's class, the pointer to this cloned world physical volume is available through the GetWorld() method defined in the base class. The user should fill the volumes in the parallel world by using this provided world volume. For a logical volume in a parallel world, the material pointer can be 0. Even if specified a valid material pointer, it will not be taken into account by any physics process.

Example 4.18.  An example source code of a concrete user parallel world class.

#include "MyParallelWorld.hh"
#include "G4LogicalVolume.hh"
#include "G4VPhysicalVolume.hh"
#include "G4Box.hh"
#include "G4PVPlacement.hh"

MyParallelWorld::MyParallelWorld(G4String worldName)
:G4VUserParallelWorld(worldName)
{;}

MyParallelWorld::~MyParallelWorld() 
{;}

void MyParallelWorld::Construct() 
{
  G4VPhysicalVolume* ghostWorld = GetWorld();
  G4LogicalVolume* worldLogical = ghostWorld->GetLogicalVolume();

  // place volumes in the parallel world here. For example ...
  //
  G4Box * ghostSolid = new G4Box("GhostdBox", 60.*cm, 60.*cm, 60.*cm);
  G4LogicalVolume * ghostLogical
        = new G4LogicalVolume(ghostSolid, 0, "GhostLogical", 0, 0, 0);
  new G4PVPlacement(0, G4ThreeVector(), ghostLogical,
                    "GhostPhysical", worldLogical, 0, 0);
}


In case the user needs to define more than one parallel worlds, each of them must be implemented through its dedicated class. Each parallel world should be registered to the mass geometry class using the method RegisterParallelWorld() available through the class G4VUserDetectorConstruction. The registration must be done -before- the mass world is registed to the G4RunManager.

Example 4.19.  Typical implementation in the main() to define a parallel world.

  // RunManager construction
  //
  G4RunManager* runManager = new G4RunManager;

  // mass world
  //
  MyDetectorConstruction* massWorld = new MyDetectorConstruction;

  // parallel world
  //
  massWorld->RegisterParallelWorld(new MyParallelWorld("ParallelScoringWorld"));

  // set mass world to run manager
  //
  runManager->SetUserInitialization(massWorld);


4.7.3.  Detector sensitivity in a parallel world

Any kind of G4VSensitiveDetector object can be defined in volumes in a parallel world, exactly at the same manner for the mass geometry. Once the user defines the sensitive detector in a parallel world, he/she must define a process which takes care of these detectors.

The G4ParallelWorldScoringProcess is the class provided for this purpose. This process must be defined to all kinds of particles which need to be "detected". This process must be ordered just after G4Transporation and prior to any other physics processes. The name of the parallel world where the G4ParallelWorldScoringProcess is responsible for, must be defined through the method SetParallelWorld() available from the class G4ParallelWorldScoringProcess. If the user has more than one parallel worlds with detectors, for each of the parallel worlds, dedicated G4ParallelWorldScoringProcess objects must be instantiated with the name of each parallel world respectively and registered to the particles.

Example 4.20.  Define G4ParallelWorldScoringProcess.

  // Add parallel world scoring process
  //
  G4ParallelWorldScoringProcess* theParallelWorldScoringProcess 
      = new G4ParallelWorldScoringProcess("ParaWorldScoringProc");
  theParallelWorldScoringProcess->SetParallelWorld("ParallelScoringWorld");

  theParticleIterator->reset();
  while( (*theParticleIterator)() )
  {
    G4ParticleDefinition* particle = theParticleIterator->value();
    if (!particle->IsShortLived())
    {
      G4ProcessManager* pmanager = particle->GetProcessManager();
      pmanager->AddProcess(theParallelWorldScoringProcess);
      pmanager->SetProcessOrderingToLast(theParallelWorldScoringProcess, idxAtRest);
      pmanager->SetProcessOrdering(theParallelWorldScoringProcess, idxAlongStep, 1);
      pmanager->SetProcessOrderingToLast(theParallelWorldScoringProcess, idxPostStep);
    }
  }


At the end of processing an event, all hits collections made for the parallel world are stored in G4HCofThisEvent as well as those for the mass geometry.