12.07.2015 Views

Geant4 User's Guide for Application Developers - Geant4 - CERN

Geant4 User's Guide for Application Developers - Geant4 - CERN

Geant4 User's Guide for Application Developers - Geant4 - CERN

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Toolkit Fundamentals3.7.3.2.1. Creation of G4AdjointSimManager in the mainThe class G4AdjointSimManager represents the manager of an adjoint simulation. This static class should becreated somewhere in the main code. The way to do that is illustrated belowint main(int argc,char** argv) {...G4AdjointSimManager* theAdjointSimManager = G4AdjointSimManager::GetInstance();...}By doing this the G4 application can be run in the reverse MC mode as well as in the <strong>for</strong>ward MC mode. It isimportant to note that G4AdjointSimManager is not a new G4RunManager and that the creation of G4RunManagerin the main and the declaration of the geometry, physics list, and user actions to G4RunManager is still needed.The definition of the adjoint and external sources and the start of an adjoint simulation can be controlled by G4UIcommands in the directory /adjoint.3.7.3.2.2. Optional declaration of adjoint user actionsDuring an adjoint simulation the user stepping, tracking, stacking and event actions declared to G4RunManager areused only during the G4 events dedicated to the <strong>for</strong>ward tracking of normal particles in the sensitive region, whileduring the events where adjoint particles are tracked backward the following happen concerning these actions:• The user stepping action is replaced by G4AdjointSteppingAction that is reponsible to stop an adjoint track whenit reaches the external source, exceed the maximum energy of the external source, or cross the adjoint sourcesurface. If needed the user can declare its own stepping action that will be called by G4AdjointSteppingActionafter the check of stopping track conditions. This stepping action can be different that the stepping action used<strong>for</strong> the <strong>for</strong>ward simulation. It is declared to G4AdjointSimManager by the following lines of code :G4AdjointSimManager* theAdjointSimManager = G4AdjointSimManager::GetInstance();theAdjointSimManager->SetAdjointSteppingAction(aUserDefinedSteppingAction);• No stacking, tracking and event actions are considered by default. If needed the user can declare toG4AdjointSimManager stacking, tracking and event actions that will be used only during the adjoint trackingphase. The following lines of code show how to declare these adjoint actions to G4AdjointSimManager:G4AdjointSimManager* theAdjointSimManager = G4AdjointSimManager::GetInstance();theAdjointSimManager->SetAdjointEventAction(aUserDefinedEventAction);theAdjointSimManager->SetAdjointStackingAction(aUserDefinedStackingAction);theAdjointSimManager->SetAdjointTrackingAction(aUserDefinedTrackingAction);By default no user run action is considered in an adjoint simulation but if needed such action can be declaredto G4AdjointSimManager as such:G4AdjointSimManager* theAdjointSimManager = G4AdjointSimManager::GetInstance();theAdjointSimManager->SetAdjointRunAction(aUserDefinedRunAction);3.7.3.2.3. Physics list <strong>for</strong> reverse and <strong>for</strong>ward electromagnetic processesTo run an adjoint simulation a specific physics list should be used where existing G4 adjoint electromagneticprocesses and their <strong>for</strong>ward equivalent have to be declared. An example of such physics list is provided by theclass G4AdjointPhysicsLits in the G4 example extended/biasing/ReverseMC01.3.7.3.2.4. Modification in the analysis part of the codeThe user code should be modified to normalize the signals computed during the <strong>for</strong>ward tracking phase to theweight of the last adjoint particle that reaches the external surface. This weight represents the statistical weightthat the last full adjoint tracks (from the adjoint source to the external source) would have in a <strong>for</strong>ward simulation.If multiplied by a signal and registered in function of energy and/or direction the simulation results will give ananswer matrix of this signal. To normalize it to a given spectrum it has to be furthermore multiplied by a directional62

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!