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3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  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 // Using the builder concepts of Geant4 we assembled (and tested) two different
 30 // Physics Lists that are particuilarly suited for Hadronterapy applications:
 31 //
 32 // 'HADRONTHERAPY_1' is more suited for protons only
 33 // 'HADRONTHERAPY_2' is suggested for better precision with ions
 34 //
 35 // The Reference physics lists (already present in the Geant4 kernel) can
 36 // be used as well. In this case the more suitable "Reference physics lists" are:
 37 // "QBBC", "QGSP_BIC", "Shielding", "QGSP_BERT",
 38 // "QGSP_BIC_AllHP" and "QGSP_BIC_HP"
 39 //
 40 // NOTE: to activate the "_HP" physics you have to set the G4PARTICLEHPDATA environment
 41 // variable pointing to the external dataset named "G4TENDL".
 42 //
 43 // All the lists can be  activated inside any macro file using the command:
 44 // /Physics/addPhysics
 45 //
 46 // Examples of usage are:
 47 // /Physics/addPhysics HADRONTHERAPY_1 or /Physics/addPhysics QGSP_BIC_HP
 48 
 49 #include "G4SystemOfUnits.hh"
 50 #include "G4RunManager.hh"
 51 #include "G4Region.hh"
 52 #include "G4RegionStore.hh"
 53 #include "HadrontherapyPhysicsList.hh"
 54 #include "HadrontherapyPhysicsListMessenger.hh"
 55 #include "HadrontherapyStepMax.hh"
 56 #include "G4PhysListFactory.hh"
 57 #include "G4VPhysicsConstructor.hh"
 58 #include "G4HadronPhysicsQGSP_BIC_HP.hh"
 59 #include "G4HadronPhysicsQGSP_BIC.hh"
 60 #include "G4EmStandardPhysics_option4.hh"
 61 #include "G4EmStandardPhysics.hh"
 62 #include "G4EmExtraPhysics.hh"
 63 #include "G4StoppingPhysics.hh"
 64 #include "G4DecayPhysics.hh"
 65 #include "G4HadronElasticPhysics.hh"
 66 #include "G4HadronElasticPhysicsHP.hh"
 67 #include "G4RadioactiveDecayPhysics.hh"
 68 #include "G4IonBinaryCascadePhysics.hh"
 69 #include "G4DecayPhysics.hh"
 70 #include "G4NeutronTrackingCut.hh"
 71 #include "G4LossTableManager.hh"
 72 #include "G4UnitsTable.hh"
 73 #include "G4ProcessManager.hh"
 74 #include "G4IonFluctuations.hh"
 75 #include "G4IonParametrisedLossModel.hh"
 76 #include "G4EmParameters.hh"
 77 #include "G4ParallelWorldPhysics.hh"
 78 #include "G4EmLivermorePhysics.hh"
 79 #include "G4AutoDelete.hh"
 80 #include "G4HadronPhysicsQGSP_BIC_AllHP.hh"
 81 #include "QGSP_BIC_HP.hh"
 82 #include "QGSP_BIC.hh"
 83 #include "G4HadronPhysicsQGSP_BERT.hh"
 84 #include "G4HadronPhysicsQGSP_BERT_HP.hh"
 85 #include "G4ParallelWorldPhysics.hh"
 86 // Physics List
 87 #include "QBBC.hh"
 88 #include "QGSP_BIC.hh"
 89 #include "Shielding.hh"
 90 #include "QGSP_BERT.hh"
 91 #include "QGSP_BIC_AllHP.hh"
 92 #include "QGSP_BIC_HP.hh"
 93 
 94 
 95 
 96 /////////////////////////////////////////////////////////////////////////////
 97 HadrontherapyPhysicsList::HadrontherapyPhysicsList() : G4VModularPhysicsList()
 98 {
 99     G4LossTableManager::Instance();
100     defaultCutValue = 1.*mm;
101     cutForGamma     = defaultCutValue;
102     cutForElectron  = defaultCutValue;
103     cutForPositron  = defaultCutValue;
104     
105     pMessenger = new HadrontherapyPhysicsListMessenger(this);
106     SetVerboseLevel(1);
107     decay_List = new G4DecayPhysics();
108     // Elecromagnetic physics
109     //
110     emPhysicsList = new G4EmStandardPhysics_option4();
111 }
112 
113 /////////////////////////////////////////////////////////////////////////////
114 HadrontherapyPhysicsList::~HadrontherapyPhysicsList()
115 {
116     delete pMessenger;
117     delete emPhysicsList;
118     delete decay_List;
119     //delete radioactiveDecay_List;
120     hadronPhys.clear();
121     for(size_t i=0; i<hadronPhys.size(); i++)
122     {
123         delete hadronPhys[i];
124     }
125 }
126 
127 /////////////////////////////////////////////////////////////////////////////
128 void HadrontherapyPhysicsList::ConstructParticle()
129 {
130     decay_List -> ConstructParticle();
131     
132 }
133 
134 /////////////////////////////////////////////////////////////////////////////
135 void HadrontherapyPhysicsList::ConstructProcess()
136 {
137     // Transportation
138     //
139     AddTransportation();
140     
141     decay_List -> ConstructProcess();
142     emPhysicsList -> ConstructProcess();
143     
144     
145     //em_config.AddModels();
146     
147     // Hadronic physics
148     //
149     for(size_t i=0; i < hadronPhys.size(); i++)
150     {
151         hadronPhys[i] -> ConstructProcess();
152     }
153     
154     // step limitation (as a full process)
155     //
156     AddStepMax();
157     
158     //Parallel world sensitivity
159     //
160     G4ParallelWorldPhysics* pWorld = new G4ParallelWorldPhysics("DetectorROGeometry");
161     pWorld->ConstructProcess();
162     
163     return;
164 }
165 
166 /////////////////////////////////////////////////////////////////////////////
167 void HadrontherapyPhysicsList::AddPhysicsList(const G4String& name)
168 {
169     if (verboseLevel>1) {
170         G4cout << "PhysicsList::AddPhysicsList: <" << name << ">" << G4endl;
171     }
172     if (name == emName) return;
173     
174     ///////////////////////////////////
175     //   ELECTROMAGNETIC MODELS
176     ///////////////////////////////////
177     if (name == "standard_opt4") {
178         emName = name;
179         delete emPhysicsList;
180         hadronPhys.clear();
181         emPhysicsList = new G4EmStandardPhysics_option4();
182         G4RunManager::GetRunManager() -> PhysicsHasBeenModified();
183         G4cout << "THE FOLLOWING ELECTROMAGNETIC PHYSICS LIST HAS BEEN ACTIVATED: G4EmStandardPhysics_option4" << G4endl;
184         
185         ////////////////////////////////////////
186         //   ELECTROMAGNETIC + HADRONIC MODELS
187         ////////////////////////////////////////
188         
189     }  else if (name == "HADRONTHERAPY_1") {
190         
191         AddPhysicsList("standard_opt4");
192         hadronPhys.push_back( new G4DecayPhysics());
193         hadronPhys.push_back( new G4RadioactiveDecayPhysics());
194         hadronPhys.push_back( new G4IonBinaryCascadePhysics());
195         hadronPhys.push_back( new G4EmExtraPhysics());
196         hadronPhys.push_back( new G4HadronElasticPhysicsHP());
197         hadronPhys.push_back( new G4StoppingPhysics());
198         hadronPhys.push_back( new G4HadronPhysicsQGSP_BIC_HP());
199         hadronPhys.push_back( new G4NeutronTrackingCut());
200         
201         G4cout << "HADRONTHERAPY_1 PHYSICS LIST has been activated" << G4endl;
202     }
203     
204     else if (name == "HADRONTHERAPY_2") {
205         
206         AddPhysicsList("standard_opt4");
207         hadronPhys.push_back( new G4DecayPhysics());
208         hadronPhys.push_back( new G4RadioactiveDecayPhysics());
209         hadronPhys.push_back( new G4IonBinaryCascadePhysics());
210         hadronPhys.push_back( new G4EmExtraPhysics());
211         hadronPhys.push_back( new G4HadronElasticPhysics());
212         hadronPhys.push_back( new G4StoppingPhysics());
213         hadronPhys.push_back( new G4HadronPhysicsQGSP_BIC_AllHP());
214         hadronPhys.push_back( new G4NeutronTrackingCut());
215         
216         G4cout << "HADRONTHERAPY_2 PHYSICS LIST has been activated" << G4endl;   
217 
218     }
219    
220     else if (name == "QGSP_BIC"){
221         auto physicsList = new QGSP_BIC;
222         G4RunManager::GetRunManager() -> SetUserInitialization(physicsList);
223         G4RunManager::GetRunManager() -> PhysicsHasBeenModified();
224         physicsList -> RegisterPhysics(new G4ParallelWorldPhysics("DetectorROGeometry"));
225     }
226     
227     else if (name == "QGSP_BERT"){
228         auto physicsList = new QGSP_BERT;
229         G4RunManager::GetRunManager() -> SetUserInitialization(physicsList);
230         G4RunManager::GetRunManager() -> PhysicsHasBeenModified();
231         physicsList -> RegisterPhysics(new G4ParallelWorldPhysics("DetectorROGeometry"));
232     }
233     
234     else if (name == "QGSP_BIC_AllHP"){
235         auto physicsList = new QGSP_BIC_AllHP;
236         G4RunManager::GetRunManager() -> SetUserInitialization(physicsList);
237         G4RunManager::GetRunManager() -> PhysicsHasBeenModified();
238         physicsList -> RegisterPhysics(new G4ParallelWorldPhysics("DetectorROGeometry"));
239     }
240     
241     else if (name == "QGSP_BIC_HP"){
242         auto physicsList = new QGSP_BIC_HP;
243         G4RunManager::GetRunManager() -> SetUserInitialization(physicsList);
244         G4RunManager::GetRunManager() -> PhysicsHasBeenModified();
245         physicsList -> RegisterPhysics(new G4ParallelWorldPhysics("DetectorROGeometry"));
246     }
247     
248     else if (name == "Shielding"){
249         auto physicsList = new Shielding;
250         G4RunManager::GetRunManager() -> SetUserInitialization(physicsList);
251         G4RunManager::GetRunManager() -> PhysicsHasBeenModified();
252         physicsList -> RegisterPhysics(new G4ParallelWorldPhysics("DetectorROGeometry"));
253     }
254         
255     else if (name == "QBBC"){
256         auto physicsList = new QBBC;
257         G4RunManager::GetRunManager() -> SetUserInitialization(physicsList);
258         G4RunManager::GetRunManager() -> PhysicsHasBeenModified();
259         physicsList -> RegisterPhysics(new G4ParallelWorldPhysics("DetectorROGeometry"));
260     }
261     
262     else {
263         G4cout << "PhysicsList::AddPhysicsList: <" << name << ">"
264         << " is not defined"
265         << G4endl;
266     }
267     
268 }
269 
270 /////////////////////////////////////////////////////////////////////////////
271 void HadrontherapyPhysicsList::AddStepMax()
272 {
273     // Step limitation seen as a process
274     // This process must exist in all threads.
275     //
276     HadrontherapyStepMax* stepMaxProcess  = new HadrontherapyStepMax();
277     
278     
279     auto particleIterator = GetParticleIterator();
280     particleIterator->reset();
281     while ((*particleIterator)()){
282         G4ParticleDefinition* particle = particleIterator->value();
283         G4ProcessManager* pmanager = particle->GetProcessManager();
284         
285         if (stepMaxProcess->IsApplicable(*particle) && pmanager)
286         {
287             pmanager ->AddDiscreteProcess(stepMaxProcess);
288         }
289     }
290 }
291