Contents Previous Next Geant4 User's Guide
For Application Developers
Detector Definition and Response


4.7 Parallel Geometries


Notice
As of Geant4 release 8.2, this functionality for defining parallel geometries is still in beta release. We appreciate your feedback.


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 new parallel navigation functionality allows the user to define more than one worlds simultaneously. The new G4Transportation process will see all worlds simultaneously; steps will be limited by both boundaries of the mass geometry 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:

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.

#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
Source listing 4.7.1
An example header file of a concrete user parallel world class.

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 NULL. Even if specified a valid material pointer, it will not be taken into account by any physics process.


#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);
}

Source listing 4.7.2
An example source code of a concrete user parallel world class.

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.

  // 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);
Source listing 4.7.3
Typical implementation in the main() to define a parallel world.

4.7.3 Detector sensitivity in a parallel world

Any kind of 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.

  // 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);
    }
  }
Source listing 4.7.4
Define G4ParallelWorldScoringProcess.

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.


About the authors