00001 00002 /* 00003 * 00004 * Copyright: Mathieu Trocme, mathieu.trocme@gmail.com (21 september 2009) 00005 * 00006 * This software is a computer program whose purpose is to: provide a universal Hit/SD output method in Geant4 with a proper Root coupling 00007 * 00008 * This software is governed by the CeCILL license under French law and abiding by the rules of distribution of free software. 00009 * You can use, modify and/or redistribute the software under the terms of the CeCILL license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". 00010 * As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability. 00011 * In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. 00012 * Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security. 00013 * 00014 * The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms. 00015 * 00016 */ 00017 00018 00019 // 00020 // Program : alpharad_new.cc 00021 // Task : Simulation of the alpharad device 00022 // Location : $G4MYSIMU (See https://sbgtrac.in2p3.fr/projects/ramses/wiki/G4_MyTuto for the list of environment variables used) 00023 // Compilation : 'cd $G4MYSIMU && make -j $NPROC' or 'rm -rf $G4TMPDIR/$G4MYSIMU_DIR $G4BINDIR/$G4MYSIMU_EXE && cd $G4MYSIMU && make -j $NPROC' # export NPROC=$(cat /proc/cpuinfo | grep "processor.*:" | wc -l) 00024 // Execution : 'cd $G4BINDIR ; [ ! -a $G4MYSIMU_MAC ] && ln -s $G4MYSIMU/$G4MYSIMU_MAC ; ./$G4MYSIMU_EXE $G4MYSIMU_MAC' 00025 // Output : See $G4BINDIR/test.root, $G4BINDIR/alpharad_new.heprep.zip 00026 // Documentation : See $G4MYSIMU/doc.html 00027 // Convention : Root coding convention: TMyClass for classes, fMyVariable for class data members, kMyVariable for constants, gMyVariable for global variables 00028 // Help : http://www.lcsim.org/software/geant4/doxygen/html/classes.html 00029 // Author : Mathieu Trocme (mathieu.trocme@ires.in2p3.fr) 00030 // Date : 21 September 2009 00031 // Framework : PhD thesis, CNRS/IPHC/DRS/RAMSES, Strasbourg, France 00032 // 00033 00034 00035 #include "G4RunManager.hh" 00036 #include "G4VisExecutive.hh" 00037 #include "G4UImanager.hh" 00038 00039 #include "TAlphaRad_DetectorConstruction.hh" 00040 #include "TAlphaRad_PhysicsList.hh" 00041 00042 #include "TGPS_PrimaryGeneratorAction.hh" 00043 00044 #include "TStandard_Analysis.hh" 00045 #include "TDummy_RunAction.hh" 00046 #include "TDummy_EventAction.hh" 00047 #include "TDummy_SteppingAction.hh" 00048 00049 #include "globals.hh" /// includes G4ios, G4Types, G4String, G4PhysicalConstants, G4SystemOfUnits, G4ExceptionSeverity, templates & algorithm 00050 00051 00052 bool gMyDebug ; /// global variable (FOR COMPILATION REASON, ROOT AND G4 TYPES CANNOT BE USED) 00053 00054 00055 int main (int argc, char** argv) 00056 { 00057 00058 ////////////////////////////// 00059 // Parsing the input line 00060 ////////////////////////////// 00061 00062 gMyDebug=false ; 00063 G4String macroFileName="" ; 00064 if ( argc == 2 || argc == 3 ) { 00065 macroFileName = G4String(argv[1]) ; 00066 FILE* fileTest = fopen (macroFileName.data(),"r") ; 00067 if ( fileTest == NULL ) { G4Exception( G4String("\n!!!\n!!! Error in main(): '" + macroFileName + "' cannot be opened or read. It may not exist. \n!!!").data() ) ; } 00068 fclose (fileTest) ; 00069 if ( argc == 3 ) { 00070 if ( G4String(argv[2]) == "debug" ) { gMyDebug=true ; } else { G4Exception("\n!!!\n!!! Error in main(): USAGE is 'alpharad_new myMacroFileName [debug]' \n!!!") ; } 00071 } 00072 } 00073 else { 00074 G4Exception( G4String("\n!!!\n!!! Error in main(): USAGE is 'alpharad_new myMacroFileName [debug]' \n!!!").data() ) ; 00075 } 00076 00077 00078 ////////////////////////////// 00079 // Declaring Managers 00080 ////////////////////////////// 00081 00082 /// Run manager 00083 00084 G4RunManager* runManager = new G4RunManager() ; 00085 00086 TAlphaRad_DetectorConstruction* theTAlphaRad_DetectorConstruction = new TAlphaRad_DetectorConstruction () ; 00087 runManager->SetUserInitialization (theTAlphaRad_DetectorConstruction) ; 00088 00089 runManager->SetUserInitialization ( new TAlphaRad_PhysicsList() ) ; 00090 00091 TGPS_PrimaryGeneratorAction* theTGPS_PrimaryGeneratorAction = new TGPS_PrimaryGeneratorAction() ; 00092 runManager->SetUserAction ( theTGPS_PrimaryGeneratorAction ) ; 00093 00094 /// Analysis Manager 00095 00096 TStandard_Analysis *analysisManager = new TStandard_Analysis(theTAlphaRad_DetectorConstruction,theTGPS_PrimaryGeneratorAction) ; 00097 runManager->SetUserAction ( new TDummy_RunAction (analysisManager) ) ; 00098 runManager->SetUserAction ( new TDummy_EventAction (analysisManager) ) ; 00099 runManager->SetUserAction ( new TDummy_SteppingAction(analysisManager) ) ; 00100 00101 runManager->Initialize() ; 00102 00103 /// Visualization manager 00104 00105 G4VisManager *visManager = new G4VisExecutive () ; 00106 visManager->Initialize (); 00107 00108 /// UI manager 00109 00110 G4UImanager* uiManager = G4UImanager::GetUIpointer() ; 00111 uiManager->ApplyCommand("/control/execute " + macroFileName) ; 00112 00113 00114 ////////////////////////////// 00115 // Cleaning 00116 ////////////////////////////// 00117 00118 delete visManager ; visManager = NULL ; 00119 delete runManager ; runManager = NULL ; 00120 //delete uiManager ; uiManager = NULL ; /// Seg. fault 00121 delete analysisManager ; analysisManager = NULL ; 00122 00123 return (0) ; 00124 00125 }