[1199] | 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: testNTST.cc,v 1.3 2006/06/29 18:25:19 gunter Exp $ |
---|
| 27 | // |
---|
| 28 | // ---------------------------------------------------------------- |
---|
| 29 | // GEANT 4 - exampleNTST : BaBar SVT standalone simulation |
---|
| 30 | // |
---|
| 31 | // For information related to this code contact: Bill Lockman |
---|
| 32 | // lockman@slac.stanford.edu |
---|
| 33 | // ---------------------------------------------------------------- |
---|
| 34 | |
---|
| 35 | #include "G4RunManager.hh" |
---|
| 36 | #include "G4UImanager.hh" |
---|
| 37 | #include "G4UIterminal.hh" |
---|
| 38 | #include "G4UItcsh.hh" |
---|
| 39 | // #include "g4std/stdio.h" |
---|
| 40 | |
---|
| 41 | #ifdef G4VIS_USE |
---|
| 42 | #include "NTSTVisManager.hh" |
---|
| 43 | #endif |
---|
| 44 | |
---|
| 45 | #include "NTSTFileRead.hh" |
---|
| 46 | #include "NTSTDetectorConstruction.hh" |
---|
| 47 | #include "NTSTPhysicsList.hh" |
---|
| 48 | #include "NTSTPrimaryGeneratorAction.hh" |
---|
| 49 | #include "NTSTRunAction.hh" |
---|
| 50 | #include "NTSTEventAction.hh" |
---|
| 51 | #include "NTSTSteppingAction.hh" |
---|
| 52 | |
---|
| 53 | #ifdef TRAP_ON_NAN_ENABLE |
---|
| 54 | #include <stdio.h> |
---|
| 55 | #include <fenv.h> |
---|
| 56 | #endif |
---|
| 57 | |
---|
| 58 | void trap_on_NaN () |
---|
| 59 | { |
---|
| 60 | #ifdef TRAP_ON_NAN_ENABLE |
---|
| 61 | // fenv_t ALL_Except(FE_ALL_EXCEPT); // fails |
---|
| 62 | fenv_t fenv_state; |
---|
| 63 | |
---|
| 64 | fegetenv(&fenv_state); |
---|
| 65 | fenv_state |= FE_ALL_EXCEPT; |
---|
| 66 | // fesetenv (FE_NOMASK_ENV); |
---|
| 67 | // G4cout << "Trying to set trap (signal) for NaN: using FE_NOMASK_ENV" << G4endl; |
---|
| 68 | |
---|
| 69 | // fesetenv (FE_DIVBYZERO|FE_INVALID); |
---|
| 70 | // G4cout << "Trying to set trap (signal) for NaN: using FE_DIVBYZERO and FE_INVALID" << G4endl; |
---|
| 71 | |
---|
| 72 | // fesetenv ((fenv_t *)FE_ALL_EXCEPT); |
---|
| 73 | fesetenv (ALL_Except); |
---|
| 74 | // fesetenv (&ALL_Except); |
---|
| 75 | G4cout << "Trying to set trap (signal) for NaN: using FE_ALL_EXCEPT" << G4endl; |
---|
| 76 | |
---|
| 77 | |
---|
| 78 | // fesetenv (FE_DIVBYZERO); |
---|
| 79 | // G4cout << "Trying to set trap (signal) for NaN: using FE_DIVBYZERO" << G4endl; |
---|
| 80 | |
---|
| 81 | // G4cout << "Setting trap for NaN using fpu_" << G4endl; |
---|
| 82 | // fpu_(); |
---|
| 83 | #endif |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | #include "G4TransportationManager.hh" |
---|
| 87 | #include "G4PropagatorInField.hh" |
---|
| 88 | |
---|
| 89 | int main(int argc,char** argv) { |
---|
| 90 | |
---|
| 91 | trap_on_NaN(); |
---|
| 92 | |
---|
| 93 | // Construct the default run manager |
---|
| 94 | G4RunManager * runManager = new G4RunManager; |
---|
| 95 | |
---|
| 96 | // set mandatory initialization classes |
---|
| 97 | NTSTDetectorConstruction* detector = new NTSTDetectorConstruction(); |
---|
| 98 | NTSTPhysicsList *physicsList = new NTSTPhysicsList(); |
---|
| 99 | |
---|
| 100 | // detector construction object |
---|
| 101 | runManager->SetUserInitialization(detector); |
---|
| 102 | |
---|
| 103 | runManager->SetUserInitialization(physicsList); |
---|
| 104 | |
---|
| 105 | // G4PropagatorInField* propagator= |
---|
| 106 | // G4TransportationManager::GetTransportationManager()->GetPropagatorInField(); |
---|
| 107 | // propagator->SetVerboseLevel(3); |
---|
| 108 | |
---|
| 109 | #ifdef G4VIS_USE |
---|
| 110 | // visualization manager |
---|
| 111 | G4VisManager* visManager = new NTSTVisManager; |
---|
| 112 | visManager->Initialize(); |
---|
| 113 | #endif |
---|
| 114 | |
---|
| 115 | // set user action classes |
---|
| 116 | runManager->SetUserAction(new NTSTPrimaryGeneratorAction); |
---|
| 117 | runManager->SetUserAction(new NTSTRunAction); |
---|
| 118 | runManager->SetUserAction(new NTSTEventAction); |
---|
| 119 | runManager->SetUserAction(new NTSTSteppingAction); |
---|
| 120 | |
---|
| 121 | // get the pointer to the User Interface manager |
---|
| 122 | G4UImanager* UI = G4UImanager::GetUIpointer(); |
---|
| 123 | |
---|
| 124 | if (argc==1) // Define UI terminal for interactive mode |
---|
| 125 | { |
---|
| 126 | G4UIsession * session = new G4UIterminal(new G4UItcsh); |
---|
| 127 | // UI->ApplyCommand("/control/execute prerunNTST.mac"); |
---|
| 128 | session->SessionStart(); |
---|
| 129 | delete session; |
---|
| 130 | } |
---|
| 131 | else // Batch mode |
---|
| 132 | { |
---|
| 133 | G4String command = "/control/execute "; |
---|
| 134 | G4String fileName = argv[1]; |
---|
| 135 | UI->ApplyCommand(command+fileName); |
---|
| 136 | } |
---|
| 137 | |
---|
| 138 | // job termination |
---|
| 139 | #ifdef G4VIS_USE |
---|
| 140 | delete visManager; |
---|
| 141 | #endif |
---|
| 142 | delete runManager; |
---|
| 143 | |
---|
| 144 | return 0; |
---|
| 145 | } |
---|
| 146 | |
---|