Back to home page

EIC code displayed by LXR

 
 

    


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

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/DetectorMessenger.cc
0028 /// \brief Implementation of the RadioBio::DetectorMessenger class
0029 
0030 #include "DetectorMessenger.hh"
0031 
0032 #include "G4UIcmdWith3VectorAndUnit.hh"
0033 #include "G4UIcmdWithADoubleAndUnit.hh"
0034 #include "G4UIcmdWithAString.hh"
0035 #include "G4UIcommand.hh"
0036 #include "G4UIdirectory.hh"
0037 #include "G4UIparameter.hh"
0038 
0039 #include "DetectorConstruction.hh"
0040 
0041 namespace RadioBio
0042 {
0043 
0044 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0045 
0046 DetectorMessenger::DetectorMessenger(DetectorConstruction* Det) : fDetector(Det)
0047 {
0048   fGeometryDir = new G4UIdirectory("/detectorGeom/");
0049   fGeometryDir->SetGuidance("commands to change geometry material and size");
0050 
0051   fMaterCmd = new G4UIcmdWithAString("/detectorGeom/setMat", this);
0052   fMaterCmd->SetGuidance("Select material of the box.");
0053   fMaterCmd->SetParameterName("choice", false);
0054   fMaterCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0055   fMaterCmd->SetToBeBroadcasted(false);
0056 
0057   fSizeCmd = new G4UIcmdWithADoubleAndUnit("/detectorGeom/setSize", this);
0058   fSizeCmd->SetGuidance("Set size of the cubic box");
0059   fSizeCmd->SetParameterName("Size", false);
0060   fSizeCmd->SetRange("Size>0.");
0061   fSizeCmd->SetUnitCategory("Length");
0062   fSizeCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0063   fSizeCmd->SetToBeBroadcasted(false);
0064 
0065   fSizeVectorCmd = new G4UIcmdWith3VectorAndUnit("/detectorGeom/setBoxSizes", this);
0066   fSizeVectorCmd->SetGuidance("Insert sizes X Y and Z");
0067   fSizeVectorCmd->SetParameterName("SizeAlongX", "SizeAlongY", "SizeAlongZ", false);
0068   fSizeVectorCmd->SetRange("SizeAlongX>0. && SizeAlongY>0. && SizeAlongZ>0.");
0069   fSizeVectorCmd->SetUnitCategory("Length");
0070   fSizeVectorCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0071   fSizeVectorCmd->SetToBeBroadcasted(false);
0072 
0073   fSizeXCmd = new G4UIcmdWithADoubleAndUnit("/detectorGeom/setSizeX", this);
0074   fSizeXCmd->SetGuidance("Set X size of the box");
0075   fSizeXCmd->SetParameterName("Size", false);
0076   fSizeXCmd->SetRange("Size>0.");
0077   fSizeXCmd->SetUnitCategory("Length");
0078   fSizeXCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0079   fSizeXCmd->SetToBeBroadcasted(false);
0080 
0081   fSizeYCmd = new G4UIcmdWithADoubleAndUnit("/detectorGeom/setSizeY", this);
0082   fSizeYCmd->SetGuidance("Set Y size of the box");
0083   fSizeYCmd->SetParameterName("Size", false);
0084   fSizeYCmd->SetRange("Size>0.");
0085   fSizeYCmd->SetUnitCategory("Length");
0086   fSizeYCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0087   fSizeYCmd->SetToBeBroadcasted(false);
0088 
0089   fSizeZCmd = new G4UIcmdWithADoubleAndUnit("/detectorGeom/setSizeZ", this);
0090   fSizeZCmd->SetGuidance("Set Z size of the box");
0091   fSizeZCmd->SetParameterName("Size", false);
0092   fSizeZCmd->SetRange("Size>0.");
0093   fSizeZCmd->SetUnitCategory("Length");
0094   fSizeZCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0095   fSizeZCmd->SetToBeBroadcasted(false);
0096 }
0097 
0098 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0099 
0100 DetectorMessenger::~DetectorMessenger()
0101 {
0102   delete fGeometryDir;
0103   delete fMaterCmd;
0104   delete fSizeCmd;
0105   delete fSizeVectorCmd;
0106   delete fSizeXCmd;
0107   delete fSizeYCmd;
0108   delete fSizeZCmd;
0109 }
0110 
0111 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0112 
0113 void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0114 {
0115   if (command == fMaterCmd) {
0116     fDetector->SetMaterial(newValue);
0117   }
0118 
0119   if (command == fSizeCmd) {
0120     fDetector->SetSize(fSizeCmd->GetNewDoubleValue(newValue));
0121   }
0122 
0123   if (command == fSizeVectorCmd) {
0124     fDetector->SetSize(fSizeVectorCmd->GetNew3VectorValue(newValue));
0125   }
0126 
0127   if (command == fSizeXCmd) {
0128     fDetector->SetSizeX(fSizeXCmd->GetNewDoubleValue(newValue));
0129   }
0130 
0131   if (command == fSizeYCmd) {
0132     fDetector->SetSizeY(fSizeYCmd->GetNewDoubleValue(newValue));
0133   }
0134 
0135   if (command == fSizeZCmd) {
0136     fDetector->SetSizeZ(fSizeZCmd->GetNewDoubleValue(newValue));
0137   }
0138 }
0139 
0140 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0141 
0142 }  // namespace RadioBio