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] [ 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 ]

Diff markup

Differences between /examples/advanced/brachytherapy/src/BrachyDetectorConstruction.cc (Version 11.3.0) and /examples/advanced/brachytherapy/src/BrachyDetectorConstruction.cc (Version 10.6.p2)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // -------------------------------------------     26 // --------------------------------------------------------------
 27 //                 GEANT 4 - Brachytherapy exa     27 //                 GEANT 4 - Brachytherapy example
 28 // -------------------------------------------     28 // --------------------------------------------------------------
 29 //                                                 29 //
 30 // Code developed by: S. Guatelli, D. Cutajar,     30 // Code developed by: S. Guatelli, D. Cutajar, A. Le
 31 // Past developers: S. Agostinelli, F. Foppian     31 // Past developers: S. Agostinelli, F. Foppiano, S. Garelli , M. Tropeano
 32 //                                                 32 //
 33 //                                                 33 //
 34 //    ****************************************     34 //    ****************************************
 35 //    *                                      *     35 //    *                                      *
 36 //    *    BrachyDetectorConstruction.cc     *     36 //    *    BrachyDetectorConstruction.cc     *
 37 //    *                                      *     37 //    *                                      *
 38 //    ****************************************     38 //    ****************************************
 39 //                                                 39 //
 40 #include "BrachyFactoryLeipzig.hh"             << 
 41 #include "BrachyFactoryTG186.hh"               << 
 42 #include "BrachyFactoryI.hh"                   << 
 43 #include "BrachyFactoryFlexi.hh"               << 
 44 #include "BrachyFactoryOncura6711.hh"          << 
 45 #include "BrachyDetectorMessenger.hh"          << 
 46 #include "BrachyDetectorConstruction.hh"       << 
 47 #include "G4SystemOfUnits.hh"                      40 #include "G4SystemOfUnits.hh"
 48 #include "G4CSGSolid.hh"                           41 #include "G4CSGSolid.hh"
 49 #include "G4MaterialPropertyVector.hh"             42 #include "G4MaterialPropertyVector.hh"
 50 #include "G4SDManager.hh"                          43 #include "G4SDManager.hh"
 51 #include "G4RunManager.hh"                         44 #include "G4RunManager.hh"
 52 #include "G4Box.hh"                                45 #include "G4Box.hh"
 53 #include "G4LogicalVolume.hh"                      46 #include "G4LogicalVolume.hh"
 54 #include "G4ThreeVector.hh"                        47 #include "G4ThreeVector.hh"
 55 #include "G4PVPlacement.hh"                        48 #include "G4PVPlacement.hh"
 56 #include "globals.hh"                              49 #include "globals.hh"
 57 #include "G4MaterialTable.hh"                      50 #include "G4MaterialTable.hh"
 58 #include "G4TransportationManager.hh"              51 #include "G4TransportationManager.hh"
 59 #include "G4Colour.hh"                             52 #include "G4Colour.hh"
 60 #include "G4UserLimits.hh"                         53 #include "G4UserLimits.hh"
 61 #include "G4VisAttributes.hh"                      54 #include "G4VisAttributes.hh"
 62 #include "G4NistManager.hh"                    <<  55 #include "BrachyMaterial.hh"
                                                   >>  56 #include "BrachyFactoryLeipzig.hh"
                                                   >>  57 #include "BrachyFactoryTG186.hh"
                                                   >>  58 #include "BrachyFactoryI.hh"
                                                   >>  59 #include "BrachyFactoryFlexi.hh"
                                                   >>  60 #include "BrachyFactoryOncura6711.hh"
                                                   >>  61 #include "BrachyDetectorMessenger.hh"
                                                   >>  62 #include "BrachyDetectorConstruction.hh"
 63                                                    63 
 64 BrachyDetectorConstruction::BrachyDetectorCons     64 BrachyDetectorConstruction::BrachyDetectorConstruction(): 
 65   fFactory(nullptr), fWorld(nullptr), fWorldLo <<  65   detectorChoice(0), factory(0),
 66   fPhantom(nullptr), fPhantomLog(nullptr), fPh <<  66   World(0), WorldLog(0), WorldPhys(0),
 67   fDetectorChoice(0)                           <<  67   Phantom(0), PhantomLog(0), PhantomPhys(0),
                                                   >>  68   phantomAbsorberMaterial(0)
 68 {                                                  69 {
 69  // Define the messenger of the Detector compo << 
 70  fDetectorMessenger = new BrachyDetectorMessen << 
 71                                                << 
 72  // Define half size of the phantom along the      70  // Define half size of the phantom along the x, y, z axis
 73  fPhantomSizeX = 15.*cm;                       <<  71  phantomSizeX = 15.*cm;
 74  fPhantomSizeY = 15.*cm;                       <<  72  phantomSizeY = 15.*cm;
 75  fPhantomSizeZ = 15.*cm;                       <<  73  phantomSizeZ = 15.*cm;
 76                                                    74  
 77  // Define the sizes of the World volume conta     75  // Define the sizes of the World volume containing the phantom
 78  fWorldSizeX = 4.0*m;                          <<  76  worldSizeX = 4.0*m;
 79  fWorldSizeY = 4.0*m;                          <<  77  worldSizeY = 4.0*m;
 80  fWorldSizeZ = 4.0*m;                          <<  78  worldSizeZ = 4.0*m;
                                                   >>  79 
                                                   >>  80  // Define the messenger of the Detector component
                                                   >>  81  // It is possible to modify geometrical parameters through UI
                                                   >>  82  detectorMessenger = new BrachyDetectorMessenger(this);
 81                                                    83 
 82   // Define the Flexi source as default source     84   // Define the Flexi source as default source modelled in the geometry
 83  fFactory = new BrachyFactoryFlexi();          <<  85  factory = new BrachyFactoryFlexi();
                                                   >>  86 
                                                   >>  87   // BrachyMaterial defined the all the materials necessary
                                                   >>  88   // for the experimental set-up 
                                                   >>  89  pMaterial = new BrachyMaterial();
 84 }                                                  90 }
 85                                                    91 
 86 BrachyDetectorConstruction::~BrachyDetectorCon     92 BrachyDetectorConstruction::~BrachyDetectorConstruction()
 87 {                                                  93 { 
 88   delete fDetectorMessenger;                   <<  94   delete pMaterial;
 89   delete fFactory;                             <<  95   delete factory;
                                                   >>  96   delete detectorMessenger;
 90 }                                                  97 }
 91                                                    98 
 92 G4VPhysicalVolume* BrachyDetectorConstruction:     99 G4VPhysicalVolume* BrachyDetectorConstruction::Construct()
 93 {                                                 100 {
                                                   >> 101  pMaterial -> DefineMaterials();
                                                   >> 102 
 94  // Model the phantom (water box)                 103  // Model the phantom (water box)
 95  ConstructPhantom();                              104  ConstructPhantom();
 96                                                   105 
 97  // Model the source in the phantom               106  // Model the source in the phantom
 98  fFactory -> CreateSource(fPhantomPhys);       << 107  factory -> CreateSource(PhantomPhys);
 99                                                   108 
100  return fWorldPhys;                            << 109  return WorldPhys;
101 }                                                 110 }
102                                                   111 
103 void BrachyDetectorConstruction::SwitchBrachyt    112 void BrachyDetectorConstruction::SwitchBrachytherapicSeed()
104 {                                                 113 {
105   // Change the source in the water phantom       114   // Change the source in the water phantom
106   fFactory -> CleanSource();                   << 115   factory -> CleanSource();
107   G4cout << "Old brachy source is deleted ..." << 116   G4cout << "Old Source is deleted ..." << G4endl;
108   delete fFactory;                             << 117   delete factory;
109                                                   118 
110   switch(fDetectorChoice)                      << 119   switch(detectorChoice)
111   {                                               120   { 
112    case 1:                                        121    case 1:
113       fFactory = new BrachyFactoryI();         << 122       factory = new BrachyFactoryI();
114       break;                                      123       break;
115    case 2:                                        124    case 2:
116       fFactory = new BrachyFactoryLeipzig();   << 125       factory = new BrachyFactoryLeipzig();
117       break;                                      126       break;
118    case 3:                                        127    case 3:
119       fFactory = new BrachyFactoryTG186();     << 128       factory = new BrachyFactoryTG186();
120       break;                                      129       break;
121    case 4:                                        130    case 4:
122       fFactory = new BrachyFactoryFlexi();     << 131       factory = new BrachyFactoryFlexi();
123       break;                                      132       break;
124    case 5:                                        133    case 5:
125       fFactory = new BrachyFactoryOncura6711() << 134       factory = new BrachyFactoryOncura6711();
126       break;                                      135       break;
127    default:                                       136    default:
128       fFactory = new BrachyFactoryFlexi();     << 137       factory = new BrachyFactoryFlexi();
129       break;                                      138       break;
130    }                                              139    }
131                                                   140 
132   fFactory -> CreateSource(fPhantomPhys);      << 141   factory -> CreateSource(PhantomPhys);
133   G4cout << "New brachy source is created ..." << 142   G4cout << "... New source is created ..." << G4endl;
134                                                   143 
135   // Notify run manager that the new geometry     144   // Notify run manager that the new geometry has been built
136   G4RunManager::GetRunManager() -> GeometryHas    145   G4RunManager::GetRunManager() -> GeometryHasBeenModified();
                                                   >> 146   G4cout << "... Geometry is notified .... THAT'S IT!!!!!" << G4endl;
137 }                                                 147 }
138                                                   148 
139 void BrachyDetectorConstruction::SelectBrachyt    149 void BrachyDetectorConstruction::SelectBrachytherapicSeed(G4String val)
140 {                                                 150 {
141   if (val == "Iodine")                            151   if (val == "Iodine") 
142     fDetectorChoice = 1;                       << 152     detectorChoice = 1;
143       else                                        153       else
144       {                                           154       {
145           if(val=="Leipzig")                      155           if(val=="Leipzig") 
146             fDetectorChoice = 2;               << 156             detectorChoice = 2;
147             else                                  157             else
148             {                                     158             {
149                 if(val=="TG186")                  159                 if(val=="TG186") 
150                   fDetectorChoice = 3;         << 160                   detectorChoice = 3;
151                   else                            161                   else
152                   {                               162                   { 
153                 if(val=="Flexi")                  163                 if(val=="Flexi") 
154                   fDetectorChoice = 4;         << 164                   detectorChoice = 4;
155                   else                            165                   else
156                   {                               166                   {
157                     if(val=="Oncura")             167                     if(val=="Oncura") 
158                        fDetectorChoice = 5;    << 168                       detectorChoice = 5;
159                                 else              169                                 else 
160                                   G4cout << va    170                                   G4cout << val <<  "is not available!!!!"  << G4endl;  
161                   }                               171                   }            
162                   }                               172                   }
163         }                                         173         }   
164   }                                               174   }
165  G4cout << "Now the brachy source is " << val  << 175  G4cout << "Now the source is " << val << G4endl;
166 }                                                 176 }
167                                                   177 
168 void BrachyDetectorConstruction::ConstructPhan    178 void BrachyDetectorConstruction::ConstructPhantom()
169 {                                                 179 {
170   // Model the water phantom                      180   // Model the water phantom 
171                                                   181 
172   // Define the light blue color                  182   // Define the light blue color
173   G4Colour  lblue   (0.0, 0.0, .75);              183   G4Colour  lblue   (0.0, 0.0, .75);
174                                                   184   
175    //Get nist material manager                 << 185   G4Material* air = pMaterial -> GetMat("Air") ;
176   G4NistManager* nist = G4NistManager::Instanc << 186   G4Material* water = pMaterial -> GetMat("Water");
177   G4Material* air = nist -> FindOrBuildMateria << 
178   G4Material* water = nist -> FindOrBuildMater << 
179                                                   187 
180   // World volume                                 188   // World volume
181   fWorld = new G4Box("World", fWorldSizeX, fWo << 189   World = new G4Box("World",worldSizeX,worldSizeY,worldSizeZ);
182   fWorldLog = new G4LogicalVolume(fWorld,air," << 190   WorldLog = new G4LogicalVolume(World,air,"WorldLog",0,0,0);
183   fWorldPhys = new G4PVPlacement(nullptr,G4Thr << 191   WorldPhys = new G4PVPlacement(0,G4ThreeVector(),"WorldPhys",WorldLog,0,false,0);
184                                                   192 
185   // Water Box                                    193   // Water Box
186   fPhantom = new G4Box("Phantom", fPhantomSize << 194   Phantom = new G4Box("Phantom",phantomSizeX,phantomSizeY,phantomSizeZ);
187                                                   195 
188   // Logical volume                               196   // Logical volume
189   fPhantomLog = new G4LogicalVolume(fPhantom,w << 197   PhantomLog = new G4LogicalVolume(Phantom,water,"PhantomLog",0,0,0);
190                                                   198 
191   // Physical volume                              199   // Physical volume
192   fPhantomPhys = new G4PVPlacement(nullptr,G4T << 200   PhantomPhys = new G4PVPlacement(0,G4ThreeVector(), // Position: rotation and translation
193                                   "PhantomPhys    201                                   "PhantomPhys", // Name
194                                   fPhantomLog, << 202                                   PhantomLog, // Associated logical volume
195                                   fWorldPhys,  << 203                                   WorldPhys, // Mother volume
196                                   false,0);       204                                   false,0);
197                                                << 205   WorldLog -> SetVisAttributes (G4VisAttributes::GetInvisible());
198   fWorldLog -> SetVisAttributes (G4VisAttribut << 
199                                                   206 
200   // Visualization attributes of the phantom      207   // Visualization attributes of the phantom
201   auto simpleBoxVisAtt = new G4VisAttributes(l << 208   G4VisAttributes* simpleBoxVisAtt = new G4VisAttributes(lblue);
202   simpleBoxVisAtt -> SetVisibility(true);         209   simpleBoxVisAtt -> SetVisibility(true);
203   simpleBoxVisAtt -> SetForceWireframe(true);     210   simpleBoxVisAtt -> SetForceWireframe(true);
204   fPhantomLog -> SetVisAttributes(simpleBoxVis << 211   PhantomLog -> SetVisAttributes(simpleBoxVisAtt);
205 }                                                 212 }
206                                                   213 
207 void BrachyDetectorConstruction::PrintDetector    214 void BrachyDetectorConstruction::PrintDetectorParameters()
208 {                                                 215 {
209   G4cout << "----------------" << G4endl          216   G4cout << "----------------" << G4endl
210          << "the phantom is a water box whose     217          << "the phantom is a water box whose size is: " << G4endl
211          << fPhantomSizeX *2./cm               << 218          << phantomSizeX *2./cm
212          << " cm * "                              219          << " cm * "
213          << fPhantomSizeY *2./cm               << 220          << phantomSizeY *2./cm
214          << " cm * "                              221          << " cm * "
215          << fPhantomSizeZ *2./cm               << 222          << phantomSizeZ *2./cm
216          << " cm" << G4endl                       223          << " cm" << G4endl
217          << "The phantom is made of "             224          << "The phantom is made of "
218          << fPhantomLog -> GetMaterial() -> Ge << 225          << phantomAbsorberMaterial -> GetName() <<G4endl
219          << "the source is at the center of th    226          << "the source is at the center of the phantom" << G4endl
220          << "----------------"                    227          << "----------------"
221          << G4endl;                               228          << G4endl;
222 }                                                 229 }
223                                                   230 
224 void BrachyDetectorConstruction::SetPhantomMat    231 void BrachyDetectorConstruction::SetPhantomMaterial(G4String materialChoice)
225 {                                                 232 {
226   // Method to change the material of the phan << 233   // It is possible to change the material of the phantom
227                                                << 234   // interactively
228   G4NistManager* nist = G4NistManager::Instanc << 
229                                                   235 
230   // Search the material by its name              236   // Search the material by its name
231   G4Material* pttoMaterial =  nist -> FindOrBu << 237   G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
232                                                   238 
233   if (pttoMaterial)                               239   if (pttoMaterial)
234   {                                               240   {
235     fPhantomLog -> SetMaterial(pttoMaterial);  << 241     phantomAbsorberMaterial = pttoMaterial;
                                                   >> 242     PhantomLog -> SetMaterial(pttoMaterial);
236     PrintDetectorParameters();                    243     PrintDetectorParameters();
237   } else  G4cout << "WARNING: material '" << m << 244   } else 
                                                   >> 245     { G4cout << "WARNING: material '" << materialChoice << "' not available!" << G4endl;}
238 }                                                 246 }
239                                                   247