| 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 | // $Id: ParaTest.cc,v 1.3 2006/12/13 15:48:29 gunter Exp $
|
|---|
| 27 | // --------------------------------------------------------------
|
|---|
| 28 | //
|
|---|
| 29 | // --------------------------------------------------------------
|
|---|
| 30 | // GEANT 4 - A01app
|
|---|
| 31 | // --------------------------------------------------------------
|
|---|
| 32 | // Comments
|
|---|
| 33 | // Tutorial for Geant4 lectures
|
|---|
| 34 | // --------------------------------------------------------------
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 | #include "G4RunManager.hh"
|
|---|
| 38 | #include "G4UImanager.hh"
|
|---|
| 39 | #include "G4UIterminal.hh"
|
|---|
| 40 | #include "G4UItcsh.hh"
|
|---|
| 41 |
|
|---|
| 42 | #include "A01DetectorConstruction.hh"
|
|---|
| 43 | #include "A01ParallelWorld.hh"
|
|---|
| 44 | #include "A01PhysicsList.hh"
|
|---|
| 45 | #include "A01PrimaryGeneratorAction.hh"
|
|---|
| 46 |
|
|---|
| 47 | #include "A01EventAction.hh"
|
|---|
| 48 |
|
|---|
| 49 | #ifdef G4VIS_USE
|
|---|
| 50 | #include "G4VisExecutive.hh"
|
|---|
| 51 | #endif
|
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 | int main(int argc,char** argv)
|
|---|
| 55 | {
|
|---|
| 56 | if(argc<3)
|
|---|
| 57 | {
|
|---|
| 58 | G4cout << "Usage : " << G4endl;
|
|---|
| 59 | G4cout << " % ParaTest para|nopara disp|nodisp [macro_file]" << G4endl;
|
|---|
| 60 | return 1;
|
|---|
| 61 | }
|
|---|
| 62 | G4bool ifPara;
|
|---|
| 63 | G4String param = argv[1];
|
|---|
| 64 | if(param=="para")
|
|---|
| 65 | { ifPara = true; }
|
|---|
| 66 | else if(param=="nopara")
|
|---|
| 67 | { ifPara = false; }
|
|---|
| 68 | else
|
|---|
| 69 | {
|
|---|
| 70 | G4cout << "Usage : " << G4endl;
|
|---|
| 71 | G4cout << " % ParaTest para|nopara disp|nodisp [macro_file]" << G4endl;
|
|---|
| 72 | return 1;
|
|---|
| 73 | }
|
|---|
| 74 | G4bool ifDisp;
|
|---|
| 75 | param = argv[2];
|
|---|
| 76 | if(param=="disp")
|
|---|
| 77 | { ifDisp = true; }
|
|---|
| 78 | else if(param=="nodisp")
|
|---|
| 79 | { ifDisp = false; }
|
|---|
| 80 | else
|
|---|
| 81 | {
|
|---|
| 82 | G4cout << "Usage : " << G4endl;
|
|---|
| 83 | G4cout << " % ParaTest para|nopara disp|nodisp [macro_file]" << G4endl;
|
|---|
| 84 | return 1;
|
|---|
| 85 | }
|
|---|
| 86 |
|
|---|
| 87 | // RunManager construction
|
|---|
| 88 | G4RunManager* runManager = new G4RunManager;
|
|---|
| 89 |
|
|---|
| 90 | #ifdef G4VIS_USE
|
|---|
| 91 | // Visualization manager construction
|
|---|
| 92 | G4VisManager* visManager = new G4VisExecutive;
|
|---|
| 93 | visManager->Initialize();
|
|---|
| 94 | #endif
|
|---|
| 95 |
|
|---|
| 96 | // mandatory user initialization classes
|
|---|
| 97 | A01DetectorConstruction* massWorld = new A01DetectorConstruction;
|
|---|
| 98 | if(ifPara) massWorld->RegisterParallelWorld(new A01ParallelWorld("ParallelScoringWorld"));
|
|---|
| 99 | runManager->SetUserInitialization(massWorld);
|
|---|
| 100 | runManager->SetUserInitialization(new A01PhysicsList(ifPara,ifDisp));
|
|---|
| 101 |
|
|---|
| 102 | // initialize Geant4 kernel
|
|---|
| 103 | runManager->Initialize();
|
|---|
| 104 |
|
|---|
| 105 | // mandatory user action class
|
|---|
| 106 | runManager->SetUserAction(new A01PrimaryGeneratorAction);
|
|---|
| 107 |
|
|---|
| 108 | // optional user action classes
|
|---|
| 109 | runManager->SetUserAction(new A01EventAction(ifPara));
|
|---|
| 110 |
|
|---|
| 111 | G4UImanager* UI = G4UImanager::GetUIpointer();
|
|---|
| 112 | if(argc>3)
|
|---|
| 113 | // execute an argument macro file if exist
|
|---|
| 114 | {
|
|---|
| 115 | G4UImanager* UImanager = G4UImanager::GetUIpointer();
|
|---|
| 116 | G4String command = "/control/execute ";
|
|---|
| 117 | G4String fileName = argv[3];
|
|---|
| 118 | UImanager->ApplyCommand(command+fileName);
|
|---|
| 119 | }
|
|---|
| 120 | else
|
|---|
| 121 | // start interactive session
|
|---|
| 122 | {
|
|---|
| 123 | UI->ApplyCommand("/control/execute vis.mac");
|
|---|
| 124 | G4UIsession* session = new G4UIterminal(new G4UItcsh);
|
|---|
| 125 | session->SessionStart();
|
|---|
| 126 | delete session;
|
|---|
| 127 | }
|
|---|
| 128 |
|
|---|
| 129 | #ifdef G4VIS_USE
|
|---|
| 130 | delete visManager;
|
|---|
| 131 | #endif
|
|---|
| 132 |
|
|---|
| 133 | delete runManager;
|
|---|
| 134 |
|
|---|
| 135 | return 0;
|
|---|
| 136 | }
|
|---|
| 137 |
|
|---|