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: S.Guatelli
0032 //
0033 ///    ****************************************
0034 //    *                                      *
0035 //    *    BrachyDetectorConstructionI.cc     *
0036 //    *                                      *
0037 //    ****************************************
0038 //
0039 //
0040 #include "BrachyDetectorConstructionI.hh"
0041 #include "globals.hh"
0042 #include "G4SystemOfUnits.hh"
0043 #include "G4CSGSolid.hh"
0044 #include "G4Sphere.hh"
0045 #include "G4MaterialPropertyVector.hh"
0046 #include "G4RunManager.hh"
0047 #include "G4Box.hh"
0048 #include "G4Tubs.hh"
0049 #include "G4LogicalVolume.hh"
0050 #include "G4ThreeVector.hh"
0051 #include "G4PVPlacement.hh"
0052 #include "G4Transform3D.hh"
0053 #include "G4RotationMatrix.hh"
0054 #include "G4TransportationManager.hh"
0055 #include "G4VisAttributes.hh"
0056 #include "G4Colour.hh"
0057 #include "G4NistManager.hh"
0058 
0059 BrachyDetectorConstructionI::BrachyDetectorConstructionI():
0060 fDefaultTub(nullptr), fCapsule(nullptr), fCapsuleTip(nullptr), fIodineCore(nullptr), fDefaultTubLog(nullptr),
0061 fCapsuleLog(nullptr), fCapsuleTipLog(nullptr), fIodineCoreLog(nullptr), fDefaultTubPhys(nullptr), 
0062 fCapsulePhys(nullptr),fCapsuleTipPhys1(nullptr),fCapsuleTipPhys2(nullptr), fIodineCorePhys(nullptr),
0063 fSimpleIodineVisAtt(nullptr), fSimpleCapsuleVisAtt(nullptr), fSimpleCapsuleTipVisAtt(nullptr)
0064 {}
0065 
0066 void BrachyDetectorConstructionI::ConstructIodine(G4VPhysicalVolume* mother)
0067 {
0068   // Model of the Bebig Isoseed I-125 brachy source
0069   G4NistManager* nist = G4NistManager::Instance();
0070   G4Material* titanium = nist -> FindOrBuildMaterial("G4_Ti");
0071   G4Material* iodine = nist -> FindOrBuildMaterial("G4_I");
0072   G4Material* air = nist -> FindOrBuildMaterial("G4_AIR");
0073   
0074   G4Colour  red     (1.0, 0.0, 0.0) ;
0075   G4Colour  magenta (1.0, 0.0, 1.0) ; 
0076   G4Colour  lblue   (0.0, 0.0, .75);
0077 
0078   // Air tub
0079   fDefaultTub = new G4Tubs("DefaultTub",0.*mm, 0.40*mm, 1.84*mm, 0.*deg, 360.*deg);
0080   fDefaultTubLog = new G4LogicalVolume(fDefaultTub,air,"DefaultTub_Log");
0081   fDefaultTubPhys = new G4PVPlacement(nullptr,
0082                                       G4ThreeVector(),
0083                                       "defaultTub_Phys",
0084                                       fDefaultTubLog,
0085                                       mother,
0086                                       false,
0087                                       0, true); 
0088   // Capsule main body ...
0089   fCapsule = new G4Tubs("fCapsule", 0.35*mm,0.40*mm,1.84*mm,0.*deg,360.*deg);
0090   fCapsuleLog = new G4LogicalVolume(fCapsule,titanium,"fCapsuleLog");
0091   fCapsulePhys = new G4PVPlacement(nullptr,
0092                                   G4ThreeVector(),
0093                                   "fCapsulePhys",
0094                                   fCapsuleLog,
0095                                   fDefaultTubPhys,
0096                                   false,
0097                                   0, true);
0098   // fCapsule tips
0099   fCapsuleTip = new G4Sphere("fCapsuleTip",
0100                             0.*mm,
0101                             0.40*mm,
0102                             0.*deg,
0103                             360.*deg,
0104                             0.*deg,
0105                             90.*deg);
0106                             
0107   fCapsuleTipLog = new G4LogicalVolume(fCapsuleTip,titanium,"fCapsuleTipLog");
0108   fCapsuleTipPhys1 = new G4PVPlacement(nullptr,
0109                                       G4ThreeVector(0.,0.,1.84*mm),
0110                                       "IodinefCapsuleTipPhys1",
0111                                       fCapsuleTipLog,
0112                                       mother,
0113                                       false,
0114                                       0, true);
0115 
0116   auto rotateMatrix = new G4RotationMatrix();
0117   rotateMatrix -> rotateX(180.0*deg);
0118   fCapsuleTipPhys2 = new G4PVPlacement(rotateMatrix, 
0119                                       G4ThreeVector(0,0,-1.84*mm),
0120                                       "IodinefCapsuleTipPhys2",
0121                                       fCapsuleTipLog,
0122                                       mother,
0123                                       false,
0124                                       0, true);
0125  
0126   // Radiactive core ...
0127   fIodineCore = new G4Tubs("ICore",0.085*mm,0.35*mm,1.75*mm,0.*deg,360.*deg);
0128   fIodineCoreLog = new G4LogicalVolume(fIodineCore,iodine,"IodineCoreLog");
0129   fIodineCorePhys = new G4PVPlacement(nullptr,
0130                                      G4ThreeVector(0.,0.,0.),
0131                                      "IodineCorePhys",
0132                                      fIodineCoreLog,
0133                                      fDefaultTubPhys,
0134                                      false,
0135                                      0, true);
0136  
0137   // Visual attributes ...
0138   
0139   fSimpleIodineVisAtt = new G4VisAttributes(magenta);
0140   fSimpleIodineVisAtt -> SetVisibility(true);
0141   fSimpleIodineVisAtt -> SetForceSolid(true);
0142   fIodineCoreLog -> SetVisAttributes(fSimpleIodineVisAtt);
0143 
0144   fSimpleCapsuleVisAtt = new G4VisAttributes(red);
0145   fSimpleCapsuleVisAtt -> SetVisibility(true);  
0146   fSimpleCapsuleVisAtt -> SetForceWireframe(true);
0147   fCapsuleLog -> SetVisAttributes( fSimpleCapsuleVisAtt);
0148 
0149   fSimpleCapsuleTipVisAtt = new G4VisAttributes(red);
0150   fSimpleCapsuleTipVisAtt -> SetVisibility(true); 
0151   fSimpleCapsuleTipVisAtt -> SetForceSolid(true);
0152   fCapsuleTipLog -> SetVisAttributes(fSimpleCapsuleTipVisAtt);
0153 }
0154 
0155 void BrachyDetectorConstructionI::CleanIodine()
0156 {
0157 delete fSimpleIodineVisAtt; fSimpleIodineVisAtt = nullptr;
0158 delete fSimpleCapsuleVisAtt; fSimpleCapsuleVisAtt = nullptr;
0159 delete fSimpleCapsuleTipVisAtt; fSimpleCapsuleTipVisAtt = nullptr;
0160 delete fCapsuleTipPhys1; fCapsuleTipPhys1 = nullptr; 
0161 delete fCapsuleTipPhys2; fCapsuleTipPhys2 = nullptr;
0162 delete fIodineCorePhys; fIodineCorePhys = nullptr;
0163 delete fCapsulePhys; fCapsulePhys = nullptr;
0164 delete fDefaultTubPhys; fDefaultTubPhys = nullptr; 
0165 delete fDefaultTubLog; fDefaultTubLog = nullptr;
0166 delete fCapsuleLog; fCapsuleLog = nullptr;
0167 delete fCapsuleTipLog; fCapsuleTipLog = nullptr;
0168 delete fIodineCoreLog; fIodineCoreLog = nullptr;
0169 delete fDefaultTub; fDefaultTub = nullptr;
0170 delete fCapsule; fCapsule = nullptr;
0171 delete fCapsuleTip; fCapsuleTip = nullptr;
0172 delete fIodineCore; fIodineCore = nullptr;
0173 
0174 G4RunManager::GetRunManager() -> GeometryHasBeenModified();
0175 }