Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-20 08:30:54

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 VoxelizedSensitiveDetectorMessenger.cc
0027 /// \brief Implementation of the RadioBio::VoxelizedSensitiveDetectorMessenger class
0028 
0029 #include "VoxelizedSensitiveDetectorMessenger.hh"
0030 
0031 #include "G4UIcmdWith3VectorAndUnit.hh"
0032 #include "G4UIcmdWithADoubleAndUnit.hh"
0033 #include "G4UIcmdWithoutParameter.hh"
0034 #include "G4UIcommand.hh"
0035 #include "G4UIdirectory.hh"
0036 #include "G4UIparameter.hh"
0037 
0038 #include "VoxelizedSensitiveDetector.hh"
0039 
0040 namespace RadioBio
0041 {
0042 
0043 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0044 
0045 VoxelizedSensitiveDetectorMessenger::VoxelizedSensitiveDetectorMessenger(
0046   VoxelizedSensitiveDetector* VoxDet)
0047   : G4UImessenger(), fVoxelizedDetector(VoxDet)
0048 {
0049   // Diretory for voxelization commands
0050   fVoxelsDir = new G4UIdirectory("/voxels/");
0051   fVoxelsDir->SetGuidance("commands to change voxels size");
0052 
0053   // Set voxel size with a ThreeVector
0054   fVoxelSizeCmd = new G4UIcmdWith3VectorAndUnit("/voxels/setVoxelSizes", this);
0055   fVoxelSizeCmd->SetGuidance("Insert voxel sizes X Y and Z");
0056   fVoxelSizeCmd->SetParameterName("SizeAlongX", "SizeAlongY", "SizeAlongZ", false);
0057   fVoxelSizeCmd->SetRange("SizeAlongX>0. && SizeAlongY>0. && SizeAlongZ>0.");
0058   fVoxelSizeCmd->SetUnitCategory("Length");
0059   fVoxelSizeCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0060   fVoxelSizeCmd->SetToBeBroadcasted(false);
0061 
0062   // Set X voxel size
0063   fVoxelSizeXCmd = new G4UIcmdWithADoubleAndUnit("/voxels/setSizeX", this);
0064   fVoxelSizeXCmd->SetGuidance("Set X width of voxels");
0065   fVoxelSizeXCmd->SetParameterName("Size", false);
0066   fVoxelSizeXCmd->SetRange("Size>0.");
0067   fVoxelSizeXCmd->SetUnitCategory("Length");
0068   fVoxelSizeXCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0069   fVoxelSizeXCmd->SetToBeBroadcasted(false);
0070 
0071   // Set Y voxel size
0072   fVoxelSizeYCmd = new G4UIcmdWithADoubleAndUnit("/voxels/setSizeY", this);
0073   fVoxelSizeYCmd->SetGuidance("Set Y width of voxels");
0074   fVoxelSizeYCmd->SetParameterName("Size", false);
0075   fVoxelSizeYCmd->SetRange("Size>0.");
0076   fVoxelSizeYCmd->SetUnitCategory("Length");
0077   fVoxelSizeYCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0078   fVoxelSizeYCmd->SetToBeBroadcasted(false);
0079 
0080   // Set Z voxel size
0081   fVoxelSizeZCmd = new G4UIcmdWithADoubleAndUnit("/voxels/setSizeZ", this);
0082   fVoxelSizeZCmd->SetGuidance("Set Z width of voxels");
0083   fVoxelSizeZCmd->SetParameterName("Size", false);
0084   fVoxelSizeZCmd->SetRange("Size>0.");
0085   fVoxelSizeZCmd->SetUnitCategory("Length");
0086   fVoxelSizeZCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0087   fVoxelSizeZCmd->SetToBeBroadcasted(false);
0088 
0089   // Update voxelized geometry
0090   fUpdateVoxCmd = new G4UIcmdWithoutParameter("/voxels/update", this);
0091   fUpdateVoxCmd->SetGuidance("Update voxelized geometry");
0092   fUpdateVoxCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
0093   fUpdateVoxCmd->SetGuidance("if you changed voxelization");
0094   fUpdateVoxCmd->AvailableForStates(G4State_Idle);
0095 }
0096 
0097 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0098 
0099 VoxelizedSensitiveDetectorMessenger::~VoxelizedSensitiveDetectorMessenger()
0100 {
0101   delete fVoxelsDir;
0102   delete fVoxelSizeCmd;
0103   delete fVoxelSizeXCmd;
0104   delete fVoxelSizeYCmd;
0105   delete fVoxelSizeZCmd;
0106   delete fUpdateVoxCmd;
0107 }
0108 
0109 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0110 
0111 void VoxelizedSensitiveDetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0112 {
0113   if (command == fVoxelSizeCmd) {
0114     fVoxelizedDetector->SetVoxelWidth(fVoxelSizeCmd->GetNew3VectorValue(newValue));
0115   }
0116 
0117   if (command == fVoxelSizeXCmd) {
0118     fVoxelizedDetector->SetVoxelWidthX(fVoxelSizeXCmd->GetNewDoubleValue(newValue));
0119   }
0120 
0121   if (command == fVoxelSizeYCmd) {
0122     fVoxelizedDetector->SetVoxelWidthY(fVoxelSizeYCmd->GetNewDoubleValue(newValue));
0123   }
0124 
0125   if (command == fVoxelSizeZCmd) {
0126     fVoxelizedDetector->SetVoxelWidthZ(fVoxelSizeZCmd->GetNewDoubleValue(newValue));
0127   }
0128 
0129   if (command == fUpdateVoxCmd) {
0130     fVoxelizedDetector->UpdateVoxelizedGeometry();
0131   }
0132 }
0133 
0134 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0135 
0136 }  // namespace RadioBio