Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:20:11

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 // Previous authors: G. Guerrieri, S. Guatelli and M. G. Pia, INFN Genova, Italy
0028 // Authors (since 2007): S. Guatelli, University of Wollongong, Australia
0029 // 
0030 //
0031 #include "G4MIRDRibCage.hh"
0032 
0033 #include "globals.hh"
0034 #include "G4SystemOfUnits.hh"
0035 #include "G4SDManager.hh"
0036 #include "G4VisAttributes.hh"
0037 #include "G4HumanPhantomMaterial.hh"
0038 #include "G4SubtractionSolid.hh"
0039 #include "G4EllipticalTube.hh"
0040 #include "G4PVReplica.hh"
0041 #include "G4Box.hh"
0042 #include "G4PVPlacement.hh"
0043 #include "G4HumanPhantomColour.hh"
0044 G4MIRDRibCage::G4MIRDRibCage():fPhysRib1(nullptr), fPhysRib2(nullptr), fPhysRib3(nullptr),
0045                         fPhysRib4(nullptr), fPhysRib5(nullptr), fPhysRib6(nullptr),
0046                         fPhysRib7(nullptr), fPhysRib8(nullptr), fPhysRib9(nullptr),
0047                         fPhysRib10(nullptr), fPhysRib11(nullptr), fPhysRib12(nullptr)
0048 {;}
0049 
0050 G4VPhysicalVolume* G4MIRDRibCage::Construct(const G4String& volumeName, G4VPhysicalVolume* mother,
0051                         const G4String& colourName, G4bool wireFrame, G4bool)
0052                         
0053 {
0054   auto* material = new G4HumanPhantomMaterial();
0055    
0056   G4cout<<"Construct "<<volumeName<<" with mother volume "<<mother->GetName()<<G4endl;
0057    
0058   auto* skeleton = material -> GetMaterial("skeleton");
0059   auto* soft = material -> GetMaterial("soft_tissue");
0060  
0061   delete material; 
0062 
0063   G4double dx= 17. *cm; // a2
0064   G4double dy= 9.8 * cm; //b2
0065   G4double thickness= 32.4 * cm; // z2/2 of cage
0066 
0067   auto* outCage = new G4EllipticalTube("outCage",dx, dy, thickness/2.);
0068 
0069   dx = 16.4 * cm; // a1
0070   dy = 9.2 * cm; // b1
0071   G4double dz = 34. *cm; // z2/2
0072 
0073   auto* inCage = new G4EllipticalTube("inCage",dx, dy, dz/2.);
0074 
0075   auto* cage = new G4SubtractionSolid("Cage",
0076                             outCage,
0077                             inCage, nullptr, G4ThreeVector(0.*cm, 0.*cm, 0. * cm)); 
0078 
0079  
0080   auto* logicRibCage = new G4LogicalVolume(cage, soft, "logicalCage", nullptr, nullptr, nullptr);
0081 
0082   G4VPhysicalVolume* physRibCage = new G4PVPlacement(nullptr,G4ThreeVector(0.0, 0.0, thickness/2. + 0.1 * cm),
0083                              // with respect to the trunk
0084                              "physicalRibCage",
0085                              logicRibCage,
0086                              mother,
0087                              false,
0088                              0, true);
0089     
0090   G4double xx = 17.*cm;
0091   G4double yy = 9.8*cm;
0092   G4double ribThickness = 1.4*cm;
0093   auto* rib_out = new G4EllipticalTube("rib_out",xx, yy, ribThickness/2.);  
0094   
0095   xx = 16.5 *cm;
0096   yy = 9.3 * cm;
0097   G4double zz = 1.5 * cm;  
0098   auto* rib_in = new G4EllipticalTube("rib_in",xx, yy, zz/2.);
0099   auto* rib = new G4SubtractionSolid("rib",rib_out, rib_in);
0100 
0101   auto* logicRib= new G4LogicalVolume(rib, skeleton, "logical" + volumeName, nullptr, nullptr, nullptr);
0102 
0103   fPhysRib1 = new G4PVPlacement(nullptr,G4ThreeVector(0.0, 0.0, (- 32.2*cm/2. + 0.8 *cm)),
0104                    // with respect to the trunk
0105                    "physicalRib",
0106                    logicRib,
0107                    physRibCage,
0108                    false,
0109                    0, true);
0110 
0111   fPhysRib2 = new G4PVPlacement(nullptr,G4ThreeVector(0.0, 0.0, ( - 32.2*cm/2. + 0.8 *cm + 2.8 *cm)),
0112                    // with respect to the trunk
0113                    "physicalRib",
0114                    logicRib,
0115                    physRibCage,
0116                    false,
0117                    0, true);
0118 
0119   fPhysRib3 = new G4PVPlacement(nullptr,G4ThreeVector(0.0, 0.0, (-thickness/2. + 0.8 * cm + 5.6 *cm)),
0120                    // with respect to the trunk
0121                    "physicalRib",
0122                    logicRib,
0123                    physRibCage,
0124                    false,
0125                    0, true);
0126 
0127   fPhysRib4 = new G4PVPlacement(nullptr,G4ThreeVector(0.0, 0.0, (-thickness/2. + 0.8 * cm + 8.4 *cm)),
0128                    // with respect to the trunk
0129                    "physicalRib",
0130                    logicRib,
0131                    physRibCage,
0132                    false,
0133                    0, true);
0134 
0135   fPhysRib5 = new G4PVPlacement(nullptr,G4ThreeVector(0.0, 0.0, (-thickness/2. + 0.8 * cm + 11.2 *cm)),
0136                    // with respect to the trunk
0137                    "physicalRib",
0138                    logicRib,
0139                    physRibCage,
0140                    false,
0141                    0, true);
0142 
0143   fPhysRib6 = new G4PVPlacement(nullptr,G4ThreeVector(0.0, 0.0, (-thickness/2. +  0.8 * cm + 14. *cm)),
0144                    // with respect to the trunk
0145                    "physicalRib",
0146                    logicRib,
0147                    physRibCage,
0148                    false,
0149                    0, true);
0150 
0151   fPhysRib7 = new G4PVPlacement(nullptr,G4ThreeVector(0.0, 0.0, (-thickness/2. + 0.8 *cm + 16.8 *cm)),
0152                    // with respect to the trunk
0153                    "physicalRib",
0154                    logicRib,
0155                    physRibCage,
0156                    false,
0157                    0, true);
0158 
0159   fPhysRib8 = new G4PVPlacement(nullptr,G4ThreeVector(0.0, 0.0, (-thickness/2. + 0.8 *cm + 19.6 *cm)),
0160                    // with respect to the trunk
0161                    "physicalRib",
0162                    logicRib,
0163                    physRibCage,
0164                    false,
0165                    0, true);
0166 
0167   fPhysRib9 = new G4PVPlacement(nullptr,G4ThreeVector(0.0, 0.0, (-thickness/2. + 0.8*cm + 22.4 *cm)),
0168                    // with respect to the trunk
0169                    "physicalRib",
0170                    logicRib,
0171                    physRibCage,
0172                    false,
0173                    0, true);
0174 
0175   fPhysRib10 = new G4PVPlacement(nullptr, G4ThreeVector(0.0, 0.0, (-thickness/2. + 0.8*cm + 25.2 *cm)),
0176                 // with respect to the trunk
0177                 "physicalRib",
0178                 logicRib,
0179                 physRibCage,
0180                 false,
0181                 0, true);
0182 
0183   fPhysRib11 = new G4PVPlacement(nullptr,G4ThreeVector(0.0, 0.0, (-thickness/2. + 0.8*cm + 28. *cm)),
0184                 // with respect to the trunk
0185                 "physicalRib",
0186                 logicRib,
0187                 physRibCage,
0188                 false,
0189                 0, true);
0190 
0191   fPhysRib12 = new G4PVPlacement(nullptr,G4ThreeVector(0.0, 0.0, (-thickness/2. + 0.8*cm + 30.8 *cm)),
0192                 // with respect to the trunk
0193                 "physicalRib",
0194                 logicRib,
0195                 physRibCage,
0196                 false,
0197                 0, true);
0198   
0199   // Visualization Attributes
0200   logicRibCage -> SetVisAttributes(G4VisAttributes::GetInvisible());
0201 
0202   //G4VisAttributes* RibCageVisAtt = new G4VisAttributes(G4Colour(0.46,0.53,0.6));
0203 
0204   auto* colourPointer = new G4HumanPhantomColour();
0205   G4Colour colour = colourPointer -> GetColour(colourName);
0206   auto* RibCageVisAtt = new G4VisAttributes(colour); 
0207   RibCageVisAtt->SetForceSolid(wireFrame);
0208   logicRib->SetVisAttributes(RibCageVisAtt);
0209 
0210   G4cout << "RibCage created !!!!!!" << G4endl;
0211   // Testing Pelvis Volume
0212   G4double RibCageVol = logicRib->GetSolid()->GetCubicVolume();
0213   G4cout << "Volume of RibCage = " << ((RibCageVol)*12.)/cm3 << " cm^3" << G4endl;
0214   
0215   // Testing RibCage Material
0216   G4String RibCageMat = logicRib->GetMaterial()->GetName();
0217   G4cout << "Material of RibCage = " << RibCageMat << G4endl;
0218   
0219   // Testing Density
0220   G4double RibCageDensity = logicRib->GetMaterial()->GetDensity();
0221   G4cout << "Density of Material = " << RibCageDensity*cm3/g << " g/cm^3" << G4endl;
0222 
0223   // Testing Mass
0224   G4double RibCageMass = (RibCageVol)* RibCageDensity * 12;// 12 is the total number of ribs;
0225   G4cout << "Mass of RibCage = " << (RibCageMass)/gram << " g" << G4endl;
0226 
0227   return physRibCage;
0228 }