Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-15 08:29:51

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 /// \file RE02NestedPhantomParameterisation.cc
0027 /// \brief Implementation of the RE02NestedPhantomParameterisation class
0028 
0029 #include "RE02NestedPhantomParameterisation.hh"
0030 
0031 #include "G4Box.hh"
0032 #include "G4LogicalVolume.hh"
0033 #include "G4Material.hh"
0034 #include "G4ThreeVector.hh"
0035 #include "G4VPhysicalVolume.hh"
0036 #include "G4VTouchable.hh"
0037 
0038 //=======================================================================
0039 // (RE02NestedPhantomParameterisation)
0040 //
0041 //  (Description)
0042 //     Class for nested parameterisation.
0043 //     This parameterisation handles material and transfomation of voxles.
0044 //
0045 //  T.Aso Created. Nov.2007.
0046 //
0047 ////////////////////////////////////////////////////////////////////
0048 
0049 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0050 RE02NestedPhantomParameterisation ::RE02NestedPhantomParameterisation(
0051   const G4ThreeVector& voxelSize, G4int nz, std::vector<G4Material*>& mat)
0052   : G4VNestedParameterisation(),
0053     fdX(voxelSize.x()),
0054     fdY(voxelSize.y()),
0055     fdZ(voxelSize.z()),
0056     fNz(nz),
0057     fMat(mat)
0058 {
0059   // Position of voxels.
0060   // x and y positions are already defined in DetectorConstruction
0061   // by using replicated volume. Here only we need to define is z positions
0062   // of voxles.
0063   fpZ.clear();
0064   G4double zp;
0065   for (G4int iz = 0; iz < fNz; iz++) {
0066     zp = (-fNz + 1 + 2 * iz) * fdZ;
0067     fpZ.push_back(zp);
0068   }
0069 }
0070 
0071 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0072 RE02NestedPhantomParameterisation::~RE02NestedPhantomParameterisation()
0073 {
0074   fpZ.clear();
0075 }
0076 
0077 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0078 //
0079 // Material assignment to geometry.
0080 //
0081 G4Material* RE02NestedPhantomParameterisation ::ComputeMaterial(G4VPhysicalVolume* /*currentVol*/,
0082                                                                 const G4int copyNo,
0083                                                                 const G4VTouchable* parentTouch)
0084 {
0085   if (parentTouch == 0)
0086     return fMat[0];  // protection for initialization and
0087                      // vis at idle state
0088   // Copy number of voxels.
0089   // Copy number of X and Y are obtained from replication number.
0090   // Copy nymber of Z is the copy number of current voxel.
0091   G4int ix = parentTouch->GetReplicaNumber(0);
0092   G4int iy = parentTouch->GetReplicaNumber(1);
0093   G4int iz = copyNo;
0094   // For demonstration purpose,a couple of materials are chosen alternately.
0095   G4Material* mat = 0;
0096   if (ix % 2 == 0 && iy % 2 == 0 && iz % 2 == 0)
0097     mat = fMat[0];
0098   else
0099     mat = fMat[1];
0100 
0101   return mat;
0102 }
0103 
0104 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0105 //
0106 //  Number of Materials
0107 //  Material scanner is required for preparing physics tables and so on before
0108 //  stating simulation, so that G4 has to know number of materials.
0109 G4int RE02NestedPhantomParameterisation::GetNumberOfMaterials() const
0110 {
0111   return fMat.size();
0112 }
0113 
0114 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0115 //
0116 // GetMaterial
0117 //  This is needed for material scanner and realizing geometry.
0118 //
0119 G4Material* RE02NestedPhantomParameterisation::GetMaterial(G4int i) const
0120 {
0121   return fMat[i];
0122 }
0123 
0124 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0125 //
0126 // Transformation of voxels.
0127 //
0128 void RE02NestedPhantomParameterisation ::ComputeTransformation(const G4int copyNo,
0129                                                                G4VPhysicalVolume* physVol) const
0130 {
0131   G4ThreeVector position(0., 0., fpZ[copyNo]);
0132   physVol->SetTranslation(position);
0133 }
0134 
0135 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0136 //
0137 // Dimensions are always same in this RE02 example.
0138 //
0139 void RE02NestedPhantomParameterisation ::ComputeDimensions(G4Box& box, const G4int,
0140                                                            const G4VPhysicalVolume*) const
0141 {
0142   box.SetXHalfLength(fdX);
0143   box.SetYHalfLength(fdY);
0144   box.SetZHalfLength(fdZ);
0145 }