Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // << 26 // Authors: S. Guatelli and M. G. Pia, INFN Genova, Italy 27 // Previous authors: G. Guerrieri, S. Guatelli << 28 // Authors (since 2007): S. Guatelli, Universi << 29 // << 30 // Contribution: F. Ambroglini INFN Perugia, I << 31 // 27 // 32 << 28 // Based on code developed by the undergraduate student G. Guerrieri >> 29 // Note: this is a preliminary beta-version of the code; an improved >> 30 // version will be distributed in the next Geant4 public release, compliant >> 31 // with the design in a forthcoming publication, and subject to a >> 32 // design and code review. >> 33 // 33 #include "G4MIRDTrunk.hh" 34 #include "G4MIRDTrunk.hh" 34 #include "globals.hh" 35 #include "globals.hh" 35 #include "G4SystemOfUnits.hh" << 36 #include "G4SDManager.hh" 36 #include "G4SDManager.hh" 37 #include "G4VisAttributes.hh" 37 #include "G4VisAttributes.hh" 38 #include "G4HumanPhantomMaterial.hh" 38 #include "G4HumanPhantomMaterial.hh" 39 #include "G4EllipticalTube.hh" 39 #include "G4EllipticalTube.hh" 40 #include "G4RotationMatrix.hh" 40 #include "G4RotationMatrix.hh" 41 #include "G4ThreeVector.hh" 41 #include "G4ThreeVector.hh" 42 #include "G4VPhysicalVolume.hh" 42 #include "G4VPhysicalVolume.hh" 43 #include "G4PVPlacement.hh" 43 #include "G4PVPlacement.hh" 44 #include "G4HumanPhantomColour.hh" 44 #include "G4HumanPhantomColour.hh" 45 45 >> 46 G4MIRDTrunk::G4MIRDTrunk() >> 47 { >> 48 } >> 49 >> 50 G4MIRDTrunk::~G4MIRDTrunk() >> 51 { >> 52 >> 53 } 46 54 47 G4VPhysicalVolume* G4MIRDTrunk::Construct(cons 55 G4VPhysicalVolume* G4MIRDTrunk::Construct(const G4String& volumeName, G4VPhysicalVolume* mother, 48 const G4String& colourName, G4bool << 56 const G4String& colourName, G4bool wireFrame,G4bool sensitivity) 49 { 57 { 50 auto* material = new G4HumanPhantomMaterial( << 58 >> 59 G4HumanPhantomMaterial* material = new G4HumanPhantomMaterial(); 51 60 52 G4cout<<"Construct "<<volumeName<<" with mot << 61 G4cout << "Construct " << volumeName << G4endl; 53 62 54 auto* soft = material -> GetMaterial("soft_t << 63 G4Material* soft = material -> GetMaterial("soft_tissue"); 55 64 56 delete material; 65 delete material; 57 66 58 // MIRD Male trunk 67 // MIRD Male trunk 59 68 60 G4double dx = 20. * cm; 69 G4double dx = 20. * cm; 61 G4double dy = 10. * cm; 70 G4double dy = 10. * cm; 62 G4double dz = 35. * cm; 71 G4double dz = 35. * cm; 63 72 64 auto* trunk = new G4EllipticalTube("Trunk",d << 73 G4EllipticalTube* trunk = new G4EllipticalTube("Trunk",dx, dy, dz); 65 74 66 auto* logicTrunk = new G4LogicalVolume(trunk << 75 G4LogicalVolume* logicTrunk = new G4LogicalVolume(trunk, soft, 67 "logical" + volumeName, 76 "logical" + volumeName, 68 nullptr, nullptr, nullptr); << 77 0, 0, 0); >> 78 G4RotationMatrix* rm = new G4RotationMatrix(); >> 79 rm -> rotateX(90.* degree); >> 80 69 // Define rotation and position here! 81 // Define rotation and position here! 70 auto* rm = new G4RotationMatrix(); << 71 rm->rotateX(180.*degree); << 72 rm->rotateY(180.*degree); << 73 G4VPhysicalVolume* physTrunk = new G4PVPlace 82 G4VPhysicalVolume* physTrunk = new G4PVPlacement(rm, 74 //G4ThreeVector(0.* cm, 0. *cm, << 83 G4ThreeVector(0.* cm, 35.0 *cm, 0.*cm), 75 G4ThreeVector(0.* cm, 0. *cm, 3 << 84 "physicalTrunk", 76 "physicalTrunk", << 85 logicTrunk, 77 logicTrunk, << 86 mother, 78 mother, << 87 false, 79 false, << 88 0, true); 80 0, true); << 89 >> 90 // Sensitive Body Part >> 91 if (sensitivity == true) >> 92 { >> 93 G4SDManager* SDman = G4SDManager::GetSDMpointer(); >> 94 logicTrunk->SetSensitiveDetector( SDman->FindSensitiveDetector("BodyPartSD") ); >> 95 } >> 96 81 // Visualization Attributes 97 // Visualization Attributes 82 auto* colourPointer = new G4HumanPhantomColo << 98 G4HumanPhantomColour* colourPointer = new G4HumanPhantomColour(); 83 G4Colour colour = colourPointer -> GetColour 99 G4Colour colour = colourPointer -> GetColour(colourName); 84 auto* TrunkVisAtt = new G4VisAttributes(colo << 100 G4VisAttributes* TrunkVisAtt = new G4VisAttributes(colour); 85 TrunkVisAtt->SetForceSolid(wireFrame); 101 TrunkVisAtt->SetForceSolid(wireFrame); 86 logicTrunk->SetVisAttributes(TrunkVisAtt); 102 logicTrunk->SetVisAttributes(TrunkVisAtt); 87 103 88 G4cout << "Trunk created !!!!!!" << G4endl; 104 G4cout << "Trunk created !!!!!!" << G4endl; 89 105 90 // Testing Trunk Volume 106 // Testing Trunk Volume 91 G4double TrunkVol = logicTrunk->GetSolid()-> 107 G4double TrunkVol = logicTrunk->GetSolid()->GetCubicVolume(); 92 G4cout << "Volume of Trunk = " << TrunkVol/c 108 G4cout << "Volume of Trunk = " << TrunkVol/cm3 << " cm^3" << G4endl; 93 109 94 // Testing Trunk Material 110 // Testing Trunk Material 95 G4String TrunkMat = logicTrunk->GetMaterial( 111 G4String TrunkMat = logicTrunk->GetMaterial()->GetName(); 96 G4cout << "Material of Trunk = " << TrunkMat 112 G4cout << "Material of Trunk = " << TrunkMat << G4endl; 97 113 98 // Testing Density 114 // Testing Density 99 G4double TrunkDensity = logicTrunk->GetMater 115 G4double TrunkDensity = logicTrunk->GetMaterial()->GetDensity(); 100 G4cout << "Density of Material = " << TrunkD 116 G4cout << "Density of Material = " << TrunkDensity*cm3/g << " g/cm^3" << G4endl; 101 117 102 // Testing Mass 118 // Testing Mass 103 G4double TrunkMass = (TrunkVol)*TrunkDensity 119 G4double TrunkMass = (TrunkVol)*TrunkDensity; 104 G4cout << "Mass of Trunk = " << TrunkMass/gr 120 G4cout << "Mass of Trunk = " << TrunkMass/gram << " g" << G4endl; >> 121 105 122 106 return physTrunk; 123 return physTrunk; 107 } 124 } 108 125