Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 09:22:03

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 //
0027 /// \file VoxelParameterisation.cc
0028 /// \brief Implementation of the VoxelParameterisation class
0029 
0030 #include "VoxelParameterisation.hh"
0031 
0032 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0033 
0034 VoxelParameterisation::VoxelParameterisation(std::map<G4String, 
0035                         G4LogicalVolume*>& voxelMap, std::vector<Voxel>* voxels)
0036     : G4VPVParameterisation(),
0037     fVoxelMap(voxelMap),
0038     fVoxels(voxels)
0039 {
0040 }
0041 
0042 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0043 
0044 VoxelParameterisation::~VoxelParameterisation()
0045 {
0046     if(fVoxels!=0)
0047         delete fVoxels;
0048 }
0049 
0050 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0051 
0052 void VoxelParameterisation::ComputeTransformation(const G4int copyNo, G4VPhysicalVolume* physVol) const
0053 {
0054     // Retrive the correct voxel data for the cpN
0055     Voxel& voxelData = fVoxels->at(copyNo);
0056 
0057     // Set the current physical volume parameters
0058     physVol->SetTranslation(voxelData.fPos);
0059     physVol->SetRotation(voxelData.fpRot);
0060     physVol->SetName(VoxelName(voxelData.fType) );
0061     physVol->SetLogicalVolume(LogicalVoxel(voxelData.fType) );
0062 }
0063 
0064 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0065 
0066 G4LogicalVolume* VoxelParameterisation::LogicalVoxel(Voxel::VoxelType type) const
0067 {
0068     G4LogicalVolume* voxel = 0;
0069 
0070     if(type==Voxel::Straight)
0071         voxel = fVoxelMap.at("VoxelStraight");
0072     else if(type==Voxel::Right)
0073         voxel =fVoxelMap.at("VoxelRight");
0074     else if(type==Voxel::Left)
0075         voxel =fVoxelMap.at("VoxelLeft");
0076     else if(type==Voxel::Up)
0077         voxel =fVoxelMap.at("VoxelUp");
0078     else if(type==Voxel::Down)
0079         voxel =fVoxelMap.at("VoxelDown");
0080     else if(type==Voxel::Straight2)
0081         voxel = fVoxelMap.at("VoxelStraight2");
0082     else if(type==Voxel::Right2)
0083         voxel =fVoxelMap.at("VoxelRight2");
0084     else if(type==Voxel::Left2)
0085         voxel =fVoxelMap.at("VoxelLeft2");
0086     else if(type==Voxel::Up2)
0087         voxel =fVoxelMap.at("VoxelUp2");
0088     else if(type==Voxel::Down2)
0089         voxel =fVoxelMap.at("VoxelDown2");
0090     else
0091     {
0092         G4ExceptionDescription msg;
0093         msg << "Voxel type "<<type<<" is not registered";
0094         G4Exception("VoxelParameterisation::GetLogicalVoxel", "", FatalException, msg);
0095     }
0096 
0097     if(voxel==0)
0098     {
0099         G4ExceptionDescription msg;
0100         msg << "Voxel is a nullptr";
0101         G4Exception("VoxelParameterisation::GetLogicalVoxel", "", FatalException, msg);
0102     }
0103 
0104     return voxel;
0105 }
0106 
0107 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0108 
0109 G4String VoxelParameterisation::VoxelName(Voxel::VoxelType type) const
0110 {
0111     G4String name ("");
0112 
0113     if(type==Voxel::Straight)
0114         name = "VoxelStraight";
0115     else if(type==Voxel::Right)
0116         name = "VoxelRight";
0117     else if(type==Voxel::Left)
0118         name = "VoxelLeft";
0119     else if(type==Voxel::Up)
0120         name = "VoxelUp";
0121     else if(type==Voxel::Down)
0122         name = "VoxelDown";
0123     else if(type==Voxel::Straight2)
0124         name = "VoxelStraight2";
0125     else if(type==Voxel::Right2)
0126         name = "VoxelRight2";
0127     else if(type==Voxel::Left2)
0128         name = "VoxelLeft2";
0129     else if(type==Voxel::Up2)
0130         name = "VoxelUp2";
0131     else if(type==Voxel::Down2)
0132         name = "VoxelDown2";
0133     else
0134     {
0135         G4ExceptionDescription msg;
0136         msg << "Voxel type "<<type<<" is not registered";
0137         G4Exception("VoxelParameterisation::GetLogicalVoxel", "", FatalException, msg);
0138     }
0139 
0140     return name;
0141 }
0142 
0143 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0144 
0145