[807] | 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 | // |
---|
| 27 | // $Id: hepmcEx02.cc,v 1.5 2006/07/05 12:04:07 gcosmo Exp $ |
---|
| 28 | // GEANT4 tag $Name: $ |
---|
| 29 | // |
---|
| 30 | // |
---|
| 31 | // -------------------------------------------------------------- |
---|
| 32 | // GEANT 4 - example of HepMC-interface |
---|
| 33 | // -------------------------------------------------------------- |
---|
| 34 | |
---|
| 35 | #include "G4RunManager.hh" |
---|
| 36 | #include "G4UImanager.hh" |
---|
| 37 | #include "G4UIterminal.hh" |
---|
| 38 | #include "G4UItcsh.hh" |
---|
| 39 | |
---|
| 40 | #include "H02DetectorConstruction.hh" |
---|
| 41 | #include "H02PhysicsList.hh" |
---|
| 42 | #include "H02PrimaryGeneratorAction.hh" |
---|
| 43 | #include "H02EventAction.hh" |
---|
| 44 | #include "H02SteppingAction.hh" |
---|
| 45 | |
---|
| 46 | #ifdef G4VIS_USE |
---|
| 47 | #include "G4VisExecutive.hh" |
---|
| 48 | #endif |
---|
| 49 | |
---|
| 50 | int main(int argc, char** argv) |
---|
| 51 | { |
---|
| 52 | G4RunManager* runManager= new G4RunManager; |
---|
| 53 | |
---|
| 54 | // User Initialization classes (mandatory) |
---|
| 55 | // |
---|
| 56 | G4VUserDetectorConstruction* detector = new H02DetectorConstruction; |
---|
| 57 | runManager-> SetUserInitialization(detector); |
---|
| 58 | // |
---|
| 59 | G4VUserPhysicsList* physics = new H02PhysicsList; |
---|
| 60 | runManager-> SetUserInitialization(physics); |
---|
| 61 | |
---|
| 62 | runManager-> Initialize(); |
---|
| 63 | |
---|
| 64 | // User Action classes |
---|
| 65 | // |
---|
| 66 | G4VUserPrimaryGeneratorAction* gen_action = new H02PrimaryGeneratorAction; |
---|
| 67 | runManager-> SetUserAction(gen_action); |
---|
| 68 | // |
---|
| 69 | G4UserEventAction* event_action = new H02EventAction; |
---|
| 70 | runManager-> SetUserAction(event_action); |
---|
| 71 | // |
---|
| 72 | G4UserSteppingAction* stepping_action = new H02SteppingAction; |
---|
| 73 | runManager-> SetUserAction(stepping_action); |
---|
| 74 | |
---|
| 75 | #ifdef G4VIS_USE |
---|
| 76 | // Initialize visualization package |
---|
| 77 | // |
---|
| 78 | G4VisManager* visManager= new G4VisExecutive; |
---|
| 79 | visManager-> Initialize(); |
---|
| 80 | G4cout << G4endl; |
---|
| 81 | #endif |
---|
| 82 | |
---|
| 83 | if(argc==1) // G4UIterminal is a (dumb) terminal |
---|
| 84 | { |
---|
| 85 | #ifdef QERAUOY |
---|
| 86 | G4UItcsh* tcsh= new |
---|
| 87 | G4UItcsh("[40;01;36mhepmcEx02[40;33m(%s)[40;32m[%/][00;30m:"); |
---|
| 88 | G4UIterminal* session= new G4UIterminal(tcsh); |
---|
| 89 | tcsh-> SetLsColor(RED, GREEN); |
---|
| 90 | #else |
---|
| 91 | G4UItcsh* tcsh= new G4UItcsh("hepmcEx01(%s)[%/]:"); |
---|
| 92 | G4UIterminal* session= new G4UIterminal(tcsh); |
---|
| 93 | #endif |
---|
| 94 | session->SessionStart(); |
---|
| 95 | delete session; |
---|
| 96 | |
---|
| 97 | } |
---|
| 98 | else // Batch mode |
---|
| 99 | { |
---|
| 100 | G4UImanager* UImanager= G4UImanager::GetUIpointer(); |
---|
| 101 | G4String command= "/control/execute "; |
---|
| 102 | G4String fileName= argv[1]; |
---|
| 103 | UImanager-> ApplyCommand(command+fileName); |
---|
| 104 | } |
---|
| 105 | |
---|
| 106 | // Free the store: user actions, physics_list and detector_description are |
---|
| 107 | // owned and deleted by the run manager, so they should not |
---|
| 108 | // be deleted in the main() program ! |
---|
| 109 | |
---|
| 110 | #ifdef G4VIS_USE |
---|
| 111 | delete visManager; |
---|
| 112 | #endif |
---|
| 113 | |
---|
| 114 | delete runManager; |
---|
| 115 | |
---|
| 116 | return 0; |
---|
| 117 | } |
---|
| 118 | |
---|