| 1 | //
|
|---|
| 2 | // ********************************************************************
|
|---|
| 3 | // * License and Disclaimer *
|
|---|
| 4 | // * *
|
|---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of *
|
|---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and *
|
|---|
| 7 | // * conditions of the Geant4 Software License, included in the file *
|
|---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These *
|
|---|
| 9 | // * include a list of copyright holders. *
|
|---|
| 10 | // * *
|
|---|
| 11 | // * Neither the authors of this software system, nor their employing *
|
|---|
| 12 | // * institutes,nor the agencies providing financial support for this *
|
|---|
| 13 | // * work make any representation or warranty, express or implied, *
|
|---|
| 14 | // * regarding this software system or assume any liability for its *
|
|---|
| 15 | // * use. Please see the license in the file LICENSE and URL above *
|
|---|
| 16 | // * for the full disclaimer and the limitation of liability. *
|
|---|
| 17 | // * *
|
|---|
| 18 | // * This code implementation is the result of the scientific and *
|
|---|
| 19 | // * technical work of the GEANT4 collaboration. *
|
|---|
| 20 | // * By using, copying, modifying or distributing the software (or *
|
|---|
| 21 | // * any work based on the software) you agree to acknowledge its *
|
|---|
| 22 | // * use in resulting scientific publications, and indicate your *
|
|---|
| 23 | // * acceptance of all terms of the Geant4 Software license. *
|
|---|
| 24 | // ********************************************************************
|
|---|
| 25 | //
|
|---|
| 26 | ///////////////////////////////////////////////////////////////////////////////
|
|---|
| 27 | #include "RE02NestedPhantomParameterisation.hh"
|
|---|
| 28 |
|
|---|
| 29 | #include "G4VPhysicalVolume.hh"
|
|---|
| 30 | #include "G4VTouchable.hh"
|
|---|
| 31 | #include "G4ThreeVector.hh"
|
|---|
| 32 | #include "G4Box.hh"
|
|---|
| 33 | #include "G4LogicalVolume.hh"
|
|---|
| 34 | #include "G4Material.hh"
|
|---|
| 35 |
|
|---|
| 36 | //=======================================================================
|
|---|
| 37 | // (RE02NestedPhantomParameterisation)
|
|---|
| 38 | //
|
|---|
| 39 | // (Description)
|
|---|
| 40 | // Class for nested parameterisation.
|
|---|
| 41 | // This parameterisation handles material and transfomation of voxles.
|
|---|
| 42 | //
|
|---|
| 43 | // T.Aso Created. Nov.2007.
|
|---|
| 44 | //
|
|---|
| 45 | ////////////////////////////////////////////////////////////////////
|
|---|
| 46 | RE02NestedPhantomParameterisation::RE02NestedPhantomParameterisation(
|
|---|
| 47 | const G4ThreeVector& voxelSize,
|
|---|
| 48 | G4int nz,
|
|---|
| 49 | std::vector<G4Material*>& mat):
|
|---|
| 50 | G4VNestedParameterisation(),fdX(voxelSize.x()),fdY(voxelSize.y()),fdZ(voxelSize.z()),
|
|---|
| 51 | fNz(nz),fmat(mat)
|
|---|
| 52 | {
|
|---|
| 53 | // Position of voxels.
|
|---|
| 54 | // x and y positions are already defined in DetectorConstruction
|
|---|
| 55 | // by using replicated volume. Here only we need to define is z positions of voxles.
|
|---|
| 56 | fpZ.clear();
|
|---|
| 57 | G4double zp;
|
|---|
| 58 | for ( G4int iz = 0; iz < fNz; iz++){
|
|---|
| 59 | zp = (-fNz+1+2*iz)*fdZ;
|
|---|
| 60 | fpZ.push_back(zp);
|
|---|
| 61 | }
|
|---|
| 62 |
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 | RE02NestedPhantomParameterisation::~RE02NestedPhantomParameterisation(){
|
|---|
| 66 | fpZ.clear();
|
|---|
| 67 | }
|
|---|
| 68 |
|
|---|
| 69 | //
|
|---|
| 70 | // Material assignment to geometry.
|
|---|
| 71 | //
|
|---|
| 72 | G4Material* RE02NestedPhantomParameterisation::ComputeMaterial(G4VPhysicalVolume* currentVol,
|
|---|
| 73 | const G4int copyNo,
|
|---|
| 74 | const G4VTouchable* parentTouch)
|
|---|
| 75 | {
|
|---|
| 76 | if(parentTouch==0) return fmat[0]; // protection for initialization and vis at idle state
|
|---|
| 77 | // Copy number of voxels.
|
|---|
| 78 | // Copy number of X and Y are obtained from replication number.
|
|---|
| 79 | // Copy nymber of Z is the copy number of current voxel.
|
|---|
| 80 | G4int ix = parentTouch->GetReplicaNumber(0);
|
|---|
| 81 | G4int iy = parentTouch->GetReplicaNumber(1);
|
|---|
| 82 | G4int iz = copyNo;
|
|---|
| 83 | // For demonstration purpose,a couple of materials are chosen alternately.
|
|---|
| 84 | G4Material* mat=0;
|
|---|
| 85 | if ( ix%2 == 0 && iy%2 == 0 && iz%2 == 0 ) mat = fmat[0];
|
|---|
| 86 | else mat = fmat[1];
|
|---|
| 87 |
|
|---|
| 88 | return mat;
|
|---|
| 89 | }
|
|---|
| 90 |
|
|---|
| 91 | //
|
|---|
| 92 | // Number of Materials
|
|---|
| 93 | // Material scanner is required for preparing physics tables and so on before
|
|---|
| 94 | // stating simulation, so that G4 has to know number of materials.
|
|---|
| 95 | G4int RE02NestedPhantomParameterisation::GetNumberOfMaterials() const{
|
|---|
| 96 | return fmat.size();
|
|---|
| 97 | }
|
|---|
| 98 |
|
|---|
| 99 | //
|
|---|
| 100 | // GetMaterial
|
|---|
| 101 | // This is needed for material scanner and realizing geometry.
|
|---|
| 102 | //
|
|---|
| 103 | G4Material* RE02NestedPhantomParameterisation::GetMaterial(G4int i) const{
|
|---|
| 104 | return fmat[i];
|
|---|
| 105 | }
|
|---|
| 106 |
|
|---|
| 107 | //
|
|---|
| 108 | // Transformation of voxels.
|
|---|
| 109 | //
|
|---|
| 110 | void RE02NestedPhantomParameterisation::ComputeTransformation(const G4int copyNo,
|
|---|
| 111 | G4VPhysicalVolume* physVol)const{
|
|---|
| 112 | G4ThreeVector position(0.,0.,fpZ[copyNo]);
|
|---|
| 113 | physVol->SetTranslation(position);
|
|---|
| 114 | }
|
|---|
| 115 |
|
|---|
| 116 | //
|
|---|
| 117 | // Dimensions are always same in this RE02 example.
|
|---|
| 118 | //
|
|---|
| 119 | void RE02NestedPhantomParameterisation::ComputeDimensions(G4Box& box,
|
|---|
| 120 | const G4int ,
|
|---|
| 121 | const G4VPhysicalVolume* ) const{
|
|---|
| 122 | box.SetXHalfLength(fdX);
|
|---|
| 123 | box.SetYHalfLength(fdY);
|
|---|
| 124 | box.SetZHalfLength(fdZ);
|
|---|
| 125 | }
|
|---|