Hadr00.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 /// \file hadronic/Hadr00/Hadr00.cc
00027 /// \brief Main program of the hadronic/Hadr00 example
00028 //
00029 //
00030 // $Id$
00031 //
00032 // -------------------------------------------------------------
00033 //      GEANT4 Hadr00
00034 //
00035 //  Application demonstrating Geant4 hadronic cross sections
00036 //
00037 //  Author: V.Ivanchenko 20 June 2008
00038 //
00039 //  Modified: 
00040 //
00041 // -------------------------------------------------------------
00042 //
00043 //
00044 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00045 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00046 
00047 #include "G4RunManager.hh"
00048 #include "G4UImanager.hh"
00049 #include "Randomize.hh"
00050 
00051 #include "DetectorConstruction.hh"
00052 #include "G4PhysListFactory.hh"
00053 #include "G4VModularPhysicsList.hh"
00054 #include "PrimaryGeneratorAction.hh"
00055 
00056 #include "RunAction.hh"
00057 #include "EventAction.hh"
00058 
00059 #ifdef G4VIS_USE
00060 #include "G4VisExecutive.hh"
00061 #endif
00062 
00063 #ifdef G4UI_USE
00064 #include "G4UIExecutive.hh"
00065 #endif
00066 
00067 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00068 
00069 int main(int argc,char** argv) {
00070 
00071   //choose the Random engine
00072   CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine());
00073 
00074   //Construct the default run manager
00075   G4RunManager * runManager = new G4RunManager();
00076 
00077   //set mandatory initialization classes
00078   runManager->SetUserInitialization(new DetectorConstruction());
00079 
00080   G4PhysListFactory factory;
00081   G4VModularPhysicsList* phys = 0;
00082   G4String physName = "";
00083 
00084   // Physics List name defined via 3nd argument
00085   if (argc==3) { physName = argv[2]; }
00086 
00087   // Physics List is defined via environment variable PHYSLIST
00088   if("" == physName) {
00089     char* path = getenv("PHYSLIST");
00090     if (path) { physName = G4String(path); }
00091   }
00092 
00093   // if name is not known to the factory use FTFP_BERT
00094   if("" == physName || !factory.IsReferencePhysList(physName)) {
00095     physName = "QGSP_BERT"; 
00096   }
00097 
00098   // reference PhysicsList via its name
00099   phys = factory.GetReferencePhysList(physName);
00100 
00101   runManager->SetUserInitialization(phys);
00102 
00103   runManager->SetUserAction(new PrimaryGeneratorAction());
00104 
00105   //set user action classes
00106   runManager->SetUserAction(new RunAction());
00107   runManager->SetUserAction(new EventAction());
00108 
00109   //get the pointer to the User Interface manager
00110   G4UImanager* UImanager = G4UImanager::GetUIpointer();
00111 #ifdef G4VIS_USE
00112   G4VisManager* visManager = 0;
00113 #endif
00114 
00115   if (argc==1)   // Define UI terminal for interactive mode
00116     {
00117 #ifdef G4VIS_USE
00118       //visualization manager
00119       visManager = new G4VisExecutive;
00120       visManager->Initialize();
00121 #endif
00122 #ifdef G4UI_USE
00123       G4UIExecutive* ui = new G4UIExecutive(argc, argv);
00124       ui->SessionStart();
00125       delete ui;
00126 #endif
00127     }
00128   else           // Batch mode
00129     {
00130      G4String command = "/control/execute ";
00131      G4String fileName = argv[1];
00132      UImanager->ApplyCommand(command+fileName);
00133     }
00134 
00135   //job termination
00136 #ifdef G4VIS_USE
00137   delete visManager;
00138 #endif
00139   delete runManager;
00140 
00141   return 0;
00142 }
00143 
00144 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

Generated on 19 Feb 2017 for QwGeant4 by  doxygen 1.6.1