ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HadrontherapyPhysicsList.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file HadrontherapyPhysicsList.cc
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // Hadrontherapy advanced example for Geant4
27 // See more at: https://twiki.cern.ch/twiki/bin/view/Geant4/AdvancedExamplesHadrontherapy
28 //
29 //
30 // ****** SUGGESTED PHYSICS FOR ACCURATE SIMULATIONS *********
31 // ****** IN MEDICAL PHYSICS APPLICATIONS *********
32 //
33 // 'HADRONTHERAPY_1' and 'HADRONTHERAPY_2' are both suggested;
34 // It can be activated inside any macro file using the command:
35 // /Physics/addPhysics HADRONTHERAPY_1 (HADRONTHERAPY_2)
36 
37 #include "G4SystemOfUnits.hh"
38 #include "G4RunManager.hh"
39 #include "G4Region.hh"
40 #include "G4RegionStore.hh"
43 #include "HadrontherapyStepMax.hh"
44 #include "G4PhysListFactory.hh"
45 #include "G4VPhysicsConstructor.hh"
49 #include "G4EmStandardPhysics.hh"
50 #include "G4EmExtraPhysics.hh"
51 #include "G4StoppingPhysics.hh"
52 #include "G4DecayPhysics.hh"
57 #include "G4DecayPhysics.hh"
58 #include "G4NeutronTrackingCut.hh"
59 #include "G4LossTableManager.hh"
60 #include "G4UnitsTable.hh"
61 #include "G4ProcessManager.hh"
62 #include "G4IonFluctuations.hh"
64 #include "G4EmProcessOptions.hh"
66 #include "G4EmLivermorePhysics.hh"
67 #include "G4AutoDelete.hh"
69 
72 {
74  defaultCutValue = 1.*mm;
78 
80  SetVerboseLevel(1);
81  decay_List = new G4DecayPhysics();
82  // Elecromagnetic physics
83  //
85 
86 }
87 
90 {
91  delete pMessenger;
92  delete emPhysicsList;
93  delete decay_List;
94  //delete radioactiveDecay_List;
95  hadronPhys.clear();
96  for(size_t i=0; i<hadronPhys.size(); i++)
97  {
98  delete hadronPhys[i];
99  }
100 }
101 
104 {
106 
107 }
108 
111 {
112  // Transportation
113  //
115 
118 
119 
120  //em_config.AddModels();
121 
122  // Hadronic physics
123  //
124  for(size_t i=0; i < hadronPhys.size(); i++)
125  {
127  }
128 
129  // step limitation (as a full process)
130  //
131  AddStepMax();
132 
133  //Parallel world sensitivity
134  //
135  G4ParallelWorldPhysics* pWorld = new G4ParallelWorldPhysics("DetectorROGeometry");
136  pWorld->ConstructProcess();
137 
138  return;
139 }
140 
143 {
144  if (verboseLevel>1) {
145  G4cout << "PhysicsList::AddPhysicsList: <" << name << ">" << G4endl;
146  }
147  if (name == emName) return;
148 
150  // ELECTROMAGNETIC MODELS
152  if (name == "standard_opt4") {
153  emName = name;
154  delete emPhysicsList;
155  hadronPhys.clear();
157  G4RunManager::GetRunManager() -> PhysicsHasBeenModified();
158  G4cout << "THE FOLLOWING ELECTROMAGNETIC PHYSICS LIST HAS BEEN ACTIVATED: G4EmStandardPhysics_option4" << G4endl;
159 
161  // ELECTROMAGNETIC + HADRONIC MODELS
163 
164  } else if (name == "HADRONTHERAPY_1") {
165 
166  AddPhysicsList("standard_opt4");
167  hadronPhys.push_back( new G4DecayPhysics());
168  hadronPhys.push_back( new G4RadioactiveDecayPhysics());
169  hadronPhys.push_back( new G4IonBinaryCascadePhysics());
170  hadronPhys.push_back( new G4EmExtraPhysics());
171  hadronPhys.push_back( new G4HadronElasticPhysicsHP());
172  hadronPhys.push_back( new G4StoppingPhysics());
173  hadronPhys.push_back( new G4HadronPhysicsQGSP_BIC_HP());
174  hadronPhys.push_back( new G4NeutronTrackingCut());
175 
176  G4cout << "HADRONTHERAPY_1 PHYSICS LIST has been activated" << G4endl;
177  }
178 
179  else if (name == "HADRONTHERAPY_2") {
180  // HP models are switched off
181  AddPhysicsList("standard_opt4");
182  hadronPhys.push_back( new G4DecayPhysics());
183  hadronPhys.push_back( new G4RadioactiveDecayPhysics());
184  hadronPhys.push_back( new G4IonBinaryCascadePhysics());
185  hadronPhys.push_back( new G4EmExtraPhysics());
186  hadronPhys.push_back( new G4HadronElasticPhysics());
187  hadronPhys.push_back( new G4StoppingPhysics());
188  hadronPhys.push_back( new G4HadronPhysicsQGSP_BIC());
189  hadronPhys.push_back( new G4NeutronTrackingCut());
190 
191  G4cout << "HADRONTHERAPY_2 PHYSICS LIST has been activated" << G4endl; }
192  else {
193  G4cout << "PhysicsList::AddPhysicsList: <" << name << ">"
194  << " is not defined"
195  << G4endl;
196  }
197 
198 }
199 
202 {
203  // Step limitation seen as a process
204  // This process must exist in all threads.
205  //
206  HadrontherapyStepMax* stepMaxProcess = new HadrontherapyStepMax();
207  G4AutoDelete::Register( stepMaxProcess );
208 
210  particleIterator->reset();
211  while ((*particleIterator)()){
213  G4ProcessManager* pmanager = particle->GetProcessManager();
214 
215  if (stepMaxProcess->IsApplicable(*particle) && pmanager)
216  {
217  pmanager ->AddDiscreteProcess(stepMaxProcess);
218  }
219  }
220 }