Geant4  10.03
exampleRMC01.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 //
28 //
29 //
30 // $Id: exampleRMC01.cc 101303 2016-11-14 11:21:18Z gcosmo $
31 //
32 //
33 // --------------------------------------------------------------
34 // GEANT 4 - exampleRMC01
35 //
36 // --------------------------------------------------------------
37 // Comments
38 //
39 // This example intends to show how to use the adjoint/reverse simulation mode.
40 //
41 // --------------------------------------------------------------
42 
43 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
44 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
45 
46 #include "G4RunManager.hh"
47 #include "G4UImanager.hh"
48 
49 #include "Randomize.hh"
50 
51 #ifdef G4VIS_USE
52 #include "G4VisExecutive.hh"
53 #endif
54 
55 #ifdef G4UI_USE
56 #include "G4UIExecutive.hh"
57 #endif
58 
59 #include "G4AdjointSimManager.hh"
62 #include "RMC01EventAction.hh"
63 #include "RMC01RunAction.hh"
64 #include "G4AdjointPhysicsList.hh"
65 
66 #include "G4AdjointSimManager.hh"
68 
69 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
70 
71 int main(int argc,char** argv) {
72 
73 
74 
75  // Construct the default run manager
76  G4RunManager * theRunManager = new G4RunManager;
77 
78 
80 
81  //Physics and geometry are declared as in a normal G4 application
82  //--------------------------------------------
83  theRunManager->SetUserInitialization(detector);
84  theRunManager->SetUserInitialization(new G4AdjointPhysicsList);
85 
86  theRunManager->SetUserAction(new RMC01PrimaryGeneratorAction);
87  theRunManager->SetUserAction(new RMC01EventAction);
88  RMC01RunAction* theRunAction = new RMC01RunAction;
89  theRunManager->SetUserAction(theRunAction);
90 
91  //The adjoint simulation manager will control the Reverse MC mode
92  //---------------------------------------------------------------
93 
94  G4AdjointSimManager* theAdjointSimManager
96 
97  //It is possible to define action that will be used during
98  // the adjoint tracking phase
99 
100  theAdjointSimManager->SetAdjointRunAction(theRunAction);
101  //theAdjointSimManager->SetAdjointEventAction(new RMC01AdjointEventAction);
102  theAdjointSimManager->SetAdjointEventAction(new RMC01EventAction);
103 
104 #ifdef G4VIS_USE
105  // visualization manager
106  G4VisManager* visManager = new G4VisExecutive;
107  visManager->Initialize();
108 
109 #endif
110 
111  // get the pointer to the User Interface manager
112  G4UImanager* UImanager = G4UImanager::GetUIpointer();
113 
114  if (argc!=1) // batch mode
115  {
116  G4String command = "/control/execute ";
117  G4String fileName = argv[1];
118  UImanager->ApplyCommand(command+fileName);
119  }
120  else
121  { // interactive mode : define UI session
122 #ifdef G4UI_USE
123  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
124  ui->SessionStart();
125  delete ui;
126 #endif
127  }
128 
129  // job termination
130 #ifdef G4VIS_USE
131  delete visManager;
132 #endif
133  delete theRunManager;
134 
135  return 0;
136 }
137 
138 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
static G4AdjointSimManager * GetInstance()
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
int main(int argc, char **argv)
Definition: exampleRMC01.cc:71
Definition of the RMC01RunAction class.
Definition of the RMC01PrimaryGeneratorAction class.
Definition of the RMC01DetectorConstruction class.
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
void Initialize()
void SetAdjointRunAction(G4UserRunAction *anAction)
void SetAdjointEventAction(G4UserEventAction *anAction)
Definition of the G4AdjointPhysicsList class.
Definition of the RMC01AdjointEventAction class.
Definition of the RMC01EventAction class.
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:446
virtual void SetUserAction(G4UserRunAction *userAction)