Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-02 08:02:52

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 // --------------------------------------------------------------
0028 //                 GEANT 4 - Brachytherapy example
0029 // --------------------------------------------------------------
0030 //
0031 // Code developed by:
0032 // S. Guatelli, D. Cutajar, J. Poder
0033 // Centre For Medical Radiation Physics, University of Wollongong
0034 //
0035 //    ****************************************
0036 //    *                                      *
0037 //    *    BrachyDetectorConstructionFlexi.cc*
0038 //    *                                      *
0039 //    ****************************************
0040 //
0041 //
0042 #include "globals.hh"
0043 #include "G4SystemOfUnits.hh"
0044 #include "BrachyDetectorConstructionFlexi.hh"
0045 #include "G4RunManager.hh"
0046 #include "G4Tubs.hh"
0047 #include "G4Cons.hh"
0048 #include "G4LogicalVolume.hh"
0049 #include "G4ThreeVector.hh"
0050 #include "G4PVPlacement.hh"
0051 #include "G4Transform3D.hh"
0052 #include "G4RotationMatrix.hh"
0053 #include "G4TransportationManager.hh"
0054 #include "G4VisAttributes.hh"
0055 #include "G4Colour.hh"
0056 #include "G4NistManager.hh"
0057 
0058 BrachyDetectorConstructionFlexi::BrachyDetectorConstructionFlexi()
0059   : fSteelShell(nullptr), fLogicalSteelShell(nullptr), fAirGap(nullptr), fLogicalAirGap(nullptr), fPhysicalAirGap(nullptr),
0060     fEnd1SteelShell(nullptr), fLogicalEnd1SteelShell(nullptr), fPhysicalEnd1SteelShell(nullptr),
0061     fEnd2SteelShell(nullptr), fLogicalEnd2SteelShell(nullptr), fPhysicalEnd2SteelShell(nullptr),
0062     fCable(nullptr), fLogicalCable(nullptr), fPhysicalCable(nullptr),
0063     fIridiumCore(nullptr), fLogicalIridiumCore(nullptr), fPhysicalIridiumCore(nullptr),
0064     fSteelAttributes(nullptr), fEndAttributes(nullptr), fSimpleIridiumVisAtt(nullptr)
0065 {}
0066 
0067 void BrachyDetectorConstructionFlexi::ConstructFlexi(G4VPhysicalVolume* mother)
0068 {
0069   G4NistManager* nist = G4NistManager::Instance();
0070   
0071   G4Material* iridiumMat = nist -> FindOrBuildMaterial("G4_Ir");
0072   G4Material* airMat = nist -> FindOrBuildMaterial("G4_AIR");
0073   
0074   //Define Stainless-steel-304 - Flexi source
0075   G4int Z; //atomic number of the element
0076   G4Element* elC = nist -> FindOrBuildElement(Z=6);
0077   G4Element* elMn = nist -> FindOrBuildElement(Z=12);
0078   G4Element* elSi = nist -> FindOrBuildElement(Z=14);
0079   G4Element* elCr = nist -> FindOrBuildElement(Z=24);
0080   G4Element* elFe = nist -> FindOrBuildElement(Z=26);
0081   G4Element* elNi = nist -> FindOrBuildElement(Z=28);
0082  
0083   constexpr G4double d = 7.999*g/cm3;
0084   auto steelMat = new G4Material("Stainless steel 304",d,6);
0085   steelMat -> AddElement(elMn, 0.02);
0086   steelMat -> AddElement(elSi, 0.01);
0087   steelMat -> AddElement(elCr, 0.19);
0088   steelMat -> AddElement(elNi, 0.10);
0089   steelMat -> AddElement(elFe, 0.6792);
0090   steelMat -> AddElement(elC, 0.0008);
0091   
0092  //Define dimensions of the outer Steel shell around the solid source - not including the ends 
0093 
0094   G4double shellr_min = 0.00 * mm;
0095   G4double shellr_max = 0.85 * mm;
0096   G4double shell_length = 3.6 * mm; 
0097   fSteelShell = new G4Tubs("steel_shell",shellr_min, shellr_max/2, shell_length/2.,0.*deg,360.*deg);
0098   fLogicalSteelShell = new G4LogicalVolume(fSteelShell, steelMat, "steel_shell_log", nullptr, nullptr, nullptr);
0099   fPhysicalSteelShell = new G4PVPlacement(nullptr,G4ThreeVector(0,0,0),"phys_steel_shell", fLogicalSteelShell, mother, false, 0, true);
0100 
0101 //Define dimensions of the air gap between Steel shell and Iridium core
0102   G4double airr_min = 0.00 * mm;
0103   G4double airr_max = 0.67 * mm;
0104   G4double air_length = 3.6 * mm; 
0105   fAirGap = new G4Tubs("air_gap", airr_min, airr_max/2, air_length/2, 0.*deg, 360.*deg);
0106   fLogicalAirGap = new G4LogicalVolume(fAirGap, airMat, "air_gap_log", nullptr, nullptr, nullptr);
0107   fPhysicalAirGap = new G4PVPlacement(nullptr, G4ThreeVector(0,0,0), "phys_air_gap", fLogicalAirGap, fPhysicalSteelShell, false, 0, true);
0108 
0109 //Define the non-cable weld end of the Steel shell 
0110   G4double end1r_min = 0.0 * mm;
0111   G4double end1r_max = 0.85 * mm;
0112   G4double end1length = 0.65 * mm; 
0113   fEnd1SteelShell = new G4Tubs("End_1_steel_shell", end1r_min, end1r_max/2, end1length/2.,0.*deg,360.*deg);
0114   fLogicalEnd1SteelShell = new G4LogicalVolume(fEnd1SteelShell, steelMat, "End1_steel_shell_log", nullptr, nullptr, nullptr);
0115   G4double end1offset_x = 0.0 * mm;
0116   G4double end1offset_y = 0.0 * mm;
0117   G4double end1offset_z = 2.125 * mm;
0118   fPhysicalEnd1SteelShell = new G4PVPlacement(nullptr,G4ThreeVector(end1offset_x,end1offset_y,end1offset_z),"phys_End1_steel_shell", fLogicalEnd1SteelShell,mother, false, 0, true);
0119 
0120 //Define the cable weld end of the Steel shell 
0121   G4double end2r_min1 = 0.0 * mm;
0122   G4double end2r_max1 = 0.85 * mm;
0123   G4double end2r_min2 = 0.0 * mm;
0124   G4double end2r_max2 = 0.5 * mm;
0125   G4double end2length = 0.4 * mm;
0126   fEnd2SteelShell = new G4Cons("End_2_steel_shell", end2r_min2, end2r_max2/2, end2r_min1, end2r_max1/2, end2length/2.0, 0.0, 360.0*deg);
0127   fLogicalEnd2SteelShell = new G4LogicalVolume(fEnd2SteelShell, steelMat, "End2_steel_shell_log", nullptr, nullptr, nullptr);
0128   G4double end2offset_x = 0.0 * mm;
0129   G4double end2offset_y = 0.0 * mm;
0130   G4double end2offset_z = -2.0 * mm; 
0131   fPhysicalEnd2SteelShell = new G4PVPlacement(nullptr,G4ThreeVector(end2offset_x,end2offset_y,end2offset_z), "phys_End2_steel_shell", fLogicalEnd2SteelShell, mother, false, 0, true);
0132 
0133 //Define the cable 
0134   G4double cable_min = 0.0 * mm;
0135   G4double cable_max = 0.5 * mm;
0136   G4double cablelength = 5.0 * mm; 
0137   fCable = new G4Tubs("cable",cable_min, cable_max/2, cablelength/2.,0.*deg,360.*deg);
0138   fLogicalCable = new G4LogicalVolume(fCable, steelMat, "cable_log", nullptr, nullptr, nullptr);
0139   G4double cableoffset_x = 0.0 * mm;
0140   G4double cableoffset_y = 0.0 * mm;
0141   G4double cableoffset_z = -4.7 * mm;
0142   fPhysicalCable = new G4PVPlacement(nullptr,G4ThreeVector(cableoffset_x,cableoffset_y,cableoffset_z),"phys_cable", fLogicalCable, mother, false, 0, true);
0143 
0144 // Define the Iridium core
0145   G4double corer_min = 0.0 * mm;    
0146   G4double corer_max = 0.6 * mm;
0147   G4double core_length = 3.5 * mm; 
0148   fIridiumCore = new G4Tubs("iridium_core",corer_min, corer_max/2,core_length/2.,0.*deg,360.*deg);
0149   fLogicalIridiumCore = new G4LogicalVolume(fIridiumCore, iridiumMat, "iridium_core_log", nullptr, nullptr, nullptr);
0150   fPhysicalIridiumCore = new G4PVPlacement(nullptr,G4ThreeVector(0,0,0), "phys_iridium_core", fLogicalIridiumCore, fPhysicalAirGap, false, 0, true);
0151 
0152 // Visualisations
0153 
0154 //Shell/cable attributes    
0155   fSteelAttributes = new G4VisAttributes(G4Colour(1.0, 0.0, 0.0)); // red
0156   fSteelAttributes -> SetVisibility(true);
0157   fSteelAttributes -> SetForceAuxEdgeVisible(true);
0158 
0159   fEndAttributes = new G4VisAttributes(G4Colour(1.0, 0.0, 0.0)); // red
0160   fEndAttributes -> SetVisibility(true);
0161   fEndAttributes -> SetForceAuxEdgeVisible(true);
0162   fLogicalSteelShell -> SetVisAttributes(fSteelAttributes);
0163   fLogicalEnd1SteelShell -> SetVisAttributes(fEndAttributes);
0164   fLogicalEnd2SteelShell -> SetVisAttributes(fEndAttributes);
0165   fLogicalCable -> SetVisAttributes(fSteelAttributes);
0166  
0167   G4Colour  magenta (1.0, 0.0, 1.0) ; 
0168 
0169   fSimpleIridiumVisAtt = new G4VisAttributes(magenta);
0170   fSimpleIridiumVisAtt -> SetVisibility(true);
0171   fSimpleIridiumVisAtt -> SetForceWireframe(true);
0172   fLogicalIridiumCore -> SetVisAttributes(fSimpleIridiumVisAtt);
0173 }
0174 
0175 void BrachyDetectorConstructionFlexi::CleanFlexi()
0176 { 
0177   delete fSimpleIridiumVisAtt; 
0178   fSimpleIridiumVisAtt = nullptr;
0179   
0180   delete fEndAttributes; 
0181   fEndAttributes = nullptr;
0182   
0183   delete fSteelAttributes; 
0184   fSteelAttributes = nullptr;
0185   
0186   delete fPhysicalIridiumCore; 
0187   fPhysicalIridiumCore = nullptr ;
0188 
0189   delete fLogicalIridiumCore; 
0190   fLogicalIridiumCore = nullptr;
0191   
0192   delete fIridiumCore; 
0193   fIridiumCore = nullptr;
0194   
0195   delete fPhysicalCable;
0196   fPhysicalCable = nullptr;
0197  
0198   delete fLogicalCable; 
0199   fLogicalCable = nullptr;
0200 
0201   delete fCable; 
0202   fCable = nullptr;
0203   
0204   delete fPhysicalEnd2SteelShell; 
0205   fPhysicalEnd2SteelShell = nullptr;
0206    
0207   delete fLogicalEnd2SteelShell; 
0208   fLogicalEnd2SteelShell = nullptr;
0209   
0210   delete fEnd2SteelShell; 
0211   fEnd2SteelShell = nullptr;
0212   
0213   delete fPhysicalEnd1SteelShell; 
0214   fPhysicalEnd1SteelShell = nullptr;
0215    
0216   delete fLogicalEnd1SteelShell; 
0217   fLogicalEnd1SteelShell = nullptr;
0218   
0219   delete fEnd1SteelShell; 
0220   fEnd1SteelShell = nullptr;
0221 
0222   delete fPhysicalAirGap;
0223   fPhysicalAirGap = nullptr;
0224 
0225   delete fLogicalAirGap;
0226   fLogicalAirGap = nullptr;
0227 
0228   delete fAirGap;
0229   fAirGap = nullptr;
0230 
0231   delete fPhysicalSteelShell;
0232   fPhysicalSteelShell = nullptr;
0233 
0234   delete fLogicalSteelShell;
0235   fLogicalSteelShell = nullptr;
0236  
0237   delete fSteelShell;
0238   fSteelShell = nullptr;
0239  
0240   G4RunManager::GetRunManager() -> GeometryHasBeenModified();
0241 }