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 // D. Cutajar
0033 //
0034 //    ****************************************
0035 //    *                                      *
0036 //    *    BrachyDetectorConstructionTG186.cc   *
0037 //    *                                      *
0038 //    ****************************************
0039 //
0040 //
0041 #include "BrachyDetectorConstructionTG186.hh"
0042 #include "globals.hh"
0043 #include "G4SystemOfUnits.hh"
0044 #include "G4Sphere.hh"
0045 #include "G4RunManager.hh"
0046 #include "G4Box.hh"
0047 #include "G4Tubs.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 BrachyDetectorConstructionTG186::BrachyDetectorConstructionTG186(): 
0059    fTG186capsule(nullptr), fTG186capsuleLog(nullptr),
0060    fTG186capsulePhys(nullptr),
0061    fTG186capsuleTip(nullptr), fTG186capsuleTipLog(nullptr),
0062    fTG186capsuleTipPhys(nullptr),
0063    fTG186iridiumCore(nullptr), fTG186iridiumCoreLog(nullptr),
0064    fTG186iridiumCorePhys(nullptr),
0065    fTG186cable(nullptr), fTG186cableLog(nullptr),
0066    fTG186cablePhys(nullptr),
0067    fTG186simpleCapsuleVisAtt(nullptr), fTG186simpleCapsuleTipVisAtt(nullptr), fTG186simpleIridiumVisAtt(nullptr),
0068    fTG186simpleCableVisAtt(nullptr)
0069 {}
0070 
0071 void BrachyDetectorConstructionTG186::ConstructTG186(G4VPhysicalVolume* mother)
0072 {
0073   G4Colour  red     (1.0, 0.0, 0.0) ;
0074   G4Colour  magenta (1.0, 0.0, 1.0) ; 
0075 
0076   G4NistManager* nist = G4NistManager::Instance();
0077   auto iridium = nist -> FindOrBuildMaterial("G4_Ir");
0078  
0079   // Stainless steel (Medical Physics, Vol 25, No 10, Oct 1998)
0080   constexpr G4double d = 8.02*g/cm3;
0081   G4int Z; //atomic number of the element
0082   G4Element* elMn = nist -> FindOrBuildElement(Z=12);
0083   G4Element* elSi = nist -> FindOrBuildElement(Z=14);
0084   G4Element* elCr = nist -> FindOrBuildElement(Z=24);
0085   G4Element* elFe = nist -> FindOrBuildElement(Z=26);
0086   G4Element* elNi = nist -> FindOrBuildElement(Z=28);
0087   auto capsuleMat = new G4Material("Stainless steel",d,5);
0088   capsuleMat -> AddElement(elMn, 0.02);
0089   capsuleMat -> AddElement(elSi, 0.01);
0090   capsuleMat -> AddElement(elCr, 0.19);
0091   capsuleMat -> AddElement(elNi, 0.10);
0092   capsuleMat -> AddElement(elFe, 0.68);
0093   
0094 
0095   // Capsule main body
0096   fTG186capsule = new G4Tubs("TG186-Capsule",0,0.5*mm,2.25*mm,0.*deg,360.*deg);
0097   fTG186capsuleLog = new G4LogicalVolume(fTG186capsule,capsuleMat,"TG186-CapsuleLog");
0098   fTG186capsulePhys = new G4PVPlacement(nullptr,
0099                                  G4ThreeVector(0,0,-0.4*mm),
0100                                  "TG186-IridiumCapsulePhys",
0101                                  fTG186capsuleLog,
0102                                  mother,
0103                                  false,
0104                                  0, true);
0105 
0106   // Capsule tip
0107   fTG186capsuleTip = new G4Sphere("Tg186-CapsuleTipIridium",
0108                             0.*mm,
0109                             0.5*mm,
0110                             0.*deg,
0111                             360.*deg,
0112                             0.*deg,
0113                             90.*deg); 
0114   
0115   fTG186capsuleTipLog = new G4LogicalVolume(fTG186capsuleTip,
0116                                       capsuleMat,
0117                                       "CapsuleTipIridumLog");
0118                                       
0119   fTG186capsuleTipPhys = new G4PVPlacement(nullptr,
0120                                      G4ThreeVector(0.,0.,1.85*mm),
0121                                      "TG186-CapsuleTipIridiumPhys",
0122                                      fTG186capsuleTipLog,
0123                                      mother,
0124                                      false,
0125                                      0, true);
0126                                      
0127   fTG186cable = new G4Tubs("TG186-cable",
0128                             0.*mm,
0129                             0.5*mm,
0130                                 1.0*mm,
0131                             0.*deg,
0132                             360.*deg); 
0133   
0134   fTG186cableLog = new G4LogicalVolume(fTG186cable,
0135                                       capsuleMat,
0136                                       "TG186-cableLog");
0137                                       
0138   fTG186cablePhys = new G4PVPlacement(nullptr,
0139                                      G4ThreeVector(0.,0.,-3.65*mm),
0140                                      "TG186-CablePhys",
0141                                      fTG186cableLog,
0142                                      mother,
0143                                      false,
0144                                      0, true);                               
0145 
0146   // Iridium core
0147   fTG186iridiumCore = new G4Tubs("TG186-IrCore",0,0.30*mm,1.75*mm,0.*deg,360.*deg);
0148   
0149   fTG186iridiumCoreLog = new G4LogicalVolume(fTG186iridiumCore,
0150                                        iridium,
0151                                        "TG186-IridiumCoreLog");
0152                                        
0153   fTG186iridiumCorePhys = new G4PVPlacement(nullptr,
0154                                       G4ThreeVector(0,0,0.4*mm),
0155                                       "TG186-IridiumCorePhys",
0156                                       fTG186iridiumCoreLog,
0157                                       fTG186capsulePhys,
0158                                       false,
0159                                       0, true);
0160 
0161   fTG186simpleCapsuleVisAtt = new G4VisAttributes(red);
0162   fTG186simpleCapsuleVisAtt -> SetVisibility(true);  
0163   fTG186simpleCapsuleVisAtt -> SetForceWireframe(true);
0164   fTG186capsuleLog -> SetVisAttributes(fTG186simpleCapsuleVisAtt);
0165 
0166   fTG186simpleCapsuleTipVisAtt = new G4VisAttributes(red);
0167   fTG186simpleCapsuleTipVisAtt -> SetVisibility(true);  
0168   fTG186simpleCapsuleTipVisAtt -> SetForceSolid(true);
0169   fTG186capsuleTipLog -> SetVisAttributes(fTG186simpleCapsuleTipVisAtt);
0170 
0171   fTG186simpleIridiumVisAtt = new G4VisAttributes(magenta);
0172   fTG186simpleIridiumVisAtt -> SetVisibility(true);
0173   fTG186simpleIridiumVisAtt -> SetForceWireframe(true);
0174   fTG186iridiumCoreLog -> SetVisAttributes(fTG186simpleIridiumVisAtt);
0175   
0176   fTG186simpleCableVisAtt = new G4VisAttributes(red);
0177   fTG186simpleCableVisAtt -> SetVisibility(true);  
0178   fTG186simpleCableVisAtt -> SetForceSolid(true);
0179   fTG186cableLog -> SetVisAttributes(fTG186simpleCableVisAtt);
0180 }
0181 
0182 void BrachyDetectorConstructionTG186::CleanTG186()
0183 { 
0184   
0185   delete fTG186simpleIridiumVisAtt; 
0186   fTG186simpleIridiumVisAtt = nullptr;
0187   
0188   delete fTG186iridiumCorePhys; 
0189   fTG186iridiumCorePhys = nullptr;
0190   
0191   delete fTG186iridiumCore; 
0192   fTG186iridiumCore = nullptr;
0193   
0194   delete fTG186iridiumCoreLog; 
0195   fTG186iridiumCoreLog = nullptr ;
0196 
0197   delete fTG186simpleCapsuleTipVisAtt; 
0198   fTG186simpleCapsuleTipVisAtt = nullptr;
0199   
0200   delete fTG186capsuleTipPhys; 
0201   fTG186capsuleTipPhys = nullptr;
0202   
0203   delete fTG186capsuleTip;
0204   fTG186capsuleTip = nullptr;
0205   
0206   delete fTG186capsuleTipLog; 
0207   fTG186capsuleTipLog = nullptr;
0208 
0209   delete fTG186simpleCapsuleVisAtt; 
0210   fTG186simpleCapsuleVisAtt = nullptr;
0211   
0212   delete fTG186capsulePhys; 
0213   fTG186capsulePhys = nullptr;
0214   
0215   delete fTG186capsule; 
0216   fTG186capsule = nullptr;
0217   
0218   delete fTG186capsuleLog; 
0219   fTG186capsuleLog = nullptr;
0220   
0221   delete fTG186cable;
0222   fTG186cable = nullptr;
0223   
0224   delete fTG186cableLog;
0225   fTG186cableLog = nullptr; 
0226    
0227   delete fTG186cablePhys;
0228   fTG186cablePhys = nullptr;
0229   
0230   delete fTG186simpleCableVisAtt; 
0231   fTG186simpleCableVisAtt = nullptr;
0232 
0233   G4RunManager::GetRunManager() -> GeometryHasBeenModified();
0234 }