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 // Previous authors: G. Guerrieri, S. Guatelli and M. G. Pia, INFN Genova, Italy
0027 // Authors (since 2007): S. Guatelli, University of Wollongong, Australia
0028 // 
0029 //
0030 #include "G4MIRDLiver.hh"
0031 #include "globals.hh"
0032 #include "G4SystemOfUnits.hh"
0033 #include "G4SDManager.hh"
0034 #include "G4VisAttributes.hh"
0035 #include "G4HumanPhantomMaterial.hh"
0036 #include "G4SDManager.hh"
0037 #include "G4PVPlacement.hh"
0038 #include "G4SubtractionSolid.hh"
0039 #include "G4Ellipsoid.hh"
0040 #include "G4ThreeVector.hh"
0041 #include "G4VPhysicalVolume.hh"
0042 #include "G4RotationMatrix.hh"
0043 #include "G4Material.hh"
0044 #include "G4EllipticalTube.hh"
0045 #include "G4Box.hh"
0046 #include "G4HumanPhantomColour.hh"
0047 #include <cmath>
0048 
0049 G4VPhysicalVolume* G4MIRDLiver::Construct(const G4String& volumeName,G4VPhysicalVolume* mother,
0050                       const G4String& colourName, G4bool wireFrame, G4bool)
0051 {
0052 
0053   G4cout << "Construct " << volumeName <<" with mother "<<mother->GetName()<<G4endl;
0054   auto* material = new G4HumanPhantomMaterial();
0055   auto* soft = material -> GetMaterial("soft_tissue");
0056   delete material;
0057 
0058   G4double dx= 14.19 *cm; //a
0059   G4double dy= 7.84 *cm;  //b
0060   G4double dz= 7.21* cm; //(z2-z1)/2
0061 
0062   auto* firstLiver = new G4EllipticalTube("FirstLiver",dx, dy, dz);
0063 
0064   G4double xx = 20.00 * cm;
0065   G4double yy = 50.00 * cm;
0066   G4double zz = 50.00 *cm;
0067 
0068   auto* subtrLiver = new G4Box("SubtrLiver", xx/2., yy/2., zz/2.);
0069 
0070   auto* rm_relative = new G4RotationMatrix();
0071   rm_relative -> rotateY(32.* degree);
0072   rm_relative -> rotateZ(40.9* degree);
0073 
0074   //  G4double aa = (1.00/31.51);
0075   //  G4double bb = (1.00/44.75);
0076   //  G4double cc = (-1.00/38.76);
0077   //  G4cout<< aa << " "<< bb << " "<<cc<< G4endl;
0078  
0079   //  G4double dd = sqrt(aa*aa + bb*bb + cc*cc);
0080   //  G4cout<< "dd" << dd << G4endl;
0081   //  G4cout << aa/dd << "" << bb/dd << " "<< cc/dd <<G4endl;
0082   //  G4cout << (std::atan(1.42))/deg << G4endl;
0083 
0084   auto* liver = new G4SubtractionSolid("Liver",
0085                              firstLiver,subtrLiver,
0086                              rm_relative,
0087                              G4ThreeVector(10.0*cm,0.0*cm,0.0 *cm));
0088 
0089   auto* logicLiver = new G4LogicalVolume(liver,
0090                             soft,
0091                             "LiverVolume",
0092                             nullptr, nullptr, nullptr);
0093 
0094   // Define rotation and position here!
0095   auto* rm = new G4RotationMatrix();
0096   rm->rotateX(180.*degree);
0097   G4VPhysicalVolume* physLiver = new G4PVPlacement(rm,G4ThreeVector(0. *cm,0. *cm,0.*cm),
0098                            "physicalLiver",
0099                            logicLiver,
0100                            mother,
0101                            false,
0102                            0,true);
0103 
0104   // Visualization Attributes
0105   auto* colourPointer = new G4HumanPhantomColour();
0106   G4Colour colour = colourPointer -> GetColour(colourName);
0107   auto* LiverVisAtt = new G4VisAttributes(colour);
0108   LiverVisAtt->SetForceSolid(wireFrame);
0109   logicLiver->SetVisAttributes(LiverVisAtt);
0110 
0111   G4cout << "Liver created !!!!!!" << G4endl;
0112 
0113   // Testing Liver Volume
0114   G4double LiverVol = logicLiver->GetSolid()->GetCubicVolume();
0115   G4cout << "Volume of Liver = " << LiverVol/cm3 << " cm^3" << G4endl;
0116 
0117   // Testing Liver Material
0118   G4String LiverMat = logicLiver->GetMaterial()->GetName();
0119   G4cout << "Material of Liver = " << LiverMat << G4endl;
0120 
0121   // Testing Density
0122   G4double LiverDensity = logicLiver->GetMaterial()->GetDensity();
0123   G4cout << "Density of Material = " << LiverDensity*cm3/g << " g/cm^3" << G4endl;
0124 
0125   // Testing Mass
0126   G4double LiverMass = (LiverVol)*LiverDensity;
0127   G4cout << "Mass of Liver = " << LiverMass/gram << " g" << G4endl;
0128 
0129   return physLiver;
0130 }