Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-08 08:29:28

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