Changeset 1230 for trunk/examples/advanced/hadrontherapy
- Timestamp:
- Jan 8, 2010, 3:02:48 PM (14 years ago)
- Location:
- trunk/examples/advanced/hadrontherapy
- Files:
-
- 23 added
- 31 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/examples/advanced/hadrontherapy/GNUmakefile
r807 r1230 1 # $Id: GNUmakefile,v 1. 5 2004/11/30 09:06:18 guatelliExp $1 # $Id: GNUmakefile,v 1.12 2009/08/13 20:48:04 kaitanie Exp $ 2 2 # -------------------------------------------------------------- 3 3 # GNUmakefile for examples module. Gabriele Cosmo, 06/04/98. … … 15 15 all: lib bin 16 16 17 include $(G4INSTALL)/config/architecture.gmk 18 19 ifdef G4ANALYSIS_USE 20 CPPFLAGS += -DANALYSIS_USE 21 endif 22 ifndef G4ANALYSIS_USE # If we don't have AIDA 23 ifdef G4ANALYSIS_USE_ROOT # And we have ROOT 24 CPPFLAGS += -DANALYSIS_USE -DG4ANALYSIS_USE_ROOT 25 CPPFLAGS += $(shell root-config --cflags) 26 LDFLAGS += $(shell root-config --glibs) 27 endif 28 endif 29 17 30 include $(G4INSTALL)/config/binmake.gmk 18 31 19 ifdef G4ANALYSIS_USE 20 CPPFLAGS += `aida-config --include` 21 LDFLAGS += `aida-config --lib` 22 LOADLIBS += `aida-config --lib` 32 ifdef G4ANALYSIS_USE 23 33 endif -
trunk/examples/advanced/hadrontherapy/Hadrontherapy.cc
r807 r1230 24 24 // ******************************************************************** 25 25 // 26 // $Id: Hadrontherapy.cc Main of the Hadrontherapy example; Version 4.0 May 2005 26 // Hadrontherapy.cc 27 // 28 // Main of the Hadrontherapy example; 29 // Released with the Geant4 9.3 version (December 2009) 30 // 31 // Last modified: G.A.P.Cirrone 32 // 33 // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy 34 // 27 35 // ---------------------------------------------------------------------------- 28 36 // GEANT 4 - Hadrontherapy example … … 30 38 // Code developed by: 31 39 // 32 // G.A.P. Cirrone(a) *, F. Di Rosa(a), S. Guatelli(b), G. Russo(a)40 // G.A.P. Cirrone(a)°, G.Cuttone(a), F.Di Rosa(a), E.Mazzaglia(a), F.Romano(a) 33 41 // 42 // Contributor authors: 43 // P.Kaitaniemi(d), A.Heikkinen(d), Gillis Danielsen (d) 44 // 45 // Past authors: 46 // M.G.Pia(b), S.Guatelli(c), G.Russo(a), M.Russo(a), A.Lechner(e) 47 // 34 48 // (a) Laboratori Nazionali del Sud 35 49 // of the INFN, Catania, Italy 36 // (b) INFN Section of Genova, Genova, Italy 50 // 51 // (b) INFN Section of Genova, Italy 37 52 // 38 // * cirrone@lns.infn.it 53 // (c) University of Wallongong, Australia 54 // 55 // (d) Helsinki Institute of Physics, Helsinki, Finland 56 // 57 // (e) CERN, (CH) 58 // 59 // *Corresponding author, email to cirrone@lns.infn.it 39 60 // ---------------------------------------------------------------------------- 61 40 62 #include "G4RunManager.hh" 41 63 #include "G4UImanager.hh" 42 64 #include "G4UIterminal.hh" 43 65 #include "G4UItcsh.hh" 44 #ifdef G4UI_USE_XM45 #include "G4UIXm.hh"46 #endif47 #ifdef G4VIS_USE48 #include "G4VisExecutive.hh"49 #endif50 66 #include "HadrontherapyEventAction.hh" 51 #include "HadrontherapyDetectorConstruction.hh"52 67 #include "HadrontherapyPhysicsList.hh" 53 #include "Hadrontherapy PhantomSD.hh"68 #include "HadrontherapyDetectorSD.hh" 54 69 #include "HadrontherapyPrimaryGeneratorAction.hh" 55 70 #include "HadrontherapyRunAction.hh" … … 61 76 #include "globals.hh" 62 77 #include "HadrontherapySteppingAction.hh" 63 #ifdef G4ANALYSIS_USE64 78 #include "HadrontherapyAnalysisManager.hh" 65 #endif 66 79 #include "HadrontherapyGeometryController.hh" 80 #include "HadrontherapyGeometryMessenger.hh" 81 #include "HadrontherapyInteractionParameters.hh" 82 #include "G4ScoringManager.hh" 83 #include "IAEAScoreWriter.hh" 84 85 #if defined(G4UI_USE_TCSH) 86 #include "G4UIterminal.hh" 87 #include "G4UItcsh.hh" 88 #endif 89 90 #ifdef G4UI_USE_XM 91 #include "G4UIXm.hh" 92 #endif 93 94 #ifdef G4VIS_USE 95 #include "G4VisExecutive.hh" 96 #endif 97 98 #ifdef G4UI_USE_QT 99 #include "G4UIQt.hh" 100 #include "G4Qt.hh" 101 #endif 102 103 ////////////////////////////////////////////////////////////////////////////////////////////// 67 104 int main(int argc ,char ** argv) 68 105 { 69 70 106 // Set the Random engine 71 72 107 CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine()); 73 108 74 109 G4RunManager* runManager = new G4RunManager; 75 110 76 // Initialize the geometry 77 runManager -> SetUserInitialization(new HadrontherapyDetectorConstruction()); 78 111 //Initialize possible analysis needs, needs to come early in order to pick up metadata 112 #ifdef ANALYSIS_USE 113 HadrontherapyAnalysisManager* analysis = HadrontherapyAnalysisManager::getInstance(); 114 analysis -> book(); 115 #endif 116 // Geometry controller is responsible for instantiating the 117 // geometries. All geometry specific setup tasks are now in class 118 // HadrontherapyGeometryController. 119 HadrontherapyGeometryController *geometryController = new HadrontherapyGeometryController(); 120 121 // Connect the geometry controller to the G4 user interface 122 HadrontherapyGeometryMessenger *geometryMessenger = new HadrontherapyGeometryMessenger(geometryController); 123 124 G4ScoringManager *scoringManager = G4ScoringManager::GetScoringManager(); 125 scoringManager->SetVerboseLevel(1); 126 scoringManager->SetScoreWriter(new IAEAScoreWriter()); 127 128 // Initialize the default Hadrontherapy geometry 129 geometryController->SetGeometry("default"); 130 131 // Initialize command based scoring 132 G4ScoringManager::GetScoringManager(); 133 79 134 // Initialize the physics 80 135 runManager -> SetUserInitialization(new HadrontherapyPhysicsList()); 136 137 // Initialize the primary particles 138 HadrontherapyPrimaryGeneratorAction *pPrimaryGenerator = new HadrontherapyPrimaryGeneratorAction(); 139 runManager -> SetUserAction(pPrimaryGenerator); 81 140 82 // Initialize the primary particles83 runManager -> SetUserAction(new HadrontherapyPrimaryGeneratorAction());84 85 // Initialize matrix86 HadrontherapyMatrix* matrix = new HadrontherapyMatrix();87 matrix -> Initialize();88 89 141 // Optional UserActions: run, event, stepping 90 142 HadrontherapyRunAction* pRunAction = new HadrontherapyRunAction(); 91 143 runManager -> SetUserAction(pRunAction); 92 144 93 HadrontherapyEventAction* pEventAction = new HadrontherapyEventAction( matrix);145 HadrontherapyEventAction* pEventAction = new HadrontherapyEventAction(); 94 146 runManager -> SetUserAction(pEventAction); 95 96 147 97 148 HadrontherapySteppingAction* steppingAction = new HadrontherapySteppingAction(pRunAction); 98 149 runManager -> SetUserAction(steppingAction); 99 150 100 101 #ifdef G4ANALYSIS_USE 102 HadrontherapyAnalysisManager* analysis = 103 HadrontherapyAnalysisManager::getInstance(); 104 analysis -> book(); 105 #endif 106 151 // Interaction data: stopping powers 152 HadrontherapyInteractionParameters* pInteraction = new HadrontherapyInteractionParameters(); 153 107 154 #ifdef G4VIS_USE 108 155 // Visualization manager 109 156 G4VisManager* visManager = new G4VisExecutive; 110 157 visManager -> Initialize(); 111 #endif 158 #endif 159 160 G4UImanager* UI = G4UImanager::GetUIpointer(); 112 161 162 if (argc!=1) // batch mode 163 { 164 G4String command = "/control/execute "; 165 G4String fileName = argv[1]; 166 UI->ApplyCommand(command+fileName); 167 } 168 169 else // interactive mode : define visualization UI terminal 170 { 171 G4UIsession* session = 0; 172 173 // If the enviroment variable for the TCSH terminal is active, it is used and the 174 // defaultMacro.mac file is executed 175 #if defined(G4UI_USE_TCSH) 176 session = new G4UIterminal(new G4UItcsh); 177 UI->ApplyCommand("/control/execute defaultMacro.mac"); 178 179 // Alternatively (if G4UI_USE_TCSH is not defined) the program search for the 180 // G$UI_USE_QT variable. It starts a graphical user interface based on the QT libraries 181 // In the following case the GUI.mac file is also executed 182 // 183 #elif defined(G4UI_USE_QT) 184 session = new G4UIQt(argc,argv); 185 UI->ApplyCommand("/control/execute macro/GUI.mac"); 186 187 // As final option, the simpler user interface terminal is opened 188 #else 189 session = new G4UIterminal(); 190 UI->ApplyCommand("/control/execute defaultMacro.mac"); 191 #endif 192 session->SessionStart(); 193 delete session; 194 } 195 HadrontherapyMatrix* matrix = HadrontherapyMatrix::getInstance(); 196 if (matrix) matrix -> TotalEnergyDeposit(); 197 198 #ifdef ANALYSIS_USE 199 analysis -> finish(); 200 #endif 201 202 // Job termination 203 #ifdef G4VIS_USE 204 delete visManager; 205 #endif 113 206 114 G4UIsession* session = 0; 115 if (argc == 1) // Define UI session for interactive mode. 116 { 117 session = new G4UIterminal(); 118 } 119 120 // Get the pointer to the User Interface manager 121 G4UImanager* UI = G4UImanager::GetUIpointer(); 122 if (session) // Define UI session for interactive mode. 123 { 124 G4cout<<" UI session starts ..."<< G4endl; 125 UI -> ApplyCommand("/control/execute defaultMacro.mac"); 126 session -> SessionStart(); 127 delete session; 128 } 129 else // Batch mode 130 { 131 G4String command = "/control/execute "; 132 G4String fileName = argv[1]; 133 UI -> ApplyCommand(command + fileName); 134 } 135 136 matrix -> TotalEnergyDeposit(); 137 138 #ifdef G4ANALYSIS_USE 139 analysis -> finish(); 140 #endif 141 142 // Job termination 143 #ifdef G4VIS_USE 144 delete visManager; 145 #endif 146 207 delete geometryMessenger; 208 delete geometryController; 209 delete pInteraction; 147 210 delete runManager; 148 149 211 return 0; 150 212 } -
trunk/examples/advanced/hadrontherapy/History
r807 r1230 1 ----------------------------------------------------------- 2 $Id: History, v 1.6 2004/02/27 G.A.P. Cirrone 3 ----------------------------------------------------------- 4 5 ==================================================== 6 Geant4 - Hadrontherapy 7 ==================================================== 8 9 Category History file 1 ------------------------------------------------------------------------------- 2 History File, 2004/02/27 G.A.P. Cirrone, Created 3 cirrone@lns.infn.it 4 http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy 5 ------------------------------------------------------------------------------- 6 7 ==================================================== 8 History file of the Hadrontherapy application 9 ==================================================== 10 11 25.11.2009 S.E.Mazzaglia & F.Romano; Tag:Hadrontherapy-V09-02-40 12 - Corrected a bug in HadrontherapyDetectorConstruction class 13 - Added G4RadiactiveDecayPhysics class to the Physics List. 14 15 22.11.2009 S.E.Mazzaglia; Tag: Hadrontherapy-V09-02-39 16 - Correction in the initialization of the passiveProtonBeamLine class. 17 18 20.11.2009 P.Kaitaniemi; Tag: hadrontherapy-V09-02-38 19 - Fixes and updates to the analysis scripts in RootScripts/iaeaBenchmark 20 - Updated RootScripts/README 21 22 19.11.2009 G.A.P.Cirrone; Tag: hadrontherapy-V09-02-37 23 - Minor revisions; 24 25 18.11.2009 G.A.P.Cirrone; Tag: hadrontherapy-V09-02-36 26 - Correction for a missing function in the HadrontherapyPhysicsListMessenger.cc class file 27 28 18.11.2009 G.A.P.Cirrone; Tag: hadrontherapy-V09-02-35 29 - Updated the README file and general code revision for the 30 Geant4 9.3 release 31 32 17.11.2009 S.E.Mazzaglia; Tag: hadrontherapy-V09-02-34 33 - Added some functionalities in order to change, via messengers, the geometry, the voxelization 34 of the detector, and the disposition in the space of the detector/phantom. 35 - Added the possibility to calculate the stopping powers for ions too. 36 - Modified the HadrontherapyDetectorROGeometry class constructor. 37 - Various additions and fixes to the matrix class. 38 39 10.11.2009 G.A.P.Cirrone; Tag: hadrontherapy-V09-02-33 40 - Added the possibility to make a graphical user interface (GUI) using the QT libraries. 41 To start a GUI the correct enviroment variables must be configured (see the Geant4 installation 42 manual) and a QT version must be installed 43 44 05.10.2009 P.Kaitaniemi; Tag: hadrontherapy-V09-02-32 45 - Fixed a compilation error with GCC 4.4 46 47 28.09.2009 S.E.Mazzaglia; Tag: hadrontherapy-V09-02-31 48 - Now the HadrontherapyDetectorConstruction class implements only phantom and detector [RO]geometry. 49 World volume and the rest of the geometry is inside another class whose messenger allows 50 modification by users with the same old syntax 51 - Removed HadrontherapyInteractionParameters from the HadrontherapyGeometryController class 52 53 20.09.2009 P.Kaitaniemi; Tag: hadrontherapy-V09-02-30 54 - Added ability to use command based scoring 55 - IAEA geometry: produce Bragg peak using command based scoring 56 - Various additions and fixes to the IAEA ROOT scripts 57 - Additional data extracted from E. Haettner's thesis 58 59 20.09.2009 P.Kaitaniemi; Tag: hadrontherapy-V09-02-29 60 - Moved HadrontherapyInteractionParameters initialization to the HadrontherapyGeometryController class 61 62 11.09.2009 G.A.P.Cirrone; Tag: hadrontherapy-V09-02-28 63 - Added messengers to control the event number and to draw only particular tracks. 64 The new command are accessible via the command /event/drawTracks and /event/PrintEventNumber 65 66 08.09.2009 S.E.Mazzaglia; Tag: hadrontherapy-V09-02-27 67 - Added a method to retrieve stopping power values for protons, alphas and electrons. 68 This method is implemented in the new class HadrontherapyInteractionParameters 69 70 13.08.2009 P.Kaitaniemi; Tag: hadrontherapy-V09-02-26 71 - Fixed compilation errors when AIDA analysis is used 72 73 03.08.2009 P.Kaitaniemi; Tag: hadrontherapy-V09-02-25 74 - Added ability to select the geometry using G4 macro commands 75 - Improved plotting scripts and improved normalization for the 76 fragment energy distribution 77 78 27.07.2009 P.Kaitaniemi; Tag: hadrontherapy-V09-02-24 79 - IAEA geometry: added ability to remove the phantom by setting its thickness to zero 80 - Collect simulation metadata: number of events, distance of the detector (IAEA geometry), 81 depth of the phantom (IAEA geometry), beam energy, energy error 82 - Added ability to produce angular distribution plots 83 84 17.07.2009 P.Kaitaniemi; Tag: hadrontherapy-V09-02-23 85 - Tuned geometry of the E. Haettner experimet (IAEADetectorConstruction) 86 - Adopted G4ANALYSIS_USE_ROOT flag to activate ROOT analysis 87 - Improved plotting scripts 88 89 13.07.2009 P.Kaitaniemi; Tag: hadrontherapy-V09-02-22 90 - Added the first version of the IAEA benchmark geometry based on 91 E. Haettner's thesis 92 - Collect fragment energy distributions 93 - Added fragment energy distribution data 94 - ROOT script preparing an IAEA benchmark figure with data 95 96 08.07.2009 G.A.P.Cirrone; Tag: hadrontherapy-V09-02-21 97 - Removed the README file in ASCII format 98 99 27.06.2009 G.A.P.Cirrone; Tag: hadrontherapy-V09-02-20 100 - Eliminated not necessary dependences in the SteppingAction class 101 - Added folders containing experimental data (its name is 'experimentalData') and 102 ROOT scripts ('RootScripts') where Root scripts are stored to 103 perform a fast comparison with experimental data. 104 A folder where simulation results are stored is also created. Its 105 name is 'simulationResults'. 106 107 27.06.2009 P. Kaitaniemi; Tag hadrontherapy-V09-02-19 108 - Added ability to change the name of the output file between runs 109 110 26.06.2009 P. Kaitaniemi; Tag hadrontherapy-V09-02-18 111 - Fixed a bug in the physics list. Local ion-ion hadronic physics was not loaded due 112 to an uninitialized variable (locIonIonInelasticIsRegistered) 113 - Ability to use /analysis/setAnalysisFile <filename> to set the name of the output file 114 - Added Doxygen documentation tags to the source code and Doxyfile for 115 documentation settings 116 - Support for direct use of ROOT for analysis in addition to the default AIDA one 117 - Local INCL/ABLA physics list for deuterons, tritons and alphas 118 119 26.06.2009 G.A.P.Cirrone; Tag hadrontherapy-V09-02-17 120 - Corrected the definition of total inelastic cross section for light ions in the 121 LocalIonIonInelasticPhysic.cc file 122 123 26.06.2009 G.A.P.Cirrone; Tag: hadrontherapy-V09-02-16 124 - Momentarely removed the class for LET calculation 125 for a conflict with the general structure of Hadrontherapy 126 127 10.06.2009 G.A.P.Cirrone; Tag: hadrontherapy-V09-02-15 128 - Corrected a bug in the detector construction 129 130 05.06.2009 G.A.P.Cirrone and S.Mazzaglia; Tag: hadrontherapy-V09-02-14 131 - Added a preliminary version of classes for LET calculation. 132 133 30.05.2009 G.A.P.Cirrone; Tag hadrontherapy-V09-02-13 134 - README_Hadrontherapy.pdf file updated and improved 135 136 29.05.2009 G.A.P.Cirrone; Tag hadrontherapy-V09-02-12 137 - Implemented the new Low energy models (Livermore and Penelope) 138 now migrated to the new interface (common to the Standard models) 139 Livermore and Penelope models can be implemented: 140 Activating the buit-in physics lists (G4EmLivermorePhysics and G4EmPenelopePhysics) 141 Activation can be done via macro commands in the usual way 142 143 19.05.2009 F.Romano; Tag hadrontherapy-V09-02-11 144 - Corrected the stepMax value in each macro in order to avoid 145 a wrong dose deposition in the first slice. 146 - Modified and revised the README and macro files. 147 148 15.05.2009 G.A.P.Cirrone; Tag hadrontherapy-V09-02-10 149 - Corrected a but in the call of a physic list 150 - Corrected a bug in the proton_therapy.mac file 151 152 14.05.2009 G.A.P.Cirrone; Tag hadrontherapy-V09-02-09 153 - Definitively added the StepMax class to change the max step lenght 154 155 14.05.2009 G.A.P.Cirrone; Tag: hadrontherapy-V09-02-08 156 - README file improved. 157 158 14.05.2009 G.A.P.Cirrone; Tag: hadrontherapy-V09-02-07 159 - Physic implementation completely changed. Now Hadrontherapy can be launched 160 with physics lists, packages and built-in physic models; 161 In the README we give some suggestion in the physic models to use. 162 All models can be activated via macro command. 163 - Improved HadrontherapyModulator.cc file; 164 165 29.03.2009 G.A.P.Cirrone; Tag: hadrontehrapy-V09-02-06 166 - Extended limits of Binary Cascade in HIProtonNeutronBinary.cc 167 - Corrected and improved "default" macro file. 168 - Improved HadrontherapyDetectorConstruction.cc file; 169 - Comments on HIProtonneutronPrecompound.cc file; 170 - Improved physicsHadronicPrecompound.mac file; 171 172 18.03.2009 G.A.P.Cirrone; Tag: hadrontherapy-V09-02-05 173 - Corrected macro file for the use of the QGSP_BIC package 174 175 18.03.2009: G.A.P.Cirrone; Tag: hadrontherapy-V09-02-04 176 - Added commands to Detector Messenger to give the possibility to choose beetween 177 different beam lines 178 - Added comments to HadrontherapyMatrix; 179 _ Improved code and added comments to HIProtonNeutronPrecompound and 180 HIProtonNeutronBinary; 181 - Corrected macro file using the Precompound inelastic model; 182 - Removed the class file HadrontherapyMaterial and improved all the geometry files 183 184 05.03.2009: G.A.P.Cirrone; Tag: hadrontherapy-V09-02-03 185 - Updated README 186 187 02.03.2009: G.A.P.Cirrone; Tag: hadrontherapy-V09-02-02 188 - Changed name of HadrontherapyBeamLine file to PassiveProtonBeamLine 189 190 02.03.2009: G.A.P.Cirrone; Tag: hadrontherapy-V09-02-01 191 - Added generation of ASCII file with dose deposited in the phantom voxels 192 193 22.02.2009: G.Folger; Tag: hadrontherapy-V09-02-00 194 - Fix a compilation warning on used ionShenCrossSection in 195 HIIonLEP.cc 196 197 20.11.2008: G.A.P.Cirrone and M.Russo; Tag: hadrontherapy-V09-01-11 198 - Fixed path of macro files 199 200 20.11.2008: G.A.P.Cirrone; Tag: hadrontherapy-V09-01-10 201 - Updated the History file 202 - Corrected cross sections definitions for ions 203 - Revised the definition and use of the electromagnetic options 204 for the use with the Standard models 205 206 20.11.2008: G.A.P.Cirrone and M.Russo; Tag: hadrontherapy-V09-01-09 207 - Updated readme and improved the comments. 208 209 20.11.2008: G.A.P.Cirrone and M.Russo; Tag: hadrontherapy-V09-01-08 210 - Add new approach for the choice of the physic models. 211 Now packaged physic lists can be used alternatively 212 to the the physic models implemented in the class files 213 EM, HE and HI. 214 - Improved the electromagnetic models for the generic ions 215 216 22.09.2008 G.A.P.Cirrone; Tag: hadrontherapy-V09-01-07 217 - Corrected the G4eBremsstrahlung() process in the file 218 EMElectronStandard.cc; 219 - Updated the head of the History file; 220 221 17.09.2008 A.Lechner; Tag: hadrontherapy-V09-01-06 222 - Corrections in the Low Energy Electromagnetic physic lists. 223 224 15.06.2008 G.A.P.Cirrone; Tag: hadrontherapy-V09-01-05 225 - Removed AIDA call from GNUmakefile 226 227 19.05.2008 G.A.P.Cirrone tag hadrontherapy-V09-01-04 228 - Added in the beam line the MOPI detector. MOPI is a microstrip 229 detector that, in the real case, is able to check during 230 the treatment, the beam simmetry of the therapy beam. 231 Its physical structure is here exactly simulated so that 232 the its contribute to the energy loss can be take into account; 233 A detailed description if the detector can be found in 234 NIM A 572 (2007) 1094-1101 and its references. 235 - Corrected the position of the Phantom and Detector; 236 - Added variables to the HadrontherapyBeamLine.cc file; 237 - Added comments to the HadrontherapyBeamLine.cc file 238 to improve the clearness. 239 - Updated the README file. 240 - Changed the default dimensions of histogram bins 241 (from 200 um to 100 um). 242 243 09.03.2008 G.A.P.Cirrone tag hadrontherapy-V09-01-03 244 - Completed the update of the new beam line 245 246 09.03.2008 G.A.P.Cirrone tag hadrontherapy-V09-01-02 247 - Added comments to the PhysicsList class; 248 - Eliminated not used production cuts in PhysicsList; 249 - Added NIST definition materials in Material class; 250 - Code review of the DetectorConstruction class; 251 - Changed name of the volume where the energy deposited is collected 252 from "phantom" to "detector". "Detector" is a more appropiate 253 name. 254 - Changed name of the volume where the detector is inserted from 255 "patient" to the more appropriate "Water Phantom"; 256 257 03.03.2008 G.A.P.Cirrone tag hadrontherapy-V09-01-01 258 - Added the generation of .root file; 259 - Removed a segmentation due to an uncorect pointer 260 in the EMHadronIonStandard class; 261 - Added options for an accurate use of Standard electromagnetic models 262 in the EMHadronIonStandard, EMElectronStandard, 263 EMPositronStandard, EMPhotonStandard and EMMuonStandard classes; 264 - Added a macro file (physicsElectromagneticStandard.mac) 265 for the use of Hadrontherapy with the Standard Electromagnetic models; 266 - Corrected in the defaultMacro.mac, a wrong command for the 267 activation of the Standard Electromagnetic models; 268 269 29.02.2007 G.A.P.Cirrone tag hadrontherapy-V09-01-00 270 - Updated README 10 271 11 272 16.11.2007 Anton Lechner tag hadrontherapy-V09-00-00 … … 31 292 32 293 07.05.2007 G.A.P. Cirrone (hadrontherapy-V08-02-02) 33 - Geometry upgrade(hadrontherapyBeamLine class) according to the experimental CATANA34 294 - Geometry upgrade(hadrontherapyBeamLine class) according 295 to the experimental CATANA proton therapy beam line; 35 296 36 297 23.04.2007 S. Guatelli (hadrontherapy-V08-02-01) -
trunk/examples/advanced/hadrontherapy/defaultMacro.mac
r807 r1230 1 #---------------------------------------------------------------------------- 2 # DEFAULT MACRO FOR THE 3 # HADRONTHERAPY EXAMPLE 1 # G.A.P.Cirrone 4 2 # 3 # Default macro file. It is called if no argument is provided at run 4 # 5 # i.e. simply typing $G4WORKDIR/bin/Linux-++/Hadrontherapy <no argument here!> 5 6 # 6 # THIS MACRO SIMPLY PERMIT TO RUN A SIMULATION 7 # WITHOUT THE VISUALISATION 7 # This macro can be used for a proton beam in water. Both electrmagnetic and 8 # hadronic models are swiched on 9 10 ######################### 11 # Set of the verboses 8 12 # 9 # THE RANGE SHIFTER MATERIAL AND THICKNESS CAN BE SPECIFIED10 #11 # NOTE THAT THE MODULATOR MATERIAL IS POLTMETHYLMETHACRILATE12 # (PMMA) FOR DEFAULT. IF ONE WANT CARRY OUT A SIMULATION WITHOUT13 # THE MODULATOR HE/SHE MUST SET "Air" the <<ModMater>> in the14 # <<GetMater>> function of the HadrontherapyModulator.cc class15 #16 # USERS SHOULD GIVE A LOOK TO THE HELP OF THE IDLE TO KNOW17 # THE ACTIVATED MESSSENGERS FOR THE GEOMETRY18 #19 # ADDITIONAL INFORMATIONS ON THE MESSENGER AVAILABLE CAN BE FOUND20 # INSIDE THE HADRONTHERAPY DOCUMENTATION (http://www.ge.infn.it/geant4/examples/).21 #22 # ANYWAY SEND ME AN E-MAIL FOR ANY QUESTION: cirrone@lns.infn.it.23 # --------------------------------------------------------------------------------24 25 26 13 /control/verbose 1 27 14 /tracking/verbose 0 28 /run/verbose 015 /run/verbose 1 29 16 /event/verbose 0 30 17 31 # SETTING FOR THE PHYSICS MODELS 32 /physics/addPhysics Decay 33 /physics/addPhysics EM-Photon-EPDL 34 /physics/addPhysics EM-Electron-EEDL 35 /physics/addPhysics EM-Positron-Standard 36 /physics/addPhysics EM-HadronIon-LowE 37 /physics/addPhysics EM-Muon-Standard 38 /physics/addPhysics HadronicEl-HadronIon-LElastic 39 /physics/addPhysics HadronicInel-ProtonNeutron-LEP 40 /physics/addPhysics HadronicInel-Ion-LEP 41 /physics/addPhysics HadronicInel-Pion-LEP 42 /physics/addPhysics HadronicAtRest-MuonMinus-Capture 18 ########################## 19 # Set of the physic models 20 # 21 /physic/addPhysics emstandard_opt3 # Electromagnetic model 22 /physic/addPhysics elastic # Hadronic elastic model 23 /physic/addPhysics binary # Hadronic inelastic model 24 /physic/addPhysics local_ion_ion_inelastic # Hadronic inelastic model for ions (local physic list) 43 25 44 # FIX THE FOLLOWIG PARAMETERS 45 # TO SET THE RANGE SHIFTER 46 #/beamLine/RangeShifter/thickness 4 cm 47 #/beamLine/RangeShifter/RSMat Water 48 #/tracking/verbose 1 49 # SET OF THE VISUALISATION CHARACTERISTICS 26 ########################## 27 # Initialisation procedure 28 # 29 /run/initialize 30 31 ########################## 32 # Visualisation 33 # 50 34 /vis/scene/create 35 #/vis/open OGLIQt # only if QT library are installed 51 36 /vis/open OGLIX 52 37 /vis/viewer/flush 38 /vis/viewer/set/viewpointThetaPhi 30 140 deg 39 /vis/viewer/zoom 1 40 /vis/viewer/pan -10 0 cm 53 41 /tracking/storeTrajectory 1 54 /vis/scene/endOfEventAction accumulate 42 #/vis/scene/endOfEventAction accumulate 43 /vis/scene/endOfEventAction accumulate -1 55 44 /vis/viewer/update 56 /run/beamOn 10057 45 46 ########################## 47 # Set here the cut and the step max for the tracking. 48 # Suggested values of cut and step: 49 # 50 /physic/setCuts 0.01 mm 51 /Step/waterPhantomStepMax 0.01 mm 58 52 53 ######################### 54 # Set the primary particle type, 55 # energy and position along the X direction 56 # 57 /gun/particle proton 58 /beam/energy/meanEnergy 62 MeV 59 /beam/energy/sigmaEnergy 400 keV 60 /beam/position/Xposition -2700 mm 59 61 62 ######################### 63 # Display the event number 64 # during the run 65 # 66 /event/printEventNumber 10 60 67 61 62 63 64 65 66 67 68 ######################### 69 # Start of the run 70 # 71 /run/beamOn 10 -
trunk/examples/advanced/hadrontherapy/include/Decay.hh
r807 r1230 24 24 // ******************************************************************** 25 25 // 26 // $Id: HadrontherapyDetectorMessenger.hh; May 2005 27 // ---------------------------------------------------------------------------- 28 // GEANT 4 - Hadrontherapy example 29 // ---------------------------------------------------------------------------- 30 // Code developed by: 31 // 32 // G.A.P. Cirrone(a)*, F. Di Rosa(a), S. Guatelli(b), G. Russo(a) 33 // 34 // (a) Laboratori Nazionali del Sud 35 // of the INFN, Catania, Italy 36 // (b) INFN Section of Genova, Genova, Italy 37 // 38 // * cirrone@lns.infn.it 39 // ---------------------------------------------------------------------------- 26 // $Id: HadrontherapyDetectorMessenger.hh; 27 // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy 40 28 41 29 // ============================== -
trunk/examples/advanced/hadrontherapy/include/HadrontherapyAnalysisManager.hh
r807 r1230 24 24 // ******************************************************************** 25 25 // 26 // ---------------------------------------------------------------------------- 27 // $Id: HadrontherapyAnalysisManager.hh; May 2005 28 // ---------------------------------------------------------------------------- 29 // GEANT 4 - Hadrontherapy example 30 // ---------------------------------------------------------------------------- 31 // Code developed by: 32 // 33 // G.A.P. Cirrone(a)*, F. Di Rosa(a), S. Guatelli(b), G. Russo(a) 34 // 35 // (a) Laboratori Nazionali del Sud 36 // of the INFN, Catania, Italy 37 // (b) INFN Section of Genova, Genova, Italy 38 // 39 // * cirrone@lns.infn.it 40 // ---------------------------------------------------------------------------- 41 42 #ifdef G4ANALYSIS_USE 26 // HadrontherapyAnalysisManager.hh; May 2005 27 // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy 28 43 29 #ifndef HADRONTHERAPYANALYSISMANAGER_HH 44 30 #define HADRONTHERAPYANALYSISMANAGER_HH 1 45 31 46 32 #include "globals.hh" 47 # include <AIDA/AIDA.h> 33 34 #ifdef ANALYSIS_USE ///< If we use analysis 35 36 #ifdef G4ANALYSIS_USE ///< If analysis is done via AIDA 37 #include <AIDA/AIDA.h> 48 38 49 39 namespace AIDA{ 50 class ITree; 40 class ITree; 51 41 class IAnalysisFactory; 52 42 class ITreeFactory; 53 43 } 54 44 #endif 45 46 #ifdef G4ANALYSIS_USE_ROOT ///< If analysis is done directly with ROOT 47 #include "TROOT.h" 48 #include "TFile.h" 49 #include "TNtuple.h" 50 #include "TH1F.h" 51 #endif 52 53 /** 54 * Messenger class for analysis-settings for HadronTherapyAnalysisManager 55 */ 56 class HadrontherapyAnalysisFileMessenger; 57 58 /** 59 * A class for connecting the simulation to an analysis package. 60 */ 55 61 class HadrontherapyAnalysisManager 56 62 { 57 63 private: 64 /** 65 * Analysis manager is a singleton object (there is only one instance). 66 * The pointer to this object is available through the use of the method getInstance(); 67 * 68 * @see getInstance 69 */ 58 70 HadrontherapyAnalysisManager(); 59 71 60 72 public: 61 73 ~HadrontherapyAnalysisManager(); 74 75 /** 76 * Get the pointer to the analysis manager. 77 */ 78 static HadrontherapyAnalysisManager* getInstance(); 79 80 /** 81 * Book the histograms and ntuples in an AIDA or ROOT file. 82 */ 83 void book(); 84 /** 85 * Set name for the analysis file .root (used by macro) 86 */ 87 void SetAnalysisFileName(G4String); 62 88 63 static HadrontherapyAnalysisManager* getInstance(); 64 65 void book(); 66 // Book the histograms and ntuples in a .hbk file 67 68 void FillEnergyDeposit(G4int voxelXId, G4int voxelYId, G4int voxelZId, 89 /** 90 * Fill the ntuple with the energy deposit in the phantom 91 */ 92 void FillEnergyDeposit(G4int voxelXId, G4int voxelYId, G4int voxelZId, 69 93 G4double energyDeposit); 70 // Fill the ntuple with the energy deposit in the phantom 71 72 void BraggPeak(G4int, G4double); 73 // Fill 1D histogram with the Bragg peak in the phantom 94 95 void BraggPeak(G4int, G4double); ///< Fill 1D histogram with the Bragg peak in the phantom 74 96 75 97 void SecondaryProtonEnergyDeposit(G4int slice, G4double energy); 76 // Fill 1D histogram with the energy deposit of secondary protons98 ///< Fill 1D histogram with the energy deposit of secondary protons 77 99 78 100 void SecondaryNeutronEnergyDeposit(G4int slice, G4double energy); 79 // Fill 1D histogram with the energy deposit of secondary neutrons101 ///< Fill 1D histogram with the energy deposit of secondary neutrons 80 102 81 103 void SecondaryAlphaEnergyDeposit(G4int slice, G4double energy); 82 // Fill 1D histogram with the energy deposit of secondary alpha particles104 ///< Fill 1D histogram with the energy deposit of secondary alpha particles 83 105 84 106 void SecondaryGammaEnergyDeposit(G4int slice, G4double energy); 85 // Fill 1D histogram with the energy deposit of secondary gamma107 ///< Fill 1D histogram with the energy deposit of secondary gamma 86 108 87 109 void SecondaryElectronEnergyDeposit(G4int slice, G4double energy); 88 // Fill 1D histogram with the energy deposit of secondary electrons110 ///< Fill 1D histogram with the energy deposit of secondary electrons 89 111 90 112 void SecondaryTritonEnergyDeposit(G4int slice, G4double energy); 91 // Fill 1D histogram with the energy deposit of secondary tritons113 ///< Fill 1D histogram with the energy deposit of secondary tritons 92 114 93 115 void SecondaryDeuteronEnergyDeposit(G4int slice, G4double energy); 94 // Fill 1D histogram with the energy deposit of secondary deuterons116 ///< Fill 1D histogram with the energy deposit of secondary deuterons 95 117 96 118 void SecondaryPionEnergyDeposit(G4int slice, G4double energy); 97 // Fill 1D histogram with the energy deposit of secondary pions119 ///< Fill 1D histogram with the energy deposit of secondary pions 98 120 99 121 void electronEnergyDistribution(G4double secondaryParticleKineticEnergy); 100 // Energy distribution of secondary electrons originated in the phantom122 ///< Energy distribution of secondary electrons originated in the phantom 101 123 102 124 void gammaEnergyDistribution(G4double secondaryParticleKineticEnergy); 103 // Energy distribution of secondary gamma originated in the phantom125 ///< Energy distribution of secondary gamma originated in the phantom 104 126 105 127 void deuteronEnergyDistribution(G4double secondaryParticleKineticEnergy); 106 // Energy distribution of secondary deuterons originated in the phantom128 ///< Energy distribution of secondary deuterons originated in the phantom 107 129 108 130 void tritonEnergyDistribution(G4double secondaryParticleKineticEnergy); 109 // Energy distribution of secondary tritons originated in the phantom131 ///< Energy distribution of secondary tritons originated in the phantom 110 132 111 133 void alphaEnergyDistribution(G4double secondaryParticleKineticEnergy); 112 // Energy distribution of secondary alpha originated in the phantom 134 ///< Energy distribution of secondary alpha originated in the phantom 135 136 void heliumEnergy(G4double secondaryParticleKineticEnergy); 137 ///< Energy distribution of the helium (He3 and alpha) particles after the phantom 138 139 void hydrogenEnergy(G4double secondaryParticleKineticEnergy); 140 ///< Energy distribution of the hydrogen (proton, d, t) particles after the phantom 141 142 void fillFragmentTuple(G4int A, G4double Z, G4double energy, G4double posX, G4double posY, G4double posZ); 143 ///< Energy ntuple 113 144 114 145 void genericIonInformation(G4int, G4double, G4int, G4double); 115 146 147 void ThintargetBeamDisp(G4double,G4double); 148 149 void startNewEvent(); 150 ///< Tell the analysis manager that a new event is starting 151 152 void setGeometryMetaData(G4double, G4double, G4double); 153 ///< from the detector construction information about the geometry can be written as metadata 154 155 void setBeamMetaData(G4double, G4double); 156 ///< metadata about the beam can be written this way 157 116 158 void finish(); 117 // Close the .hbk file with the histograms and the ntuples 159 ///< Close the .hbk file with the histograms and the ntuples 160 161 void flush(); 162 163 #ifdef G4ANALYSIS_USE_ROOT 164 private: 165 TH1F *createHistogram1D(const TString name, const TString title, int bins, double xmin, double xmax) { 166 TH1F *histo = new TH1F(name, title, bins, xmin, xmax); 167 histo->SetLineWidth(2); 168 return histo; 169 } 170 #endif 118 171 119 172 private: 120 173 static HadrontherapyAnalysisManager* instance; 174 HadrontherapyAnalysisFileMessenger* fMess; 175 G4String analysisFileName; 176 #ifdef G4ANALYSIS_USE 121 177 AIDA::IAnalysisFactory* aFact; 122 AIDA::ITree* theTree; 178 AIDA::ITree* theTree; 123 179 AIDA::IHistogramFactory *histFact; 124 180 AIDA::ITupleFactory *tupFact; … … 129 185 AIDA::IHistogram1D *h5; 130 186 AIDA::IHistogram1D *h6; 131 AIDA::IHistogram1D *h7; 132 AIDA::IHistogram1D *h8; 187 AIDA::IHistogram1D *h7; 188 AIDA::IHistogram1D *h8; 133 189 AIDA::IHistogram1D *h9; 134 190 AIDA::IHistogram1D *h10; 135 191 AIDA::IHistogram1D *h11; 136 AIDA::IHistogram1D *h12; 137 AIDA::IHistogram1D *h13; 192 AIDA::IHistogram1D *h12; 193 AIDA::IHistogram1D *h13; 138 194 AIDA::IHistogram1D *h14; 195 AIDA::IHistogram1D *h15; 196 AIDA::IHistogram1D *h16; 139 197 AIDA::ITuple *ntuple; 140 198 AIDA::ITuple *ionTuple; 199 AIDA::ITuple *fragmentTuple; 200 #endif 201 #ifdef G4ANALYSIS_USE_ROOT 202 TFile *theTFile; 203 TH1F *histo1; 204 TH1F *histo2; 205 TH1F *histo3; 206 TH1F *histo4; 207 TH1F *histo5; 208 TH1F *histo6; 209 TH1F *histo7; 210 TH1F *histo8; 211 TH1F *histo9; 212 TH1F *histo10; 213 TH1F *histo11; 214 TH1F *histo12; 215 TH1F *histo13; 216 TH1F *histo14; 217 TH1F *histo15; 218 TH1F *histo16; 219 220 TNtuple *theROOTNtuple; 221 TNtuple *theROOTIonTuple; 222 TNtuple *fragmentNtuple; // fragments 223 TNtuple *metaData; 224 #endif 225 G4long eventCounter; // Simulation metadata 226 G4double detectorDistance; 227 G4double phantomDepth; 228 G4double beamEnergy; 229 G4double energyError; 230 G4double phantomCenterDistance; 141 231 }; 142 232 #endif 143 #endif 144 233 234 #endif 235 -
trunk/examples/advanced/hadrontherapy/include/HadrontherapyDetectorConstruction.hh
r807 r1230 24 24 // ******************************************************************** 25 25 // 26 // $Id: HadrontherapyDetectorConstruction.hh; Version 4.0 May 2005 27 // ---------------------------------------------------------------------------- 28 // GEANT 4 - Hadrontherapy example 29 // ---------------------------------------------------------------------------- 30 // Code developed by: 31 // 32 // G.A.P. Cirrone(a)*, F. Di Rosa(a), S. Guatelli(b), G. Russo(a) 33 // 34 // (a) Laboratori Nazionali del Sud 35 // of the INFN, Catania, Italy 36 // (b) INFN Section of Genova, Genova, Italy 37 // 38 // * cirrone@lns.infn.it 39 // ---------------------------------------------------------------------------- 26 // HadrontherapyDetectorConstruction.hh; 27 // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy// 40 28 41 29 #ifndef HadrontherapyDetectorConstruction_H 42 30 #define HadrontherapyDetectorConstruction_H 1 43 31 32 #include "G4Box.hh" 44 33 #include "globals.hh" 45 #include "G4VUserDetectorConstruction.hh" 34 #include "G4VisAttributes.hh" 35 #include "G4LogicalVolume.hh" 36 #include "G4UnitsTable.hh" 46 37 47 38 class G4VPhysicalVolume; 48 39 class G4LogicalVolume; 49 class HadrontherapyPhantomROGeometry; 50 class HadrontherapyBeamLine; 40 class HadrontherapyDetectorROGeometry; 51 41 class HadrontherapyDetectorMessenger; 52 class HadrontherapyModulator; 53 class HadrontherapyPhantomSD; 54 class HadrontherapyMaterial; 42 class HadrontherapyDetectorSD; 43 class HadrontherapyMatrix; 55 44 56 class HadrontherapyDetectorConstruction : public G4VUserDetectorConstruction45 class HadrontherapyDetectorConstruction 57 46 { 58 47 public: 59 48 60 HadrontherapyDetectorConstruction( );49 HadrontherapyDetectorConstruction(G4VPhysicalVolume*); 61 50 62 51 ~HadrontherapyDetectorConstruction(); 63 52 64 G4VPhysicalVolume* Construct();65 53 66 54 private: 67 55 68 void ConstructBeamLine(); 69 // This method allows to define the beam line geometry in the 70 // experimental set-up 56 void ConstructPhantom(); 57 void ConstructDetector(); 58 void ConstructSensitiveDetector(G4ThreeVector position_respect_to_WORLD); 59 60 public: 61 // Get detector position relative to WORLD 62 inline G4ThreeVector GetDetectorToWorldPosition() 63 { 64 return phantomPosition + detectorPosition; 65 } 66 ///////////////////////////////////////////////////////////////////////////// 67 // Get displacement between phantom and detector by detector position, phantom and detector sizes 68 inline G4ThreeVector GetDetectorToPhantomPosition() 69 { 70 return G4ThreeVector(phantomSizeX - detectorSizeX + detectorPosition.getX(), 71 phantomSizeY - detectorSizeY + detectorPosition.getY(), 72 phantomSizeZ - detectorSizeZ + detectorPosition.getZ() 73 ); 74 } 71 75 72 void ConstructPhantom(); 73 // This method allows to define the phantom geometry in the 74 // experimental set-up 75 76 void ConstructSensitiveDetector(); 77 // The sensitive detector is associated to the phantom volume 76 ///////////////////////////////////////////////////////////////////////////// 77 // Calculate (and set) detector position by displacement, phantom and detector sizes 78 inline void SetDetectorPosition() 79 { 80 // Adjust detector position 81 detectorPosition.setX(detectorToPhantomPosition.getX() - phantomSizeX + detectorSizeX); 82 detectorPosition.setY(detectorToPhantomPosition.getY() - phantomSizeY + detectorSizeY); 83 detectorPosition.setZ(detectorToPhantomPosition.getZ() - phantomSizeZ + detectorSizeZ); 84 85 if (detectorPhysicalVolume) detectorPhysicalVolume -> SetTranslation(detectorPosition); 86 } 87 ///////////////////////////////////////////////////////////////////////////// 88 // Check whether detector is inside phantom 89 inline bool IsInside(G4double detectorHalfX, 90 G4double detectorHalfY, 91 G4double detectorHalfZ, 92 G4double phantomHalfX, 93 G4double phantomHalfY, 94 G4double phantomHalfZ, 95 G4ThreeVector detectorToPhantomPosition) 96 { 97 // Dimensions check... X Y and Z 98 // Firstly check what dimension we are modifying 99 if (detectorHalfX > 0. && phantomHalfX > 0. && detectorToPhantomPosition.getX() >=0.) 100 { 101 if (detectorHalfX > phantomHalfX) 102 { 103 G4cout << "Error: Detector X dimension must be smaller or equal to the corrispondent of the phantom" << G4endl; 104 return false; 105 } 106 if ( 2*(phantomHalfX - detectorHalfX) < detectorToPhantomPosition.getX()) 107 { 108 G4cout << "Error: X dimension doesn't fit with detector to phantom relative position" << G4endl; 109 return false; 110 } 111 } 78 112 79 public: 113 if (detectorHalfY > 0. && phantomHalfY > 0.&& detectorToPhantomPosition.getY() >=0.) 114 { 115 if (detectorHalfY > phantomHalfY) 116 { 117 G4cout << "Error: Detector Y dimension must be smaller or equal to the corrispondent of the phantom" << G4endl; 118 return false; 119 } 120 if ( 2*(phantomHalfY - detectorHalfY) < detectorToPhantomPosition.getY()) 121 { 122 G4cout << "Error: Y dimension doesn't fit with detector to phantom relative position" << G4endl; 123 return false; 124 } 125 } 80 126 81 void SetModulatorAngle(G4double angle); 82 // This method allows moving the modulator through UI commands 127 if (detectorHalfZ > 0. && phantomHalfZ > 0.&& detectorToPhantomPosition.getZ() >=0.) 128 { 129 if (detectorHalfZ > phantomHalfZ) 130 { 131 G4cout << "Error: Detector Z dimension must be smaller or equal to the corrispondent of the phantom" << G4endl; 132 return false; 133 } 134 if ( 2*(phantomHalfZ - detectorHalfZ) < detectorToPhantomPosition.getZ()) 135 { 136 G4cout << "Error: Z dimension doesn't fit with detector to phantom relative position" << G4endl; 137 return false; 138 } 139 } 140 /* 141 G4cout << "Displacement between Phantom and Detector is: "; 142 G4cout << "DX= "<< G4BestUnit(detectorToPhantomPosition.getX(),"Length") << 143 "DY= "<< G4BestUnit(detectorToPhantomPosition.getY(),"Length") << 144 "DZ= "<< G4BestUnit(detectorToPhantomPosition.getZ(),"Length") << G4endl; 145 */ 146 return true; 147 } 148 ///////////////////////////////////////////////////////////////////////////// 83 149 84 void SetRangeShifterXPosition(G4double translation); 85 // This method allows to move the Range Shifter along 86 // the X axis through UI commands 150 G4bool SetNumberOfVoxelBySize(G4double sizeX, G4double sizeY, G4double sizeZ); 151 G4bool SetDetectorSize(G4double sizeX, G4double sizeY, G4double sizeZ); 152 G4bool SetPhantomSize(G4double sizeX, G4double sizeY, G4double sizeZ); 153 G4bool SetPhantomPosition(G4ThreeVector); 154 G4bool SetDetectorToPhantomPosition(G4ThreeVector DetectorToPhantomPosition); 155 G4LogicalVolume* GetDetectorLogicalVolume(){ return detectorLogicalVolume;} 87 156 88 void SetRangeShifterXSize(G4double halfSize);89 // This method allows to change the size of the range shifter along90 // the X axis through UI command.91 157 92 void SetFirstScatteringFoilSize(G4double halfSize); 93 // This method allows to change the size of the first scattering foil 94 // along the X axis through UI command. 158 private: 95 159 96 void SetSecondScatteringFoilSize (G4double halfSize); 97 // This method allows to change the size of the second scattering foil 98 // along the X axis through UI command. 160 HadrontherapyDetectorMessenger* detectorMessenger; 99 161 100 void SetOuterRadiusStopper (G4double value); 101 // This method allows to change the size of the outer radius of the stopper 102 // through UI command. 162 G4VisAttributes* skyBlue; 163 G4VisAttributes* red; 103 164 104 void SetInnerRadiusFinalCollimator (G4double value); 105 // This method allows to change the size of the inner radius of the 106 // final collimator through UI command. 165 G4VPhysicalVolume* motherPhys; 107 166 108 void SetRSMaterial(G4String material);109 // This method allows to change the material110 // of the range shifter through UI command.167 HadrontherapyDetectorSD* detectorSD; // Pointer to sensitive detector 168 HadrontherapyDetectorROGeometry* detectorROGeometry; // Pointer to ROGeometry 169 HadrontherapyMatrix* matrix; 111 170 112 G4 double ComputeVoxelSize() {return phantomSizeX/numberOfVoxelsAlongX;};113 // Returns the size of the voxel along the X axis114 115 private: 171 G4VPhysicalVolume* phantomPhysicalVolume; 172 G4LogicalVolume* phantomLogicalVolume; 173 G4LogicalVolume* detectorLogicalVolume; 174 G4VPhysicalVolume* detectorPhysicalVolume; 116 175 117 HadrontherapyPhantomSD* phantomSD; // Pointer to sensitive detector118 119 HadrontherapyPhantomROGeometry* phantomROGeometry; // Pointer to ROGeometry120 121 HadrontherapyBeamLine* beamLine; // Pointer to the beam line122 // geometry component123 124 HadrontherapyModulator* modulator; // Pointer to the modulator125 // geometry component126 127 G4VPhysicalVolume* physicalTreatmentRoom;128 G4VPhysicalVolume* patientPhysicalVolume;129 G4LogicalVolume* phantomLogicalVolume;130 G4VPhysicalVolume* phantomPhysicalVolume;131 132 HadrontherapyDetectorMessenger* detectorMessenger;133 HadrontherapyMaterial* material;134 135 176 G4double phantomSizeX; 136 177 G4double phantomSizeY; 137 178 G4double phantomSizeZ; 138 179 180 G4double detectorSizeX; 181 G4double detectorSizeY; 182 G4double detectorSizeZ; 183 184 G4ThreeVector phantomPosition, detectorPosition, detectorToPhantomPosition; // phantom center, detector center, detector to phantom relative position 185 186 G4double sizeOfVoxelAlongX; 187 G4double sizeOfVoxelAlongY; 188 G4double sizeOfVoxelAlongZ; 189 139 190 G4int numberOfVoxelsAlongX; 140 191 G4int numberOfVoxelsAlongY; 141 192 G4int numberOfVoxelsAlongZ; 193 194 G4Box* phantom; 195 G4Box* detector; 196 142 197 }; 143 198 #endif -
trunk/examples/advanced/hadrontherapy/include/HadrontherapyDetectorMessenger.hh
r807 r1230 24 24 // ******************************************************************** 25 25 // 26 // $Id: HadrontherapyDetectorMessenger.hh; May 2005 27 // ---------------------------------------------------------------------------- 28 // GEANT 4 - Hadrontherapy example 29 // ---------------------------------------------------------------------------- 30 // Code developed by: 31 // 32 // G.A.P. Cirrone(a)*, F. Di Rosa(a), S. Guatelli(b), G. Russo(a) 33 // 34 // (a) Laboratori Nazionali del Sud 35 // of the INFN, Catania, Italy 36 // (b) INFN Section of Genova, Genova, Italy 37 // 38 // * cirrone@lns.infn.it 39 // ---------------------------------------------------------------------------- 26 // HadrontherapyDetectorMessenger.hh; 27 // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy// 28 40 29 #ifndef HadrontherapyDetectorMessenger_h 41 30 #define HadrontherapyDetectorMessenger_h 1 … … 48 37 class G4UIcmdWithADoubleAndUnit; 49 38 class G4UIcmdWithAString; 39 class G4UIcmdWith3VectorAndUnit; 50 40 51 41 class HadrontherapyDetectorMessenger: public G4UImessenger … … 55 45 ~HadrontherapyDetectorMessenger(); 56 46 57 47 void SetNewValue(G4UIcommand*, G4String); 58 48 59 49 private: 60 50 61 // Pointer to the detector component51 // Pointer to the phantom/detector 62 52 HadrontherapyDetectorConstruction* hadrontherapyDetector; 63 64 G4UIdirectory* modulatorDir; // Control of the modulator65 G4UIdirectory* beamLineDir; // Control of the beam line66 67 G4UIdirectory* rangeShifterDir;68 // Control of the range shifter component of the beam line69 53 70 G4UIdirectory* firstScatteringFoilDir; 71 // Control of the first scattering foil component of the beam line 72 73 G4UIdirectory* secondScatteringFoilDir; 74 // Control of the first scattering foil component of the beam line 75 76 G4UIdirectory* rangeStopperDir; 77 // Control of the range stopper component of the beam line 78 79 G4UIdirectory* finalCollimatorDir; 80 // Control of the final collimator component of the beam line 81 82 G4UIcmdWithADoubleAndUnit* modulatorAngleCmd; 83 // UI command to rotate the modulator wheel 54 G4UIdirectory *changeThePhantomDir, *changeTheDetectorDir; 84 55 85 G4UIcmdWithAString* rangeShifterMatCmd; 86 // UI command to set the material of the rangeShifter component of 87 // the beam line 88 89 G4UIcmdWithADoubleAndUnit* rangeShifterXSizeCmd; 90 // UI command to set half of the X size of the rangeShifter component of 91 // the beam line 92 93 G4UIcmdWithADoubleAndUnit* rangeShifterXPositionCmd; 94 // UI command to change the X position of the rangeShifter component of 95 // the beam line 96 97 G4UIcmdWithADoubleAndUnit* firstScatteringFoilXSizeCmd; 98 // UI command to set half X size of the first scattering foil of 99 // the beam line 100 101 G4UIcmdWithADoubleAndUnit* secondScatteringFoilXSizeCmd; 102 // UI command to set half X size of the second scattering foil 103 // the beam line 104 105 G4UIcmdWithADoubleAndUnit* outerRadiusStopperCmd; 106 // UI command to set the outer radius of the range stopper component of 107 // the beam line 108 109 G4UIcmdWithADoubleAndUnit* innerRadiusFinalCollimatorCmd; 110 // UI command to set the inner radius of the final collimator component of 111 // the beam line 56 G4UIcmdWith3VectorAndUnit *changeThePhantomSizeCmd, 57 *changeThePhantomPositionCmd, 58 *changeTheDetectorSizeCmd, 59 *changeTheDetectorToPhantomPositionCmd, 60 *changeTheDetectorVoxelCmd; 112 61 }; 113 62 #endif -
trunk/examples/advanced/hadrontherapy/include/HadrontherapyDummySD.hh
r807 r1230 24 24 // ******************************************************************** 25 25 // 26 // ---------------------------------------------------------------------------- 27 // GEANT 4 - Hadrontherapy example 28 // ---------------------------------------------------------------------------- 29 // Code developed by: 30 // 31 // G.A.P. Cirrone(a)*, G. Candiano, F. Di Rosa(a), S. Guatelli(b), G. Russo(a) 32 // 33 // (a) Laboratori Nazionali del Sud 34 // of the National Institute for Nuclear Physics, Catania, Italy 35 // (b) National Institute for Nuclear Physics Section of Genova, genova, Italy 36 // 37 // * cirrone@lns.infn.it 38 // -------------------------------------------------------------- 26 // HadrontherapyDummySD.hh 27 // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy 39 28 40 29 #ifndef HadrontherapyDummySD_h -
trunk/examples/advanced/hadrontherapy/include/HadrontherapyEventAction.hh
r807 r1230 24 24 // ******************************************************************** 25 25 // 26 // $Id: HadrontherapyEventAction.hh; May 2005 27 // ---------------------------------------------------------------------------- 28 // GEANT 4 - Hadrontherapy example 29 // ---------------------------------------------------------------------------- 30 // Code developed by: 31 // 32 // G.A.P. Cirrone(a)*, G. Candiano, F. Di Rosa(a), S. Guatelli(b), G. Russo(a) 33 // 34 // (a) Laboratori Nazionali del Sud 35 // of the National Institute for Nuclear Physics, Catania, Italy 36 // (b) National Institute for Nuclear Physics Section of Genova, genova, Italy 37 // 38 // * cirrone@lns.infn.it 39 // -------------------------------------------------------------- 26 // HadrontherapyEventAction.hh; 27 // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy 40 28 41 29 #ifndef HadrontherapyEventAction_h … … 46 34 47 35 class HadrontherapyMatrix; 36 class HadrontherapyEventActionMessenger; 48 37 49 38 class HadrontherapyEventAction : public G4UserEventAction 50 39 { 51 40 public: 52 HadrontherapyEventAction( HadrontherapyMatrix*);41 HadrontherapyEventAction(); 53 42 ~HadrontherapyEventAction(); 54 43 … … 56 45 void BeginOfEventAction(const G4Event*); 57 46 void EndOfEventAction(const G4Event*); 58 47 48 void SetPrintModulo(G4int val) 49 { 50 printModulo = val; 51 }; 52 53 void SetDrawFlag(G4String val) 54 { 55 drawFlag = val; 56 }; 57 59 58 private: 60 59 G4String drawFlag; //Visualisation flag 61 60 G4int hitsCollectionID; 62 61 HadrontherapyMatrix *matrix; 62 G4int printModulo; 63 HadrontherapyEventActionMessenger* pointerEventMessenger; 63 64 }; 64 65 -
trunk/examples/advanced/hadrontherapy/include/HadrontherapyMatrix.hh
r807 r1230 24 24 // ******************************************************************** 25 25 // 26 // $Id: HadrontherapyMatrix.hh; May 2005 27 // ---------------------------------------------------------------------------- 28 // GEANT 4 - Hadrontherapy example 29 // ---------------------------------------------------------------------------- 30 // Code developed by: 31 // 32 // G.A.P. Cirrone(a)*, F. Di Rosa(a), S. Guatelli(b), G. Russo(a) 33 // 34 // (a) Laboratori Nazionali del Sud 35 // of the National Institute for Nuclear Physics, Catania, Italy 36 // (b) National Institute for Nuclear Physics Section of Genova, genova, Italy 37 // 38 // * cirrone@lns.infn.it 39 // ---------------------------------------------------------------------------- 26 // HadrontherapyMatrix.hh; 27 // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy 40 28 41 29 #ifndef HadrontherapyMatrix_H … … 43 31 44 32 #include "globals.hh" 33 #include <vector> 45 34 46 35 // The information: energy deposit and position in the phantom … … 49 38 class HadrontherapyMatrix 50 39 { 40 private: 41 HadrontherapyMatrix(G4int voxelX, G4int voxelY, G4int voxelZ); //<--- this is supposed to be a singleton 42 51 43 public: 52 HadrontherapyMatrix(); 44 53 45 ~HadrontherapyMatrix(); 46 // Get object instance only 47 static HadrontherapyMatrix* getInstance(); 48 // Make & Get instance 49 static HadrontherapyMatrix* getInstance(G4int nX, G4int nY, G4int nZ); 50 51 void flush(); 54 52 55 53 void Initialize(); 56 54 // All the elements of the matrix are initialised to zero 57 55 58 56 void Fill(G4int i, G4int j, G4int k, G4double energyDeposit); 59 57 // The matrix is filled with the energy deposit … … 64 62 // Store the information of the matrix in a ntuple and in 65 63 // a 1D Histogram 64 65 inline G4int Index(G4int i, G4int j, G4int k){ return (i * numberVoxelY + j) * numberVoxelZ + k; } 66 // Get a unique index from a three dimensional voxel information 66 67 67 68 private: 69 70 static HadrontherapyMatrix* instance; 68 71 G4int numberVoxelX; 69 72 G4int numberVoxelY; -
trunk/examples/advanced/hadrontherapy/include/HadrontherapyParticles.hh
r807 r1230 24 24 // ******************************************************************** 25 25 // 26 // $Id: HadrontherapyParticles.hh; May 2005 27 // ---------------------------------------------------------------------------- 28 // GEANT 4 - Hadrontherapy example 29 // ---------------------------------------------------------------------------- 30 // Code developed by: 31 // 32 // G.A.P. Cirrone(a)*, F. Di Rosa(a), S. Guatelli(b), G. Russo(a) 33 // 34 // (a) Laboratori Nazionali del Sud 35 // of the National Institute for Nuclear Physics, Catania, Italy 36 // (b) National Institute for Nuclear Physics Section of Genova, genova, Italy 37 // 38 // * cirrone@lns.infn.it 39 // ---------------------------------------------------------------------------- 26 // HadrontherapyParticles.hh; 27 // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy 40 28 41 29 #ifndef HADRONTHERAPYPARTICLES_HH -
trunk/examples/advanced/hadrontherapy/include/HadrontherapyPhysicsList.hh
r807 r1230 24 24 // ******************************************************************** 25 25 // 26 // $Id: HadrontherapyPhysicsList.hh,v 1.0 27 // ---------------------------------------------------------------------------- 28 // GEANT 4 - Hadrontherapy example 29 // ---------------------------------------------------------------------------- 30 // Code developed by: 31 // 32 // G.A.P. Cirrone(a)*, F. Di Rosa(a), S. Guatelli(b), G. Russo(a) 33 // 34 // (a) Laboratori Nazionali del Sud 35 // of the National Institute for Nuclear Physics, Catania, Italy 36 // (b) National Institute for Nuclear Physics Section of Genova, genova, Italy 37 // 38 // * cirrone@lns.infn.it 39 // ---------------------------------------------------------------------------- 40 #ifndef HADRONTHERAPYPHYSICSLIST_H 41 #define HADRONTHERAPYPHYSICSLIST_H 1 26 // HadrontherapyPhysicsList.hh 27 // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy 28 29 #ifndef HadrontherapyPhysicsList_h 30 #define HadrontherapyPhysicsList_h 1 42 31 43 32 #include "G4VModularPhysicsList.hh" 33 #include "G4EmConfigurator.hh" 44 34 #include "globals.hh" 45 35 36 class G4VPhysicsConstructor; 37 class HadrontherapyStepMax; 46 38 class HadrontherapyPhysicsListMessenger; 47 39 … … 49 41 { 50 42 public: 43 51 44 HadrontherapyPhysicsList(); 52 45 virtual ~HadrontherapyPhysicsList(); 53 46 54 virtual void SetCuts(); 55 void AddPhysicsList(const G4String& name); 56 47 void ConstructParticle(); 48 49 void SetCuts(); 50 void SetCutForGamma(G4double); 51 void SetCutForElectron(G4double); 52 void SetCutForPositron(G4double); 53 54 void AddPhysicsList(const G4String& name); 55 void ConstructProcess(); 56 57 void AddStepMax(); 58 HadrontherapyStepMax* GetStepMaxProcess() {return stepMaxProcess;}; 59 void AddPackage(const G4String& name); 60 57 61 private: 58 G4bool decayIsRegistered;59 G4bool emElectronIsRegistered;60 G4bool emPositronIsRegistered;61 G4bool emPhotonIsRegistered;62 G4bool emIonIsRegistered;63 G4bool emMuonIsRegistered;64 G4bool hadrElasticHadronIonIsRegistered;65 G4bool hadrInelasticPionIsRegistered;66 G4bool hadrInelasticIonIsRegistered;67 G4bool hadrInelasticProtonNeutronIsRegistered;68 G4bool hadrAtRestMuonIsRegistered;69 62 70 HadrontherapyPhysicsListMessenger* messenger; 63 G4EmConfigurator em_config; 64 65 G4double cutForGamma; 66 G4double cutForElectron; 67 G4double cutForPositron; 68 69 G4bool helIsRegisted; 70 G4bool bicIsRegisted; 71 G4bool biciIsRegisted; 72 G4bool locIonIonInelasticIsRegistered; 73 G4bool radioactiveDecayIsRegisted; 74 75 G4String emName; 76 G4VPhysicsConstructor* emPhysicsList; 77 G4VPhysicsConstructor* decPhysicsList; 78 std::vector<G4VPhysicsConstructor*> hadronPhys; 79 80 HadrontherapyStepMax* stepMaxProcess; 81 82 HadrontherapyPhysicsListMessenger* pMessenger; 71 83 }; 72 84 73 85 #endif 74 75 76 -
trunk/examples/advanced/hadrontherapy/include/HadrontherapyPhysicsListMessenger.hh
r807 r1230 24 24 // ******************************************************************** 25 25 // 26 // $Id: HadrontherapyPhisicsListMessenger.hh; May 2005 27 // ---------------------------------------------------------------------------- 28 // GEANT 4 - Hadrontherapy example 29 // ---------------------------------------------------------------------------- 30 // Code developed by: 31 // 32 // G.A.P. Cirrone(a)*, F. Di Rosa(a), S. Guatelli(b), G. Russo(a) 33 // 34 // (a) Laboratori Nazionali del Sud 35 // of the National Institute for Nuclear Physics, Catania, Italy 36 // (b) National Institute for Nuclear Physics Section of Genova, genova, Italy 37 // 38 // * cirrone@lns.infn.it 39 // ---------------------------------------------------------------------------- 26 // HadrontherapyPhysicsListsMessenger.hh 27 // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy 40 28 41 #ifndef H ADRONTHERAPYPHYSICSLISTMESSENGER_HH42 #define H ADRONTHERAPYPHYSICSLISTMESSENGER_HH129 #ifndef HadrontherapyPhysicsListMessenger_h 30 #define HadrontherapyPhysicsListMessenger_h 1 43 31 44 32 #include "globals.hh" … … 47 35 class HadrontherapyPhysicsList; 48 36 class G4UIdirectory; 49 class G4UIcmdWithoutParameter;50 class G4UIcmdWithADouble;51 37 class G4UIcmdWithADoubleAndUnit; 52 class G4UIcmdWithABool;53 38 class G4UIcmdWithAString; 54 39 55 class HadrontherapyPhysicsListMessenger: public G4UImessenger { 40 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 56 41 57 public: 42 class HadrontherapyPhysicsListMessenger: public G4UImessenger 43 { 44 public: 58 45 59 HadrontherapyPhysicsListMessenger(HadrontherapyPhysicsList* physList); 46 HadrontherapyPhysicsListMessenger(HadrontherapyPhysicsList* ); 47 ~HadrontherapyPhysicsListMessenger(); 48 49 void SetNewValue(G4UIcommand*, G4String); 50 51 private: 60 52 61 ~HadrontherapyPhysicsListMessenger();62 63 void SetNewValue(G4UIcommand*, G4String);64 65 private: 66 67 HadrontherapyPhysicsList* physicsList;68 G4UI directory* listDir;69 G4UIcmdWithAString* p hysicsListCmd;53 HadrontherapyPhysicsList* pPhysicsList; 54 55 G4UIdirectory* physDir; 56 G4UIcmdWithADoubleAndUnit* gammaCutCmd; 57 G4UIcmdWithADoubleAndUnit* electCutCmd; 58 G4UIcmdWithADoubleAndUnit* protoCutCmd; 59 G4UIcmdWithADoubleAndUnit* allCutCmd; 60 G4UIcmdWithAString* pListCmd; 61 G4UIcmdWithAString* packageListCmd; 70 62 }; 63 64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 71 65 72 66 #endif 73 67 74 75 76 77 78 79 80 -
trunk/examples/advanced/hadrontherapy/include/HadrontherapyPrimaryGeneratorAction.hh
r807 r1230 24 24 // ******************************************************************** 25 25 // 26 // $Id: HadrontherapyPrimaryGeneratorAction.hh; May 2005 27 // ---------------------------------------------------------------------------- 28 // GEANT 4 - Hadrontherapy example 29 // ---------------------------------------------------------------------------- 30 // Code developed by: 31 // 32 // G.A.P. Cirrone(a)*, F. Di Rosa(a), S. Guatelli(b), G. Russo(a) 33 // 34 // (a) Laboratori Nazionali del Sud 35 // of the National Institute for Nuclear Physics, Catania, Italy 36 // (b) National Institute for Nuclear Physics Section of Genova, genova, Italy 37 // 38 // * cirrone@lns.infn.it 39 // ---------------------------------------------------------------------------- 26 // HadrontherapyPrimaryGeneratorAction.hh; May 2005 27 // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy 40 28 41 29 #ifndef HadrontherapyPrimaryGeneratorAction_h … … 68 56 void SetsigmaMomentumY(G4double); 69 57 void SetsigmaMomentumZ(G4double); 58 G4double GetmeanKineticEnergy(void); 70 59 71 60 private: -
trunk/examples/advanced/hadrontherapy/include/HadrontherapyPrimaryGeneratorMessenger.hh
r807 r1230 24 24 // ******************************************************************** 25 25 // 26 // $Id: HadrontherapyPrimaryGeneratorMessenger.hh; May 2005 27 // ---------------------------------------------------------------------------- 28 // GEANT 4 - Hadrontherapy example 29 // ---------------------------------------------------------------------------- 30 // Code developed by: 31 // 32 // G.A.P. Cirrone(a)*, F. Di Rosa(a), S. Guatelli(b), G. Russo(a) 33 // 34 // (a) Laboratori Nazionali del Sud 35 // of the National Institute for Nuclear Physics, Catania, Italy 36 // (b) National Institute for Nuclear Physics Section of Genova, genova, Italy 37 // 38 // * cirrone@lns.infn.it 39 // ---------------------------------------------------------------------------- 26 // HadrontherapyPrimaryGeneratorMessenger.hh; 27 // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy 40 28 41 29 #ifndef HadrontherapyPrimaryGeneratorMessenger_h -
trunk/examples/advanced/hadrontherapy/include/HadrontherapyRunAction.hh
r807 r1230 24 24 // ******************************************************************** 25 25 // 26 // $Id: HadrontherapyRunAction.hh,v 3.0, September 2004; 27 // ---------------------------------------------------------------------------- 28 // GEANT 4 - Hadrontherapy example 29 // ---------------------------------------------------------------------------- 30 // Code developed by: 31 // 32 // G.A.P. Cirrone(a)*, F. Di Rosa(a), S. Guatelli(b), G. Russo(a) 33 // 34 // (a) Laboratori Nazionali del Sud 35 // of the INFN, Catania, Italy 36 // (b) INFN Section of Genova, Genova, Italy 37 // 38 // * cirrone@lns.infn.it 39 // ---------------------------------------------------------------------------- 26 // HadrontherapyRunAction.hh 27 // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy 40 28 41 29 #ifndef HadrontherapyRunAction_h … … 51 39 class HadrontherapyRunMessenger; 52 40 class HadrontherapyFactory; 53 class HadrontherapyFactoryIr;54 class HadrontherapyFactoryI;55 56 57 41 58 42 class HadrontherapyRunAction : public G4UserRunAction -
trunk/examples/advanced/hadrontherapy/include/HadrontherapySteppingAction.hh
r807 r1230 24 24 // ******************************************************************** 25 25 // 26 // $Id: HadrontherapyProtonSteppingAction.hh; May 2005 27 // ---------------------------------------------------------------------------- 28 // GEANT 4 - Hadrontherapy example 29 // ---------------------------------------------------------------------------- 30 // Code developed by: 31 // 32 // G.A.P. Cirrone(a)*, F. Di Rosa(a), S. Guatelli(b), G. Russo(a) 33 // 34 // (a) Laboratori Nazionali del Sud 35 // of the INFN, Catania, Italy 36 // (b) INFN Section of Genova, Genova, Italy 37 // 38 // * cirrone@lns.infn.it 39 // ---------------------------------------------------------------------------- 26 // HadrontherapyProtonSteppingAction.hh; 27 // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy 40 28 41 29 #ifndef HadrontherapySteppingAction_h -
trunk/examples/advanced/hadrontherapy/src/HadrontherapyAnalysisManager.cc
r807 r1230 24 24 // ******************************************************************** 25 25 // 26 // $Id: HadrontherapyAnalisysManager.cc; May 2005 27 // ---------------------------------------------------------------------------- 28 // GEANT 4 - Hadrontherapy example 29 // ---------------------------------------------------------------------------- 30 // Code developed by: 31 // 32 // G.A.P. Cirrone(a)*, F. Di Rosa(a), S. Guatelli(b), G. Russo(a) 33 // 34 // (a) Laboratori Nazionali del Sud 35 // of the INFN, Catania, Italy 36 // (b) INFN Section of Genova, Genova, Italy 37 // 38 // * cirrone@lns.infn.it 39 // ---------------------------------------------------------------------------- 40 41 #ifdef G4ANALYSIS_USE 26 // $Id: HadrontherapyAnalisysManager.cc; 27 // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy 28 42 29 #include "HadrontherapyAnalysisManager.hh" 43 30 #include "HadrontherapyMatrix.hh" 31 #include "HadrontherapyAnalysisFileMessenger.hh" 32 #include <time.h> 33 #ifdef ANALYSIS_USE 44 34 HadrontherapyAnalysisManager* HadrontherapyAnalysisManager::instance = 0; 45 35 46 HadrontherapyAnalysisManager::HadrontherapyAnalysisManager() : 47 aFact(0), theTree(0), histFact(0), tupFact(0), h1(0), h2(0), h3(0), 48 h4(0), h5(0), h6(0), h7(0), h8(0), h9(0), h10(0), h11(0), h12(0), h13(0), h14(0), ntuple(0), 49 ionTuple(0) 50 { 51 } 52 53 HadrontherapyAnalysisManager::~HadrontherapyAnalysisManager() 54 { 36 #ifdef G4ANALYSIS_USE_ROOT 37 #undef G4ANALYSIS_USE 38 #endif 39 40 ///////////////////////////////////////////////////////////////////////////// 41 42 #ifdef G4ANALYSIS_USE 43 HadrontherapyAnalysisManager::HadrontherapyAnalysisManager() : 44 analysisFileName("DoseDistribution.root"), aFact(0), theTree(0), histFact(0), tupFact(0), h1(0), h2(0), h3(0), 45 h4(0), h5(0), h6(0), h7(0), h8(0), h9(0), h10(0), h11(0), h12(0), h13(0), h14(0), h15(0), h16(0), ntuple(0), 46 ionTuple(0), 47 fragmentTuple(0), 48 eventCounter(0) 49 { 50 fMess = new HadrontherapyAnalysisFileMessenger(this); 51 } 52 #endif 53 #ifdef G4ANALYSIS_USE_ROOT 54 HadrontherapyAnalysisManager::HadrontherapyAnalysisManager() : 55 analysisFileName("DoseDistribution.root"),theTFile(0), histo1(0), histo2(0), histo3(0), 56 histo4(0), histo5(0), histo6(0), histo7(0), histo8(0), histo9(0), histo10(0), histo11(0), histo12(0), histo13(0), histo14(0), histo15(0), histo16(0), 57 theROOTNtuple(0), 58 theROOTIonTuple(0), 59 fragmentNtuple(0), 60 metaData(0), 61 eventCounter(0) 62 { 63 fMess = new HadrontherapyAnalysisFileMessenger(this); 64 } 65 #endif 66 ///////////////////////////////////////////////////////////////////////////// 67 HadrontherapyAnalysisManager::~HadrontherapyAnalysisManager() 68 { 69 delete(fMess); //kill the messenger 70 #ifdef G4ANALYSIS_USE 71 delete fragmentTuple; 72 fragmentTuple = 0; 73 55 74 delete ionTuple; 56 75 ionTuple = 0; 57 76 58 77 delete ntuple; 59 78 ntuple = 0; 60 79 80 delete h16; 81 h16 = 0; 82 83 delete h15; 84 h15 = 0; 85 61 86 delete h14; 62 87 h14 = 0; … … 100 125 delete h1; 101 126 h1 = 0; 102 127 103 128 delete tupFact; 104 129 tupFact = 0; … … 112 137 delete aFact; 113 138 aFact = 0; 114 } 115 139 #endif 140 #ifdef G4ANALYSIS_USE_ROOT 141 delete metaData; 142 metaData = 0; 143 144 delete fragmentNtuple; 145 fragmentNtuple = 0; 146 147 delete theROOTIonTuple; 148 theROOTIonTuple = 0; 149 150 delete theROOTNtuple; 151 theROOTNtuple = 0; 152 153 delete histo16; 154 histo14 = 0; 155 156 delete histo15; 157 histo14 = 0; 158 159 delete histo14; 160 histo14 = 0; 161 162 delete histo13; 163 histo13 = 0; 164 165 delete histo12; 166 histo12 = 0; 167 168 delete histo11; 169 histo11 = 0; 170 171 delete histo10; 172 histo10 = 0; 173 174 delete histo9; 175 histo9 = 0; 176 177 delete histo8; 178 histo8 = 0; 179 180 delete histo7; 181 histo7 = 0; 182 183 delete histo6; 184 histo6 = 0; 185 186 delete histo5; 187 histo5 = 0; 188 189 delete histo4; 190 histo4 = 0; 191 192 delete histo3; 193 histo3 = 0; 194 195 delete histo2; 196 histo2 = 0; 197 198 delete histo1; 199 histo1 = 0; 200 #endif 201 } 202 ///////////////////////////////////////////////////////////////////////////// 116 203 HadrontherapyAnalysisManager* HadrontherapyAnalysisManager::getInstance() 117 204 { … … 120 207 } 121 208 122 void HadrontherapyAnalysisManager::book() 123 { 209 ///////////////////////////////////////////////////////////////////////////// 210 void HadrontherapyAnalysisManager::SetAnalysisFileName(G4String aFileName) 211 { 212 this->analysisFileName = aFileName; 213 } 214 215 ///////////////////////////////////////////////////////////////////////////// 216 void HadrontherapyAnalysisManager::book() 217 { 218 #ifdef G4ANALYSIS_USE 124 219 // Build up the analysis factory 125 220 aFact = AIDA_createAnalysisFactory(); 126 221 AIDA::ITreeFactory* treeFact = aFact -> createTreeFactory(); 127 222 128 // Create the .hbk file 129 G4String fileName = "hadrontherapy.hbk"; 223 // Create the .hbk or the .root file 224 G4String fileName = "DoseDistribution.hbk"; 225 226 std::string opts = "export=root"; 227 130 228 theTree = treeFact -> create(fileName,"hbook",false,true); 229 theTree = treeFact -> create(analysisFileName,"ROOT",false,true,opts); 230 231 // Factories are not "managed" by an AIDA analysis system. 232 // They must be deleted by the AIDA user code. 131 233 delete treeFact; 132 234 … … 136 238 137 239 // Create the histograms with the enrgy deposit along the X axis 138 h1 = histFact -> createHistogram1D("10","slice, energy", 200, 0., 200. );139 140 h2 = histFact -> createHistogram1D("20","Secondary protons - slice, energy", 200, 0., 200. );141 142 h3 = histFact -> createHistogram1D("30","Secondary neutrons - slice, energy", 200, 0., 200. );143 144 h4 = histFact -> createHistogram1D("40","Secondary alpha - slice, energy", 200, 0., 200. );145 146 h5 = histFact -> createHistogram1D("50","Secondary gamma - slice, energy", 200, 0., 200. );147 148 h6 = histFact -> createHistogram1D("60","Secondary electron - slice, energy", 200, 0., 200. );149 150 h7 = histFact -> createHistogram1D("70","Secondary triton - slice, energy", 200, 0., 200. );151 152 h8 = histFact -> createHistogram1D("80","Secondary deuteron - slice, energy", 200, 0., 200. );153 154 h9 = histFact -> createHistogram1D("90","Secondary pion - slice, energy", 200, 0., 200. );155 240 h1 = histFact -> createHistogram1D("10","slice, energy", 400, 0., 400. ); 241 242 h2 = histFact -> createHistogram1D("20","Secondary protons - slice, energy", 400, 0., 400. ); 243 244 h3 = histFact -> createHistogram1D("30","Secondary neutrons - slice, energy", 400, 0., 400. ); 245 246 h4 = histFact -> createHistogram1D("40","Secondary alpha - slice, energy", 400, 0., 400. ); 247 248 h5 = histFact -> createHistogram1D("50","Secondary gamma - slice, energy", 400, 0., 400. ); 249 250 h6 = histFact -> createHistogram1D("60","Secondary electron - slice, energy", 400, 0., 400. ); 251 252 h7 = histFact -> createHistogram1D("70","Secondary triton - slice, energy", 400, 0., 400. ); 253 254 h8 = histFact -> createHistogram1D("80","Secondary deuteron - slice, energy", 400, 0., 400. ); 255 256 h9 = histFact -> createHistogram1D("90","Secondary pion - slice, energy", 400, 0., 400. ); 257 156 258 h10 = histFact -> createHistogram1D("100","Energy distribution of secondary electrons", 70, 0., 70. ); 157 259 158 260 h11 = histFact -> createHistogram1D("110","Energy distribution of secondary photons", 70, 0., 70. ); 159 261 160 262 h12 = histFact -> createHistogram1D("120","Energy distribution of secondary deuterons", 70, 0., 70. ); 161 263 162 264 h13 = histFact -> createHistogram1D("130","Energy distribution of secondary tritons", 70, 0., 70. ); 163 265 164 266 h14 = histFact -> createHistogram1D("140","Energy distribution of secondary alpha particles", 70, 0., 70. ); 267 268 h15 = histFact -> createHistogram1D("150","Energy distribution of helium fragments after the phantom", 70, 0., 500.); 269 270 h16 = histFact -> createHistogram1D("160","Energy distribution of hydrogen fragments after the phantom", 70, 0., 500.); 165 271 166 272 // Create the ntuple … … 173 279 G4String options2 = ""; 174 280 if (tupFact) ionTuple = tupFact -> create("2","2", columnNames2, options2); 175 } 176 177 void HadrontherapyAnalysisManager::FillEnergyDeposit(G4int i, 178 G4int j, 281 282 // Create the fragment ntuple 283 G4String columnNames3 = "int a; double z; double energy; double posX; double posY; double posZ;"; 284 G4String options3 = ""; 285 if (tupFact) fragmentTuple = tupFact -> create("3","3", columnNames3, options3); 286 #endif 287 #ifdef G4ANALYSIS_USE_ROOT 288 // Use ROOT 289 theTFile = new TFile(analysisFileName, "RECREATE"); 290 291 // Create the histograms with the energy deposit along the X axis 292 histo1 = createHistogram1D("braggPeak","slice, energy", 400, 0., 27.9); //<different waterthicknesses are accoutned for in ROOT-analysis stage 293 histo2 = createHistogram1D("h20","Secondary protons - slice, energy", 400, 0., 400.); 294 histo3 = createHistogram1D("h30","Secondary neutrons - slice, energy", 400, 0., 400.); 295 histo4 = createHistogram1D("h40","Secondary alpha - slice, energy", 400, 0., 400.); 296 histo5 = createHistogram1D("h50","Secondary gamma - slice, energy", 400, 0., 400.); 297 histo6 = createHistogram1D("h60","Secondary electron - slice, energy", 400, 0., 400.); 298 histo7 = createHistogram1D("h70","Secondary triton - slice, energy", 400, 0., 400.); 299 histo8 = createHistogram1D("h80","Secondary deuteron - slice, energy", 400, 0., 400.); 300 histo9 = createHistogram1D("h90","Secondary pion - slice, energy", 400, 0., 400.); 301 histo10 = createHistogram1D("h100","Energy distribution of secondary electrons", 70, 0., 70.); 302 histo11 = createHistogram1D("h110","Energy distribution of secondary photons", 70, 0., 70.); 303 histo12 = createHistogram1D("h120","Energy distribution of secondary deuterons", 70, 0., 70.); 304 histo13 = createHistogram1D("h130","Energy distribution of secondary tritons", 70, 0., 70.); 305 histo14 = createHistogram1D("h140","Energy distribution of secondary alpha particles", 70, 0., 70.); 306 histo15 = createHistogram1D("heliumEnergyAfterPhantom","Energy distribution of secondary helium fragments after the phantom", 307 70, 0., 500.); 308 histo16 = createHistogram1D("hydrogenEnergyAfterPhantom","Energy distribution of secondary helium fragments after the phantom", 309 70, 0., 500.); 310 311 theROOTNtuple = new TNtuple("theROOTNtuple", "Energy deposit by slice", "i:j:k:energy"); 312 theROOTIonTuple = new TNtuple("theROOTIonTuple", "Generic ion information", "a:z:occupancy:energy"); 313 fragmentNtuple = new TNtuple("fragmentNtuple", "Fragments", "A:Z:energy:posX:posY:posZ"); 314 metaData = new TNtuple("metaData", "Metadata", "events:detectorDistance:waterThickness:beamEnergy:energyError:phantomCenterDistance"); 315 #endif 316 } 317 318 ///////////////////////////////////////////////////////////////////////////// 319 void HadrontherapyAnalysisManager::FillEnergyDeposit(G4int i, 320 G4int j, 179 321 G4int k, 180 322 G4double energy) 181 323 { 324 #ifdef G4ANALYSIS_USE 182 325 if (ntuple) { 183 326 G4int iSlice = ntuple -> findColumn("i"); … … 185 328 G4int kSlice = ntuple -> findColumn("k"); 186 329 G4int iEnergy = ntuple -> findColumn("energy"); 187 330 188 331 ntuple -> fill(iSlice,i); 189 ntuple -> fill(jSlice,j); 332 ntuple -> fill(jSlice,j); 190 333 ntuple -> fill(kSlice,k); 191 334 ntuple -> fill(iEnergy, energy); } 192 335 193 ntuple -> addRow(); 194 } 195 336 ntuple -> addRow(); 337 #endif 338 #ifdef G4ANALYSIS_USE_ROOT 339 if (theROOTNtuple) { 340 theROOTNtuple->Fill(i, j, k, energy); 341 } 342 #endif 343 } 344 345 ///////////////////////////////////////////////////////////////////////////// 196 346 void HadrontherapyAnalysisManager::BraggPeak(G4int slice, G4double energy) 197 347 { 348 #ifdef G4ANALYSIS_USE 198 349 h1 -> fill(slice,energy); 199 } 200 350 #endif 351 #ifdef G4ANALYSIS_USE_ROOT 352 histo1->SetBinContent(slice, energy); //This uses setbincontent instead of fill to get labels correct 353 #endif 354 } 355 356 ///////////////////////////////////////////////////////////////////////////// 201 357 void HadrontherapyAnalysisManager::SecondaryProtonEnergyDeposit(G4int slice, G4double energy) 202 358 { 359 #ifdef G4ANALYSIS_USE 203 360 h2 -> fill(slice,energy); 204 } 205 361 #endif 362 #ifdef G4ANALYSIS_USE_ROOT 363 histo2->Fill(slice, energy); 364 #endif 365 } 366 367 ///////////////////////////////////////////////////////////////////////////// 206 368 void HadrontherapyAnalysisManager::SecondaryNeutronEnergyDeposit(G4int slice, G4double energy) 207 369 { 370 #ifdef G4ANALYSIS_USE 208 371 h3 -> fill(slice,energy); 209 } 210 372 #endif 373 #ifdef G4ANALYSIS_USE_ROOT 374 histo3->Fill(slice, energy); 375 #endif 376 } 377 378 ///////////////////////////////////////////////////////////////////////////// 211 379 void HadrontherapyAnalysisManager::SecondaryAlphaEnergyDeposit(G4int slice, G4double energy) 212 380 { 381 #ifdef G4ANALYSIS_USE 213 382 h4 -> fill(slice,energy); 214 } 215 383 #endif 384 #ifdef G4ANALYSIS_USE_ROOT 385 histo4->Fill(slice, energy); 386 #endif 387 } 388 389 ///////////////////////////////////////////////////////////////////////////// 216 390 void HadrontherapyAnalysisManager::SecondaryGammaEnergyDeposit(G4int slice, G4double energy) 217 391 { 392 #ifdef G4ANALYSIS_USE 218 393 h5 -> fill(slice,energy); 219 } 220 394 #endif 395 #ifdef G4ANALYSIS_USE_ROOT 396 histo5->Fill(slice, energy); 397 #endif 398 } 399 400 ///////////////////////////////////////////////////////////////////////////// 221 401 void HadrontherapyAnalysisManager::SecondaryElectronEnergyDeposit(G4int slice, G4double energy) 222 402 { 403 #ifdef G4ANALYSIS_USE 223 404 h6 -> fill(slice,energy); 224 } 225 405 #endif 406 #ifdef G4ANALYSIS_USE_ROOT 407 histo6->Fill(slice, energy); 408 #endif 409 } 410 411 ///////////////////////////////////////////////////////////////////////////// 226 412 void HadrontherapyAnalysisManager::SecondaryTritonEnergyDeposit(G4int slice, G4double energy) 227 413 { 414 #ifdef G4ANALYSIS_USE 228 415 h7 -> fill(slice,energy); 229 } 230 416 #endif 417 #ifdef G4ANALYSIS_USE_ROOT 418 histo7->Fill(slice, energy); 419 #endif 420 } 421 422 ///////////////////////////////////////////////////////////////////////////// 231 423 void HadrontherapyAnalysisManager::SecondaryDeuteronEnergyDeposit(G4int slice, G4double energy) 232 424 { 425 #ifdef G4ANALYSIS_USE 233 426 h8 -> fill(slice,energy); 234 } 235 427 #endif 428 #ifdef G4ANALYSIS_USE_ROOT 429 histo8->Fill(slice, energy); 430 #endif 431 } 432 433 ///////////////////////////////////////////////////////////////////////////// 236 434 void HadrontherapyAnalysisManager::SecondaryPionEnergyDeposit(G4int slice, G4double energy) 237 435 { 436 #ifdef G4ANALYSIS_USE 238 437 h9 -> fill(slice,energy); 239 } 240 438 #endif 439 #ifdef G4ANALYSIS_USE_ROOT 440 histo9->Fill(slice, energy); 441 #endif 442 } 443 444 ///////////////////////////////////////////////////////////////////////////// 241 445 void HadrontherapyAnalysisManager::electronEnergyDistribution(G4double energy) 242 446 { 447 #ifdef G4ANALYSIS_USE 243 448 h10 -> fill(energy); 244 } 245 449 #endif 450 #ifdef G4ANALYSIS_USE_ROOT 451 histo10->Fill(energy); 452 #endif 453 } 454 455 ///////////////////////////////////////////////////////////////////////////// 246 456 void HadrontherapyAnalysisManager::gammaEnergyDistribution(G4double energy) 247 457 { 458 #ifdef G4ANALYSIS_USE 248 459 h11 -> fill(energy); 249 } 250 460 #endif 461 #ifdef G4ANALYSIS_USE_ROOT 462 histo11->Fill(energy); 463 #endif 464 } 465 466 ///////////////////////////////////////////////////////////////////////////// 251 467 void HadrontherapyAnalysisManager::deuteronEnergyDistribution(G4double energy) 252 468 { 469 #ifdef G4ANALYSIS_USE 253 470 h12 -> fill(energy); 254 } 255 471 #endif 472 #ifdef G4ANALYSIS_USE_ROOT 473 histo12->Fill(energy); 474 #endif 475 } 476 477 ///////////////////////////////////////////////////////////////////////////// 256 478 void HadrontherapyAnalysisManager::tritonEnergyDistribution(G4double energy) 257 479 { 480 #ifdef G4ANALYSIS_USE 258 481 h13 -> fill(energy); 259 } 260 482 #endif 483 #ifdef G4ANALYSIS_USE_ROOT 484 histo13->Fill(energy); 485 #endif 486 } 487 488 ///////////////////////////////////////////////////////////////////////////// 261 489 void HadrontherapyAnalysisManager::alphaEnergyDistribution(G4double energy) 262 490 { 491 #ifdef G4ANALYSIS_USE 263 492 h14 -> fill(energy); 264 } 265 266 void HadrontherapyAnalysisManager::genericIonInformation(G4int a, 267 G4double z, 493 #endif 494 #ifdef G4ANALYSIS_USE_ROOT 495 histo14->Fill(energy); 496 #endif 497 } 498 ///////////////////////////////////////////////////////////////////////////// 499 void HadrontherapyAnalysisManager::heliumEnergy(G4double secondaryParticleKineticEnergy) 500 { 501 #ifdef G4ANALYSIS_USE 502 h15->fill(secondaryParticleKineticEnergy); 503 #endif 504 #ifdef G4ANALYSIS_USE_ROOT 505 histo15->Fill(secondaryParticleKineticEnergy); 506 #endif 507 } 508 509 ///////////////////////////////////////////////////////////////////////////// 510 void HadrontherapyAnalysisManager::hydrogenEnergy(G4double secondaryParticleKineticEnergy) 511 { 512 #ifdef G4ANALYSIS_USE 513 h16->fill(secondaryParticleKineticEnergy); 514 #endif 515 #ifdef G4ANALYSIS_USE_ROOT 516 histo16->Fill(secondaryParticleKineticEnergy); 517 #endif 518 } 519 520 521 522 void HadrontherapyAnalysisManager::fillFragmentTuple(G4int A, G4double Z, G4double energy, G4double posX, G4double posY, G4double posZ) 523 { 524 #ifdef G4ANALYSIS_USE 525 if (fragmentTuple) { 526 G4int aIndex = fragmentTuple -> findColumn("a"); 527 G4int zIndex = fragmentTuple -> findColumn("z"); 528 G4int energyIndex = fragmentTuple -> findColumn("energy"); 529 G4int posXIndex = fragmentTuple -> findColumn("posX"); 530 G4int posYIndex = fragmentTuple -> findColumn("posY"); 531 G4int posZIndex = fragmentTuple -> findColumn("posZ"); 532 533 fragmentTuple -> fill(aIndex,A); 534 fragmentTuple -> fill(zIndex,Z); 535 fragmentTuple -> fill(energyIndex, energy); 536 fragmentTuple -> fill(posXIndex, posX); 537 fragmentTuple -> fill(posYIndex, posY); 538 fragmentTuple -> fill(posZIndex, posZ); 539 fragmentTuple -> addRow(); 540 } 541 #endif 542 #ifdef G4ANALYSIS_USE_ROOT 543 //G4cout <<" A = " << A << " Z = " << Z << " energy = " << energy << G4endl; 544 fragmentNtuple->Fill(A, Z, energy, posX, posY, posZ); 545 #endif 546 } 547 548 ///////////////////////////////////////////////////////////////////////////// 549 void HadrontherapyAnalysisManager::genericIonInformation(G4int a, 550 G4double z, 268 551 G4int electronOccupancy, 269 G4double energy) 270 { 552 G4double energy) 553 { 554 #ifdef G4ANALYSIS_USE 271 555 if (ionTuple) { 272 556 G4int aIndex = ionTuple -> findColumn("a"); 273 557 G4int zIndex = ionTuple -> findColumn("z"); 274 G4int electronIndex = ionTuple -> findColumn("occupancy"); 558 G4int electronIndex = ionTuple -> findColumn("occupancy"); 275 559 G4int energyIndex = ionTuple -> findColumn("energy"); 276 560 277 561 ionTuple -> fill(aIndex,a); 278 ionTuple -> fill(zIndex,z); 279 ionTuple -> fill(electronIndex, electronOccupancy); 562 ionTuple -> fill(zIndex,z); 563 ionTuple -> fill(electronIndex, electronOccupancy); 280 564 ionTuple -> fill(energyIndex, energy); 281 565 } 282 ionTuple -> addRow(); 283 } 284 285 void HadrontherapyAnalysisManager::finish() 286 { 566 ionTuple -> addRow(); 567 #endif 568 #ifdef G4ANALYSIS_USE_ROOT 569 if (theROOTIonTuple) { 570 theROOTIonTuple->Fill(a, z, electronOccupancy, energy); 571 } 572 #endif 573 } 574 575 ///////////////////////////////////////////////////////////////////////////// 576 void HadrontherapyAnalysisManager::startNewEvent() 577 { 578 eventCounter++; 579 } 580 ///////////////////////////////////////////////////////////////////////////// 581 void HadrontherapyAnalysisManager::setGeometryMetaData(G4double endDetectorPosition, G4double waterThickness, G4double phantomCenter) 582 { 583 this->detectorDistance = endDetectorPosition; 584 this->phantomDepth = waterThickness; 585 this->phantomCenterDistance = phantomCenter; 586 } 587 void HadrontherapyAnalysisManager::setBeamMetaData(G4double meanKineticEnergy,G4double sigmaEnergy) 588 { 589 this->beamEnergy = meanKineticEnergy; 590 this->energyError = sigmaEnergy; 591 } 592 ///////////////////////////////////////////////////////////////////////////// 593 void HadrontherapyAnalysisManager::flush() 594 { 595 HadrontherapyMatrix* matrix = HadrontherapyMatrix::getInstance(); 596 597 matrix->TotalEnergyDeposit(); 598 #ifdef G4ANALYSIS_USE 599 theTree -> commit(); 600 theTree ->close(); 601 #endif 602 #ifdef G4ANALYSIS_USE_ROOT 603 metaData->Fill((Float_t) eventCounter,(Float_t) detectorDistance, (Float_t) phantomDepth, (Float_t) beamEnergy,(Float_t) energyError, (Float_t) phantomCenterDistance); 604 metaData->Write(); 605 theROOTNtuple->Write(); 606 theROOTIonTuple->Write(); 607 fragmentNtuple->Write(); 608 theTFile->Write(); 609 // theTFile->Clear(); 610 theTFile->Close(); 611 #endif 612 eventCounter = 0; 613 matrix->flush(); 614 } 615 ///////////////////////////////////////////////////////////////////////////// 616 void HadrontherapyAnalysisManager::finish() 617 { 618 #ifdef G4ANALYSIS_USE 287 619 // Write all histograms to file 288 620 theTree -> commit(); 289 290 621 // Close (will again commit) 291 622 theTree ->close(); 292 } 293 #endif 294 295 296 297 298 299 300 301 302 303 304 623 #endif 624 #ifdef G4ANALYSIS_USE_ROOT 625 metaData->Fill((Float_t) eventCounter,(Float_t) detectorDistance, (Float_t) phantomDepth, (Float_t) beamEnergy,(Float_t) energyError, (Float_t) phantomCenterDistance); 626 metaData->Write(); 627 theROOTNtuple->Write(); 628 theROOTIonTuple->Write(); 629 fragmentNtuple->Write(); 630 theTFile->Write(); 631 theTFile->Close(); 632 #endif 633 eventCounter = 0; 634 } 635 636 #endif 637 638 639 640 641 642 643 644 645 -
trunk/examples/advanced/hadrontherapy/src/HadrontherapyDetectorConstruction.cc
r807 r1230 24 24 // ******************************************************************** 25 25 // 26 // $Id: HadrontherapyDetectorConstruction.cc; Version 4.0 May 2005 27 // ---------------------------------------------------------------------------- 28 // GEANT 4 - Hadrontherapy example 29 // ---------------------------------------------------------------------------- 30 // Code developed by: 26 // HadrontherapyDetectorConstruction.cc 31 27 // 32 // G.A.P. Cirrone(a)*, F. Di Rosa(a), S. Guatelli(b), G. Russo(a) 33 // 34 // (a) Laboratori Nazionali del Sud 35 // of the INFN, Catania, Italy 36 // (b) INFN Section of Genova, Genova, Italy 37 // 38 // * cirrone@lns.infn.it 39 // ---------------------------------------------------------------------------- 28 // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy 40 29 41 30 #include "G4SDManager.hh" … … 50 39 #include "G4Colour.hh" 51 40 #include "G4UserLimits.hh" 41 #include "G4UnitsTable.hh" 52 42 #include "G4VisAttributes.hh" 53 #include "HadrontherapyPhantomROGeometry.hh" 43 #include "G4NistManager.hh" 44 #include "HadrontherapyDetectorROGeometry.hh" 54 45 #include "HadrontherapyDetectorMessenger.hh" 55 #include "Hadrontherapy PhantomSD.hh"46 #include "HadrontherapyDetectorSD.hh" 56 47 #include "HadrontherapyDetectorConstruction.hh" 57 #include "HadrontherapyMaterial.hh" 58 #include "HadrontherapyBeamLine.hh" 59 #include "HadrontherapyModulator.hh" 60 61 HadrontherapyDetectorConstruction::HadrontherapyDetectorConstruction() 62 : phantomSD(0), phantomROGeometry(0), beamLine(0), modulator(0), 63 physicalTreatmentRoom(0), 64 patientPhysicalVolume(0), 65 phantomLogicalVolume(0), 66 phantomPhysicalVolume(0) 67 { 68 // Messenger to change parameters of the geometry 48 #include "HadrontherapyMatrix.hh" 49 50 ///////////////////////////////////////////////////////////////////////////// 51 HadrontherapyDetectorConstruction::HadrontherapyDetectorConstruction(G4VPhysicalVolume* physicalTreatmentRoom) 52 : motherPhys(physicalTreatmentRoom), 53 detectorSD(0), detectorROGeometry(0), matrix(0), 54 phantomPhysicalVolume(0), 55 detectorLogicalVolume(0), detectorPhysicalVolume(0), 56 phantomSizeX(20.*cm), phantomSizeY(20.*cm), phantomSizeZ(20.*cm), // Default half dimensions 57 detectorSizeX(2.*cm), detectorSizeY(2.*cm), detectorSizeZ(2.*cm), 58 phantomPosition(20.*cm, 0.*cm, 0.*cm), 59 detectorToPhantomPosition(0.*cm,18.*cm,18.*cm)// Default displacement of the detector respect to the phantom 60 { 61 // NOTE! that the HadrontherapyDetectorConstruction class 62 // does NOT inherit from G4VUserDetectorConstruction G4 class 63 // So the Construct() mandatory virtual method is inside another geometric class 64 // (like the passiveProtonBeamLIne, ...) 65 66 // Messenger to change parameters of the phantom/detector geometry 69 67 detectorMessenger = new HadrontherapyDetectorMessenger(this); 70 68 71 material = new HadrontherapyMaterial(); 72 73 // Phantom sizes 74 phantomSizeX = 20.*mm; 75 phantomSizeY = 20.*mm; 76 phantomSizeZ = 20.*mm; 77 78 // Number of the phantom voxels 79 numberOfVoxelsAlongX = 200; 80 numberOfVoxelsAlongY = 200; 81 numberOfVoxelsAlongZ = 200; 82 } 83 69 // Default detector voxels size 70 // 200 slabs along the beam direction (X) 71 sizeOfVoxelAlongX = 200 *um; 72 sizeOfVoxelAlongY = 2 * detectorSizeY; 73 sizeOfVoxelAlongZ = 2 * detectorSizeZ; 74 75 // Calculate (and eventually set) detector position by displacement, phantom size and detector size 76 SetDetectorPosition(); 77 78 // Build phantom and associated detector 79 ConstructPhantom(); 80 ConstructDetector(); 81 // Set number of the detector voxels along X Y and Z directions. 82 // This will construct also the sensitive detector, the ROGeometry 83 // and the matrix where the energy deposited is collected! 84 SetNumberOfVoxelBySize(sizeOfVoxelAlongX, sizeOfVoxelAlongY, sizeOfVoxelAlongZ); 85 } 86 87 ///////////////////////////////////////////////////////////////////////////// 84 88 HadrontherapyDetectorConstruction::~HadrontherapyDetectorConstruction() 85 89 { 86 delete material; 87 if (phantomROGeometry) delete phantomROGeometry; 88 delete detectorMessenger; 89 } 90 91 G4VPhysicalVolume* HadrontherapyDetectorConstruction::Construct() 90 delete detectorROGeometry;// This should be safe in C++ even if the argument is a NULL pointer 91 delete matrix; 92 delete detectorMessenger; 93 } 94 95 void HadrontherapyDetectorConstruction::ConstructPhantom() 96 { 97 //---------------------------------------- 98 // Phantom: 99 // A box used to approximate tissues 100 //---------------------------------------- 101 102 G4bool isotopes = false; 103 G4Material* waterNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_WATER", isotopes); 104 phantom = new G4Box("Phantom",phantomSizeX, phantomSizeY, phantomSizeZ); 105 phantomLogicalVolume = new G4LogicalVolume(phantom, 106 waterNist, 107 "phantomLog", 0, 0, 0); 108 109 phantomPhysicalVolume = new G4PVPlacement(0, 110 phantomPosition, 111 "phantomPhys", 112 phantomLogicalVolume, 113 motherPhys, 114 false, 115 0); 116 117 // Visualisation attributes of the phantom 118 red = new G4VisAttributes(G4Colour(255/255., 0/255. ,0/255.)); 119 red -> SetVisibility(true); 120 red -> SetForceSolid(true); 121 //red -> SetForceWireframe(true); 122 phantomLogicalVolume -> SetVisAttributes(red); 123 } 124 125 ///////////////////////////////////////////////////////////////////////////// 126 void HadrontherapyDetectorConstruction::ConstructDetector() 127 { 128 //----------- 129 // Detector 130 //----------- 131 G4bool isotopes = false; 132 G4Material* waterNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_WATER", isotopes); 133 detector = new G4Box("Detector",detectorSizeX,detectorSizeY,detectorSizeZ); 134 detectorLogicalVolume = new G4LogicalVolume(detector, 135 waterNist, 136 "DetectorLog", 137 0,0,0); 138 // Detector is attached by default to the phantom face directly exposed to the beam 139 detectorPhysicalVolume = new G4PVPlacement(0, 140 detectorPosition, // Setted by displacement 141 "DetectorPhys", 142 detectorLogicalVolume, 143 phantomPhysicalVolume, 144 false,0); 145 146 // Visualisation attributes of the detector 147 skyBlue = new G4VisAttributes( G4Colour(135/255. , 206/255. , 235/255. )); 148 skyBlue -> SetVisibility(true); 149 skyBlue -> SetForceSolid(true); 150 //skyBlue -> SetForceWireframe(true); 151 detectorLogicalVolume -> SetVisAttributes(skyBlue); 152 153 } 154 ///////////////////////////////////////////////////////////////////////////// 155 void HadrontherapyDetectorConstruction::ConstructSensitiveDetector(G4ThreeVector detectorToWorldPosition) 92 156 { 93 // Define the materials of the experimental set-up 94 material -> DefineMaterials(); 95 96 // Define the geometry components 97 ConstructBeamLine(); 98 ConstructPhantom(); 99 100 // Set the sensitive detector where the energy deposit is collected 101 ConstructSensitiveDetector(); 157 // Install new Sensitive Detector and ROGeometry 158 delete detectorROGeometry; // this should be safe in C++ also if we have a NULL pointer 159 160 // Sensitive Detector and ReadOut geometry definition 161 G4SDManager* sensitiveDetectorManager = G4SDManager::GetSDMpointer(); 162 163 G4String sensitiveDetectorName = "Detector"; 164 if (!detectorSD) 165 { 166 // The sensitive detector is instantiated 167 detectorSD = new HadrontherapyDetectorSD(sensitiveDetectorName); 168 } 169 // The Read Out Geometry is instantiated 170 G4String ROGeometryName = "DetectorROGeometry"; 171 detectorROGeometry = new HadrontherapyDetectorROGeometry(ROGeometryName, 172 detectorToWorldPosition, 173 detectorSizeX, 174 detectorSizeY, 175 detectorSizeZ, 176 numberOfVoxelsAlongX, 177 numberOfVoxelsAlongY, 178 numberOfVoxelsAlongZ); 179 180 G4cout << "Instantiating new Read Out Geometry \"" << ROGeometryName << "\""<< G4endl; 181 // This will invoke Build() HadrontherapyDetectorROGeometry virtual method 182 detectorROGeometry -> BuildROGeometry(); 183 // Attach ROGeometry to SDetector 184 detectorSD -> SetROgeometry(detectorROGeometry); 185 //sensitiveDetectorManager -> Activate(sensitiveDetectorName, true); 186 if (!sensitiveDetectorManager -> FindSensitiveDetector(sensitiveDetectorName, false)) 187 { 188 G4cout << "Registering new DetectorSD \"" << sensitiveDetectorName << "\""<< G4endl; 189 // Register user SD 190 sensitiveDetectorManager -> AddNewDetector(detectorSD); 191 // Attach SD to detector logical volume 192 detectorLogicalVolume -> SetSensitiveDetector(detectorSD); 193 } 194 } 195 196 ///////////////// 197 // MESSENGERS // 198 //////////////// 199 G4bool HadrontherapyDetectorConstruction::SetNumberOfVoxelBySize(G4double sizeX, G4double sizeY, G4double sizeZ) 200 { 201 // Only change positive dimensions 202 // XXX numberOfVoxels must be an integer, warn the user 203 204 if (sizeX > 0) 205 { 206 if (sizeX > 2*detectorSizeX) 207 { 208 G4cout << "WARNING: Voxel X size must be smaller or equal than that of detector X" << G4endl; 209 return false; 210 } 211 // Round to the nearest integer 212 numberOfVoxelsAlongX = lrint(2 * detectorSizeX / sizeX); 213 sizeOfVoxelAlongX = (2 * detectorSizeX / numberOfVoxelsAlongX ); 214 if(sizeOfVoxelAlongX!=sizeX) G4cout << "Rounding " << 215 G4BestUnit(sizeX, "Length") << " to " << 216 G4BestUnit(sizeOfVoxelAlongX, "Length") << G4endl; 217 } 218 219 if (sizeY > 0) 220 { 221 if (sizeY > 2*detectorSizeY) 222 { 223 G4cout << "WARNING: Voxel Y size must be smaller or equal than that of detector Y" << G4endl; 224 return false; 225 } 226 numberOfVoxelsAlongY = lrint(2 * detectorSizeY / sizeY); 227 sizeOfVoxelAlongY = (2 * detectorSizeY / numberOfVoxelsAlongY ); 228 if(sizeOfVoxelAlongY!=sizeY) G4cout << "Rounding " << 229 G4BestUnit(sizeY, "Length") << " to " << 230 G4BestUnit(sizeOfVoxelAlongY, "Length") << G4endl; 231 } 232 if (sizeZ > 0) 233 { 234 if (sizeZ > 2*detectorSizeZ) 235 { 236 G4cout << "WARNING: Voxel Z size must be smaller or equal than that of detector Z" << G4endl; 237 return false; 238 } 239 numberOfVoxelsAlongZ = lrint(2 * detectorSizeZ / sizeZ); 240 sizeOfVoxelAlongZ = (2 * detectorSizeZ / numberOfVoxelsAlongZ ); 241 if(sizeOfVoxelAlongZ!=sizeZ) G4cout << "Rounding " << 242 G4BestUnit(sizeZ, "Length") << " to " << 243 G4BestUnit(sizeOfVoxelAlongZ, "Length") << G4endl; 244 } 245 246 G4cout << "The (X, Y, Z) sizes of the Voxels are: (" << 247 G4BestUnit(sizeOfVoxelAlongX, "Length") << ", " << 248 G4BestUnit(sizeOfVoxelAlongY, "Length") << ", " << 249 G4BestUnit(sizeOfVoxelAlongZ, "Length") << ')' << G4endl; 250 251 G4cout << "The number of Voxels along (X,Y,Z) is: (" << 252 numberOfVoxelsAlongX << ", " << 253 numberOfVoxelsAlongY << ", " << 254 numberOfVoxelsAlongZ << ')' << G4endl; 255 256 // This will clear the existing matrix (together with data inside it)! 257 matrix = HadrontherapyMatrix::getInstance(numberOfVoxelsAlongX, 258 numberOfVoxelsAlongY, 259 numberOfVoxelsAlongZ); 260 261 // Here construct the Sensitive Detector and Read Out Geometry 262 ConstructSensitiveDetector(GetDetectorToWorldPosition()); 263 G4RunManager::GetRunManager() -> GeometryHasBeenModified(); 264 return true; 265 } 266 ///////////////////////////////////////////////////////////////////////////// 267 G4bool HadrontherapyDetectorConstruction::SetDetectorSize(G4double sizeX, G4double sizeY, G4double sizeZ) 268 { 269 // Check that the detector stay inside the phantom 270 if (sizeX > 0 && sizeX < sizeOfVoxelAlongX) {G4cout << "WARNING: Detector X size must be bigger than that of Voxel X" << G4endl; return false;} 271 if (sizeY > 0 && sizeY < sizeOfVoxelAlongY) {G4cout << "WARNING: Detector Y size must be bigger than that of Voxel Y" << G4endl; return false;} 272 if (sizeZ > 0 && sizeZ < sizeOfVoxelAlongZ) {G4cout << "WARNING: Detector Z size must be bigger than that of Voxel Z" << G4endl; return false;} 273 274 if (!IsInside(sizeX/2, 275 sizeY/2, 276 sizeZ/2, 277 phantomSizeX, 278 phantomSizeY, 279 phantomSizeZ, 280 detectorToPhantomPosition)) 281 {return false;} 282 // Negative or null values mean don't change it! 283 if (sizeX > 0) { 284 detectorSizeX = sizeX/2; 285 detector -> SetXHalfLength(detectorSizeX); 286 } 287 288 if (sizeY > 0) { 289 detectorSizeY = sizeY/2; 290 detector -> SetYHalfLength(detectorSizeY); 291 } 292 293 if (sizeZ > 0) { 294 detectorSizeZ = sizeZ/2; 295 detector -> SetZHalfLength(detectorSizeZ); 296 } 297 298 299 G4cout << "The (X, Y, Z) dimensions of the detector are : (" << 300 G4BestUnit( detector -> GetXHalfLength()*2., "Length") << ", " << 301 G4BestUnit( detector -> GetYHalfLength()*2., "Length") << ", " << 302 G4BestUnit( detector -> GetZHalfLength()*2., "Length") << ')' << G4endl; 303 // Adjust detector position 304 SetDetectorPosition(); 305 // Adjust voxels number accordingly to new detector geometry 306 // Matrix will be re-instantiated! 307 // Voxels and ROGeometry must follow the detector! 308 SetNumberOfVoxelBySize(sizeOfVoxelAlongX, sizeOfVoxelAlongY, sizeOfVoxelAlongZ); 309 G4RunManager::GetRunManager() -> GeometryHasBeenModified(); 310 return true; 311 } 312 313 ///////////////////////////////////////////////////////////////////////////// 314 G4bool HadrontherapyDetectorConstruction::SetPhantomSize(G4double sizeX, G4double sizeY, G4double sizeZ) 315 { 316 317 if (!IsInside(detectorSizeX, 318 detectorSizeY, 319 detectorSizeZ, 320 sizeX/2,//method parameters 321 sizeY/2, 322 sizeZ/2, 323 detectorToPhantomPosition 324 )) 325 return false; 326 327 // Only change positive dimensions 328 if (sizeX > 0) { 329 phantomSizeX = sizeX/2; 330 phantom -> SetXHalfLength(phantomSizeX); 331 } 332 if (sizeY > 0) { 333 phantomSizeY = sizeY/2; 334 phantom -> SetYHalfLength(phantomSizeY); 335 } 336 337 if (sizeZ > 0) { 338 phantomSizeZ = sizeZ/2; 339 phantom -> SetZHalfLength(phantomSizeZ); 340 } 102 341 103 return physicalTreatmentRoom; 104 } 105 106 void HadrontherapyDetectorConstruction::ConstructBeamLine() 107 { 108 G4Material* air = material -> GetMat("Air") ; 109 G4Material* water = material -> GetMat("Water"); 110 111 // --------------------- 112 // Treatment room - World volume 113 //--------------------- 114 115 // Treatment room sizes 116 const G4double worldX = 400.0 *cm; 117 const G4double worldY = 400.0 *cm; 118 const G4double worldZ = 400.0 *cm; 119 120 G4Box* treatmentRoom = new G4Box("TreatmentRoom",worldX,worldY,worldZ); 121 122 G4LogicalVolume* logicTreatmentRoom = new G4LogicalVolume(treatmentRoom, 123 air, 124 "logicTreatmentRoom", 125 0,0,0); 126 127 128 129 physicalTreatmentRoom = new G4PVPlacement(0, 130 G4ThreeVector(), 131 "physicalTreatmentRoom", 132 logicTreatmentRoom, 133 0,false,0); 134 135 G4double maxStepTreatmentRoom = 0.1 *mm; 136 logicTreatmentRoom -> SetUserLimits(new G4UserLimits(maxStepTreatmentRoom)); 137 138 // The treatment room is invisible in the Visualisation 139 logicTreatmentRoom -> SetVisAttributes (G4VisAttributes::Invisible); 140 141 beamLine = new HadrontherapyBeamLine(physicalTreatmentRoom); 142 beamLine -> HadrontherapyBeamLineSupport(); 143 beamLine -> HadrontherapyBeamScatteringFoils(); 144 beamLine -> HadrontherapyBeamCollimators(); 145 beamLine -> HadrontherapyBeamMonitoring(); 146 beamLine -> HadrontherapyBeamNozzle(); 147 beamLine -> HadrontherapyBeamFinalCollimator(); 148 149 modulator = new HadrontherapyModulator(); 150 modulator -> BuildModulator(physicalTreatmentRoom); 151 152 // Patient - Mother volume of the phantom 153 G4Box* patient = new G4Box("patient",20 *cm, 20 *cm, 20 *cm); 154 155 G4LogicalVolume* patientLogicalVolume = new G4LogicalVolume(patient, 156 water, 157 "patientLog", 0, 0, 0); 158 159 patientPhysicalVolume = new G4PVPlacement(0,G4ThreeVector(0., 0., 0.), 160 "patientPhys", 161 patientLogicalVolume, 162 physicalTreatmentRoom, 163 false,0); 164 165 // Visualisation attributes of the patient 166 G4VisAttributes * redWire = new G4VisAttributes(G4Colour(1. ,0. ,0.)); 167 redWire -> SetVisibility(true); 168 redWire -> SetForceWireframe(true); 169 patientLogicalVolume -> SetVisAttributes(redWire); 170 } 171 172 void HadrontherapyDetectorConstruction::ConstructPhantom() 173 { 174 G4Colour lightBlue (0.0, 0.0, .75); 175 176 G4Material* water = material -> GetMat("Water"); 177 178 //ComputeVoxelSize(); 179 180 //---------------------- 181 // Water phantom 182 //---------------------- 183 G4Box* phantom = new G4Box("Phantom",phantomSizeX,phantomSizeY,phantomSizeZ); 184 185 phantomLogicalVolume = new G4LogicalVolume(phantom, 186 water, 187 "PhantomLog", 188 0,0,0); 189 190 // Fixing the max step allowed in the phantom 191 G4double maxStep = 0.01 *mm; 192 phantomLogicalVolume -> SetUserLimits(new G4UserLimits(maxStep)); 193 194 G4double phantomXtranslation = -180.*mm; 195 phantomPhysicalVolume = new G4PVPlacement(0, 196 G4ThreeVector(phantomXtranslation, 0.0 *mm, 0.0 *mm), 197 "PhantomPhys", 198 phantomLogicalVolume, 199 patientPhysicalVolume, 200 false,0); 201 202 // Visualisation attributes of the phantom 203 G4VisAttributes* simpleBoxVisAttributes = new G4VisAttributes(lightBlue); 204 simpleBoxVisAttributes -> SetVisibility(true); 205 simpleBoxVisAttributes -> SetForceSolid(true); 206 phantomLogicalVolume -> SetVisAttributes(simpleBoxVisAttributes); 207 208 // ************** 209 // Cut per Region 210 // ************** 211 212 // A smaller cut is fixed in the phantom to calculate the energy deposit with the 213 // required accuracy 214 G4Region* aRegion = new G4Region("PhantomLog"); 215 phantomLogicalVolume -> SetRegion(aRegion); 216 aRegion -> AddRootLogicalVolume(phantomLogicalVolume); 217 } 218 219 void HadrontherapyDetectorConstruction::ConstructSensitiveDetector() 220 { 221 // Sensitive Detector and ReadOut geometry definition 222 G4SDManager* sensitiveDetectorManager = G4SDManager::GetSDMpointer(); 223 224 G4String sensitiveDetectorName = "Phantom"; 225 226 if(!phantomSD) 227 { 228 // The sensitive detector is instantiated 229 phantomSD = new HadrontherapyPhantomSD(sensitiveDetectorName); 230 231 // The Read Out Geometry is instantiated 232 G4String ROGeometryName = "PhantomROGeometry"; 233 phantomROGeometry = new HadrontherapyPhantomROGeometry(ROGeometryName, 234 phantomSizeX, 235 phantomSizeY, 236 phantomSizeZ, 237 numberOfVoxelsAlongX, 238 numberOfVoxelsAlongY, 239 numberOfVoxelsAlongZ); 240 phantomROGeometry -> BuildROGeometry(); 241 phantomSD -> SetROgeometry(phantomROGeometry); 242 sensitiveDetectorManager -> AddNewDetector(phantomSD); 243 phantomLogicalVolume -> SetSensitiveDetector(phantomSD); 244 } 245 } 246 247 void HadrontherapyDetectorConstruction::SetModulatorAngle(G4double value) 248 { 249 modulator -> SetModulatorAngle(value); 250 G4RunManager::GetRunManager() -> GeometryHasBeenModified(); 251 } 252 253 void HadrontherapyDetectorConstruction::SetRangeShifterXPosition(G4double value) 254 { 255 beamLine -> SetRangeShifterXPosition(value); 256 G4RunManager::GetRunManager() -> GeometryHasBeenModified(); 257 } 258 259 void HadrontherapyDetectorConstruction::SetRangeShifterXSize(G4double value) 260 { 261 beamLine -> SetRangeShifterXSize(value); 262 G4RunManager::GetRunManager() -> GeometryHasBeenModified(); 263 } 264 265 void HadrontherapyDetectorConstruction::SetFirstScatteringFoilSize(G4double value) 266 { 267 beamLine -> SetFirstScatteringFoilXSize(value); 268 G4RunManager::GetRunManager() -> GeometryHasBeenModified(); 269 } 270 271 void HadrontherapyDetectorConstruction::SetSecondScatteringFoilSize(G4double value) 272 { 273 beamLine -> SetSecondScatteringFoilXSize(value); 274 G4RunManager::GetRunManager() -> GeometryHasBeenModified(); 275 } 276 277 void HadrontherapyDetectorConstruction::SetOuterRadiusStopper(G4double value) 278 { 279 beamLine -> SetOuterRadiusStopper(value); 280 G4RunManager::GetRunManager() -> GeometryHasBeenModified(); 281 } 282 283 void HadrontherapyDetectorConstruction::SetInnerRadiusFinalCollimator(G4double value) 284 { 285 beamLine -> SetInnerRadiusFinalCollimator(value); 286 G4RunManager::GetRunManager() -> GeometryHasBeenModified(); 287 } 288 289 void HadrontherapyDetectorConstruction::SetRSMaterial(G4String materialChoice) 290 { 291 beamLine -> SetRSMaterial(materialChoice); 292 } 293 294 295 342 343 G4cout << "The (X, Y, Z) dimensions of the phantom are : (" << 344 G4BestUnit( phantom -> GetXHalfLength()*2., "Length") << ", " << 345 G4BestUnit( phantom -> GetYHalfLength()*2., "Length") << ", " << 346 G4BestUnit( phantom -> GetZHalfLength()*2., "Length") << ')' << G4endl; 347 //G4cout << '\n' << "Coordinate volume: " << phantomPhysicalVolume -> GetTranslation() << G4endl; 348 // Adjust detector position inside phantom 349 SetDetectorPosition(); 350 351 ConstructSensitiveDetector(GetDetectorToWorldPosition()); 352 G4RunManager::GetRunManager() -> GeometryHasBeenModified(); 353 return true; 354 } 355 ///////////////////////////////////////////////////////////////////////////// 356 G4bool HadrontherapyDetectorConstruction::SetPhantomPosition(G4ThreeVector displacement) 357 { 358 // Set Phantom position respect to the World 359 // TODO check for overlap! 360 phantomPosition = displacement; 361 if (phantomPhysicalVolume) 362 { 363 phantomPhysicalVolume -> SetTranslation(phantomPosition); 364 G4cout << "Displacement between Phantom and World is: "; 365 G4cout << "DX= "<< G4BestUnit(phantomPosition.getX(),"Length") << ", " << 366 "DY= "<< G4BestUnit(phantomPosition.getY(),"Length") << ", " << 367 "DZ= "<< G4BestUnit(phantomPosition.getZ(),"Length") << G4endl; 368 369 // Redraw ROGeometry! 370 ConstructSensitiveDetector(GetDetectorToWorldPosition()); 371 G4RunManager::GetRunManager() -> GeometryHasBeenModified(); 372 } 373 return true; 374 } 375 376 ///////////////////////////////////////////////////////////////////////////// 377 G4bool HadrontherapyDetectorConstruction::SetDetectorToPhantomPosition(G4ThreeVector displacement) 378 { 379 // Ignore negative values 380 if (displacement[0] < 0.) displacement[0] = detectorToPhantomPosition[0]; 381 if (displacement[1] < 0.) displacement[1] = detectorToPhantomPosition[1]; 382 if (displacement[2] < 0.) displacement[2] = detectorToPhantomPosition[2]; 383 384 if (!IsInside(detectorSizeX, 385 detectorSizeY, 386 detectorSizeZ, 387 phantomSizeX, 388 phantomSizeY, 389 phantomSizeZ, 390 displacement // method parameter! 391 )) 392 {return false;} 393 detectorToPhantomPosition = displacement; 394 395 // Adjust detector position inside phantom 396 SetDetectorPosition(); 397 398 ConstructSensitiveDetector(GetDetectorToWorldPosition()); 399 G4RunManager::GetRunManager() -> GeometryHasBeenModified(); 400 return true; 401 } -
trunk/examples/advanced/hadrontherapy/src/HadrontherapyDetectorMessenger.cc
r807 r1230 24 24 // ******************************************************************** 25 25 // 26 // $Id: HadrontherapyDetectorMessenger.cc; May 2005 27 // ---------------------------------------------------------------------------- 28 // GEANT 4 - Hadrontherapy example 29 // ---------------------------------------------------------------------------- 30 // Code developed by: 31 // 32 // G.A.P. Cirrone(a)*, F. Di Rosa(a), S. Guatelli(b), G. Russo(a) 33 // 34 // (a) Laboratori Nazionali del Sud 35 // of the INFN, Catania, Italy 36 // (b) INFN Section of Genova, Genova, Italy 37 // 38 // * cirrone@lns.infn.it 39 // ---------------------------------------------------------------------------- 26 // $Id: HadrontherapyDetectorMessenger.cc; 27 // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy 28 29 40 30 #include "HadrontherapyDetectorMessenger.hh" 41 31 #include "HadrontherapyDetectorConstruction.hh" … … 43 33 #include "G4UIcmdWithADoubleAndUnit.hh" 44 34 #include "G4UIcmdWithAString.hh" 35 #include "G4UIcmdWith3VectorAndUnit.hh" 45 36 46 HadrontherapyDetectorMessenger::HadrontherapyDetectorMessenger( 47 37 ///////////////////////////////////////////////////////////////////////////// 38 HadrontherapyDetectorMessenger::HadrontherapyDetectorMessenger(HadrontherapyDetectorConstruction* detector) 48 39 :hadrontherapyDetector(detector) 49 { 50 modulatorDir = new G4UIdirectory("/modulator/"); 51 modulatorDir -> SetGuidance("Command to rotate the modulator wheel"); 52 53 beamLineDir = new G4UIdirectory("/beamLine/"); 54 beamLineDir -> SetGuidance("set specification of range shifter"); 40 { 41 // Change Phantom size 42 changeThePhantomDir = new G4UIdirectory("/changePhantom/"); 43 changeThePhantomDir -> SetGuidance("Command to change the Phantom Size/position"); 44 changeThePhantomSizeCmd = new G4UIcmdWith3VectorAndUnit("/changePhantom/size", this); 45 changeThePhantomSizeCmd -> SetGuidance("Insert sizes X Y and Z" 46 "\n 0 or negative values mean <<Don't change it!>>"); 47 changeThePhantomSizeCmd -> SetParameterName("PhantomSizeAlongX", 48 "PhantomSizeAlongY", 49 "PhantomSizeAlongZ", false); 50 changeThePhantomSizeCmd -> SetDefaultUnit("mm"); 51 changeThePhantomSizeCmd -> SetUnitCandidates("um mm cm"); 52 changeThePhantomSizeCmd -> AvailableForStates(G4State_Idle); 55 53 56 rangeShifterDir = new G4UIdirectory("/beamLine/RangeShifter/");57 rangeShifterDir -> SetGuidance("set specification of range shifter");58 54 59 firstScatteringFoilDir = new G4UIdirectory("/beamLine/ScatteringFoil1/"); 60 firstScatteringFoilDir -> SetGuidance("set specification of first scattering foil"); 61 62 secondScatteringFoilDir = new G4UIdirectory("/beamLine/ScatteringFoil2/"); 63 secondScatteringFoilDir -> SetGuidance("set specification of second scattering foil"); 64 65 rangeStopperDir = new G4UIdirectory("/beamLine/Stopper/"); 66 rangeStopperDir -> SetGuidance("set specification of stopper"); 55 // Change Phantom position 56 changeThePhantomPositionCmd = new G4UIcmdWith3VectorAndUnit("/changePhantom/position", this); 57 changeThePhantomPositionCmd -> SetGuidance("Insert X Y and Z dimensions for the position of the center of the Phantom" 58 " respect to that of the \"World\""); 59 changeThePhantomPositionCmd -> SetParameterName("PositionAlongX", 60 "PositionAlongY", 61 "PositionAlongZ", false); 62 changeThePhantomPositionCmd -> SetDefaultUnit("mm"); 63 changeThePhantomPositionCmd -> SetUnitCandidates("mm cm m"); 64 changeThePhantomPositionCmd -> AvailableForStates(G4State_Idle); 67 65 68 finalCollimatorDir = new G4UIdirectory("/beamLine/FinalCollimator/");69 finalCollimatorDir -> SetGuidance("set specification of final collimator");70 66 71 modulatorAngleCmd = new G4UIcmdWithADoubleAndUnit("/modulator/angle",this); 72 modulatorAngleCmd -> SetGuidance("Set Modulator Angle"); 73 modulatorAngleCmd -> SetParameterName("Size",false); 74 modulatorAngleCmd -> SetRange("Size>=0."); 75 modulatorAngleCmd -> SetUnitCategory("Angle"); 76 modulatorAngleCmd -> AvailableForStates(G4State_Idle); 77 78 rangeShifterMatCmd = new G4UIcmdWithAString("/beamLine/RangeShifter/RSMat",this); 79 rangeShifterMatCmd -> SetGuidance("Set material of range shifter"); 80 rangeShifterMatCmd -> SetParameterName("choice",false); 81 rangeShifterMatCmd -> AvailableForStates(G4State_Idle); 82 83 rangeShifterXSizeCmd = new G4UIcmdWithADoubleAndUnit("/beamLine/RangeShifter/thickness",this); 84 rangeShifterXSizeCmd -> SetGuidance("Set half of the thickness of range shifter along X axis"); 85 rangeShifterXSizeCmd -> SetParameterName("Size",false); 86 rangeShifterXSizeCmd -> SetDefaultUnit("mm"); 87 rangeShifterXSizeCmd -> SetUnitCandidates("mm cm m"); 88 rangeShifterXSizeCmd -> AvailableForStates(G4State_Idle); 89 90 rangeShifterXPositionCmd = new G4UIcmdWithADoubleAndUnit("/beamLine/RangeShifter/position",this); 91 rangeShifterXPositionCmd -> SetGuidance("Set position of range shifter"); 92 rangeShifterXPositionCmd -> SetParameterName("Size",false); 93 rangeShifterXPositionCmd -> SetDefaultUnit("mm"); 94 rangeShifterXPositionCmd -> SetUnitCandidates("mm cm m"); 95 rangeShifterXPositionCmd -> AvailableForStates(G4State_Idle); 96 97 firstScatteringFoilXSizeCmd = new G4UIcmdWithADoubleAndUnit("/beamLine/ScatteringFoil1/thickness",this); 98 firstScatteringFoilXSizeCmd -> SetGuidance("Set hlaf thickness of first scattering foil"); 99 firstScatteringFoilXSizeCmd -> SetParameterName("Size",false); 100 firstScatteringFoilXSizeCmd -> SetDefaultUnit("mm"); 101 firstScatteringFoilXSizeCmd -> SetUnitCandidates("mm cm m"); 102 firstScatteringFoilXSizeCmd -> AvailableForStates(G4State_Idle); 103 104 secondScatteringFoilXSizeCmd = new G4UIcmdWithADoubleAndUnit("/beamLine/ScatteringFoil2/thickness",this); 105 secondScatteringFoilXSizeCmd -> SetGuidance("Set half thickness of second scattering foil"); 106 secondScatteringFoilXSizeCmd -> SetParameterName("Size",false); 107 secondScatteringFoilXSizeCmd -> SetDefaultUnit("mm"); 108 secondScatteringFoilXSizeCmd -> SetUnitCandidates("mm cm m"); 109 secondScatteringFoilXSizeCmd -> AvailableForStates(G4State_Idle); 110 111 outerRadiusStopperCmd = new G4UIcmdWithADoubleAndUnit("/beamLine/Stopper/outRadius",this); 112 outerRadiusStopperCmd -> SetGuidance("Set size of outer radius"); 113 outerRadiusStopperCmd -> SetParameterName("Size",false); 114 outerRadiusStopperCmd -> SetDefaultUnit("mm"); 115 outerRadiusStopperCmd -> SetUnitCandidates("mm cm m"); 116 outerRadiusStopperCmd -> AvailableForStates(G4State_Idle); 117 118 innerRadiusFinalCollimatorCmd = new G4UIcmdWithADoubleAndUnit("/beamLine/FinalCollimator/halfInnerRad",this); 119 innerRadiusFinalCollimatorCmd -> SetGuidance("Set size of inner radius ( max 21.5 mm)"); 120 innerRadiusFinalCollimatorCmd -> SetParameterName("Size",false); 121 innerRadiusFinalCollimatorCmd -> SetDefaultUnit("mm"); 122 innerRadiusFinalCollimatorCmd -> SetUnitCandidates("mm cm m"); 123 innerRadiusFinalCollimatorCmd -> AvailableForStates(G4State_Idle); 67 // Change detector size 68 changeTheDetectorDir = new G4UIdirectory("/changeDetector/"); 69 changeTheDetectorDir -> SetGuidance("Command to change the Detector's Size/position/Voxels"); 70 71 changeTheDetectorSizeCmd = new G4UIcmdWith3VectorAndUnit("/changeDetector/size",this); 72 changeTheDetectorSizeCmd -> SetGuidance("Insert sizes for X Y and Z dimensions of the Detector" 73 "\n 0 or negative values mean <<Don't change it>>"); 74 changeTheDetectorSizeCmd -> SetParameterName("DetectorSizeAlongX", "DetectorSizeAlongY", "DetectorSizeAlongZ", false); 75 changeTheDetectorSizeCmd -> SetDefaultUnit("mm"); 76 changeTheDetectorSizeCmd -> SetUnitCandidates("um mm cm"); 77 changeTheDetectorSizeCmd -> AvailableForStates(G4State_Idle); 78 79 // Change the detector to phantom displacement 80 changeTheDetectorToPhantomPositionCmd = new G4UIcmdWith3VectorAndUnit("/changeDetector/displacement",this); 81 changeTheDetectorToPhantomPositionCmd -> SetGuidance("Insert X Y and Z displacements between Detector and Phantom" 82 "\nNegative values mean <<Don't change it!>>"); 83 changeTheDetectorToPhantomPositionCmd -> SetParameterName("DisplacementAlongX", 84 "DisplacementAlongY", 85 "DisplacementAlongZ", false); 86 changeTheDetectorToPhantomPositionCmd -> SetDefaultUnit("mm"); 87 changeTheDetectorToPhantomPositionCmd -> SetUnitCandidates("um mm cm"); 88 changeTheDetectorToPhantomPositionCmd -> AvailableForStates(G4State_Idle); 89 90 // Change voxels by its size 91 changeTheDetectorVoxelCmd = new G4UIcmdWith3VectorAndUnit("/changeDetector/voxelSize",this); 92 changeTheDetectorVoxelCmd -> SetGuidance("Insert Voxel sizes for X Y and Z dimensions" 93 "\n 0 or negative values mean <<Don't change it!>>"); 94 changeTheDetectorVoxelCmd -> SetParameterName("VoxelSizeAlongX", "VoxelSizeAlongY", "VoxelSizeAlongZ", false); 95 changeTheDetectorVoxelCmd -> SetDefaultUnit("mm"); 96 changeTheDetectorVoxelCmd -> SetUnitCandidates("um mm cm"); 97 changeTheDetectorVoxelCmd -> AvailableForStates(G4State_Idle); 98 } 99 100 ///////////////////////////////////////////////////////////////////////////// 101 HadrontherapyDetectorMessenger::~HadrontherapyDetectorMessenger() 102 { 103 delete changeThePhantomDir; 104 delete changeThePhantomSizeCmd; 105 delete changeThePhantomPositionCmd; 106 delete changeTheDetectorDir; 107 delete changeTheDetectorSizeCmd; 108 delete changeTheDetectorToPhantomPositionCmd; 109 delete changeTheDetectorVoxelCmd; 124 110 } 125 111 126 HadrontherapyDetectorMessenger::~HadrontherapyDetectorMessenger() 127 { 128 delete innerRadiusFinalCollimatorCmd; 129 delete outerRadiusStopperCmd; 130 delete secondScatteringFoilXSizeCmd; 131 delete firstScatteringFoilXSizeCmd; 132 delete rangeShifterXPositionCmd; 133 delete rangeShifterXSizeCmd; 134 delete rangeShifterMatCmd; 135 delete modulatorAngleCmd; 136 delete finalCollimatorDir; 137 delete rangeStopperDir; 138 delete secondScatteringFoilDir; 139 delete firstScatteringFoilDir; 140 delete rangeShifterDir; 141 delete beamLineDir; 142 delete modulatorDir; 112 ///////////////////////////////////////////////////////////////////////////// 113 void HadrontherapyDetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue) 114 { 115 116 if( command == changeThePhantomSizeCmd) 117 { 118 G4ThreeVector size = changeThePhantomSizeCmd -> GetNew3VectorValue(newValue); 119 hadrontherapyDetector -> SetPhantomSize(size.getX(),size.getY(),size.getZ()); 120 } 121 else if (command == changeThePhantomPositionCmd ) 122 { 123 G4ThreeVector size = changeThePhantomPositionCmd -> GetNew3VectorValue(newValue); 124 hadrontherapyDetector -> SetPhantomPosition(size); 125 } 126 else if (command == changeTheDetectorSizeCmd) 127 { 128 G4ThreeVector size = changeTheDetectorSizeCmd -> GetNew3VectorValue(newValue); 129 hadrontherapyDetector -> SetDetectorSize(size.getX(),size.getY(),size.getZ()); 130 } 131 else if (command == changeTheDetectorToPhantomPositionCmd) 132 { 133 G4ThreeVector size = changeTheDetectorToPhantomPositionCmd-> GetNew3VectorValue(newValue); 134 hadrontherapyDetector -> SetDetectorToPhantomPosition(size); 135 } 136 else if (command == changeTheDetectorVoxelCmd) 137 { 138 G4ThreeVector size = changeTheDetectorVoxelCmd -> GetNew3VectorValue(newValue); 139 hadrontherapyDetector -> SetNumberOfVoxelBySize(size.getX(),size.getY(),size.getZ()); 140 } 143 141 } 144 145 void HadrontherapyDetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)146 {147 if( command == modulatorAngleCmd )148 { hadrontherapyDetector -> SetModulatorAngle149 (modulatorAngleCmd -> GetNewDoubleValue(newValue));}150 151 if( command == rangeShifterMatCmd )152 { hadrontherapyDetector -> SetRSMaterial(newValue);}153 154 if( command == rangeShifterXSizeCmd )155 { hadrontherapyDetector -> SetRangeShifterXSize156 (rangeShifterXSizeCmd -> GetNewDoubleValue(newValue));}157 158 if( command == rangeShifterXPositionCmd )159 { hadrontherapyDetector -> SetRangeShifterXPosition160 (rangeShifterXPositionCmd -> GetNewDoubleValue(newValue));}161 162 if( command == firstScatteringFoilXSizeCmd )163 { hadrontherapyDetector -> SetFirstScatteringFoilSize164 (firstScatteringFoilXSizeCmd -> GetNewDoubleValue(newValue));}165 166 if( command == secondScatteringFoilXSizeCmd )167 { hadrontherapyDetector -> SetSecondScatteringFoilSize168 (secondScatteringFoilXSizeCmd -> GetNewDoubleValue(newValue));}169 170 if( command == outerRadiusStopperCmd )171 { hadrontherapyDetector -> SetOuterRadiusStopper(172 outerRadiusStopperCmd -> GetNewDoubleValue(newValue));}173 174 if( command == innerRadiusFinalCollimatorCmd )175 { hadrontherapyDetector -> SetInnerRadiusFinalCollimator176 (innerRadiusFinalCollimatorCmd -> GetNewDoubleValue(newValue));}177 }178 -
trunk/examples/advanced/hadrontherapy/src/HadrontherapyEventAction.cc
r807 r1230 24 24 // ******************************************************************** 25 25 // 26 // $Id: HadrontherapyEventAction.cc; May 2005 27 // ---------------------------------------------------------------------------- 28 // GEANT 4 - Hadrontherapy example 29 // ---------------------------------------------------------------------------- 30 // Code developed by: 31 // 32 // G.A.P. Cirrone(a)*, G. Candiano, F. Di Rosa(a), S. Guatelli(b), G. Russo(a) 33 // 34 // (a) Laboratori Nazionali del Sud 35 // of the National Institute for Nuclear Physics, Catania, Italy 36 // (b) National Institute for Nuclear Physics Section of Genova, genova, Italy 37 // 38 // * cirrone@lns.infn.it 39 // -------------------------------------------------------------- 26 // $Id: HadrontherapyEventAction.cc; 27 // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy 28 40 29 #include "G4Event.hh" 41 30 #include "G4EventManager.hh" … … 48 37 #include "G4VVisManager.hh" 49 38 #include "HadrontherapyEventAction.hh" 50 #include "Hadrontherapy PhantomHit.hh"51 #include "Hadrontherapy PhantomSD.hh"39 #include "HadrontherapyDetectorHit.hh" 40 #include "HadrontherapyDetectorSD.hh" 52 41 #include "HadrontherapyDetectorConstruction.hh" 53 42 #include "HadrontherapyMatrix.hh" 43 #include "HadrontherapyEventActionMessenger.hh" 54 44 55 HadrontherapyEventAction::HadrontherapyEventAction(HadrontherapyMatrix* matrixPointer) : 56 drawFlag("all" ) 45 ///////////////////////////////////////////////////////////////////////////// 46 HadrontherapyEventAction::HadrontherapyEventAction() : 47 drawFlag("all" ),printModulo(1000), pointerEventMessenger(0) 57 48 { 58 49 hitsCollectionID = -1; 59 matrix = matrixPointer;50 pointerEventMessenger = new HadrontherapyEventActionMessenger(this); 60 51 } 61 52 53 ///////////////////////////////////////////////////////////////////////////// 62 54 HadrontherapyEventAction::~HadrontherapyEventAction() 63 55 { 56 delete pointerEventMessenger; 64 57 } 65 58 66 void HadrontherapyEventAction::BeginOfEventAction(const G4Event* ) 67 { 68 G4SDManager* pSDManager = G4SDManager::GetSDMpointer(); 69 if(hitsCollectionID == -1) 70 hitsCollectionID = pSDManager -> GetCollectionID("HadrontherapyPhantomHitsCollection"); 59 ///////////////////////////////////////////////////////////////////////////// 60 void HadrontherapyEventAction::BeginOfEventAction(const G4Event* evt) 61 { 62 G4int evtNb = evt->GetEventID(); 63 64 //printing survey 65 if (evtNb%printModulo == 0) 66 G4cout << "\n---> Begin of Event: " << evtNb << G4endl; 67 68 G4SDManager* pSDManager = G4SDManager::GetSDMpointer(); 69 if(hitsCollectionID == -1) 70 hitsCollectionID = pSDManager -> GetCollectionID("HadrontherapyDetectorHitsCollection"); 71 71 } 72 72 73 ///////////////////////////////////////////////////////////////////////////// 73 74 void HadrontherapyEventAction::EndOfEventAction(const G4Event* evt) 74 75 { 75 76 if(hitsCollectionID < 0) 76 return; 77 77 return; 78 78 G4HCofThisEvent* HCE = evt -> GetHCofThisEvent(); 79 HadrontherapyPhantomHitsCollection* CHC = NULL;80 79 81 80 if(HCE) 82 CHC = (HadrontherapyPhantomHitsCollection*)(HCE -> GetHC(hitsCollectionID)); 83 84 if(CHC) 85 { 86 if(matrix) 87 { 88 // Fill the matrix with the information: voxel and associated energy deposit 89 // in the phantom at the end of the event 81 { 82 HadrontherapyDetectorHitsCollection* CHC = (HadrontherapyDetectorHitsCollection*)(HCE -> GetHC(hitsCollectionID)); 83 if(CHC) 84 { 85 matrix = HadrontherapyMatrix::getInstance(); 86 if(matrix) 87 { 88 // Fill the matrix with the information: voxel and associated energy deposit 89 // in the detector at the end of the event 90 90 91 91 G4int HitCount = CHC -> entries(); … … 98 98 matrix -> Fill(i, j, k, energyDeposit/MeV); 99 99 } 100 }100 } 101 101 } 102 102 } 103 103 // Extract the trajectories and draw them in the visualisation 104 104 -
trunk/examples/advanced/hadrontherapy/src/HadrontherapyMatrix.cc
r807 r1230 24 24 // ******************************************************************** 25 25 // 26 // $Id: HadrontherapyPhantomSD.cc; May 2005 27 // ---------------------------------------------------------------------------- 28 // GEANT 4 - Hadrontherapy example 29 // ---------------------------------------------------------------------------- 30 // Code developed by: 31 // 32 // G.A.P. Cirrone(a)*, F. Di Rosa(a), S. Guatelli(b), G. Russo(a) 33 // 34 // (a) Laboratori Nazionali del Sud 35 // of the National Institute for Nuclear Physics, Catania, Italy 36 // (b) National Institute for Nuclear Physics Section of Genova, genova, Italy 37 // 38 // * cirrone@lns.infn.it 39 // ---------------------------------------------------------------------------- 26 // $Id: HadrontherapyMatrix.cc; 27 // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy// 40 28 41 29 #include "HadrontherapyMatrix.hh" … … 44 32 #include <fstream> 45 33 46 HadrontherapyMatrix::HadrontherapyMatrix() 34 HadrontherapyMatrix* HadrontherapyMatrix::instance = NULL; 35 // Static method that only return a pointer to the matrix object 36 HadrontherapyMatrix* HadrontherapyMatrix::getInstance() 37 { 38 return instance; 39 } 40 // This STATIC method delete (!) the old matrix and rewrite a new object returning a pointer to it 41 HadrontherapyMatrix* HadrontherapyMatrix::getInstance(G4int voxelX, G4int voxelY, G4int voxelZ) 42 { 43 if (instance) delete instance; 44 instance = new HadrontherapyMatrix(voxelX, voxelY, voxelZ); 45 instance -> Initialize(); 46 return instance; 47 } 48 49 HadrontherapyMatrix::HadrontherapyMatrix(G4int voxelX, G4int voxelY, G4int voxelZ): 50 matrix(0) 47 51 { 48 // Number of the voxels of the phantom 49 numberVoxelX = 200; 50 numberVoxelY = 200; 51 numberVoxelZ = 200; 52 53 // Create the matrix 52 // Number of the voxels of the phantom 53 // For Y = Z = 1 the phantom is divided in slices (and not in voxels) 54 // orthogonal to the beam axis 55 numberVoxelX = voxelX; 56 numberVoxelY = voxelY; 57 numberVoxelZ = voxelZ; 58 // Create the dose matrix 54 59 matrix = new G4double[numberVoxelX*numberVoxelY*numberVoxelZ]; 60 if (matrix) G4cout << "Matrix: Memory space to store physical dose into " << 61 numberVoxelX*numberVoxelY*numberVoxelZ << 62 " voxels has been allocated " << G4endl; 63 else G4Exception("Can't allocate memory to store physical dose!"); 55 64 } 56 65 57 66 HadrontherapyMatrix::~HadrontherapyMatrix() 58 67 { 59 delete[] matrix; 68 delete[] matrix; 69 } 70 71 void HadrontherapyMatrix::flush() 72 { 73 if(matrix) 74 for(int i=0; i<numberVoxelX*numberVoxelY*numberVoxelZ; i++) 75 { 76 matrix[i] = 0; 77 } 60 78 } 61 79 void HadrontherapyMatrix::Initialize() 62 80 { 63 // Initialise the elemnts of the matrix to zero 64 81 // Initialise the elements of the matrix to zero 65 82 for(G4int i = 0; i < numberVoxelX; i++) 66 83 { 67 84 for(G4int j = 0; j < numberVoxelY; j++) 68 {69 for(G4int k = 0; k < numberVoxelZ; k++)85 { 86 for(G4int k = 0; k < numberVoxelZ; k++) 70 87 71 matrix[(i*numberVoxelY+j)*numberVoxelZ+k] = 0.;72 }88 matrix[Index(i,j,k)] = 0.; 89 } 73 90 } 74 91 } … … 78 95 { 79 96 if (matrix) 80 matrix[ (i*numberVoxelY+j)*numberVoxelZ+k] += energyDeposit;97 matrix[Index(i,j,k)] += energyDeposit; 81 98 82 // Store the energy deposit in the matrix elem nt corresponding83 // to the phantom voxel 99 // Store the energy deposit in the matrix element corresponding 100 // to the phantom voxel i, j, k 84 101 } 85 102 … … 95 112 if (matrix) 96 113 { 97 for(G4int l = 0; l < numberVoxelZ; l++) 98 { 99 k = l; 100 101 for(G4int m = 0; m < numberVoxelY; m++) 102 { 103 j = m * numberVoxelZ + k; 114 std::ofstream ofs; 115 ofs.open("DoseDistribution.out"); 116 117 for(G4int l = 0; l < numberVoxelZ; l++) 118 { 119 k = l; 120 121 for(G4int m = 0; m < numberVoxelY; m++) 122 { 123 j = m * numberVoxelZ + k; 104 124 105 125 for(G4int n = 0; n < numberVoxelX; n++) … … 108 128 if(matrix[i] != 0) 109 129 { 110 111 #ifdef G4ANALYSIS_USE 130 ofs << n << '\t' << m << '\t' << 131 k << '\t' << matrix[i] << G4endl; 132 133 #ifdef ANALYSIS_USE 112 134 HadrontherapyAnalysisManager* analysis = 113 135 HadrontherapyAnalysisManager::getInstance(); 114 136 analysis -> FillEnergyDeposit(n, m, k, matrix[i]); 115 137 analysis -> BraggPeak(n, matrix[i]); 116 138 #endif 117 139 } 118 140 } 119 141 } 120 142 } -
trunk/examples/advanced/hadrontherapy/src/HadrontherapyModulator.cc
r807 r1230 24 24 // ******************************************************************** 25 25 // 26 // $Id: HadrontherapyModulator.cc; May 2005 27 // ---------------------------------------------------------------------------- 28 // GEANT 4 - Hadrontherapy example 29 // ---------------------------------------------------------------------------- 30 // Code developed by: 31 // 32 // G.A.P. Cirrone(a)*, F. Di Rosa(a), S. Guatelli(b), G. Russo(a) 33 // 34 // (a) Laboratori Nazionali del Sud 35 // of the National Institute for Nuclear Physics, Catania, Italy 36 // (b) National Institute for Nuclear Physics Section of Genova, genova, Italy 37 // 38 // * cirrone@lns.infn.it 39 // ---------------------------------------------------------------------------- 26 // $Id: HadrontherapyModulator.cc; 27 // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy 40 28 41 29 #include "G4Material.hh" … … 51 39 #include "G4VisAttributes.hh" 52 40 #include "G4Colour.hh" 53 #include "HadrontherapyMaterial.hh"54 41 #include "HadrontherapyModulator.hh" 55 #include "HadrontherapyMaterial.hh"56 42 #include "G4Transform3D.hh" 57 43 #include "G4ios.hh" 58 44 #include <fstream> 59 45 #include "G4RunManager.hh" 46 #include "G4NistManager.hh" 60 47 61 48 HadrontherapyModulator::HadrontherapyModulator():physiMotherMod(0), … … 141 128 rm -> rotateY(phi); 142 129 } 143 130 ///////////////////////////////////////////////////////////////////////////// 144 131 HadrontherapyModulator::~HadrontherapyModulator() 145 132 { 146 133 delete rm; 147 134 } 148 135 ///////////////////////////////////////////////////////////////////////////// 149 136 void HadrontherapyModulator::BuildModulator(G4VPhysicalVolume* motherVolume) 150 137 { 151 152 153 //Materials used for the modulator wheel 154 HadrontherapyMaterial* material = new HadrontherapyMaterial(); 155 156 G4Material* Mod0Mater = material -> GetMat("Air"); 157 G4Material* ModMater = material -> GetMat("Air"); 158 delete material; 159 138 G4bool isotopes = false; 139 G4Material* airNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR", isotopes); 140 141 G4Material* Mod0Mater = airNist; 142 G4Material* ModMater = airNist; 143 160 144 G4double innerRadiusOfTheTube = 2.5 *cm; 161 145 G4double outerRadiusOfTheTube = 9.5 *cm; … … 163 147 164 148 // Mother of the modulator wheel 165 166 G4ThreeVector positionMotherMod = G4ThreeVector(-2260.50 *mm, 30 *mm, 50 *mm); 149 G4ThreeVector positionMotherMod = G4ThreeVector(-1960.50 *mm, 30 *mm, 50 *mm); 167 150 168 151 G4Box* solidMotherMod = new G4Box("MotherMod", 12 *cm, 12 *cm, 12 *cm); 169 152 170 153 G4LogicalVolume * logicMotherMod = new G4LogicalVolume(solidMotherMod, Mod0Mater,"MotherMod",0,0,0); 171 172 173 154 174 155 physiMotherMod = new G4PVPlacement(rm,positionMotherMod, "MotherMod", … … 200 181 logicMod0 = new G4LogicalVolume(solidMod0, Mod0Mater, "Mod0",0,0,0); 201 182 202 203 183 physiMod0 = new G4PVPlacement(G4Transform3D(rm2, positionMod0), 204 184 logicMod0, … … 212 192 // First modulator sclice 213 193 //---------------------------------------------------------- 214 215 194 216 195 G4double startAngleOfTheTube1 = 54.267*deg; -
trunk/examples/advanced/hadrontherapy/src/HadrontherapyParticles.cc
r807 r1230 24 24 // ******************************************************************** 25 25 // 26 // $Id: HadrontherapyParticles.cc; May 2005 27 // ---------------------------------------------------------------------------- 28 // GEANT 4 - Hadrontherapy example 29 // ---------------------------------------------------------------------------- 30 // Code developed by: 31 // 32 // G.A.P. Cirrone(a)*, F. Di Rosa(a), S. Guatelli(b), G. Russo(a) 33 // 34 // (a) Laboratori Nazionali del Sud 35 // of the National Institute for Nuclear Physics, Catania, Italy 36 // (b) National Institute for Nuclear Physics Section of Genova, genova, Italy 37 // 38 // * cirrone@lns.infn.it 39 // ---------------------------------------------------------------------------- 26 // $Id: HadrontherapyParticles.cc; 27 // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy 28 40 29 #include "HadrontherapyParticles.hh" 41 30 #include "G4ParticleDefinition.hh" -
trunk/examples/advanced/hadrontherapy/src/HadrontherapyPhysicsList.cc
r807 r1230 24 24 // ******************************************************************** 25 25 // 26 // $Id: HadrontherapyPhysicsList.cc,v 1.0 27 // ---------------------------------------------------------------------------- 28 // GEANT 4 - Hadrontherapy example 29 // ---------------------------------------------------------------------------- 30 // Code developed by: 31 // 32 // G.A.P. Cirrone(a)*, F. Di Rosa(a), S. Guatelli(b), G. Russo(a) 33 // 34 // (a) Laboratori Nazionali del Sud 35 // of the National Institute for Nuclear Physics, Catania, Italy 36 // (b) National Institute for Nuclear Physics Section of Genova, genova, Italy 37 // 38 // * cirrone@lns.infn.it 39 // ---------------------------------------------------------------------------- 40 41 #include "globals.hh" 42 #include "G4ProcessManager.hh" 43 #include "G4Region.hh" 44 #include "G4RegionStore.hh" 45 #include "G4ParticleDefinition.hh" 46 #include "G4ParticleTypes.hh" 47 #include "G4ParticleTable.hh" 26 // HadrontherapyPhysicsList.cc 27 // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy 28 29 // This class provides all the physic models that can be activated inside Hadrontherapy; 30 // Each model can be setted via macro commands; 31 // Inside Hadrontherapy the models can be activate with three different complementar methods: 32 // 33 // 1. Use of the *Packages*. 34 // Packages (that are contained inside the 35 // Geant4 distribution at $G4INSTALL/source/physics_lists/lists) provide a full set 36 // of models (both electromagnetic and hadronic). 37 // The User can use this method simply add the line /physic/addPackage <nameOfPackage> 38 // in his/her macro file. No other action is required. 39 // For Hadrontherapy applications we suggest the use of the QGSP_BIC package 40 // for proton beams. The same can be used 41 // also for ligth ion beam. 42 // Example of use of package can be found in the packageQGSP_BIC.mac file. 43 // 44 // 2. Use of the *Physic Lists*. 45 // Physic lists are also already ready to use inside the Geant4 distribution 46 // ($G4INSTALL/source/physics_lists/builders). To use them the simple 47 // /physic/addPhysics <nameOfPhysicList> command must be used in the macro. 48 // In Hadrontherapy we provide physics list to activate Electromagnetic, 49 // Hadronic elastic and Hadronic inelastic models. 50 // 51 // For Hadrontherapy we suggest the use of: 52 // 53 // /physic/addPhysic/emstandard_option3 (electromagnetic model) 54 // /physic/addPhysic/QElastic (hadronic elastic model) 55 // /physic/addPhysic/binary (hadronic inelastic models for proton and neutrons) 56 // /physic/addPhysic/binary_ion (hadronic inelastic models for ions) 57 // 58 // Example of the use of physics lists can be found in the macro files included in the 59 // 'macro' folder . 60 // 61 // 3. Use of a *local* physics. In this case the models are implemented in local files 62 // contained in the Hadrontherapy folder. The use of local physic is recommended 63 // to more expert Users. 64 // We provide as local, only the LocalStandardICRU73EmPhysic.cc (an Elecromagnetic 65 // implementation containing the new ICRU73 data table for ions stopping powers) 66 // and the LocalIonIonInelasticPhysic.cc (physic list to use for the ion-ion interaction 67 // case) 68 // The *local* physics can be activated with the same /physic/addPhysic <nameOfPhysic> command; 69 // 70 // While Packages approch must be used exclusively, Physics List and Local physics can 71 // be activated, if necessary, contemporaneously in the same simulation run. 72 // 73 // AT MOMENT, IF ACCURATE RESULTS ARE NEDED, WE STRONGLY RECOMMEND THE USE OF THE MACROS: 74 // proton_therapy.mac: use of the built-in Geant4 physics list for proton beams) 75 // ion_therapy.mac : use of mixed combination of native Geant4 physic lists 76 // and local physic for ion-ion enelastic processes) 77 48 78 #include "HadrontherapyPhysicsList.hh" 49 79 #include "HadrontherapyPhysicsListMessenger.hh" 50 #include "HadrontherapyParticles.hh" 51 #include "Decay.hh" 52 #include "EMPhotonStandard.hh" 53 #include "EMPhotonEPDL.hh" 54 #include "EMPhotonPenelope.hh" 55 #include "EMElectronStandard.hh" 56 #include "EMElectronEEDL.hh" 57 #include "EMElectronPenelope.hh" 58 #include "EMPositronStandard.hh" 59 #include "EMPositronPenelope.hh" 60 #include "EMMuonStandard.hh" 61 #include "EMHadronIonLowEICRU49.hh" 62 #include "EMHadronIonLowEZiegler1977.hh" 63 #include "EMHadronIonLowEZiegler1985.hh" 64 #include "EMHadronIonStandard.hh" 65 #include "HIProtonNeutronPrecompound.hh" 66 #include "HIProtonNeutronBertini.hh" 67 #include "HIProtonNeutronBinary.hh" 68 #include "HIProtonNeutronLEP.hh" 69 #include "HIProtonNeutronPrecompoundGEM.hh" 70 #include "HIProtonNeutronPrecompoundFermi.hh" 71 #include "HIProtonNeutronPrecompoundGEMFermi.hh" 72 #include "HIPionBertini.hh" 73 #include "HIPionLEP.hh" 74 #include "HIIonLEP.hh" 75 #include "HEHadronIonLElastic.hh" 76 #include "HEHadronIonBertiniElastic.hh" 77 #include "HEHadronIonQElastic.hh" 78 #include "HEHadronIonUElastic.hh" 79 #include "HRMuonMinusCapture.hh" 80 81 82 HadrontherapyPhysicsList::HadrontherapyPhysicsList(): G4VModularPhysicsList(), 83 decayIsRegistered(false), 84 emElectronIsRegistered(false), 85 emPositronIsRegistered(false), 86 emPhotonIsRegistered(false), 87 emIonIsRegistered(false), 88 emMuonIsRegistered(false), 89 hadrElasticHadronIonIsRegistered(false), 90 hadrInelasticPionIsRegistered(false), 91 hadrInelasticIonIsRegistered(false), 92 hadrInelasticProtonNeutronIsRegistered(false), 93 hadrAtRestMuonIsRegistered(false) 94 { 95 // The secondary production threshold is set to 10. mm 96 // for all the particles in all the experimental set-up 97 // The phantom is defined as a Geant4 Region. Here the cut is fixed to 0.001 mm 98 defaultCutValue = 0.01 * mm; 99 100 // Messenger: it is possible to activate physics processes and models interactively 101 messenger = new HadrontherapyPhysicsListMessenger(this); 80 #include "HadrontherapyStepMax.hh" 81 #include "G4PhysListFactory.hh" 82 #include "G4VPhysicsConstructor.hh" 83 84 // Local physic directly implemented in the Hadronthrapy directory 85 #include "LocalIonIonInelasticPhysic.hh" // Physic dedicated to the ion-ion inelastic processes 86 #include "LocalINCLIonIonInelasticPhysic.hh" // Physic dedicated to the ion-ion inelastic processes using INCL/ABLA 87 88 // Physic lists (contained inside the Geant4 distribution) 89 #include "G4EmStandardPhysics_option3.hh" 90 #include "G4EmLivermorePhysics.hh" 91 #include "G4EmPenelopePhysics.hh" 92 #include "G4DecayPhysics.hh" 93 #include "G4HadronElasticPhysics.hh" 94 #include "G4HadronDElasticPhysics.hh" 95 #include "G4HadronHElasticPhysics.hh" 96 #include "G4HadronQElasticPhysics.hh" 97 #include "G4HadronInelasticQBBC.hh" 98 #include "G4IonBinaryCascadePhysics.hh" 99 #include "G4Decay.hh" 100 101 #include "G4LossTableManager.hh" 102 #include "G4UnitsTable.hh" 103 #include "G4ProcessManager.hh" 104 105 #include "G4IonFluctuations.hh" 106 #include "G4IonParametrisedLossModel.hh" 107 #include "G4EmProcessOptions.hh" 108 109 #include "G4RadioactiveDecayPhysics.hh" 110 111 ///////////////////////////////////////////////////////////////////////////// 112 HadrontherapyPhysicsList::HadrontherapyPhysicsList() : G4VModularPhysicsList() 113 { 114 G4LossTableManager::Instance(); 115 defaultCutValue = 1.*mm; 116 cutForGamma = defaultCutValue; 117 cutForElectron = defaultCutValue; 118 cutForPositron = defaultCutValue; 119 120 helIsRegisted = false; 121 bicIsRegisted = false; 122 biciIsRegisted = false; 123 locIonIonInelasticIsRegistered = false; 124 radioactiveDecayIsRegisted = false; 125 126 stepMaxProcess = 0; 127 128 pMessenger = new HadrontherapyPhysicsListMessenger(this); 102 129 103 130 SetVerboseLevel(1); 104 131 105 // Register all the particles involved in the experimental set-up 106 RegisterPhysics( new HadrontherapyParticles("particles") ); 107 } 108 132 // EM physics 133 emPhysicsList = new G4EmStandardPhysics_option3(1); 134 emName = G4String("emstandard_opt3"); 135 136 // Deacy physics and all particles 137 decPhysicsList = new G4DecayPhysics(); 138 } 139 140 ///////////////////////////////////////////////////////////////////////////// 109 141 HadrontherapyPhysicsList::~HadrontherapyPhysicsList() 110 { 111 delete messenger; 112 } 113 142 { 143 delete pMessenger; 144 delete emPhysicsList; 145 delete decPhysicsList; 146 for(size_t i=0; i<hadronPhys.size(); i++) {delete hadronPhys[i];} 147 } 148 149 ///////////////////////////////////////////////////////////////////////////// 150 void HadrontherapyPhysicsList::AddPackage(const G4String& name) 151 { 152 G4PhysListFactory factory; 153 G4VModularPhysicsList* phys =factory.GetReferencePhysList(name); 154 G4int i=0; 155 const G4VPhysicsConstructor* elem= phys->GetPhysics(i); 156 G4VPhysicsConstructor* tmp = const_cast<G4VPhysicsConstructor*> (elem); 157 while (elem !=0) 158 { 159 RegisterPhysics(tmp); 160 elem= phys->GetPhysics(++i) ; 161 tmp = const_cast<G4VPhysicsConstructor*> (elem); 162 } 163 } 164 165 ///////////////////////////////////////////////////////////////////////////// 166 void HadrontherapyPhysicsList::ConstructParticle() 167 { 168 decPhysicsList->ConstructParticle(); 169 } 170 171 ///////////////////////////////////////////////////////////////////////////// 172 void HadrontherapyPhysicsList::ConstructProcess() 173 { 174 // transportation 175 // 176 AddTransportation(); 177 178 // electromagnetic physics list 179 // 180 emPhysicsList->ConstructProcess(); 181 em_config.AddModels(); 182 183 // decay physics list 184 // 185 decPhysicsList->ConstructProcess(); 186 187 // hadronic physics lists 188 for(size_t i=0; i<hadronPhys.size(); i++) { 189 hadronPhys[i]->ConstructProcess(); 190 } 191 192 // step limitation (as a full process) 193 // 194 AddStepMax(); 195 } 196 197 ///////////////////////////////////////////////////////////////////////////// 114 198 void HadrontherapyPhysicsList::AddPhysicsList(const G4String& name) 115 199 { 116 G4cout << "Adding PhysicsList component " << name << G4endl; 117 118 119 // **************** 120 // *** A. DECAY *** 121 // **************** 122 123 124 if (name == "Decay") 125 { 126 if (decayIsRegistered) 127 { 128 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 129 << " cannot be registered ---- decay List already existing" 130 << G4endl; 131 } 132 else 133 { 134 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 135 << " is registered" << G4endl; 136 RegisterPhysics( new Decay(name) ); 137 decayIsRegistered = true; 138 } 139 } 140 141 142 // *************************************** 143 // *** B. ELECTROMAGNETIC INTERACTIONS *** 144 // *************************************** 145 146 147 // *************** 148 // *** Photons *** 149 // *************** 150 151 // *** Option I: Standard 152 153 if (name == "EM-Photon-Standard") 154 { 155 if (emPhotonIsRegistered) 156 { 157 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 158 << " cannot be registered ---- photon List already existing" 159 << G4endl; 160 } 161 else 162 { 163 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 164 << " is registered" << G4endl; 165 RegisterPhysics( new EMPhotonStandard(name) ); 166 emPhotonIsRegistered = true; 167 } 168 } 169 170 171 // *** Option II: Low Energy based on the Livermore libraries 172 173 if (name == "EM-Photon-EPDL") 174 { 175 if (emPhotonIsRegistered) 176 { 177 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 178 << " cannot be registered ---- photon List already existing" 179 << G4endl; 180 } 181 else 182 { 183 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 184 << " is registered" << G4endl; 185 RegisterPhysics( new EMPhotonEPDL(name) ); 186 emPhotonIsRegistered = true; 187 } 188 } 189 190 191 // *** Option III: Low Energy Penelope 192 193 if (name == "EM-Photon-Penelope") 194 { 195 if (emPhotonIsRegistered) 196 { 197 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 198 << " cannot be registered ---- photon List already existing" 199 << G4endl; 200 } 201 else 202 { 203 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 204 << " is registered" << G4endl; 205 RegisterPhysics( new EMPhotonPenelope(name) ); 206 emPhotonIsRegistered = true; 207 } 208 } 209 210 211 // ***************** 212 // *** Electrons *** 213 // ***************** 214 215 // *** Option I: Standard 216 217 if (name == "EM-Electron-Standard") 218 { 219 if (emElectronIsRegistered) 220 { 221 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 222 << " cannot be registered ---- electron List already existing" 223 << G4endl; 224 } 225 else 226 { 227 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 228 << " is registered" << G4endl; 229 RegisterPhysics( new EMElectronStandard(name) ); 230 emElectronIsRegistered = true; 231 } 232 } 233 234 235 // *** Option II: Low Energy based on the Livermore libraries 236 237 if (name == "EM-Electron-EEDL") 238 { 239 if (emElectronIsRegistered) 240 { 241 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 242 << " cannot be registered ---- electron List already existing" 243 << G4endl; 244 } 245 else 246 { 247 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 248 << " is registered" << G4endl; 249 RegisterPhysics( new EMElectronEEDL(name) ); 250 emElectronIsRegistered = true; 251 } 252 } 253 254 255 // *** Option III: Low Energy Penelope 256 257 if (name == "EM-Electron-Penelope") 258 { 259 if (emElectronIsRegistered) 260 { 261 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 262 << " cannot be registered ---- electron List already existing" 263 << G4endl; 264 } 265 else 266 { 267 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 268 << " is registered" << G4endl; 269 RegisterPhysics( new EMElectronPenelope(name) ); 270 emElectronIsRegistered = true; 271 } 272 } 273 274 275 // ***************** 276 // *** Positrons *** 277 // ***************** 278 279 // *** Option I: Standard 280 if (name == "EM-Positron-Standard") 281 { 282 if (emPositronIsRegistered) 283 { 284 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 285 << " cannot be registered ---- positron List already existing" 286 << G4endl; 287 } 288 else 289 { 290 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 291 << " is registered" << G4endl; 292 RegisterPhysics( new EMPositronStandard(name) ); 293 emPositronIsRegistered = true; 294 } 295 } 296 297 298 // *** Option II: Low Energy Penelope 299 300 if (name == "EM-Positron-Penelope") 301 { 302 if (emPositronIsRegistered) 303 { 304 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 305 << " cannot be registered ---- positron List already existing" 306 << G4endl; 307 } 308 else 309 { 310 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 311 << " is registered" << G4endl; 312 RegisterPhysics( new EMPositronPenelope(name) ); 313 emPositronIsRegistered = true; 314 } 315 } 316 317 318 // ************************ 319 // *** Hadrons and Ions *** 320 // ************************ 321 322 // *** Option I: Low Energy with ICRU49 stopping power parametrisation 323 324 if (name == "EM-HadronIon-LowE") 325 { 326 if (emIonIsRegistered) 327 { 328 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 329 << " cannot be registered ---- proton List already existing" 330 << G4endl; 331 } 332 else 333 { 334 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 335 << " is registered" << G4endl; 336 RegisterPhysics( new EMHadronIonLowEICRU49(name) ); 337 emIonIsRegistered = true; 338 } 339 } 340 341 342 // *** Option II: Low Energy with Ziegler 1977 stopping power parametrisation 343 344 if (name == "EM-HadronIon-LowEZiegler1977") 345 { 346 if (emIonIsRegistered) 347 { 348 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 349 << " cannot be registered ---- proton List already existing" 350 << G4endl; 351 } 352 else 353 { 354 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 355 << " is registered" << G4endl; 356 RegisterPhysics( new EMHadronIonLowEZiegler1977(name) ); 357 emIonIsRegistered = true; 358 } 359 } 360 361 362 // *** Option III: Low Energy with Ziegler 1985 stopping power parametrisation 363 364 if (name == "EM-HadronIon-LowEZiegler1985") 365 { 366 if (emIonIsRegistered) 367 { 368 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 369 << " cannot be registered ---- proton List already existing" 370 << G4endl; 371 } 372 else 373 { 374 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 375 << " is registered" << G4endl; 376 RegisterPhysics( new EMHadronIonLowEZiegler1985(name) ); 377 emIonIsRegistered = true; 378 } 379 } 380 381 382 // *** Option IV: Standard 383 384 if (name == "EM-HadronIon-Standard") 385 { 386 if (emIonIsRegistered) 387 { 388 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 389 << " cannot be registered ---- ion List already existing" 390 << G4endl; 391 } 392 else 393 { 394 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 395 << " is registered" << G4endl; 396 RegisterPhysics( new EMHadronIonStandard(name) ); 397 emIonIsRegistered = true; 398 } 399 } 400 401 402 // ************* 403 // *** Muons *** 404 // ************* 405 406 // *** Option I: Standard 407 408 if (name == "EM-Muon-Standard") 409 { 410 if (emMuonIsRegistered) 411 { 412 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 413 << " cannot be registered ---- decay List already existing" 414 << G4endl; 415 } 416 else 417 { 418 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 419 << " is registered" << G4endl; 420 RegisterPhysics( new EMMuonStandard(name) ); 421 emMuonIsRegistered = true; 422 } 423 } 424 425 426 // ******************************** 427 // *** C. HADRONIC INTERACTIONS *** 428 // ******************************** 429 430 431 // ****************************** 432 // *** C.1. ELASTIC PROCESSES *** 433 // ****************************** 434 435 436 // ************************ 437 // *** Hadrons and Ions *** 438 // ************************ 439 440 // *** Option I: GHEISHA like LEP model 441 442 if (name == "HadronicEl-HadronIon-LElastic") 443 { 444 if (hadrElasticHadronIonIsRegistered) 445 { 446 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 447 << " cannot be registered ---- hadronic Elastic Scattering List already existing" 448 << G4endl; 449 } 450 else 451 { 452 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 453 << " is registered" << G4endl; 454 RegisterPhysics( new HEHadronIonLElastic(name) ); 455 hadrElasticHadronIonIsRegistered = true; 456 } 457 } 458 459 460 // *** Option II: Bertini model 461 462 if (name == "HadronicEl-HadronIon-Bert") 463 { 464 if (hadrElasticHadronIonIsRegistered) 465 { 466 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 467 << " cannot be registered ---- hadronic Elastic Scattering List already existing" 468 << G4endl; 469 } 470 else 471 { 472 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 473 << " is registered" << G4endl; 474 RegisterPhysics( new HEHadronIonBertiniElastic(name) ); 475 hadrElasticHadronIonIsRegistered = true; 476 } 477 } 478 479 480 // *** Option III: Process G4QElastic 481 482 if (name == "HadronicEl-HadronIon-QElastic") 483 { 484 if (hadrElasticHadronIonIsRegistered) 485 { 486 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 487 << " cannot be registered ---- hadronic Elastic Scattering List already existing" 488 << G4endl; 489 } 490 else 491 { 492 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 493 << " is registered" << G4endl; 494 RegisterPhysics( new HEHadronIonQElastic(name) ); 495 hadrElasticHadronIonIsRegistered = true; 496 } 497 } 498 499 500 // *** Option III: Process G4UHadronElasticProcess 501 502 if (name == "HadronicEl-HadronIon-UElastic") 503 { 504 if (hadrElasticHadronIonIsRegistered) 505 { 506 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 507 << " cannot be registered ---- hadronic Elastic Scattering List already existing" 508 << G4endl; 509 } 510 else 511 { 512 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 513 << " is registered" << G4endl; 514 RegisterPhysics( new HEHadronIonUElastic(name) ); 515 hadrElasticHadronIonIsRegistered = true; 516 } 517 } 518 519 520 // ******************************** 521 // *** C.2. INELASTIC PROCESSES *** 522 // ******************************** 523 524 525 // ************* 526 // *** Pions *** 527 // ************* 528 529 // *** Option I: Bertini model 530 531 if (name == "HadronicInel-Pion-Bertini") 532 { 533 if (hadrInelasticPionIsRegistered) 534 { 535 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 536 << " cannot be registered ---- decay List already existing" 537 << G4endl; 538 } 539 else 540 { 541 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 542 << " is registered" << G4endl; 543 RegisterPhysics( new HIPionBertini(name) ); 544 hadrInelasticPionIsRegistered = true; 545 } 546 } 547 548 549 // *** Option II: GHEISHA like LEP model 550 551 if (name == "HadronicInel-Pion-LEP") 552 { 553 if (hadrInelasticPionIsRegistered) 554 { 555 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 556 << " cannot be registered ---- decay List already existing" 557 << G4endl; 558 } 559 else 560 { 561 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 562 << " is registered" << G4endl; 563 RegisterPhysics( new HIPionLEP(name) ); 564 hadrInelasticPionIsRegistered = true; 565 } 566 } 567 568 569 // ************ 570 // *** Ions *** 571 // ************ 572 573 // *** Option I: GHEISHA like LEP model 574 575 if (name == "HadronicInel-Ion-LEP") 576 { 577 if (hadrInelasticIonIsRegistered) 578 { 579 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 580 << " cannot be registered ---- decay List already existing" 581 << G4endl; 582 } 583 else 584 { 585 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 586 << " is registered" << G4endl; 587 RegisterPhysics( new HIIonLEP(name) ); 588 hadrInelasticIonIsRegistered = true; 589 } 590 } 591 592 593 // ************************* 594 // *** Protons, Neutrons *** 595 // ************************* 596 597 // *** Option I: GHEISHA like LEP model 598 599 if (name == "HadronicInel-ProtonNeutron-LEP") 600 { 601 if (hadrInelasticProtonNeutronIsRegistered) 602 { 603 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 604 << " cannot be registered ---- decay List already existing" 605 << G4endl; 606 } 607 else 608 { 609 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 610 << " is registered" << G4endl; 611 RegisterPhysics( new HIProtonNeutronLEP(name) ); 612 hadrInelasticProtonNeutronIsRegistered = true; 613 } 614 } 615 616 617 // *** Option II: Bertini Cascade Model 618 619 if (name == "HadronicInel-ProtonNeutron-Bert") 620 { 621 if (hadrInelasticProtonNeutronIsRegistered) 622 { 623 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 624 << " cannot be registered ---- decay List already existing" 625 << G4endl; 626 } 627 else 628 { 629 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 630 << " is registered" << G4endl; 631 RegisterPhysics( new HIProtonNeutronBertini(name) ); 632 hadrInelasticProtonNeutronIsRegistered = true; 633 } 634 } 635 636 637 // *** Option III: Binary Cascade Model 638 639 if (name == "HadronicInel-ProtonNeutron-Bin") 640 { 641 if (hadrInelasticProtonNeutronIsRegistered) 642 { 643 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 644 << " cannot be registered ---- decay List already existing" 645 << G4endl; 646 } 647 else 648 { 649 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 650 << " is registered" << G4endl; 651 RegisterPhysics( new HIProtonNeutronBinary(name) ); 652 hadrInelasticProtonNeutronIsRegistered = true; 653 } 654 } 655 656 657 // *** Option IV: Precompound Model combined with Default Evaporation 658 659 if (name == "HadronicInel-ProtonNeutron-Prec") 660 { 661 if (hadrInelasticProtonNeutronIsRegistered) 662 { 663 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 664 << " cannot be registered ---- decay List already existing" 665 << G4endl; 666 } 667 else 668 { 669 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 670 << " is registered" << G4endl; 671 RegisterPhysics( new HIProtonNeutronPrecompound(name) ); 672 hadrInelasticProtonNeutronIsRegistered = true; 673 } 674 } 675 676 677 // *** Option V: Precompound Model combined with GEM Evaporation 678 679 if (name == "HadronicInel-ProtonNeutron-PrecGEM") 680 { 681 if (hadrInelasticProtonNeutronIsRegistered) 682 { 683 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 684 << " cannot be registered ---- decay List already existing" 685 << G4endl; 686 } 687 else 688 { 689 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 690 << " is registered" << G4endl; 691 RegisterPhysics( new HIProtonNeutronPrecompoundGEM(name) ); 692 hadrInelasticProtonNeutronIsRegistered = true; 693 } 694 } 695 696 697 // *** Option VI: Precompound Model combined with default Evaporation 698 // and Fermi Break-up model 699 700 if (name == "HadronicInel-ProtonNeutron-PrecFermi") 701 { 702 if (hadrInelasticProtonNeutronIsRegistered) 703 { 704 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 705 << " cannot be registered ---- decay List already existing" 706 << G4endl; 707 } 708 else 709 { 710 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 711 << " is registered" << G4endl; 712 RegisterPhysics( new HIProtonNeutronPrecompoundFermi(name) ); 713 hadrInelasticProtonNeutronIsRegistered = true; 714 } 715 } 716 717 718 // *** Option VII: Precompound Model combined with GEM Evaporation 719 // and Fermi Break-up model 720 721 if (name == "HadronicInel-ProtonNeutron-PrecGEMFermi") 722 { 723 if (hadrInelasticProtonNeutronIsRegistered) 724 { 725 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 726 << " cannot be registered ---- decay List already existing" 727 << G4endl; 728 } 729 else 730 { 731 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 732 << " is registered" << G4endl; 733 RegisterPhysics( new HIProtonNeutronPrecompoundGEMFermi(name) ); 734 hadrInelasticProtonNeutronIsRegistered = true; 735 } 736 } 737 738 739 // ****************************** 740 // *** C.3. AT-REST PROCESSES *** 741 // ****************************** 742 743 744 // ************** 745 // *** Muons- *** 746 // ************** 747 748 // *** Option I: Muon Minus Capture at Rest 749 750 if (name == "HadronicAtRest-MuonMinus-Capture") 751 { 752 if (hadrAtRestMuonIsRegistered) 753 { 754 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 755 << " cannot be registered ---- decay List already existing" 756 << G4endl; 757 } 758 else 759 { 760 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 761 << " is registered" << G4endl; 762 RegisterPhysics( new HRMuonMinusCapture(name) ); 763 hadrAtRestMuonIsRegistered = true; 764 } 765 } 766 767 } 768 200 201 if (verboseLevel>1) { 202 G4cout << "PhysicsList::AddPhysicsList: <" << name << ">" << G4endl; 203 } 204 if (name == emName) return; 205 206 ///////////////////////////////////////////////////////////////////////////// 207 // ELECTROMAGNETIC MODELS 208 ///////////////////////////////////////////////////////////////////////////// 209 210 if (name == "standard_opt3") { 211 emName = name; 212 delete emPhysicsList; 213 emPhysicsList = new G4EmStandardPhysics_option3(); 214 G4cout << "THE FOLLOWING ELECTROMAGNETIC PHYSICS LIST HAS BEEN ACTIVATED: G4EmStandardPhysics_option3" << G4endl; 215 216 } else if (name == "LowE_Livermore") { 217 emName = name; 218 delete emPhysicsList; 219 emPhysicsList = new G4EmLivermorePhysics(); 220 G4cout << "THE FOLLOWING ELECTROMAGNETIC PHYSICS LIST HAS BEEN ACTIVATED: G4EmLivermorePhysics" << G4endl; 221 222 } else if (name == "LowE_Penelope") { 223 emName = name; 224 delete emPhysicsList; 225 emPhysicsList = new G4EmPenelopePhysics(); 226 G4cout << "THE FOLLOWING ELECTROMAGNETIC PHYSICS LIST HAS BEEN ACTIVATED: G4EmLivermorePhysics" << G4endl; 227 228 ///////////////////////////////////////////////////////////////////////////// 229 // HADRONIC MODELS 230 ///////////////////////////////////////////////////////////////////////////// 231 } else if (name == "elastic" && !helIsRegisted) { 232 G4cout << "THE FOLLOWING HADRONIC ELASTIC PHYSICS LIST HAS BEEN ACTIVATED: G4HadronElasticPhysics()" << G4endl; 233 hadronPhys.push_back( new G4HadronElasticPhysics()); 234 helIsRegisted = true; 235 236 } else if (name == "DElastic" && !helIsRegisted) { 237 hadronPhys.push_back( new G4HadronDElasticPhysics()); 238 helIsRegisted = true; 239 240 } else if (name == "HElastic" && !helIsRegisted) { 241 hadronPhys.push_back( new G4HadronHElasticPhysics()); 242 helIsRegisted = true; 243 244 } else if (name == "QElastic" && !helIsRegisted) { 245 hadronPhys.push_back( new G4HadronQElasticPhysics()); 246 helIsRegisted = true; 247 248 } else if (name == "binary" && !bicIsRegisted) { 249 hadronPhys.push_back(new G4HadronInelasticQBBC()); 250 bicIsRegisted = true; 251 G4cout << "THE FOLLOWING HADRONIC INELASTIC PHYSICS LIST HAS BEEN ACTIVATED: G4HadronInelasticQBBC()" << G4endl; 252 253 } else if (name == "binary_ion" && !biciIsRegisted) { 254 hadronPhys.push_back(new G4IonBinaryCascadePhysics()); 255 biciIsRegisted = true; 256 257 } else if (name == "local_ion_ion_inelastic" && !locIonIonInelasticIsRegistered) { 258 hadronPhys.push_back(new LocalIonIonInelasticPhysic()); 259 locIonIonInelasticIsRegistered = true; 260 261 } else if (name == "local_incl_ion_ion_inelastic" && !locIonIonInelasticIsRegistered) { 262 hadronPhys.push_back(new LocalINCLIonIonInelasticPhysic()); 263 locIonIonInelasticIsRegistered = true; 264 265 } else if (name == "radioactive_decay" && !radioactiveDecayIsRegisted ) { 266 hadronPhys.push_back(new G4RadioactiveDecayPhysics()); 267 radioactiveDecayIsRegisted = true; 268 269 } else { 270 271 G4cout << "PhysicsList::AddPhysicsList: <" << name << ">" 272 << " is not defined" 273 << G4endl; 274 } 275 } 276 277 ///////////////////////////////////////////////////////////////////////////// 278 void HadrontherapyPhysicsList::AddStepMax() 279 { 280 // Step limitation seen as a process 281 stepMaxProcess = new HadrontherapyStepMax(); 282 283 theParticleIterator->reset(); 284 while ((*theParticleIterator)()){ 285 G4ParticleDefinition* particle = theParticleIterator->value(); 286 G4ProcessManager* pmanager = particle->GetProcessManager(); 287 288 if (stepMaxProcess->IsApplicable(*particle) && pmanager) 289 { 290 pmanager ->AddDiscreteProcess(stepMaxProcess); 291 } 292 } 293 } 294 295 ///////////////////////////////////////////////////////////////////////////// 769 296 void HadrontherapyPhysicsList::SetCuts() 770 { 771 // Set the threshold of production equal to the defaultCutValue 772 // in the experimental set-up 773 G4VUserPhysicsList::SetCutsWithDefault(); 774 775 G4double lowlimit=250*eV; 776 G4ProductionCutsTable::GetProductionCutsTable() ->SetEnergyRange(lowlimit, 100.*GeV); 777 // Definition of a smaller threshold of production in the phantom region 778 // where high accuracy is required in the energy deposit calculation 779 780 G4String regionName = "PhantomLog"; 781 G4Region* region = G4RegionStore::GetInstance()->GetRegion(regionName); 782 G4ProductionCuts* cuts = new G4ProductionCuts ; 783 G4double regionCut = 0.01*mm; 784 cuts -> SetProductionCut(regionCut,G4ProductionCuts::GetIndex("gamma")); 785 cuts -> SetProductionCut(regionCut,G4ProductionCuts::GetIndex("e-")); 786 cuts -> SetProductionCut(regionCut,G4ProductionCuts::GetIndex("e+")); 787 cuts -> SetProductionCut(regionCut,G4ProductionCuts::GetIndex("proton")); 788 cuts -> SetProductionCut(regionCut,G4ProductionCuts::GetIndex("genericIons")); 789 region -> SetProductionCuts(cuts); 297 { 298 299 if (verboseLevel >0){ 300 G4cout << "PhysicsList::SetCuts:"; 301 G4cout << "CutLength : " << G4BestUnit(defaultCutValue,"Length") << G4endl; 302 } 303 304 // set cut values for gamma at first and for e- second and next for e+, 305 // because some processes for e+/e- need cut values for gamma 306 SetCutValue(cutForGamma, "gamma"); 307 SetCutValue(cutForElectron, "e-"); 308 SetCutValue(cutForPositron, "e+"); 790 309 791 310 if (verboseLevel>0) DumpCutValuesTable(); 792 311 } 793 312 794 313 ///////////////////////////////////////////////////////////////////////////// 314 void HadrontherapyPhysicsList::SetCutForGamma(G4double cut) 315 { 316 cutForGamma = cut; 317 SetParticleCuts(cutForGamma, G4Gamma::Gamma()); 318 } 319 320 ///////////////////////////////////////////////////////////////////////////// 321 void HadrontherapyPhysicsList::SetCutForElectron(G4double cut) 322 { 323 cutForElectron = cut; 324 SetParticleCuts(cutForElectron, G4Electron::Electron()); 325 } 326 327 ///////////////////////////////////////////////////////////////////////////// 328 void HadrontherapyPhysicsList::SetCutForPositron(G4double cut) 329 { 330 cutForPositron = cut; 331 SetParticleCuts(cutForPositron, G4Positron::Positron()); 332 } -
trunk/examples/advanced/hadrontherapy/src/HadrontherapyPhysicsListMessenger.cc
r807 r1230 24 24 // ******************************************************************** 25 25 // 26 // $Id: HadrontherapyPhisicsListMessenger.cc; May 2005 27 // ---------------------------------------------------------------------------- 28 // GEANT 4 - Hadrontherapy example 29 // ---------------------------------------------------------------------------- 30 // Code developed by: 31 // 32 // G.A.P. Cirrone(a)*, F. Di Rosa(a), S. Guatelli(b), G. Russo(a) 33 // 34 // (a) Laboratori Nazionali del Sud 35 // of the National Institute for Nuclear Physics, Catania, Italy 36 // (b) National Institute for Nuclear Physics Section of Genova, genova, Italy 37 // 38 // * cirrone@lns.infn.it 39 // ---------------------------------------------------------------------------- 26 // HadrontherapyPhysicsListMessenger.cc 27 // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy 28 40 29 #include "HadrontherapyPhysicsListMessenger.hh" 30 41 31 #include "HadrontherapyPhysicsList.hh" 42 32 #include "G4UIdirectory.hh" 43 #include "G4UIcmdWithoutParameter.hh"44 #include "G4UIcmdWithADouble.hh"45 33 #include "G4UIcmdWithADoubleAndUnit.hh" 46 #include "G4UIcmdWithABool.hh"47 34 #include "G4UIcmdWithAString.hh" 48 35 49 HadrontherapyPhysicsListMessenger::HadrontherapyPhysicsListMessenger(HadrontherapyPhysicsList * physList) 50 :physicsList(physList) 51 { 52 listDir = new G4UIdirectory("/physics/"); 53 // Building modular PhysicsList 36 ///////////////////////////////////////////////////////////////////////////// 37 HadrontherapyPhysicsListMessenger::HadrontherapyPhysicsListMessenger(HadrontherapyPhysicsList* pPhys) 38 :pPhysicsList(pPhys) 39 { 40 physDir = new G4UIdirectory("/physic/"); 41 physDir->SetGuidance("Commands to activate physics models and set cuts"); 42 43 gammaCutCmd = new G4UIcmdWithADoubleAndUnit("/physic/setGCut",this); 44 gammaCutCmd->SetGuidance("Set gamma cut."); 45 gammaCutCmd->SetParameterName("Gcut",false); 46 gammaCutCmd->SetUnitCategory("Length"); 47 gammaCutCmd->SetRange("Gcut>0.0"); 48 gammaCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 54 49 55 physicsListCmd = new G4UIcmdWithAString("/physics/addPhysics",this); 56 physicsListCmd->SetGuidance("Add chunks of PhysicsList."); 57 physicsListCmd->SetParameterName("physList",false); 58 physicsListCmd->AvailableForStates(G4State_PreInit); 50 electCutCmd = new G4UIcmdWithADoubleAndUnit("/physic/setECut",this); 51 electCutCmd->SetGuidance("Set electron cut."); 52 electCutCmd->SetParameterName("Ecut",false); 53 electCutCmd->SetUnitCategory("Length"); 54 electCutCmd->SetRange("Ecut>0.0"); 55 electCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 56 57 protoCutCmd = new G4UIcmdWithADoubleAndUnit("/physic/setPCut",this); 58 protoCutCmd->SetGuidance("Set positron cut."); 59 protoCutCmd->SetParameterName("Pcut",false); 60 protoCutCmd->SetUnitCategory("Length"); 61 protoCutCmd->SetRange("Pcut>0.0"); 62 protoCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 63 64 allCutCmd = new G4UIcmdWithADoubleAndUnit("/physic/setCuts",this); 65 allCutCmd->SetGuidance("Set cut for all."); 66 allCutCmd->SetParameterName("cut",false); 67 allCutCmd->SetUnitCategory("Length"); 68 allCutCmd->SetRange("cut>0.0"); 69 allCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 70 71 pListCmd = new G4UIcmdWithAString("/physic/addPhysics",this); 72 pListCmd->SetGuidance("Add physics list."); 73 pListCmd->SetParameterName("PList",false); 74 pListCmd->AvailableForStates(G4State_PreInit); 75 76 packageListCmd = new G4UIcmdWithAString("/physic/addPackage",this); 77 packageListCmd->SetGuidance("Add physics package."); 78 packageListCmd->SetParameterName("package",false); 79 packageListCmd->AvailableForStates(G4State_PreInit); 59 80 } 60 81 82 ///////////////////////////////////////////////////////////////////////////// 61 83 HadrontherapyPhysicsListMessenger::~HadrontherapyPhysicsListMessenger() 62 84 { 63 delete physicsListCmd; 64 delete listDir; 85 delete gammaCutCmd; 86 delete electCutCmd; 87 delete protoCutCmd; 88 delete allCutCmd; 89 delete pListCmd; 90 delete physDir; 91 delete packageListCmd; 65 92 } 66 93 67 void HadrontherapyPhysicsListMessenger::SetNewValue(G4UIcommand* command,G4String newValue) 68 { 69 if (command == physicsListCmd) 70 { physicsList->AddPhysicsList(newValue);} 71 } 94 ///////////////////////////////////////////////////////////////////////////// 95 void HadrontherapyPhysicsListMessenger::SetNewValue(G4UIcommand* command, 96 G4String newValue) 97 { 98 if( command == gammaCutCmd ) 99 { pPhysicsList->SetCutForGamma(gammaCutCmd->GetNewDoubleValue(newValue));} 100 101 if( command == electCutCmd ) 102 { pPhysicsList->SetCutForElectron(electCutCmd->GetNewDoubleValue(newValue));} 103 104 if( command == protoCutCmd ) 105 { pPhysicsList->SetCutForPositron(protoCutCmd->GetNewDoubleValue(newValue));} 106 107 if( command == allCutCmd ) 108 { 109 G4double cut = allCutCmd->GetNewDoubleValue(newValue); 110 pPhysicsList->SetCutForGamma(cut); 111 pPhysicsList->SetCutForElectron(cut); 112 pPhysicsList->SetCutForPositron(cut); 113 } 114 115 if( command == pListCmd ) 116 { pPhysicsList->AddPhysicsList(newValue);} 72 117 73 118 119 if( command == packageListCmd ) 120 { pPhysicsList->AddPackage(newValue);} 74 121 75 122 76 77 123 } -
trunk/examples/advanced/hadrontherapy/src/HadrontherapyPrimaryGeneratorAction.cc
r807 r1230 24 24 // ******************************************************************** 25 25 // 26 // $Id: HadrontherapyPositronPrimaryGeneratorAction.cc; May 2005 26 // HadrontherapyPrimarygeneratorAction.cc; 27 // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy 27 28 // ---------------------------------------------------------------------------- 28 29 // GEANT 4 - Hadrontherapy example … … 30 31 // Code developed by: 31 32 // 32 // G.A.P. Cirrone(a)*, F. Di Rosa(a), S. Guatelli(b), G. Russo(a)33 // G.A.P. Cirrone(a)*, F.Romano(a) 33 34 // 34 35 // (a) Laboratori Nazionali del Sud 35 // of the National Institute for Nuclear Physics, Catania, Italy 36 // (b) National Institute for Nuclear Physics Section of Genova, genova, Italy 36 // of the INFN, Catania, Italy 37 37 // 38 38 // * cirrone@lns.infn.it 39 // ---------------------------------------------------------------------------- 39 // 40 // ------------------------------------------------------------------------------ 41 40 42 #include "HadrontherapyPrimaryGeneratorAction.hh" 41 43 #include "HadrontherapyPrimaryGeneratorMessenger.hh" … … 45 47 #include "G4ParticleDefinition.hh" 46 48 #include "Randomize.hh" 49 #include "HadrontherapyAnalysisManager.hh" 47 50 48 51 HadrontherapyPrimaryGeneratorAction::HadrontherapyPrimaryGeneratorAction() … … 75 78 76 79 // Define the energy of primary particles: 77 // gaussian distribution with mean energy = 6 4.55*MeV78 // and sigma = 300.0 *keV79 G4double defaultMeanKineticEnergy = 6 3.50 *MeV;80 // gaussian distribution with mean energy = 62.0 *MeV 81 // and sigma = 400.0 *keV 82 G4double defaultMeanKineticEnergy = 62.0 *MeV; 80 83 meanKineticEnergy = defaultMeanKineticEnergy; 81 84 82 G4double defaultsigmaEnergy = 300.0 *keV;85 G4double defaultsigmaEnergy = 400.0 *keV; 83 86 sigmaEnergy = defaultsigmaEnergy; 87 88 #ifdef ANALYSIS_USE 89 // Write these values into the analysis if needed. Have to be written separately on change. 90 HadrontherapyAnalysisManager::getInstance()->setBeamMetaData(meanKineticEnergy, sigmaEnergy); 91 #endif 84 92 85 93 // Define the parameters of the initial position: 86 94 // the y, z coordinates have a gaussian distribution 87 G4double defaultX0 = -3248.59 *mm; 95 96 G4double defaultX0 = -2700.0 *mm; 88 97 X0 = defaultX0; 89 98 … … 111 120 void HadrontherapyPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent) 112 121 { 122 #ifdef ANALYSIS_USE 123 // Increment the event counter 124 HadrontherapyAnalysisManager::getInstance()->startNewEvent(); 125 #endif 126 113 127 // **************************************** 114 128 // Set the beam angular apread … … 162 176 163 177 void HadrontherapyPrimaryGeneratorAction::SetmeanKineticEnergy (G4double val ) 164 { meanKineticEnergy = val;} 178 { 179 meanKineticEnergy = val; 180 #ifdef ANALYSIS_USE 181 // Update the beam-data in the analysis manager 182 HadrontherapyAnalysisManager::getInstance()->setBeamMetaData(meanKineticEnergy, sigmaEnergy); 183 #endif 184 185 } 165 186 166 187 void HadrontherapyPrimaryGeneratorAction::SetsigmaEnergy (G4double val ) 167 { sigmaEnergy = val;} 188 { 189 sigmaEnergy = val; 190 #ifdef ANALYSIS_USE 191 // Update the sigmaenergy in the metadata. 192 HadrontherapyAnalysisManager::getInstance()->setBeamMetaData(meanKineticEnergy, sigmaEnergy); 193 #endif 194 } 168 195 169 196 void HadrontherapyPrimaryGeneratorAction::SetXposition (G4double val ) … … 187 214 void HadrontherapyPrimaryGeneratorAction::SetsigmaMomentumZ (G4double val ) 188 215 { sigmaMomentumZ = val;} 216 217 G4double HadrontherapyPrimaryGeneratorAction::GetmeanKineticEnergy(void) 218 { return meanKineticEnergy;} -
trunk/examples/advanced/hadrontherapy/src/HadrontherapyPrimaryGeneratorMessenger.cc
r807 r1230 24 24 // ******************************************************************** 25 25 // 26 // $Id: HadrontherapyPrimaryGeneratorMessenger.cc; May 2005 27 // ---------------------------------------------------------------------------- 28 // GEANT 4 - Hadrontherapy example 29 // ---------------------------------------------------------------------------- 30 // Code developed by: 31 // 32 // G.A.P. Cirrone(a)*, F. Di Rosa(a), S. Guatelli(b), G. Russo(a) 33 // 34 // (a) Laboratori Nazionali del Sud 35 // of the National Institute for Nuclear Physics, Catania, Italy 36 // (b) National Institute for Nuclear Physics Section of Genova, genova, Italy 37 // 38 // * cirrone@lns.infn.it 39 // ---------------------------------------------------------------------------- 26 // HadrontherapyPrimaryGeneratorMessenger.cc; 27 // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy 40 28 41 29 #include "HadrontherapyPrimaryGeneratorMessenger.hh" -
trunk/examples/advanced/hadrontherapy/src/HadrontherapyRunAction.cc
r807 r1230 24 24 // ******************************************************************** 25 25 // 26 // $Id: HadrontherapyRunAction.cc,v 3.0, September 2004; 27 // ---------------------------------------------------------------------------- 28 // GEANT 4 - Hadrontherapy example 29 // ---------------------------------------------------------------------------- 30 // Code developed by: 31 // 32 // G.A.P. Cirrone(a)*, F. Di Rosa(a), S. Guatelli(b), G. Russo(a) 33 // 34 // (a) Laboratori Nazionali del Sud 35 // of the INFN, Catania, Italy 36 // (b) INFN Section of Genova, Genova, Italy 37 // 38 // * cirrone@lns.infn.it 39 // ---------------------------------------------------------------------------- 26 // $Id: HadrontherapyRunAction.cc 27 // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy 40 28 41 29 #include "HadrontherapyRunAction.hh" -
trunk/examples/advanced/hadrontherapy/src/HadrontherapySteppingAction.cc
r807 r1230 24 24 // ******************************************************************** 25 25 // 26 // $Id: HadrontherapyProtonSteppingAction.cc; May 2005 27 // ---------------------------------------------------------------------------- 28 // GEANT 4 - Hadrontherapy example 29 // ---------------------------------------------------------------------------- 30 // Code developed by: 31 // 32 // G.A.P. Cirrone(a)*, F. Di Rosa(a), S. Guatelli(b), G. Russo(a) 33 // 34 // (a) Laboratori Nazionali del Sud 35 // of the INFN, Catania, Italy 36 // (b) INFN Section of Genova, Genova, Italy 37 // 38 // * cirrone@lns.infn.it 39 // ---------------------------------------------------------------------------- 26 // HadrontherapyProtonSteppingAction.cc; 27 // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy 40 28 41 29 #include "G4SteppingManager.hh" … … 52 40 #include "G4ParticleTypes.hh" 53 41 54 #ifdef G4ANALYSIS_USE55 42 #include "HadrontherapyAnalysisManager.hh" 56 #endif57 43 58 44 #include "HadrontherapyRunAction.hh" 59 45 60 HadrontherapySteppingAction::HadrontherapySteppingAction( HadrontherapyRunAction* run) 46 ///////////////////////////////////////////////////////////////////////////// 47 HadrontherapySteppingAction::HadrontherapySteppingAction( HadrontherapyRunAction *run) 61 48 { 62 49 runAction = run; 63 50 } 64 51 52 ///////////////////////////////////////////////////////////////////////////// 65 53 HadrontherapySteppingAction::~HadrontherapySteppingAction() 66 54 { 67 55 } 68 56 57 ///////////////////////////////////////////////////////////////////////////// 69 58 void HadrontherapySteppingAction::UserSteppingAction(const G4Step* aStep) 70 59 { 60 if( aStep->GetTrack()->GetVolume()->GetName() == "NewDetectorPhys"){ 61 #ifdef ANALYSIS_USE 62 G4ParticleDefinition *def = aStep->GetTrack()->GetDefinition(); 63 G4double secondaryParticleKineticEnergy = aStep->GetTrack()->GetKineticEnergy(); 64 G4String particleType = def->GetParticleType(); // particle type = nucleus for d, t, He3, alpha, and heavier nuclei 65 G4String particleName = def->GetParticleName(); // e.g. for alpha: the name = "alpha" and type = "nucleus" 66 if(particleType == "nucleus") { 67 G4int A = def->GetBaryonNumber(); 68 G4double Z = def->GetPDGCharge(); 69 G4double posX = aStep->GetTrack()->GetPosition().x() / cm; 70 G4double posY = aStep->GetTrack()->GetPosition().y() / cm; 71 G4double posZ = aStep->GetTrack()->GetPosition().z() / cm; 72 G4double energy = secondaryParticleKineticEnergy / A / MeV; 73 74 HadrontherapyAnalysisManager* analysisMgr = HadrontherapyAnalysisManager::getInstance(); 75 analysisMgr->fillFragmentTuple(A, Z, energy, posX, posY, posZ); 76 } else if(particleName == "proton") { // proton (hydrogen-1) is a special case 77 G4double posX = aStep->GetTrack()->GetPosition().x() / cm ; 78 G4double posY = aStep->GetTrack()->GetPosition().y() / cm ; 79 G4double posZ = aStep->GetTrack()->GetPosition().z() / cm ; 80 G4double energy = secondaryParticleKineticEnergy * MeV; // Hydrogen-1: A = 1, Z = 1 81 HadrontherapyAnalysisManager::getInstance()->fillFragmentTuple(1, 1.0, energy, posX, posY, posZ); 82 } 83 84 G4String secondaryParticleName = def -> GetParticleName(); 85 //G4cout <<"Particle: " << secondaryParticleName << G4endl; 86 //G4cout <<"Energy: " << secondaryParticleKineticEnergy << G4endl; 87 HadrontherapyAnalysisManager* analysis = HadrontherapyAnalysisManager::getInstance(); 88 //There is a bunch of stuff recorded with the energy 0, something should perhaps be done about this. 89 if(secondaryParticleName == "proton") { 90 analysis->hydrogenEnergy(secondaryParticleKineticEnergy / MeV); 91 } 92 if(secondaryParticleName == "deuteron") { 93 analysis->hydrogenEnergy((secondaryParticleKineticEnergy/2) / MeV); 94 } 95 if(secondaryParticleName == "triton") { 96 analysis->hydrogenEnergy((secondaryParticleKineticEnergy/3) / MeV); 97 } 98 if(secondaryParticleName == "alpha") { 99 analysis->heliumEnergy((secondaryParticleKineticEnergy/4) / MeV); 100 } 101 if(secondaryParticleName == "He3"){ 102 analysis->heliumEnergy((secondaryParticleKineticEnergy/3) / MeV); 103 } 104 #endif 105 106 aStep->GetTrack()->SetTrackStatus(fKillTrackAndSecondaries); 107 } 108 71 109 // Electromagnetic and hadronic processes of primary particles in the phantom 72 73 if ((aStep -> GetTrack() -> GetTrackID() == 1) &&110 //setting phantomPhys correctly will break something here fixme 111 if ((aStep -> GetTrack() -> GetTrackID() == 1) && 74 112 (aStep -> GetTrack() -> GetVolume() -> GetName() == "PhantomPhys") && 75 113 (aStep -> GetPostStepPoint() -> GetProcessDefinedStep() != NULL)) … … 96 134 // Retrieve information about the secondaries originated in the phantom 97 135 98 #ifdef G4ANALYSIS_USE 99 G4SteppingManager* steppingManager = fpSteppingManager; 100 G4Track* theTrack = aStep -> GetTrack(); 101 136 G4SteppingManager* steppingManager = fpSteppingManager; 137 102 138 // check if it is alive 103 if(theTrack-> GetTrackStatus() == fAlive) { return; }139 //if(theTrack-> GetTrackStatus() == fAlive) { return; } 104 140 105 141 // Retrieve the secondary particles … … 110 146 G4String volumeName = (*fSecondary)[lp1] -> GetVolume() -> GetName(); 111 147 112 if (volumeName == " PhantomPhys")148 if (volumeName == "phantomPhys") 113 149 { 150 #ifdef ANALYSIS_USE 114 151 G4String secondaryParticleName = (*fSecondary)[lp1]->GetDefinition() -> GetParticleName(); 115 152 G4double secondaryParticleKineticEnergy = (*fSecondary)[lp1] -> GetKineticEnergy(); 116 153 117 154 HadrontherapyAnalysisManager* analysis = HadrontherapyAnalysisManager::getInstance(); 118 155 … … 137 174 G4int a = (*fSecondary)[lp1]-> GetDynamicParticle() -> GetDefinition() -> GetBaryonNumber(); 138 175 G4int electronOccupancy = (*fSecondary)[lp1] -> GetDynamicParticle() -> GetTotalOccupancy(); 139 // If a generic ion is originated in the phantom, its baryonic number, PDG charge, 176 177 // If a generic ion is originated in the detector, its baryonic number, PDG charge, 140 178 // total number of electrons in the orbitals are stored in a ntuple 141 analysis -> genericIonInformation(a, z, electronOccupancy, secondaryParticleKineticEnergy/MeV); 179 analysis -> genericIonInformation(a, z, electronOccupancy, secondaryParticleKineticEnergy/MeV); 142 180 } 181 #endif 143 182 } 144 183 } 145 #endif146 184 } 147 185
Note: See TracChangeset
for help on using the changeset viewer.