Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/examples/advanced/doiPET/src/doiPETDetectorConstruction.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 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/doiPET/src/doiPETDetectorConstruction.cc (Version 11.3.0) and /examples/advanced/doiPET/src/doiPETDetectorConstruction.cc (Version 11.0.p1)


  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 //GEANT4 - Depth-of-Interaction enabled Positr     26 //GEANT4 - Depth-of-Interaction enabled Positron emission tomography (PET) advanced example 
 27                                                    27 
 28 //Authors and contributors                         28 //Authors and contributors
 29                                                    29 
 30 // Author list to be updated, with names of co     30 // Author list to be updated, with names of co-authors and contributors from National Institute of Radiological Sciences (NIRS)
 31                                                    31 
 32 // Abdella M. Ahmed (1, 2), Andrew Chacon (1,      32 // Abdella M. Ahmed (1, 2), Andrew Chacon (1, 2), Harley Rutherford (1, 2),
 33 // Hideaki Tashima (3), Go Akamatsu (3), Akram     33 // Hideaki Tashima (3), Go Akamatsu (3), Akram Mohammadi (3), Eiji Yoshida (3), Taiga Yamaya (3)
 34 // Susanna Guatelli (2), and Mitra Safavi-Naei     34 // Susanna Guatelli (2), and Mitra Safavi-Naeini (1, 2)
 35                                                    35 
 36 // (1) Australian Nuclear Science and Technolo     36 // (1) Australian Nuclear Science and Technology Organisation, Australia
 37 // (2) University of Wollongong, Australia         37 // (2) University of Wollongong, Australia
 38 // (3) National Institute of Radiological Scie     38 // (3) National Institute of Radiological Sciences, Japan
 39                                                    39 
 40                                                    40 
 41                                                    41 
 42 //A whole-body PET scanner with depth-of-inter     42 //A whole-body PET scanner with depth-of-intercation (DOI) detector is 
 43 //defined in the doiPETDetectorConstruction cl     43 //defined in the doiPETDetectorConstruction class and varius types phantoms 
 44 //are also defined based on the NEMA NU-2 2012     44 //are also defined based on the NEMA NU-2 2012 standard protocol for
 45 //performance evaluation PET scanners.             45 //performance evaluation PET scanners. 
 46 //The scanner's geometrical specifications (li     46 //The scanner's geometrical specifications (like number of crystals, number of rings ...) are defined as a global variable in the doiPETGlobalParameters.hh
 47 //If the phantom is other there the phantoms d     47 //If the phantom is other there the phantoms defined, exception will be thrown. If you want to run the simulation without phantom (for any reason),
 48 //you can comment out ConstructPhantom(world_l     48 //you can comment out ConstructPhantom(world_logicalV) method. 
 49                                                    49 
 50 #include "doiPETDetectorConstruction.hh"           50 #include "doiPETDetectorConstruction.hh"
 51 #include "doiPETAnalysis.hh"                       51 #include "doiPETAnalysis.hh"
 52 #include "doiPETDetectorConstructionMessenger.     52 #include "doiPETDetectorConstructionMessenger.hh"
 53 #include "doiPETGlobalParameters.hh"               53 #include "doiPETGlobalParameters.hh"
 54                                                    54 
 55 #include "G4NistManager.hh"                        55 #include "G4NistManager.hh"
 56 #include "G4Box.hh"                                56 #include "G4Box.hh"
 57 #include "G4Tubs.hh"                               57 #include "G4Tubs.hh"
 58 #include "G4LogicalVolume.hh"                      58 #include "G4LogicalVolume.hh"
 59 #include "G4PVPlacement.hh"                        59 #include "G4PVPlacement.hh"
 60 #include "G4RotationMatrix.hh"                     60 #include "G4RotationMatrix.hh"
 61 #include "G4Transform3D.hh"                        61 #include "G4Transform3D.hh"
 62 #include "G4SDManager.hh"                          62 #include "G4SDManager.hh"
 63 #include "G4MultiFunctionalDetector.hh"            63 #include "G4MultiFunctionalDetector.hh"
 64 #include "G4VPrimitiveScorer.hh"                   64 #include "G4VPrimitiveScorer.hh"
 65 #include "G4PSEnergyDeposit.hh"                    65 #include "G4PSEnergyDeposit.hh"
 66 #include "G4PSDoseDeposit.hh"                      66 #include "G4PSDoseDeposit.hh"
 67 #include "G4VisAttributes.hh"                      67 #include "G4VisAttributes.hh"
 68 #include "G4PhysicalConstants.hh"                  68 #include "G4PhysicalConstants.hh"
 69 #include "G4SystemOfUnits.hh"                      69 #include "G4SystemOfUnits.hh"
 70                                                    70 
 71 //                                                 71 //
 72 #include "G4SubtractionSolid.hh"                   72 #include "G4SubtractionSolid.hh"
 73 #include "G4UnionSolid.hh"                         73 #include "G4UnionSolid.hh"
 74 #include "G4IntersectionSolid.hh"                  74 #include "G4IntersectionSolid.hh"
 75 //                                                 75 //
 76 #include "G4Element.hh"                            76 #include "G4Element.hh"
 77 #include "G4Material.hh"                           77 #include "G4Material.hh"
 78 #include "G4Sphere.hh"                             78 #include "G4Sphere.hh"
 79 #include "G4Colour.hh"                             79 #include "G4Colour.hh"
 80 #include "G4RunManager.hh"                         80 #include "G4RunManager.hh"
 81 #include "G4StateManager.hh"                       81 #include "G4StateManager.hh"
 82 #include "G4GeometryManager.hh"                    82 #include "G4GeometryManager.hh"
 83 #include "G4PhysicalVolumeStore.hh"                83 #include "G4PhysicalVolumeStore.hh"
 84 #include "G4LogicalVolumeStore.hh"                 84 #include "G4LogicalVolumeStore.hh"
 85 #include "G4SolidStore.hh"                         85 #include "G4SolidStore.hh"
 86                                                    86 
 87                                                    87 
 88 //////////////////////////////////////////////     88 ////////////////////////////////////////////////////////////////////////////////////////
 89                                                    89 
 90 doiPETDetectorConstruction::doiPETDetectorCons     90 doiPETDetectorConstruction::doiPETDetectorConstruction()
 91   : G4VUserDetectorConstruction(),                 91   : G4VUserDetectorConstruction(),
 92   fCheckOverlaps(true)                             92   fCheckOverlaps(true)
 93 {                                                  93 {
 94   DefineMaterials();                               94   DefineMaterials();
 95   fDetectorMessenger = new doiPETDetectorConst     95   fDetectorMessenger = new doiPETDetectorConstructionMessenger(this);
 96                                                    96 
 97   //Initialize variables. The following variab     97   //Initialize variables. The following variables can be changed via the run.mac file.
 98   PhantomType = "NEMA_imageQualityPhantom_whol     98   PhantomType = "NEMA_imageQualityPhantom_wholeBody";//"Phantom_sensitivity";// "NEMA_phantom_NECR";//  
 99   phantomRadius = 100 * mm;                        99   phantomRadius = 100 * mm;
100   phantomLength = 700 * mm;                       100   phantomLength = 700 * mm;
101   phantomPosition = G4ThreeVector(0,0,0);         101   phantomPosition = G4ThreeVector(0,0,0);
102   numOfSleeves = 5;                               102   numOfSleeves = 5;
103 }                                                 103 }
104                                                   104 
105 //////////////////////////////////////////////    105 //////////////////////////////////////////////////////////////////////////////////////
106                                                   106 
107 doiPETDetectorConstruction::~doiPETDetectorCon    107 doiPETDetectorConstruction::~doiPETDetectorConstruction()
108 {                                                 108 {
109   delete fDetectorMessenger;                      109   delete fDetectorMessenger;
110 }                                                 110 }
111                                                   111 
112 /////////////////////////////////// Define Mat    112 /////////////////////////////////// Define Materials /////////////////////////////////////////////////////
113                                                   113 
114 void doiPETDetectorConstruction::DefineMateria    114 void doiPETDetectorConstruction::DefineMaterials()
115 {                                                 115 {
116   G4NistManager* nist = G4NistManager::Instanc    116   G4NistManager* nist = G4NistManager::Instance();
117                                                   117 
118   //Define air                                    118   //Define air
119   air = nist->FindOrBuildMaterial("G4_AIR");      119   air = nist->FindOrBuildMaterial("G4_AIR");
120                                                   120 
121   //Define PMMA                                   121   //Define PMMA
122   pmma  = nist->FindOrBuildMaterial("G4_PLEXIG    122   pmma  = nist->FindOrBuildMaterial("G4_PLEXIGLASS"); //Default 1.19 g/cm3
123                                                   123 
124   //Define water                                  124   //Define water
125   water  = nist->FindOrBuildMaterial("G4_WATER    125   water  = nist->FindOrBuildMaterial("G4_WATER");
126                                                   126 
127   //Defining polyethylene from NIST and modify    127   //Defining polyethylene from NIST and modifying the density
128   polyethylene = nist->BuildMaterialWithNewDen    128   polyethylene = nist->BuildMaterialWithNewDensity("polyethylene","G4_POLYETHYLENE",0.959*g/cm3);
129   polyethylene->GetIonisation()->SetMeanExcita    129   polyethylene->GetIonisation()->SetMeanExcitationEnergy(56*eV);
130                                                   130 
131   //polyethylene_NEMA, defualt density 0.94 g/    131   //polyethylene_NEMA, defualt density 0.94 g/cm3, and excitation energy = 57.4 eV
132   polyethylene_NEMA = nist->FindOrBuildMateria    132   polyethylene_NEMA = nist->FindOrBuildMaterial("G4_POLYETHYLENE");
133                                                   133 
134                                                   134 
135   //Define expanded polystyrene by modifiying     135   //Define expanded polystyrene by modifiying the density to mimic lung phantom used in phantom experiment
136   polystyrene = nist->BuildMaterialWithNewDens    136   polystyrene = nist->BuildMaterialWithNewDensity( "polystyrene","G4_POLYSTYRENE",0.3*g/cm3); 
137                                                   137 
138   isotopes = false;                               138   isotopes = false;
139                                                   139 
140   //Defile Aluminum material for the detetor c    140   //Defile Aluminum material for the detetor cover
141   Aluminum = nist->FindOrBuildMaterial("G4_Al"    141   Aluminum = nist->FindOrBuildMaterial("G4_Al", isotopes);
142                                                   142 
143   //Define elements for the GSO  crystal (scin    143   //Define elements for the GSO  crystal (scintillator) 
144   O = nist->FindOrBuildElement("O" , isotopes)    144   O = nist->FindOrBuildElement("O" , isotopes); 
145   Si = nist->FindOrBuildElement("Si", isotopes    145   Si = nist->FindOrBuildElement("Si", isotopes);
146   Gd = nist->FindOrBuildElement("Gd", isotopes    146   Gd = nist->FindOrBuildElement("Gd", isotopes);  
147                                                   147 
148                                                   148 
149   //define GSO crystal for PET detector           149   //define GSO crystal for PET detector
150   GSO = new G4Material("GSO", 6.7*g/cm3, 3);      150   GSO = new G4Material("GSO", 6.7*g/cm3, 3);
151   GSO->AddElement(Gd, 2);                         151   GSO->AddElement(Gd, 2);
152   GSO->AddElement(Si, 1);                         152   GSO->AddElement(Si, 1);
153   GSO->AddElement(O,  5);                         153   GSO->AddElement(O,  5); 
154   crystalMaterial   = nist->FindOrBuildMateria    154   crystalMaterial   = nist->FindOrBuildMaterial("GSO");
155 }                                                 155 }
156                                                   156 
157 //////////////////////////////////////////////    157 ////////////////////////////////////////////////////////////////////////////////////////
158                                                   158 
159 G4VPhysicalVolume* doiPETDetectorConstruction:    159 G4VPhysicalVolume* doiPETDetectorConstruction::Construct()
160 {                                                 160 {
161   //size of the world                             161   //size of the world
162   worldSizeX = 2 * m;//0.5 *mm                    162   worldSizeX = 2 * m;//0.5 *mm
163   worldSizeY = 2 * m;//0.5*mm                     163   worldSizeY = 2 * m;//0.5*mm
164   worldSizeZ = 4. * m;                            164   worldSizeZ = 4. * m;
165                                                   165 
166                                                   166 
167   // Define a solid shape to describe the worl    167   // Define a solid shape to describe the world volume
168   G4Box* solid_world = new G4Box("world", worl    168   G4Box* solid_world = new G4Box("world", worldSizeX/2., worldSizeY/2., worldSizeZ/2.);
169                                                   169 
170   // Define a logical volume for the world vol    170   // Define a logical volume for the world volume
171   world_logicalV = new G4LogicalVolume(solid_w    171   world_logicalV = new G4LogicalVolume(solid_world, air, "world_logicalV", 0,0,0);
172                                                   172 
173                                                   173 
174   // Define the physical world volume             174   // Define the physical world volume
175   world_physicalV = new G4PVPlacement(0,G4Thre    175   world_physicalV = new G4PVPlacement(0,G4ThreeVector(),world_logicalV, "world_physicalV", 0, false, 0, fCheckOverlaps);
176   world_logicalV->SetVisAttributes (G4VisAttri    176   world_logicalV->SetVisAttributes (G4VisAttributes::GetInvisible());
177                                                   177 
178   //NOTE!!!                                       178   //NOTE!!!
179   //The scanner specification (like size and n    179   //The scanner specification (like size and number of crystals in each detctor) are given in the "doiPETGlobalParameters.hh" header file.
180                                                   180 
181   //Each block detector is identified with its    181   //Each block detector is identified with its unique number, blockIndex.
182   blockIndex = 0;                                 182   blockIndex = 0;
183                                                   183 
184   //Each crystal is identified with its unique    184   //Each crystal is identified with its unique number, crystalIndex
185   crystalIndex = 0;                               185   crystalIndex = 0;
186                                                   186 
187   //This is to place the phantom.                 187   //This is to place the phantom. 
188                                                   188 
189   ConstructPhantom(world_logicalV);               189   ConstructPhantom(world_logicalV);
190                                                   190 
191   //Define air volume (box) to fill the detect    191   //Define air volume (box) to fill the detector block. Crystal elements (scintillators) is then placed.
192   sizeOfAirBox_DOI = (numberOfCrystal_DOI * si    192   sizeOfAirBox_DOI = (numberOfCrystal_DOI * sizeOfCrystal_DOI) + (numberOfCrystal_DOI - 1)*crystalGap_DOI;
193   sizeOfAirBox_axial = (numberOfCrystal_axial     193   sizeOfAirBox_axial = (numberOfCrystal_axial * sizeOfCrystal_axial) + (numberOfCrystal_axial - 1)*crystalGap_axial;
194   sizeOfAirBox_tangential = (numberOfCrystal_t    194   sizeOfAirBox_tangential = (numberOfCrystal_tangential * sizeOfCrystal_tangential) + (numberOfCrystal_tangential - 1)*crystalGap_tangential;
195                                                   195 
196   //This will pass the size of the detector bl    196   //This will pass the size of the detector block so that the position of the PMT will be calculated with respect to the axis of the detector block.
197   //see doiPETAnalysis.cc                         197   //see doiPETAnalysis.cc
198   pAnalysis = doiPETAnalysis::GetInstance();      198   pAnalysis = doiPETAnalysis::GetInstance();
199   pAnalysis->GetSizeOfDetector(sizeOfAirBox_DO    199   pAnalysis->GetSizeOfDetector(sizeOfAirBox_DOI,sizeOfAirBox_tangential, sizeOfAirBox_axial);
200                                                   200 
201   G4cout<<"size of crytal element: "<<sizeOfCr    201   G4cout<<"size of crytal element: "<<sizeOfCrystal_tangential<<" "<<sizeOfCrystal_axial<<" "<<sizeOfCrystal_DOI<<G4endl;
202   G4cout<<"Size of detector block (without Al     202   G4cout<<"Size of detector block (without Al cover): "<<sizeOfAirBox_tangential<<" "<<sizeOfAirBox_axial<<" "<<sizeOfAirBox_DOI<<G4endl;
203                                                   203 
204                                                   204 
205                                                   205 
206   //Define the size of the detector block.        206   //Define the size of the detector block. 
207   sizeOfBlockDetector_DOI = sizeOfAirBox_DOI +    207   sizeOfBlockDetector_DOI = sizeOfAirBox_DOI + AluminumCoverThickness;
208   sizeOfBlockDetector_axial = sizeOfAirBox_axi    208   sizeOfBlockDetector_axial = sizeOfAirBox_axial + AluminumCoverThickness;
209   sizeOfBlockDetector_tangential = sizeOfAirBo    209   sizeOfBlockDetector_tangential = sizeOfAirBox_tangential + AluminumCoverThickness;
210                                                   210 
211                                                   211 
212                                                   212 
213   //Define solid shape for the detector block     213   //Define solid shape for the detector block
214   G4Box* blockDetector = new G4Box("blockDetec    214   G4Box* blockDetector = new G4Box("blockDetector",sizeOfBlockDetector_DOI/2,sizeOfBlockDetector_tangential/2,sizeOfBlockDetector_axial/2);
215                                                   215 
216   //Define the logical volume for the detector    216   //Define the logical volume for the detector block
217   blockDetector_logicalV = new G4LogicalVolume    217   blockDetector_logicalV = new G4LogicalVolume(blockDetector,Aluminum,"blockDetector_logicalV", 0,0,0);
218                                                   218 
219                                                   219 
220                                                   220 
221   //Define air (box) inside the detector block    221   //Define air (box) inside the detector block. Crystal elements will be placed in it.
222   G4Box* airBox = new G4Box("airBox", sizeOfAi    222   G4Box* airBox = new G4Box("airBox", sizeOfAirBox_DOI/2, sizeOfAirBox_tangential/2,sizeOfAirBox_axial/2);
223                                                   223 
224   //Define the logical volume                     224   //Define the logical volume
225   airBox_logicalV = new G4LogicalVolume(airBox    225   airBox_logicalV = new G4LogicalVolume(airBox,air,"airBox_logicalV", 0,0,0);
226                                                   226 
227   //Define its physical volume and place it in    227   //Define its physical volume and place it inside the detector block
228   airBox_physicalV = new G4PVPlacement (0,G4Th    228   airBox_physicalV = new G4PVPlacement (0,G4ThreeVector(0,0,0),airBox_logicalV,"airBox_physicalV", blockDetector_logicalV,false,0,fCheckOverlaps);
229                                                   229 
230                                                   230 
231   ///////////////////////////////////////// Ar    231   ///////////////////////////////////////// Arrange the PET ring and place the PET detectors in the ring(s) ////////////////////////////////////
232                                                   232 
233   for(G4int Ring = 0; Ring< numberOfRings; Rin    233   for(G4int Ring = 0; Ring< numberOfRings; Ring++)
234   {                                               234   {
235     //place the detectors in a ring along the     235     //place the detectors in a ring along the axial direction. Note that the ring gap between two adjcent rings is measured from scintillator to scintillator.  It does not include the Aluminum thickness cover.
236                                                   236 
237     detectorPositionZ = (Ring-((G4double)numbe    237     detectorPositionZ = (Ring-((G4double)numberOfRings)/2 + 0.5)*(sizeOfBlockDetector_axial + ringGap - AluminumCoverThickness);
238                                                   238 
239     for(G4int i = 0; i<numberOfDetector_perRin    239     for(G4int i = 0; i<numberOfDetector_perRing; i++)
240     {                                             240     {
241       //The azimuthal angle to arrange the det    241       //The azimuthal angle to arrange the detectors in a ring
242       thetaDetector = (double)(i*twopi/numberO    242       thetaDetector = (double)(i*twopi/numberOfDetector_perRing);
243                                                   243 
244       //The radius of the scanner is measured     244       //The radius of the scanner is measured from opposing crystal (scintillator) faces. It does not include the Aluminum thickness cover.
245       detectorPositionX = (scannerRadius + siz    245       detectorPositionX = (scannerRadius + sizeOfBlockDetector_DOI/2 - AluminumCoverThickness/2)*std::cos(thetaDetector);
246       detectorPositionY = (scannerRadius + siz    246       detectorPositionY = (scannerRadius + sizeOfBlockDetector_DOI/2 - AluminumCoverThickness/2)*std::sin(thetaDetector);
247                                                   247 
248       //Define the rotation matrix for correct    248       //Define the rotation matrix for correct placement of detetors
249       G4RotationMatrix rotm_PET = G4RotationMa    249       G4RotationMatrix rotm_PET = G4RotationMatrix();
250       rotm_PET.rotateZ(thetaDetector);            250       rotm_PET.rotateZ(thetaDetector);
251       G4ThreeVector uz_PET = G4ThreeVector(det    251       G4ThreeVector uz_PET = G4ThreeVector(detectorPositionX,detectorPositionY,detectorPositionZ);
252       G4Transform3D transform = G4Transform3D(    252       G4Transform3D transform = G4Transform3D(rotm_PET,uz_PET);
253                                                   253 
254       //Define the physical volume of the dete    254       //Define the physical volume of the detectors.
255       blockDetector_physicalV = new G4PVPlacem    255       blockDetector_physicalV = new G4PVPlacement (transform,blockDetector_logicalV,"blockDetector_physicalV", world_logicalV,false,blockIndex,fCheckOverlaps);
256       blockIndex++;                               256       blockIndex++;
257       //G4cout<<Ring<<" "<<detectorPositionX-     257       //G4cout<<Ring<<" "<<detectorPositionX- ((sizeOfBlockDetector_DOI - AluminumCoverThickness)/2)*cos(thetaDetector)<<" "<<detectorPositionY- ((sizeOfBlockDetector_DOI- AluminumCoverThickness)/2)*sin(thetaDetector)<<" "<<detectorPositionZ<<G4endl;
258                                                   258 
259     }                                             259     }
260   }                                               260   }
261                                                   261 
262   //Define the solid crystal                      262   //Define the solid crystal
263   G4VSolid* CrystalSolid = new G4Box("Crystal"    263   G4VSolid* CrystalSolid = new G4Box("Crystal", sizeOfCrystal_DOI/2., sizeOfCrystal_tangential/2., sizeOfCrystal_axial/2.);
264                                                   264 
265   //Define the local volume of the crystal        265   //Define the local volume of the crystal
266   crystal_logicalV = new G4LogicalVolume(Cryst    266   crystal_logicalV = new G4LogicalVolume(CrystalSolid,crystalMaterial,"Crystal_logicalV", 0,0,0);
267                                                   267 
268   //Place the crystals inside the detectors an    268   //Place the crystals inside the detectors and give them a unique number with crystalIndex.
269   for(G4int i_DOI = 0; i_DOI<numberOfCrystal_D    269   for(G4int i_DOI = 0; i_DOI<numberOfCrystal_DOI; i_DOI++){
270     crystalPositionX=(i_DOI-((G4double)numberO    270     crystalPositionX=(i_DOI-((G4double)numberOfCrystal_DOI)/2 + 0.5)*(sizeOfCrystal_DOI + crystalGap_DOI);
271     for(G4int i_axial=0; i_axial< numberOfCrys    271     for(G4int i_axial=0; i_axial< numberOfCrystal_axial;i_axial++){
272       crystalPositionZ = (i_axial-((G4double)n    272       crystalPositionZ = (i_axial-((G4double)numberOfCrystal_axial)/2 + 0.5)*(sizeOfCrystal_axial + crystalGap_axial);
273       for(G4int i_tan=0; i_tan<numberOfCrystal    273       for(G4int i_tan=0; i_tan<numberOfCrystal_tangential;i_tan++){
274         crystalPositionY=(i_tan-((G4double)num    274         crystalPositionY=(i_tan-((G4double)numberOfCrystal_tangential)/2 + 0.5)*(sizeOfCrystal_tangential + crystalGap_tangential);
275                                                   275 
276         //G4cout<<crystalIndex<<" "<<crystalPo    276         //G4cout<<crystalIndex<<" "<<crystalPositionX<<" "<<crystalPositionY<<" "<<crystalPositionZ<<G4endl;
277         //place the crystal inside the block d    277         //place the crystal inside the block detector. 
278         crystal_physicalV = new G4PVPlacement     278         crystal_physicalV = new G4PVPlacement (0, G4ThreeVector (crystalPositionX,crystalPositionY,crystalPositionZ), crystal_logicalV, "Crystal_physicalV", airBox_logicalV,false,crystalIndex/*,fCheckOverlaps*/);
279         crystalIndex++;                           279         crystalIndex++;
280       }                                           280       }
281     }                                             281     }
282   }                                               282   }
283                                                   283 
284   //******************  Visualization ********    284   //******************  Visualization *****************************//
285                                                   285 
286   //visualization for the block detector          286   //visualization for the block detector
287   G4VisAttributes* blockDetectorVisAtt;           287   G4VisAttributes* blockDetectorVisAtt;
288   blockDetectorVisAtt = new G4VisAttributes(G4    288   blockDetectorVisAtt = new G4VisAttributes(G4Colour(1,1.0,1.0));
289   blockDetectorVisAtt->SetVisibility (true);      289   blockDetectorVisAtt->SetVisibility (true);
290   //blockDetectorVisAtt->SetForceWireframe (tr    290   //blockDetectorVisAtt->SetForceWireframe (true);
291   blockDetector_logicalV->SetVisAttributes (bl    291   blockDetector_logicalV->SetVisAttributes (blockDetectorVisAtt);
292   //blockDetector_logicalV->SetVisAttributes (    292   //blockDetector_logicalV->SetVisAttributes (G4VisAttributes::GetInvisible());
293                                                   293 
294   //visualization for the the box filled with     294   //visualization for the the box filled with air
295   G4VisAttributes* airBoxVisAtt;                  295   G4VisAttributes* airBoxVisAtt;
296   airBoxVisAtt = new G4VisAttributes(G4Colour(    296   airBoxVisAtt = new G4VisAttributes(G4Colour(1,1.0,1.0));
297   airBoxVisAtt->SetVisibility (true);             297   airBoxVisAtt->SetVisibility (true);
298   airBoxVisAtt->SetForceWireframe (true);         298   airBoxVisAtt->SetForceWireframe (true);
299   airBox_logicalV->SetVisAttributes (airBoxVis    299   airBox_logicalV->SetVisAttributes (airBoxVisAtt);
300   airBox_logicalV->SetVisAttributes (G4VisAttr    300   airBox_logicalV->SetVisAttributes (G4VisAttributes::GetInvisible());
301                                                   301 
302   //visualization for the crystal                 302   //visualization for the crystal
303   G4VisAttributes* crystalVisAtt;                 303   G4VisAttributes* crystalVisAtt;
304   crystalVisAtt = new G4VisAttributes(G4Colour    304   crystalVisAtt = new G4VisAttributes(G4Colour(0.88,0.55,1.0));
305   //crystalVisAtt->SetVisibility (true);          305   //crystalVisAtt->SetVisibility (true);
306   crystalVisAtt->SetForceWireframe (true);        306   crystalVisAtt->SetForceWireframe (true);
307   crystal_logicalV->SetVisAttributes (crystalV    307   crystal_logicalV->SetVisAttributes (crystalVisAtt);
308   crystal_logicalV->SetVisAttributes (G4VisAtt    308   crystal_logicalV->SetVisAttributes (G4VisAttributes::GetInvisible());
309                                                   309 
310                                                   310 
311   //always return the physical World              311   //always return the physical World
312   return world_physicalV;                         312   return world_physicalV;
313 }                                                 313 }
314                                                   314 
315                                                   315 
316 //////////////////////////////////////////////    316 /////////////////////////////////////////////// Construct Phantom //////////////////////////////////////////////
317                                                   317 
318 void doiPETDetectorConstruction::ConstructPhan    318 void doiPETDetectorConstruction::ConstructPhantom(G4LogicalVolume* worldLogical)
319 {                                                 319 {
320   G4cout<<"------------------================-    320   G4cout<<"------------------================- " <<PhantomType<<" Phantom has been used  -==================-----------\n"<<G4endl;
321                                                   321 
322   //The following phantoms are defined based o    322   //The following phantoms are defined based on NEMA NU-2 Standards Publication (Performance Measurements of Positron Emission Tomographs)
323   if(PhantomType == "NEMA_imageQualityPhantom_    323   if(PhantomType == "NEMA_imageQualityPhantom_wholeBody"){
324                                                   324 
325     //The body phantom (also called image qual    325     //The body phantom (also called image quality phantom) can presisely be created by the G4UninSolid method from (1) one big half cylinder (with a diameter of 150 mm), 
326     //(2) two small full (or quarter) cylinder    326     //(2) two small full (or quarter) cylinders (with 80mm), and (3) a box with a height width of 140 mm and height of 80mm. 
327     //All the material to surround (hold) the     327     //All the material to surround (hold) the water is PMMA.
328                                                   328 
329     //offset position for the body phantom. Th    329     //offset position for the body phantom. The center of the body phantom is mover by 35 mm in the +y direction
330     yOffsetBodyPhantom =  35*mm;                  330     yOffsetBodyPhantom =  35*mm;
331                                                   331 
332     //The body phantom is moved by 70 mm in th    332     //The body phantom is moved by 70 mm in the z direction so that the sphere (cold and hot spheres) are coplanar with the middle slice of the scanner
333     zOffsetBodyPhantom =70*mm;                    333     zOffsetBodyPhantom =70*mm;
334                                                   334 
335     //length (in the z-direction) of the body     335     //length (in the z-direction) of the body phantom. 
336     lengthOfBodyPhantom = 180*mm; //Interior l    336     lengthOfBodyPhantom = 180*mm; //Interior length ( = 180m mm) + wallthickness (= 3mm)
337                                                   337 
338     //outer radius of the body phantom. (inner    338     //outer radius of the body phantom. (inner radius + wallthinkness)
339     radiusOfBodyPhantom = 147 * mm;               339     radiusOfBodyPhantom = 147 * mm;
340                                                   340 
341     //wall thickness of the surrounding pmma p    341     //wall thickness of the surrounding pmma phantom
342     wallThicknessOfBodyPhantom = 3 * mm;          342     wallThicknessOfBodyPhantom = 3 * mm;
343                                                   343 
344     //                                            344     //
345     radiusOfSmallcyl = 77 * mm;                   345     radiusOfSmallcyl = 77 * mm;
346     boxWidth = 140*mm;// along the x-axis         346     boxWidth = 140*mm;// along the x-axis
347     boxHeight = 77 * mm; // along the y-axis      347     boxHeight = 77 * mm; // along the y-axis
348                                                   348 
349                                                   349 
350     /************************* Surrounding PMM    350     /************************* Surrounding PMMA ***********************************/
351                                                   351 
352     //define a half cylinder                      352     //define a half cylinder
353     G4Tubs* halfcyl_pmma = new G4Tubs("halfcyl    353     G4Tubs* halfcyl_pmma = new G4Tubs("halfcyl_pmma", 0*mm,(radiusOfBodyPhantom + wallThicknessOfBodyPhantom),(lengthOfBodyPhantom + wallThicknessOfBodyPhantom)/2,0*deg,180*deg);
354                                                   354 
355     //define two full small cylinder. (It can     355     //define two full small cylinder. (It can be also be a quarter or half). 
356     G4Tubs* cyl1_pmma = new G4Tubs("cyl_pmma",    356     G4Tubs* cyl1_pmma = new G4Tubs("cyl_pmma", 0*mm,radiusOfSmallcyl + wallThicknessOfBodyPhantom, (lengthOfBodyPhantom + wallThicknessOfBodyPhantom)/2,0*deg,360*deg);
357     G4Tubs* cyl2_pmma = new G4Tubs("cyl_pmma",    357     G4Tubs* cyl2_pmma = new G4Tubs("cyl_pmma", 0*mm,radiusOfSmallcyl + wallThicknessOfBodyPhantom, (lengthOfBodyPhantom + wallThicknessOfBodyPhantom)/2,0*deg,360*deg);
358                                                   358 
359     //define a box                                359     //define a box
360     G4Box*  box_pmma = new G4Box("box_pmma", b    360     G4Box*  box_pmma = new G4Box("box_pmma", boxWidth/2, (boxHeight + wallThicknessOfBodyPhantom)/2, (lengthOfBodyPhantom + wallThicknessOfBodyPhantom)/2);
361                                                   361 
362     //a translation vector for the small cylin    362     //a translation vector for the small cylinder with respect to the half cylinder at position (70 mm,0,0)
363     G4ThreeVector translation_cyl1 = G4ThreeVe    363     G4ThreeVector translation_cyl1 = G4ThreeVector(boxWidth/2, 0, 0);
364                                                   364 
365     //a translation vector for the small cylin    365     //a translation vector for the small cylinder with respect to the half cylinder at position (-70 mm,0,0)
366     G4ThreeVector translation_cyl2 = G4ThreeVe    366     G4ThreeVector translation_cyl2 = G4ThreeVector(-boxWidth/2, 0, 0);
367                                                   367 
368     //translation for the box with respect to     368     //translation for the box with respect to half cylinder
369     G4ThreeVector translation_box = G4ThreeVec    369     G4ThreeVector translation_box = G4ThreeVector(0,-(boxHeight + wallThicknessOfBodyPhantom)/2, 0);
370                                                   370 
371     //define union1_pmma by uniting the solids    371     //define union1_pmma by uniting the solids of halfcyl and cyl1
372     G4UnionSolid* union1_pmma = new G4UnionSol    372     G4UnionSolid* union1_pmma = new G4UnionSolid("union1",halfcyl_pmma,cyl1_pmma,0,translation_cyl1);
373                                                   373 
374     //define union2_pmma by uniting the solids    374     //define union2_pmma by uniting the solids of union1_pmma and cyl2
375     G4UnionSolid* union2_pmma = new G4UnionSol    375     G4UnionSolid* union2_pmma = new G4UnionSolid("union2",union1_pmma,cyl2_pmma,0,translation_cyl2);
376                                                   376 
377     //********** Now define the solid volume o    377     //********** Now define the solid volume of the surrounding PMMA body phantom *********//
378     //define phantom by uniting the solids of     378     //define phantom by uniting the solids of union2_pmma and box_pmma 
379     G4UnionSolid* phantom = new G4UnionSolid("    379     G4UnionSolid* phantom = new G4UnionSolid("phantom",union2_pmma,box_pmma,0,translation_box);
380                                                   380 
381     //Define the logical volume of the body ph    381     //Define the logical volume of the body phantom
382     phantom_logicalV = new G4LogicalVolume(pha    382     phantom_logicalV = new G4LogicalVolume(phantom, pmma, "phantom_logicalV",0,0,0);
383                                                   383 
384     //Define the physical volume of the body p    384     //Define the physical volume of the body phantom
385     phantom_physicalV = new G4PVPlacement(0, G    385     phantom_physicalV = new G4PVPlacement(0, G4ThreeVector(0,-yOffsetBodyPhantom,-(lengthOfBodyPhantom + 2*wallThicknessOfBodyPhantom)/2 + zOffsetBodyPhantom), phantom_logicalV, "pmma_phantom_physicalV", worldLogical, false, 0, fCheckOverlaps); 
386                                                   386 
387                                                   387 
388                                                   388 
389     //****************************** Water ins    389     //****************************** Water inside the PMMA phantom ********************************/
390                                                   390 
391     //define a half cylinder                      391     //define a half cylinder
392     G4Tubs* halfcyl_water = new G4Tubs("halfcy    392     G4Tubs* halfcyl_water = new G4Tubs("halfcyl_water", 0*mm,radiusOfBodyPhantom,lengthOfBodyPhantom/2,0*deg,180*deg);
393                                                   393 
394     //define a full small cylinder phantom. (I    394     //define a full small cylinder phantom. (It can be also be a quarter or half).
395     G4Tubs* cyl1_water = new G4Tubs("cyl_water    395     G4Tubs* cyl1_water = new G4Tubs("cyl_water", 0*mm,radiusOfSmallcyl, lengthOfBodyPhantom/2,0*deg,360*deg);
396     G4Tubs* cyl2_water = new G4Tubs("cyl_water    396     G4Tubs* cyl2_water = new G4Tubs("cyl_water", 0*mm,radiusOfSmallcyl, lengthOfBodyPhantom/2,0*deg,360*deg);
397                                                   397 
398     //define a box                                398     //define a box
399     G4Box*  box_water = new G4Box("box_water",    399     G4Box*  box_water = new G4Box("box_water", boxWidth/2, boxHeight/2, lengthOfBodyPhantom/2);
400                                                   400 
401     //a translation vector for the small cylin    401     //a translation vector for the small cylinder with respect to the half cylinder at position (70 mm,0,0)
402     G4ThreeVector translation_cyl1_water = G4T    402     G4ThreeVector translation_cyl1_water = G4ThreeVector(boxWidth/2, 0, 0);
403                                                   403 
404     //a translation vector for the small cylin    404     //a translation vector for the small cylinder with respect to the half cylinder at position (-70 mm,0,0)
405     G4ThreeVector translation_cyl2_water = G4T    405     G4ThreeVector translation_cyl2_water = G4ThreeVector(-boxWidth/2, 0, 0);
406                                                   406 
407     //translation for the box with respect to     407     //translation for the box with respect to half cylinder
408     G4ThreeVector translation_box_water = G4Th    408     G4ThreeVector translation_box_water = G4ThreeVector(0,-boxHeight/2, 0);
409                                                   409 
410     //define union1_water by uniting the solid    410     //define union1_water by uniting the solids of halfcyl and cyl1
411     G4UnionSolid* union1_water = new G4UnionSo    411     G4UnionSolid* union1_water = new G4UnionSolid("union1",halfcyl_water,cyl1_water,0,translation_cyl1_water);
412                                                   412 
413     //define union2_water by uniting the solid    413     //define union2_water by uniting the solids of union1_water and cyl2
414     G4UnionSolid* union2_water = new G4UnionSo    414     G4UnionSolid* union2_water = new G4UnionSolid("union2",union1_water,cyl2_water,0,translation_cyl2_water);
415                                                   415 
416     //********** Now define the solid volume o    416     //********** Now define the solid volume of the body phantom to be filled with water *********//
417     //define phantom by uniting the solids of     417     //define phantom by uniting the solids of union2_water and box_water 
418     G4UnionSolid* phantom_water = new G4UnionS    418     G4UnionSolid* phantom_water = new G4UnionSolid("phantom_water",union2_water,box_water,0,translation_box_water);
419                                                   419 
420     //Define the logical volume of the body ph    420     //Define the logical volume of the body phantom
421     water_logicalV = new G4LogicalVolume(phant    421     water_logicalV = new G4LogicalVolume(phantom_water, water, "phantom_logicalV",0,0,0);
422                                                   422 
423     //Define the physical volume of the body p    423     //Define the physical volume of the body phantom
424     water_physicalV = new G4PVPlacement(0, G4T    424     water_physicalV = new G4PVPlacement(0, G4ThreeVector(0,0,0), water_logicalV, "phantom_physicalV", phantom_logicalV, false, 0, fCheckOverlaps); 
425                                                   425 
426     //                                            426     //
427     /////////////////////////////// lung phant    427     /////////////////////////////// lung phantom /////////////////////////////////////////////////////
428                                                   428 
429     //A lung phantom (with low density materia    429     //A lung phantom (with low density material) is inserted in the body phantom. 
430     G4double wallThiknessOfLungPhantom = 4 *mm    430     G4double wallThiknessOfLungPhantom = 4 *mm;
431     radiusOfLungPhantom = 21 *mm;                 431     radiusOfLungPhantom = 21 *mm;
432                                                   432 
433     //define surrounding pmma phantom for the     433     //define surrounding pmma phantom for the lung
434     //Define the solid shape for the lung phan    434     //Define the solid shape for the lung phantom
435     G4Tubs* phantom_lungPMMA = new G4Tubs("Pha    435     G4Tubs* phantom_lungPMMA = new G4Tubs("Phantom_lung", 0*mm, radiusOfLungPhantom + wallThiknessOfLungPhantom,lengthOfBodyPhantom/2,0*deg,360*deg);
436                                                   436 
437     //Define the logical volume of for the lun    437     //Define the logical volume of for the lung phantom
438     lung_logicalV_PMMA = new G4LogicalVolume(p    438     lung_logicalV_PMMA = new G4LogicalVolume(phantom_lungPMMA, pmma, "coldRegion_logicalV",0,0,0);
439                                                   439 
440     //Define the physical volume for the lung     440     //Define the physical volume for the lung phantom. The center of the lung phantom is moved (in the y-axis) by the same distance as that of the body phantom.
441     lung_physicalVPMMA = new G4PVPlacement(0,     441     lung_physicalVPMMA = new G4PVPlacement(0, G4ThreeVector(0,yOffsetBodyPhantom,0), lung_logicalV_PMMA, "coldRegion_physicalV", water_logicalV, false, 0, fCheckOverlaps);
442                                                   442 
443                                                   443 
444     //Define the solid shape for the lung phan    444     //Define the solid shape for the lung phantom
445     G4Tubs* phantom_lung = new G4Tubs("Phantom    445     G4Tubs* phantom_lung = new G4Tubs("Phantom_lung", 0*mm,radiusOfLungPhantom,lengthOfBodyPhantom/2,0*deg,360*deg);
446                                                   446 
447     //Define the logical volume of for the lun    447     //Define the logical volume of for the lung phantom
448     lung_logicalV = new G4LogicalVolume(phanto    448     lung_logicalV = new G4LogicalVolume(phantom_lung, polystyrene, "coldRegion_logicalV",0,0,0);
449                                                   449 
450     //Define the physical volume for the lung     450     //Define the physical volume for the lung phantom and place it in the phantom_lungPMMA.
451     lung_physicalV = new G4PVPlacement(0, G4Th    451     lung_physicalV = new G4PVPlacement(0, G4ThreeVector(0,0,0), lung_logicalV, "coldRegion_physicalV", lung_logicalV_PMMA, false, 0, fCheckOverlaps);
452     //lung_logicalV->SetVisAttributes (G4VisAt    452     //lung_logicalV->SetVisAttributes (G4VisAttributes::Invisible);
453                                                   453 
454                                                   454 
455     ////////////////////////////////// Test ph    455     ////////////////////////////////// Test phantom ////////////////////////////////////////////////////////
456     //This phantom has the same characteristic    456     //This phantom has the same characteristics with that of NECR phantom except its axial position.
457                                                   457 
458     hieghtOfTestPhantom = 705* mm;                458     hieghtOfTestPhantom = 705* mm;
459     diameterOfTestPhantom = 203 * mm;             459     diameterOfTestPhantom = 203 * mm;
460     G4double zOffset_testPhantom = 0*mm;//this    460     G4double zOffset_testPhantom = 0*mm;//this is to make some gap between the phantoms if necessary
461                                                   461 
462     //Define the solid shape for the test phan    462     //Define the solid shape for the test phantom
463     G4Tubs* phantom_test = new G4Tubs("Phantom    463     G4Tubs* phantom_test = new G4Tubs("Phantom", 0*mm,diameterOfTestPhantom/2,hieghtOfTestPhantom/2,0*deg,360*deg);
464                                                   464 
465     //Define the logical volume of the test ph    465     //Define the logical volume of the test phantom
466     test_logicalV = new G4LogicalVolume(phanto    466     test_logicalV = new G4LogicalVolume(phantom_test, polyethylene_NEMA, "phantom_logicalV",0,0,0);
467                                                   467 
468     //Define the physical volume of the test p    468     //Define the physical volume of the test phantom. The test phantom is placed next to the body phantom. 
469     test_physicalV = new G4PVPlacement(0,G4Thr    469     test_physicalV = new G4PVPlacement(0,G4ThreeVector(0,0,hieghtOfTestPhantom/2+zOffsetBodyPhantom + zOffset_testPhantom), test_logicalV, "phantom_physicalV", worldLogical, false, 0,fCheckOverlaps);
470     //test_logicalV->SetVisAttributes (G4VisAt    470     //test_logicalV->SetVisAttributes (G4VisAttributes::Invisible);
471                                                   471 
472     ////////////////////////////////// Six Sph    472     ////////////////////////////////// Six Spherical phantoms for hot and cold lesions (sources) placed inside the body phatom ///////////////////////////////////
473                                                   473 
474     //Define diameter from the center of the b    474     //Define diameter from the center of the body phantom to the center of the spheres
475     distanceFromCenter = 114.4*mm;                475     distanceFromCenter = 114.4*mm;
476                                                   476 
477     //Define total number of spherical phantom    477     //Define total number of spherical phantoms (both hot and cold spheres)
478     numberOfSpheres = 6;                          478     numberOfSpheres = 6;
479                                                   479 
480     //Define the wall thickness of the spheric    480     //Define the wall thickness of the spherical phantoms. It should be less than or equal to 1 mm according to the NEMA NU-2 protocol.
481     sphereWallThickness = 1*mm;                   481     sphereWallThickness = 1*mm;
482                                                   482 
483     //The centers of the sphere phantoms are p    483     //The centers of the sphere phantoms are placed 68 mm from the endplate of the body phantom so that the plane through the centers of the spheres is coplanar with to the middile slice of the scanner
484     zOffsetSpherePhantom = lengthOfBodyPhantom    484     zOffsetSpherePhantom = lengthOfBodyPhantom/2 + wallThicknessOfBodyPhantom- zOffsetBodyPhantom;
485                                                   485 
486     //Place the spherical phantoms in the body    486     //Place the spherical phantoms in the body phantom
487     for(G4int i = 0; i < numberOfSpheres; i++)    487     for(G4int i = 0; i < numberOfSpheres; i++){
488       if(i == 0) sphereDiameter = 37*mm;//cold    488       if(i == 0) sphereDiameter = 37*mm;//cold sphere
489       if(i == 1) sphereDiameter = 10*mm;// hot    489       if(i == 1) sphereDiameter = 10*mm;// hot sphere
490       if(i == 2) sphereDiameter = 13*mm;// hot    490       if(i == 2) sphereDiameter = 13*mm;// hot sphere
491       if(i == 3) sphereDiameter = 17*mm;// hot    491       if(i == 3) sphereDiameter = 17*mm;// hot sphere
492       if(i == 4) sphereDiameter = 22*mm;// hot    492       if(i == 4) sphereDiameter = 22*mm;// hot sphere
493       if(i == 5) sphereDiameter = 28*mm;// col    493       if(i == 5) sphereDiameter = 28*mm;// cold sphere
494                                                   494 
495       spherePositionX = distanceFromCenter/2*s    495       spherePositionX = distanceFromCenter/2*std::cos(((G4double)i*twopi/numberOfSpheres));
496       spherePositionY = distanceFromCenter/2*s    496       spherePositionY = distanceFromCenter/2*std::sin(((G4double)i*twopi/numberOfSpheres));
497       //zOffsetBodyPhantom = 0;                   497       //zOffsetBodyPhantom = 0;
498                                                   498 
499       //hot sphere phantoms                       499       //hot sphere phantoms
500       if(i>0 && i <5){                            500       if(i>0 && i <5){
501                                                   501 
502         //Surrounding PMMA phantom for the hot    502         //Surrounding PMMA phantom for the hot sphere
503         //Define the solid shape for the surro    503         //Define the solid shape for the surrounding PMMA phantom for the hot sphere pahntom
504         G4Sphere* hotSpherePMMA = new G4Sphere    504         G4Sphere* hotSpherePMMA = new G4Sphere("hotSphere", 0., sphereDiameter/2 + sphereWallThickness, 0*deg, 360*deg, 0*deg, 180*deg);
505                                                   505 
506         //Deifne the logical volume of the sur    506         //Deifne the logical volume of the surrounding PMMA for the hot sphere phantom
507         hotSpherePMMA_logicalV = new G4Logical    507         hotSpherePMMA_logicalV = new G4LogicalVolume(hotSpherePMMA, pmma , "hotSphere_logicalV",0,0,0);
508                                                   508 
509         //Deifne the physical volume of the su    509         //Deifne the physical volume of the surrounding PMMA for the hot sphere phantom
510         hotSpherePMMA_physicalV = new G4PVPlac    510         hotSpherePMMA_physicalV = new G4PVPlacement(0, G4ThreeVector(spherePositionX,spherePositionY+yOffsetBodyPhantom,zOffsetSpherePhantom), hotSpherePMMA_logicalV, "hotSphere_physicalV", water_logicalV, false, i,fCheckOverlaps);
511                                                   511 
512                                                   512 
513         //Defining and placing the water in th    513         //Defining and placing the water in the surrounding PMMA for hot sphere
514         //Define the solid shape of the water     514         //Define the solid shape of the water phantom for the hot sphere phantom
515         G4Sphere* hotSphereWater = new G4Spher    515         G4Sphere* hotSphereWater = new G4Sphere("hotSphere", 0., sphereDiameter/2, 0*deg, 360*deg, 0*deg, 180*deg);
516                                                   516 
517         //Define the logical volume of the wat    517         //Define the logical volume of the water phatom for the hot sphere
518         hotSphereWater_logicalV = new G4Logica    518         hotSphereWater_logicalV = new G4LogicalVolume(hotSphereWater, water , "hotSphere_logicalV",0,0,0);
519                                                   519 
520         //Define the physical volume of the wa    520         //Define the physical volume of the water phatom for the hot sphere
521         hotSphereWater_physicalV = new G4PVPla    521         hotSphereWater_physicalV = new G4PVPlacement(0, G4ThreeVector(0,0,0), hotSphereWater_logicalV, "phantom_physicalV", hotSpherePMMA_logicalV, false, i,fCheckOverlaps);
522         //G4cout<<"Hot sphere "<<i<<" is place    522         //G4cout<<"Hot sphere "<<i<<" is placed. "<< " sphereDiameter = " <<sphereDiameter <<" "<< "Position " <<spherePositionX<<" "<< spherePositionY<<", "<<sphereDiameter<<G4endl;
523         //hotSpherePMMA_logicalV->SetVisAttrib    523         //hotSpherePMMA_logicalV->SetVisAttributes (G4VisAttributes::Invisible);
524         //hotSphereWater_logicalV->SetVisAttri    524         //hotSphereWater_logicalV->SetVisAttributes (G4VisAttributes::Invisible);
525       }                                           525       }
526                                                   526 
527       //Cold sphere phantoms                      527       //Cold sphere phantoms
528       if(i==0 || i==5){                           528       if(i==0 || i==5){
529         //Surrounding PMMA phantom for the col    529         //Surrounding PMMA phantom for the cold sphere
530         //Define the solid shape for the surro    530         //Define the solid shape for the surrounding PMMA phantom for the cold sphere pahntom
531         G4Sphere* coldSpherePMMA = new G4Spher    531         G4Sphere* coldSpherePMMA = new G4Sphere("coldSphere", 0., sphereDiameter/2 + sphereWallThickness, 0*deg, 360*deg, 0*deg, 180*deg);
532                                                   532 
533         //Deifne the logical volume of the sur    533         //Deifne the logical volume of the surrounding PMMA for the cold sphere phantom
534         coldSpherePMMA_logicalV = new G4Logica    534         coldSpherePMMA_logicalV = new G4LogicalVolume(coldSpherePMMA, pmma , "coldRegion_logicalV",0,0,0);
535                                                   535 
536         //Deifne the physical volume of the su    536         //Deifne the physical volume of the surrounding PMMA for the cold sphere phantom
537         coldSpherePMMA_physicalV = new G4PVPla    537         coldSpherePMMA_physicalV = new G4PVPlacement(0, G4ThreeVector(spherePositionX,spherePositionY+yOffsetBodyPhantom,zOffsetSpherePhantom), coldSpherePMMA_logicalV, "coldRegion_physicalV", water_logicalV, false, i,fCheckOverlaps);
538                                                   538 
539                                                   539 
540         //Defining and placing the water in th    540         //Defining and placing the water in the surrounding PMMA for cold sphere
541         //Define the solid shape of the water     541         //Define the solid shape of the water phantom for the cold sphere phantom
542         G4Sphere* coldSphereWater = new G4Sphe    542         G4Sphere* coldSphereWater = new G4Sphere("coldSphere", 0., sphereDiameter/2, 0*deg, 360*deg, 0*deg, 180*deg);
543                                                   543 
544         //Define the logical volume of the wat    544         //Define the logical volume of the water phatom for the cold sphere
545         coldSphereWater_logicalV = new G4Logic    545         coldSphereWater_logicalV = new G4LogicalVolume(coldSphereWater, water , "coldRegion_logicalV",0,0,0);
546                                                   546 
547         //Define the physical volume of the wa    547         //Define the physical volume of the water phatom for the cold sphere
548         coldSphereWater_physicalV = new G4PVPl    548         coldSphereWater_physicalV = new G4PVPlacement(0, G4ThreeVector(0,0,0), coldSphereWater_logicalV, "coldRegion_physicalV", coldSpherePMMA_logicalV, false, i,fCheckOverlaps);
549         //G4cout<<"Cold sphere "<<i<<" is plac    549         //G4cout<<"Cold sphere "<<i<<" is placed. "<< " sphereDiameter = " <<sphereDiameter <<" "<< "Position " <<spherePositionX<<" "<< spherePositionY<<" "<<sphereDiameter<<G4endl;
550         //coldSpherePMMA_logicalV->SetVisAttri    550         //coldSpherePMMA_logicalV->SetVisAttributes (G4VisAttributes::Invisible);
551         //coldSphereWater_logicalV->SetVisAttr    551         //coldSphereWater_logicalV->SetVisAttributes (G4VisAttributes::Invisible);
552       }                                           552       }        
553     }                                             553     }
554   }                                               554   }
555                                                   555 
556   else if(PhantomType == "NEMA_imageQualityPha    556   else if(PhantomType == "NEMA_imageQualityPhantom_smallAnimal"){
557     //The follwoing is for NEMA NU-2 image qua    557     //The follwoing is for NEMA NU-2 image quality phantom for small animal
558     //To see the details of the phantom, pleas    558     //To see the details of the phantom, please see: http://www.qrm.de/content/pdf/QRM-MicroPET-IQ.pdf
559                                                   559 
560     //Outside radius of PMMMA                     560     //Outside radius of PMMMA 
561     phantomRadius = 16.75*mm;// dia=33.5*mm;      561     phantomRadius = 16.75*mm;// dia=33.5*mm;
562                                                   562 
563     //Outside length of PMMA                      563     //Outside length of PMMA
564     phantomLength = 63*mm;                        564     phantomLength = 63*mm;
565                                                   565 
566     //Dimension of water phantom to be filled     566     //Dimension of water phantom to be filled with activity (hot region).
567     waterPhantomRadius = 15*mm;                   567     waterPhantomRadius = 15*mm; 
568     waterPhantomLength = 30*mm;                   568     waterPhantomLength = 30*mm;
569                                                   569 
570                                                   570 
571     //Dimension of rod phantom (hot region)       571     //Dimension of rod phantom (hot region)
572     rodPhantomLength = 20*mm;                     572     rodPhantomLength = 20*mm;
573                                                   573 
574     //There are five rod phantoms with differe    574     //There are five rod phantoms with different diameters
575     numberOfRods = 5;                             575     numberOfRods = 5;
576                                                   576 
577     //Distance from the center of the cylinder    577     //Distance from the center of the cylinder to the center of the rods
578     distanceFromCenter = 7*mm;                    578     distanceFromCenter = 7*mm;  
579                                                   579 
580     //surrounding PMMA phantom.                   580     //surrounding PMMA phantom.
581     //Define PMMA solid                           581     //Define PMMA solid
582     G4Tubs* phantom = new G4Tubs("Phantom", 0*    582     G4Tubs* phantom = new G4Tubs("Phantom", 0*mm,phantomRadius,phantomLength/2,0*deg,360*deg);
583                                                   583 
584     //Define PMMA logical volume                  584     //Define PMMA logical volume
585     phantom_logicalV = new G4LogicalVolume(pha    585     phantom_logicalV = new G4LogicalVolume(phantom, pmma, "phantom_logicalV",0,0,0);
586                                                   586 
587     //Define PMMA physical volume                 587     //Define PMMA physical volume
588     phantom_physicalV = new G4PVPlacement(0,G4    588     phantom_physicalV = new G4PVPlacement(0,G4ThreeVector(0,0,0), phantom_logicalV, "pmma_phantom_physicalV", worldLogical, false, 0,fCheckOverlaps);
589                                                   589 
590     //The rods are placed at one end of the su    590     //The rods are placed at one end of the surrounding PMMA cylinderical phantom
591     rodPositionZ = -waterPhantomLength/2;         591     rodPositionZ = -waterPhantomLength/2;
592                                                   592 
593     for(G4int i = 0; i < numberOfRods; i++){      593     for(G4int i = 0; i < numberOfRods; i++){
594                                                   594 
595       if(i == 0) rodDiameter = 1 * mm;            595       if(i == 0) rodDiameter = 1 * mm;
596       if(i == 1) rodDiameter = 2 * mm;            596       if(i == 1) rodDiameter = 2 * mm;
597       if(i == 2) rodDiameter = 3 * mm;            597       if(i == 2) rodDiameter = 3 * mm;
598       if(i == 3) rodDiameter = 4 * mm;            598       if(i == 3) rodDiameter = 4 * mm;
599       if(i == 4) rodDiameter = 5 * mm;            599       if(i == 4) rodDiameter = 5 * mm;
600                                                   600 
601       rodPositionX = distanceFromCenter*std::c    601       rodPositionX = distanceFromCenter*std::cos(((G4double)i*twopi/numberOfRods));
602       rodPositionY = distanceFromCenter*std::s    602       rodPositionY = distanceFromCenter*std::sin(((G4double)i*twopi/numberOfRods));
603                                                   603 
604       //Define rod phantom                        604       //Define rod phantom 
605       G4Tubs* rod_phantom = new G4Tubs("Phanto    605       G4Tubs* rod_phantom = new G4Tubs("Phantom", 0*mm,rodDiameter/2,rodPhantomLength/2,0*deg,360*deg);
606                                                   606 
607       //Define rod phantom logical volume         607       //Define rod phantom logical volume
608       rod_phantom_logicalV = new G4LogicalVolu    608       rod_phantom_logicalV = new G4LogicalVolume(rod_phantom, water, "rod_phantom_logicalV",0,0,0);
609                                                   609 
610       //Define rod phantom physical volume        610       //Define rod phantom physical volume
611       rod_phantom_physicalV = new G4PVPlacemen    611       rod_phantom_physicalV = new G4PVPlacement(0,G4ThreeVector(rodPositionX,rodPositionY,rodPositionZ), rod_phantom_logicalV, "phantom_physicalV", phantom_logicalV, false, 0, fCheckOverlaps);
612     }                                             612     }
613                                                   613 
614     //Out dimensions of the surrounding PMMA f    614     //Out dimensions of the surrounding PMMA for cold region chambers
615     chamberPhantomLength = 15*mm;                 615     chamberPhantomLength = 15*mm;
616     chamberDiameter = 10*mm;                      616     chamberDiameter = 10*mm;
617                                                   617 
618     //Wall thickness of the surrounding PMMA p    618     //Wall thickness of the surrounding PMMA phantom for the cold region chambers
619     wallThicknessOfChamber = 1*mm;                619     wallThicknessOfChamber = 1*mm;
620                                                   620 
621     //The centers of the cold chambers is         621     //The centers of the cold chambers is 
622     chamberPositionX = distanceFromCenter;        622     chamberPositionX = distanceFromCenter;
623     chamberPositionY = 0*mm;                      623     chamberPositionY = 0*mm;
624     chamberPositionZ =  waterPhantomLength/2 -    624     chamberPositionZ =  waterPhantomLength/2 - chamberPhantomLength/2;
625                                                   625 
626     //hot region filled with water                626     //hot region filled with water
627     G4Tubs* water_phantom = new G4Tubs("Phanto    627     G4Tubs* water_phantom = new G4Tubs("Phantom", 0*mm,waterPhantomRadius,waterPhantomLength/2,0*deg,360*deg);
628                                                   628 
629     waterPhantom_logicalV = new G4LogicalVolum    629     waterPhantom_logicalV = new G4LogicalVolume(water_phantom, water, "waterPhantom_logicalV",0,0,0);
630                                                   630 
631     //place the phantom at one end of the PMMA    631     //place the phantom at one end of the PMMA phantom
632     WaterPhantom_physicalV = new G4PVPlacement    632     WaterPhantom_physicalV = new G4PVPlacement(0,G4ThreeVector(0,0,rodPhantomLength/2), waterPhantom_logicalV, "phantom_physicalV", phantom_logicalV, false, 0,fCheckOverlaps);
633     //waterPhantom_logicalV->SetVisAttributes     633     //waterPhantom_logicalV->SetVisAttributes (G4VisAttributes::Invisible);
634                                                   634 
635     //define the surrounding PMMA chamber         635     //define the surrounding PMMA chamber
636     G4Tubs* chamberPMMA = new G4Tubs("chamber_    636     G4Tubs* chamberPMMA = new G4Tubs("chamber_phantom1", 0*mm,chamberDiameter/2,chamberPhantomLength/2,0*deg,360*deg);
637                                                   637 
638     //define the logical volume of the surroun    638     //define the logical volume of the surrounding PMMA chamber
639     chamberPMMA_logicalV = new G4LogicalVolume    639     chamberPMMA_logicalV = new G4LogicalVolume(chamberPMMA, pmma, "chamberPMMA_logicalV",0,0,0);
640                                                   640 
641     //define the physical volume of the surrou    641     //define the physical volume of the surrounding PMMA chamber
642     chamberPMMA_physicalV = new G4PVPlacement(    642     chamberPMMA_physicalV = new G4PVPlacement(0,G4ThreeVector(chamberPositionX, chamberPositionY, chamberPositionZ), chamberPMMA_logicalV, "pmma_phantom_physicalV", waterPhantom_logicalV, false, 0,fCheckOverlaps);
643                                                   643 
644                                                   644 
645     //Two cold region chambers: one of them fi    645     //Two cold region chambers: one of them filled with (non-radioactive) water and the other with air and is placed inside a hot region
646     //chamber one filled with water (cold regi    646     //chamber one filled with water (cold region)
647     //Define the cold region chamber phantom t    647     //Define the cold region chamber phantom to be filled with water
648     G4Tubs* chamberWater = new G4Tubs("chamber    648     G4Tubs* chamberWater = new G4Tubs("chamber_phantom1", 0*mm,chamberDiameter/2 - wallThicknessOfChamber,chamberPhantomLength/2 - wallThicknessOfChamber,0*deg,360*deg);
649                                                   649 
650     //Define the logical volume of the cold re    650     //Define the logical volume of the cold region phantom
651     chamberWater_logicalV = new G4LogicalVolum    651     chamberWater_logicalV = new G4LogicalVolume(chamberWater, water, "chamber_phantom_logicalV",0,0,0);
652                                                   652 
653     //Define the physical volume of the cold r    653     //Define the physical volume of the cold region phantom
654     chamberWater_physicalV = new G4PVPlacement    654     chamberWater_physicalV = new G4PVPlacement(0,G4ThreeVector(0,0,0), chamberWater_logicalV, "coldRegion_physicalV", chamberPMMA_logicalV, false, 0,fCheckOverlaps);
655                                                   655 
656     //chamber2 filled with air                    656     //chamber2 filled with air 
657     //Place the surrounding chamber at another    657     //Place the surrounding chamber at another location (at -chamberPositionX)
658     chamberPMMA_physicalV = new G4PVPlacement(    658     chamberPMMA_physicalV = new G4PVPlacement(0,G4ThreeVector(-chamberPositionX, chamberPositionY, chamberPositionZ), chamberPMMA_logicalV, "pmma_phantom_physicalV", waterPhantom_logicalV, false, 0,fCheckOverlaps);
659                                                   659 
660     //Define the logical volume of the cold re    660     //Define the logical volume of the cold region phantom to be filled with air
661     G4Tubs* chamberAir = new G4Tubs("chamber_p    661     G4Tubs* chamberAir = new G4Tubs("chamber_phantom1", 0*mm,chamberDiameter/2 - wallThicknessOfChamber,chamberPhantomLength/2 - wallThicknessOfChamber,0*deg,360*deg);
662                                                   662 
663     //Define its logical volume                   663     //Define its logical volume 
664     chamberAir_logicalV = new G4LogicalVolume(    664     chamberAir_logicalV = new G4LogicalVolume(chamberAir, air, "chamber_phantom_logicalV",0,0,0);
665                                                   665 
666     //Define the physical volume of air-filled    666     //Define the physical volume of air-filled chamber 
667     chamberAir_physicalV = new G4PVPlacement(0    667     chamberAir_physicalV = new G4PVPlacement(0,G4ThreeVector(0,0,0), chamberAir_logicalV, "coldRegion_physicalV", chamberPMMA_logicalV, false, 0,fCheckOverlaps);
668                                                   668 
669   }                                               669   }
670                                                   670 
671   else if(PhantomType == "NEMA_phantom_NECR"){    671   else if(PhantomType == "NEMA_phantom_NECR"){
672     //////////////////////////////   Phantom f    672     //////////////////////////////   Phantom for NECR //////////////////////////////////////
673     //The phantom is 203 mm in diameter and 70    673     //The phantom is 203 mm in diameter and 700 mm in height and is placed at the center of the AFOV
674                                                   674 
675     //Define its solid shape                      675     //Define its solid shape 
676     G4Tubs* phantom = new G4Tubs("Phantom", 0*    676     G4Tubs* phantom = new G4Tubs("Phantom", 0*mm,phantomRadius,phantomLength/2,0*deg,360*deg);
677                                                   677 
678     //Define its logical volume                   678     //Define its logical volume
679     phantom_logicalV = new G4LogicalVolume(pha    679     phantom_logicalV = new G4LogicalVolume(phantom, polyethylene_NEMA, "phantom_logicalV",0,0,0);
680                                                   680 
681     //Define its physical volume                  681     //Define its physical volume
682     phantom_physicalV = new G4PVPlacement(0,G4    682     phantom_physicalV = new G4PVPlacement(0,G4ThreeVector(0,0,0), phantom_logicalV, "phantom_physicalV", worldLogical, false, 0,fCheckOverlaps);
683   }                                               683   }
684   else if(PhantomType == "Phantom_sensitivity"    684   else if(PhantomType == "Phantom_sensitivity"){
685                                                   685 
686     /////////////////////////////////////////     686     ///////////////////////////////////////// Sensitiviy phantom  /////////////////////////////////////////////
687     //There are six diffrent sizes of the sens    687     //There are six diffrent sizes of the sensitivity phantom which differe in their diameter. 
688     //The size of the phantom can be changed v    688     //The size of the phantom can be changed via the macro file by changing the number of sleeves
689     //The length of sensitivity phantom is 700    689     //The length of sensitivity phantom is 700 mm
690     //(3.9, 6.4), (7.0, 9.5), (10.2, 12.7), (1    690     //(3.9, 6.4), (7.0, 9.5), (10.2, 12.7), (13.4, 15.9), (16.6, 19.1)
691                                                   691 
692     G4double Rmin, Rmax;                          692     G4double Rmin, Rmax;
693     G4cout<<"Total number of sleeves : "<<numO    693     G4cout<<"Total number of sleeves : "<<numOfSleeves<<G4endl;
694                                                   694 
695     for(G4int i=0; i<numOfSleeves; i++){          695     for(G4int i=0; i<numOfSleeves; i++){
696       if(i==0){                                   696       if(i==0){
697         Rmin = 3.9/2 * mm;                        697         Rmin = 3.9/2 * mm;
698         Rmax = 3.2 * mm;                          698         Rmax = 3.2 * mm; 
699         }                                         699         }
700       if(i==1){                                   700       if(i==1){
701         Rmin = 7.0/2 * mm;                        701         Rmin = 7.0/2 * mm;
702         Rmax = 4.75 * mm;                         702         Rmax = 4.75 * mm;
703       }                                           703       }
704       if(i==2){                                   704       if(i==2){
705         Rmin = 10.2/2 * mm;                       705         Rmin = 10.2/2 * mm;
706         Rmax = 6.35*mm;                           706         Rmax = 6.35*mm;
707       }                                           707       }
708       if(i==3){                                   708       if(i==3){
709         Rmin = 13.4/2 * mm;                       709         Rmin = 13.4/2 * mm;
710         Rmax = 7.95 *mm;                          710         Rmax = 7.95 *mm;
711       }                                           711       }
712       if(i==4){                                   712       if(i==4){
713         Rmin = 16.6/2 * mm;                       713         Rmin = 16.6/2 * mm;
714         Rmax = 9.55 * mm;                         714         Rmax = 9.55 * mm;
715                                                   715         
716       }                                           716       }
717       G4cout<<"Sleeve "<<i+1 <<" is placed, Rm    717       G4cout<<"Sleeve "<<i+1 <<" is placed, Rmin = "<<Rmin<< " mm, Rmax = "<<Rmax<< " mm, "<< "length = " <<phantomLength <<" mm."<<G4endl;
718                                                   718 
719       //Concenric aluminum sleeves                719       //Concenric aluminum sleeves
720       G4Tubs* phantom = new G4Tubs("Phantom_se    720       G4Tubs* phantom = new G4Tubs("Phantom_sensitivity", Rmin,Rmax,phantomLength/2,0*deg,360*deg);
721                                                   721 
722       //Define its logical volume. The Matrial    722       //Define its logical volume. The Matrial of the tubes are Aluminum
723       phantom_logicalV = new G4LogicalVolume(p    723       phantom_logicalV = new G4LogicalVolume(phantom, Aluminum, "phantom_logicalV",0,0,0);
724                                                   724 
725       //Define its physical volume                725       //Define its physical volume
726       phantom_physicalV = new G4PVPlacement(0,    726       phantom_physicalV = new G4PVPlacement(0, phantomPosition, phantom_logicalV, "phantom_physicalV", worldLogical, false, 0,fCheckOverlaps);
727     }                                             727     }
728                                                   728 
729     //Define the inner most polyethylene (PE)     729     //Define the inner most polyethylene (PE) tube with a diameter of 3 mm. This size will not be changed. This is the phantom that holds the source.
730     G4Tubs* phantomPE = new G4Tubs("Phantom_se    730     G4Tubs* phantomPE = new G4Tubs("Phantom_sensitivity", 0 *mm,1.5*mm,phantomLength/2,0*deg,360*deg);
731                                                   731 
732     //Define its logical volume. The Matrial o    732     //Define its logical volume. The Matrial of the tubes are polyethylene
733     phantomPE_logicalV = new G4LogicalVolume(p    733     phantomPE_logicalV = new G4LogicalVolume(phantomPE, polyethylene_NEMA, "phantom_logicalV",0,0,0);
734                                                   734 
735     //Define its physical volume                  735     //Define its physical volume
736     phantomPE_physicalV = new G4PVPlacement(0,    736     phantomPE_physicalV = new G4PVPlacement(0, phantomPosition, phantomPE_logicalV, "phantom_physicalV", worldLogical, false, 0,fCheckOverlaps);
737                                                   737 
738                                                   738 
739     G4cout<<"---------------Phantom dimension:    739     G4cout<<"---------------Phantom dimension: "<<"radius (mm) = "<<phantomRadius<<" "<<"Length (mm) = "<<phantomLength<<G4endl;
740     G4cout<<"---------------Phantom position (    740     G4cout<<"---------------Phantom position (mm) : "<<phantomPosition<<G4endl;
741   }                                               741   }
742   else if(PhantomType == "Phantom_spatialResol    742   else if(PhantomType == "Phantom_spatialResolution"){
743     ////////////////// phantom for point sourc    743     ////////////////// phantom for point source (For spatial resolution evaluation) /////////////////////////////////
744     //The position of the point source phantom    744     //The position of the point source phantom can be changed in the macro file. 
745     //It has cylindrical shape and its radius     745     //It has cylindrical shape and its radius and length can be set in the macro file
746                                                   746 
747     //Define its solid shape                      747     //Define its solid shape
748     G4Tubs* phantom = new G4Tubs("Phantom_poin    748     G4Tubs* phantom = new G4Tubs("Phantom_point", 0., phantomRadius,phantomLength/2,0*deg,360*deg);
749                                                   749 
750     //Define its logical volume                   750     //Define its logical volume
751     phantom_logicalV = new G4LogicalVolume(pha    751     phantom_logicalV = new G4LogicalVolume(phantom, polyethylene_NEMA , "phantom_logicalV",0,0,0);
752                                                   752 
753     //place the phantom                           753     //place the phantom
754     phantomPosition = G4ThreeVector(phantomPos    754     phantomPosition = G4ThreeVector(phantomPosition.x(),phantomPosition.y(),phantomPosition.z());
755                                                   755 
756     //Define its physical volume                  756     //Define its physical volume
757     phantom_physicalV = new G4PVPlacement(0, p    757     phantom_physicalV = new G4PVPlacement(0, phantomPosition, phantom_logicalV, "phantom_physicalV", worldLogical, false, 0,fCheckOverlaps);
758     G4cout<<"---------------Phantom dimension:    758     G4cout<<"---------------Phantom dimension: "<<"radius (mm) = "<<phantomRadius<<" "<<", Length (mm) = "<<phantomLength<<G4endl;
759     G4cout<<"---------------Phantom position:     759     G4cout<<"---------------Phantom position: "<<phantomPosition<< "mm"<<G4endl;  
760   }                                               760   }
761                                                   761 
762   else if (PhantomType == "Normalization")        762   else if (PhantomType == "Normalization")
763   {                                               763   {
764     //The normalization phantom is a hallow cy    764     //The normalization phantom is a hallow cylindrical phantom to represent a (rotating) line source. The source is confined in the phantom.
765     //The thickness of the phantom is 3 mm, an    765     //The thickness of the phantom is 3 mm, and its diameter is 350 mm. 
766                                                   766 
767     //Define the solid shape.                     767     //Define the solid shape. 
768     G4Tubs* phantom = new G4Tubs("Phantom", ph    768     G4Tubs* phantom = new G4Tubs("Phantom", phantomRadius - 3*mm, phantomRadius,phantomLength/2,0*deg,360*deg);
769                                                   769 
770     //Define its logical volume.                  770     //Define its logical volume.
771     phantom_logicalV = new G4LogicalVolume(pha    771     phantom_logicalV = new G4LogicalVolume(phantom, polyethylene_NEMA, "phantom_logicalV",0,0,0);
772                                                   772 
773     //Define its physical volume                  773     //Define its physical volume
774     phantom_physicalV = new G4PVPlacement(0, p    774     phantom_physicalV = new G4PVPlacement(0, phantomPosition, phantom_logicalV, "phantom_physicalV", worldLogical, false, 0,fCheckOverlaps);
775                                                   775 
776                                                   776 
777     G4cout<<"---------------Phantom dimension:    777     G4cout<<"---------------Phantom dimension: "<<"radius (mm) = "<<phantomRadius<<" "<<"Length = "<<phantomLength<<G4endl;
778     G4cout<<"---------------Phantom position :    778     G4cout<<"---------------Phantom position : "<<phantomPosition<< "mm"<<G4endl;
779                                                   779 
780   }                                               780   }
781   //-------------------------------------=====    781   //-------------------------------------================- No Phantom Set -==================------------------
782   else                                            782   else
783   {                                               783   {
784     G4cerr << "*******************************    784     G4cerr << "****************************************\nERROR: Phantom Remains: " << PhantomType <<"\n****************************************" << G4endl;
785     exit(0);                                      785     exit(0);
786                                                   786 
787   }                                               787   }
788   ///////////Visualization of phantoms////////    788   ///////////Visualization of phantoms///////////
789                                                   789 
790   G4VisAttributes* phantomVisAtt;                 790   G4VisAttributes* phantomVisAtt;
791   phantomVisAtt = new G4VisAttributes(G4Colour    791   phantomVisAtt = new G4VisAttributes(G4Colour(0.88,0.55,1.0));
792   phantomVisAtt->SetVisibility (true);            792   phantomVisAtt->SetVisibility (true);
793   phantomVisAtt->SetForceWireframe (true);        793   phantomVisAtt->SetForceWireframe (true);
794   phantom_logicalV->SetVisAttributes (phantomV    794   phantom_logicalV->SetVisAttributes (phantomVisAtt);
795   //phantom_logicalV->SetVisAttributes (G4VisA    795   //phantom_logicalV->SetVisAttributes (G4VisAttributes::Invisible);  
796 }                                                 796 }
797                                                   797 
798 //Change the type of the phantom via .mac file    798 //Change the type of the phantom via .mac file
799 void doiPETDetectorConstruction::ChangePhantom    799 void doiPETDetectorConstruction::ChangePhantom(G4String NewPhantomtype)
800 {                                                 800 {
801   PhantomType = NewPhantomtype;                   801   PhantomType = NewPhantomtype;
802 }                                                 802 }
803                                                   803 
804 //Change position of the phantom via .mac file    804 //Change position of the phantom via .mac file
805 void doiPETDetectorConstruction::SetPhantomPos    805 void doiPETDetectorConstruction::SetPhantomPosition(G4ThreeVector NewphantomPosition)
806 {                                                 806 {
807   phantomPosition = NewphantomPosition;           807   phantomPosition = NewphantomPosition;
808 }                                                 808 }
809                                                   809 
810 //Change the radius of the phantom via .mac fi    810 //Change the radius of the phantom via .mac file
811 void doiPETDetectorConstruction::SetPhantomRad    811 void doiPETDetectorConstruction::SetPhantomRadius(G4double newPhantomRadius){
812   phantomRadius = newPhantomRadius;               812   phantomRadius = newPhantomRadius;
813 }                                                 813 }
814                                                   814 
815 //Change the length of the phantom via .mac fi    815 //Change the length of the phantom via .mac file
816 void doiPETDetectorConstruction::SetPhantomLen    816 void doiPETDetectorConstruction::SetPhantomLength(G4double newPhantomLength){
817   phantomLength = newPhantomLength;               817   phantomLength = newPhantomLength;
818 }                                                 818 }
819 //                                                819 //
820 void doiPETDetectorConstruction::SetNumberOfSl    820 void doiPETDetectorConstruction::SetNumberOfSleeves(G4int NewNumOfSleeves){
821   numOfSleeves = NewNumOfSleeves;                 821   numOfSleeves = NewNumOfSleeves;
822   //G4cout<<"numOfSleeves "<<numOfSleeves<<G4e    822   //G4cout<<"numOfSleeves "<<numOfSleeves<<G4endl;
823 }                                                 823 }
824                                                   824