[834] | 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 | // |
---|
[1093] | 27 | // $Id: test19.cc,v 1.30 2009/07/28 12:50:51 lgarnier Exp $ |
---|
[954] | 28 | // GEANT4 tag $Name: $ |
---|
[834] | 29 | // |
---|
| 30 | // |
---|
| 31 | |
---|
| 32 | // Usage: test19 [<session>] [<verbosity>] |
---|
| 33 | // Without verbosity, verbosity=warnings. |
---|
| 34 | // Without session, session=new G4UIterminal(), or if G4UI_USE_TCSH is set |
---|
| 35 | // session=new G4UIterminal(new G4UItcsh), |
---|
| 36 | |
---|
| 37 | #include <stdio.h> |
---|
| 38 | #include <ctype.h> |
---|
| 39 | #include <stdlib.h> |
---|
| 40 | |
---|
| 41 | #include "globals.hh" |
---|
| 42 | //#include "SharedSolidDetectorConstruction.hh" |
---|
| 43 | #include "test19DetectorConstruction.hh" |
---|
| 44 | #include "MyPhysicsList.hh" |
---|
| 45 | #include "MyRunAction.hh" |
---|
| 46 | #include "MyPrimaryGeneratorAction.hh" |
---|
| 47 | #include "MyEventAction.hh" |
---|
| 48 | #include "MySteppingAction.hh" |
---|
| 49 | |
---|
| 50 | #include "G4UIterminal.hh" |
---|
[1086] | 51 | #if defined(G4UI_USE_GAG) |
---|
| 52 | #include "G4UIGAG.hh" |
---|
| 53 | #elif defined(G4UI_USE_TCSH) |
---|
| 54 | #include "G4UItcsh.hh" |
---|
| 55 | #elif defined(G4UI_USE_WO) |
---|
[834] | 56 | #include "G4UIWo.hh" |
---|
[1086] | 57 | #elif defined(G4UI_USE_XM) |
---|
[834] | 58 | #include "G4UIXm.hh" |
---|
[1086] | 59 | #elif defined(G4UI_USE_XAW) |
---|
[834] | 60 | #include "G4UIXaw.hh" |
---|
[1086] | 61 | #elif defined(G4UI_USE_WIN32) |
---|
[834] | 62 | #include "G4UIWin32.hh" |
---|
[1086] | 63 | #elif defined(G4UI_USE_QT) |
---|
[1025] | 64 | #include "G4UIQt.hh" |
---|
| 65 | #endif |
---|
[834] | 66 | |
---|
| 67 | #include "G4RunManager.hh" |
---|
| 68 | |
---|
| 69 | #ifdef G4VIS_USE |
---|
| 70 | #include "G4VisExecutive.hh" |
---|
| 71 | // G4VisExecutive is a G4VisManager that implements graphics system |
---|
| 72 | // registration in the user domain. |
---|
| 73 | #include "G4XXX.hh" |
---|
| 74 | #include "G4XXXFile.hh" |
---|
| 75 | #include "G4XXXStored.hh" |
---|
| 76 | #ifdef G4VIS_USE_XXXSG |
---|
| 77 | #include "G4XXXSG.hh" |
---|
| 78 | #endif |
---|
| 79 | #endif |
---|
| 80 | |
---|
| 81 | |
---|
| 82 | #ifdef G4UI_USE_WIN32 |
---|
| 83 | #include <windows.h> |
---|
| 84 | int WINAPI WinMain ( |
---|
| 85 | HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpszCmdLine,int nCmdShow) { |
---|
| 86 | #else |
---|
| 87 | int main (int argc, char** argv) { |
---|
| 88 | #endif |
---|
| 89 | |
---|
| 90 | G4String verbosityString("warnings"); |
---|
| 91 | #ifndef G4UI_USE_WIN32 |
---|
| 92 | if ((argc >= 3)) verbosityString = argv[2]; |
---|
| 93 | #endif |
---|
| 94 | |
---|
| 95 | // Choose (G)UI. |
---|
| 96 | G4UIsession* session; |
---|
| 97 | #ifdef G4UI_USE_WIN32 |
---|
| 98 | session = new G4UIWin32 (hInstance,hPrevInstance,lpszCmdLine,nCmdShow); |
---|
| 99 | #else |
---|
| 100 | if (argc >= 2) { |
---|
[1086] | 101 | #if defined(G4UI_USE_TCSH) |
---|
[834] | 102 | if (strcmp (argv[1], "tcsh")==0) session = |
---|
[1086] | 103 | new G4UIterminal(new G4UItcsh); |
---|
| 104 | #elif defined(G4UI_USE_WO) |
---|
[1025] | 105 | if (strcmp (argv[1], "Wo")==0) session = new G4UIWo (argc, argv); |
---|
[1086] | 106 | #elif defined(G4UI_USE_XM) |
---|
[1025] | 107 | if (strcmp (argv[1], "Xm")==0) session = new G4UIXm (argc, argv); |
---|
[1086] | 108 | #elif defined(G4UI_USE_XAW) |
---|
[1025] | 109 | if (strcmp (argv[1], "Xaw")==0) session = new G4UIXaw (argc, argv); |
---|
[1086] | 110 | #elif defined(G4UI_USE_GAG) |
---|
[1025] | 111 | if (strcmp (argv[1], "gag")==0) session = new G4UIGAG ; |
---|
[1086] | 112 | #elif defined(G4UI_USE_QT) |
---|
[1093] | 113 | if (strcmp (argv[1], "Qt")==0) session = new G4UIQt (argc, argv); |
---|
[1086] | 114 | #else |
---|
| 115 | session = new G4UIterminal(); |
---|
| 116 | #endif |
---|
[1093] | 117 | else session = new G4UIterminal(); |
---|
[834] | 118 | } |
---|
[1025] | 119 | else |
---|
| 120 | { |
---|
| 121 | G4cerr << "You should define a UI in order to interact with test" << G4endl; |
---|
| 122 | return 0; |
---|
| 123 | } |
---|
[834] | 124 | #endif |
---|
| 125 | G4UImanager::GetUIpointer()->SetSession(session); //So that Pause works.. |
---|
| 126 | |
---|
| 127 | // Run manager |
---|
| 128 | G4cout << "RunManager is constructing...." << G4endl; |
---|
| 129 | G4RunManager * runManager = new G4RunManager; |
---|
| 130 | |
---|
| 131 | // User initialization classes |
---|
| 132 | runManager -> SetUserInitialization (new test19DetectorConstruction); |
---|
| 133 | //runManager -> SetUserInitialization (new SharedSolidDetectorConstruction); |
---|
| 134 | runManager -> SetUserInitialization (new MyPhysicsList); |
---|
| 135 | |
---|
| 136 | // UserAction classes. |
---|
| 137 | runManager -> SetUserAction (new MyRunAction); |
---|
| 138 | runManager -> SetUserAction (new MyPrimaryGeneratorAction); |
---|
| 139 | runManager -> SetUserAction (new MyEventAction); |
---|
| 140 | runManager -> SetUserAction (new MySteppingAction); |
---|
| 141 | |
---|
| 142 | //Initialize G4 kernel |
---|
| 143 | //runManager->Initialize(); // Do this with /run/initialize so that |
---|
| 144 | // you can, optionally, choose detector |
---|
| 145 | // (/test19det/detector N) first. |
---|
| 146 | |
---|
| 147 | #ifdef G4VIS_USE |
---|
| 148 | // Instantiate and initialise Visualization Manager. |
---|
| 149 | G4VisManager* visManager = new G4VisExecutive; |
---|
| 150 | visManager -> SetVerboseLevel (verbosityString); |
---|
| 151 | visManager -> RegisterGraphicsSystem(new G4XXX); |
---|
| 152 | visManager -> RegisterGraphicsSystem(new G4XXXFile); |
---|
| 153 | visManager -> RegisterGraphicsSystem(new G4XXXStored); |
---|
| 154 | #ifdef G4VIS_USE_XXXSG |
---|
| 155 | visManager -> RegisterGraphicsSystem(new G4XXXSG); |
---|
| 156 | #endif |
---|
| 157 | visManager -> Initialize (); |
---|
| 158 | #endif |
---|
| 159 | |
---|
| 160 | G4UImanager* UI = G4UImanager::GetUIpointer (); |
---|
| 161 | |
---|
| 162 | #ifdef G4UI_USE_WIN32 |
---|
| 163 | G4cout << "Reading win32.g4m file...." << G4endl; |
---|
| 164 | UI -> ApplyCommand ("/control/execute win32.g4m"); |
---|
| 165 | #else |
---|
| 166 | G4cout << "Reading test19.g4m file...." << G4endl; |
---|
| 167 | UI -> ApplyCommand ("/control/execute test19.g4m"); |
---|
| 168 | #endif |
---|
| 169 | |
---|
| 170 | G4cout << |
---|
| 171 | "Choose a detector with /test19det/detector (or let default be" |
---|
| 172 | " constructed)." |
---|
| 173 | << G4endl; |
---|
| 174 | |
---|
| 175 | // Start an interactive session. |
---|
| 176 | session -> SessionStart(); |
---|
| 177 | |
---|
| 178 | #ifdef G4VIS_USE |
---|
| 179 | G4cout << "vis_test19: Deleting vis manager..." << G4endl; |
---|
| 180 | delete visManager; |
---|
| 181 | G4cout << "vis_test19: Vis manager deleted." << G4endl; |
---|
| 182 | #endif |
---|
| 183 | G4cout << "vis_test19: Deleting run manager..." << G4endl; |
---|
| 184 | delete runManager; |
---|
| 185 | G4cout << "vis_test19: Run manager deleted." << G4endl; |
---|
| 186 | G4cout << "vis_test19: Deleting session..." << G4endl; |
---|
| 187 | delete session; |
---|
| 188 | G4cout << "vis_test19: Session deleted." << G4endl; |
---|
| 189 | |
---|
| 190 | return 0; |
---|
| 191 | } |
---|