Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:22:20

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