Geant4 Cross Reference |
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 /// \file VoxelParameterisation.cc 28 /// \brief Implementation of the VoxelParameterisation class 29 30 #include "VoxelParameterisation.hh" 31 32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 33 34 VoxelParameterisation::VoxelParameterisation(std::map<G4String, 35 G4LogicalVolume*>& voxelMap, std::vector<Voxel>* voxels) 36 : G4VPVParameterisation(), 37 fVoxelMap(voxelMap), 38 fVoxels(voxels) 39 { 40 } 41 42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 43 44 VoxelParameterisation::~VoxelParameterisation() 45 { 46 if(fVoxels!=0) 47 delete fVoxels; 48 } 49 50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 51 52 void VoxelParameterisation::ComputeTransformation(const G4int copyNo, G4VPhysicalVolume* physVol) const 53 { 54 // Retrive the correct voxel data for the cpN 55 Voxel& voxelData = fVoxels->at(copyNo); 56 57 // Set the current physical volume parameters 58 physVol->SetTranslation(voxelData.fPos); 59 physVol->SetRotation(voxelData.fpRot); 60 physVol->SetName(VoxelName(voxelData.fType) ); 61 physVol->SetLogicalVolume(LogicalVoxel(voxelData.fType) ); 62 } 63 64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 65 66 G4LogicalVolume* VoxelParameterisation::LogicalVoxel(Voxel::VoxelType type) const 67 { 68 G4LogicalVolume* voxel = 0; 69 70 if(type==Voxel::Straight) 71 voxel = fVoxelMap.at("VoxelStraight"); 72 else if(type==Voxel::Right) 73 voxel =fVoxelMap.at("VoxelRight"); 74 else if(type==Voxel::Left) 75 voxel =fVoxelMap.at("VoxelLeft"); 76 else if(type==Voxel::Up) 77 voxel =fVoxelMap.at("VoxelUp"); 78 else if(type==Voxel::Down) 79 voxel =fVoxelMap.at("VoxelDown"); 80 else if(type==Voxel::Straight2) 81 voxel = fVoxelMap.at("VoxelStraight2"); 82 else if(type==Voxel::Right2) 83 voxel =fVoxelMap.at("VoxelRight2"); 84 else if(type==Voxel::Left2) 85 voxel =fVoxelMap.at("VoxelLeft2"); 86 else if(type==Voxel::Up2) 87 voxel =fVoxelMap.at("VoxelUp2"); 88 else if(type==Voxel::Down2) 89 voxel =fVoxelMap.at("VoxelDown2"); 90 else 91 { 92 G4ExceptionDescription msg; 93 msg << "Voxel type "<<type<<" is not registered"; 94 G4Exception("VoxelParameterisation::GetLogicalVoxel", "", FatalException, msg); 95 } 96 97 if(voxel==0) 98 { 99 G4ExceptionDescription msg; 100 msg << "Voxel is a nullptr"; 101 G4Exception("VoxelParameterisation::GetLogicalVoxel", "", FatalException, msg); 102 } 103 104 return voxel; 105 } 106 107 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 108 109 G4String VoxelParameterisation::VoxelName(Voxel::VoxelType type) const 110 { 111 G4String name (""); 112 113 if(type==Voxel::Straight) 114 name = "VoxelStraight"; 115 else if(type==Voxel::Right) 116 name = "VoxelRight"; 117 else if(type==Voxel::Left) 118 name = "VoxelLeft"; 119 else if(type==Voxel::Up) 120 name = "VoxelUp"; 121 else if(type==Voxel::Down) 122 name = "VoxelDown"; 123 else if(type==Voxel::Straight2) 124 name = "VoxelStraight2"; 125 else if(type==Voxel::Right2) 126 name = "VoxelRight2"; 127 else if(type==Voxel::Left2) 128 name = "VoxelLeft2"; 129 else if(type==Voxel::Up2) 130 name = "VoxelUp2"; 131 else if(type==Voxel::Down2) 132 name = "VoxelDown2"; 133 else 134 { 135 G4ExceptionDescription msg; 136 msg << "Voxel type "<<type<<" is not registered"; 137 G4Exception("VoxelParameterisation::GetLogicalVoxel", "", FatalException, msg); 138 } 139 140 return name; 141 } 142 143 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 144 145 146