Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-13 08:05:59

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 DetectorMessenger class
0028 
0029 // This example is provided by the Geant4-DNA collaboration
0030 // Any report or published results obtained using the Geant4-DNA software
0031 // shall cite the following Geant4-DNA collaboration publications:
0032 // Med. Phys. 45 (2018) e722-e739
0033 // Phys. Med. 31 (2015) 861-874
0034 // Med. Phys. 37 (2010) 4692-4708
0035 // Int. J. Model. Simul. Sci. Comput. 1 (2010) 157–178
0036 //
0037 // The Geant4-DNA web site is available at http://geant4-dna.org
0038 //
0039 
0040 #include "DetectorMessenger.hh"
0041 
0042 #include "DetectorConstruction.hh"
0043 
0044 #include "G4UIcmdWithADoubleAndUnit.hh"
0045 #include "G4UIcmdWithAString.hh"
0046 
0047 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0048 
0049 DetectorMessenger::DetectorMessenger(DetectorConstruction* Det)
0050   : G4UImessenger(),
0051     fDetector(Det),
0052     fTestemDir(0),
0053     fDetDir(0),
0054     fMaterWorldCmd(0),
0055     fMaterCytoCmd(0),
0056     fMaterNuclCmd(0),
0057     fNuclRadiusCmd(0),
0058     fCytoThicknessCmd(0),
0059     fTrackingCutCmd(0)
0060 {
0061   fTestemDir = new G4UIdirectory("/svalue/");
0062   fTestemDir->SetGuidance("Detector control");
0063 
0064   fDetDir = new G4UIdirectory("/svalue/det/");
0065   fDetDir->SetGuidance("Detector construction commands");
0066 
0067   fMaterWorldCmd = new G4UIcmdWithAString("/svalue/det/setWorldMat", this);
0068   fMaterWorldCmd->SetGuidance("Select material of the World");
0069   fMaterWorldCmd->SetParameterName("choice", false);
0070   fMaterWorldCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0071   fMaterWorldCmd->SetToBeBroadcasted(false);
0072 
0073   fMaterNuclCmd = new G4UIcmdWithAString("/svalue/det/setNuclMat", this);
0074   fMaterNuclCmd->SetGuidance("Select material of the nucleus");
0075   fMaterNuclCmd->SetParameterName("choice", false);
0076   fMaterNuclCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0077   fMaterNuclCmd->SetToBeBroadcasted(false);
0078 
0079   fMaterCytoCmd = new G4UIcmdWithAString("/svalue/det/setCytoMat", this);
0080   fMaterCytoCmd->SetGuidance("Select material of the cytoplasm");
0081   fMaterCytoCmd->SetParameterName("choice", false);
0082   fMaterCytoCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0083   fMaterCytoCmd->SetToBeBroadcasted(false);
0084 
0085   fNuclRadiusCmd = new G4UIcmdWithADoubleAndUnit("/svalue/det/setNuclRadius", this);
0086   fNuclRadiusCmd->SetGuidance("Set radius of the nucleus");
0087   fNuclRadiusCmd->SetParameterName("Radius", false);
0088   fNuclRadiusCmd->SetRange("Radius>0.");
0089   fNuclRadiusCmd->SetUnitCategory("Length");
0090   fNuclRadiusCmd->AvailableForStates(G4State_PreInit);
0091   fNuclRadiusCmd->SetToBeBroadcasted(false);
0092 
0093   fCytoThicknessCmd = new G4UIcmdWithADoubleAndUnit("/svalue/det/setCytoThickness", this);
0094   fCytoThicknessCmd->SetGuidance("Set thickness of the cytoplasm");
0095   fCytoThicknessCmd->SetParameterName("Thickness", false);
0096   fCytoThicknessCmd->SetRange("Thickness>0.");
0097   fCytoThicknessCmd->SetUnitCategory("Length");
0098   fCytoThicknessCmd->AvailableForStates(G4State_PreInit);
0099   fCytoThicknessCmd->SetToBeBroadcasted(false);
0100 
0101   fTrackingCutCmd = new G4UIcmdWithADoubleAndUnit("/svalue/det/setTrackingCut", this);
0102   fTrackingCutCmd->SetGuidance("Set tracking cut in the absorber");
0103   fTrackingCutCmd->SetParameterName("Cut", false);
0104   fTrackingCutCmd->SetRange("Cut>0.");
0105   fTrackingCutCmd->SetUnitCategory("Energy");
0106   fTrackingCutCmd->AvailableForStates(G4State_PreInit);
0107   fTrackingCutCmd->SetToBeBroadcasted(false);
0108 }
0109 
0110 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0111 
0112 DetectorMessenger::~DetectorMessenger()
0113 {
0114   delete fMaterWorldCmd;
0115   delete fMaterCytoCmd;
0116   delete fMaterNuclCmd;
0117   delete fNuclRadiusCmd;
0118   delete fCytoThicknessCmd;
0119   delete fTrackingCutCmd;
0120   delete fDetDir;
0121   delete fTestemDir;
0122 }
0123 
0124 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0125 
0126 void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0127 {
0128   if (command == fMaterWorldCmd) {
0129     fDetector->SetWorldMaterial(newValue);
0130   }
0131 
0132   if (command == fMaterCytoCmd) {
0133     fDetector->SetCytoMaterial(newValue);
0134   }
0135 
0136   if (command == fMaterNuclCmd) {
0137     fDetector->SetNuclMaterial(newValue);
0138   }
0139 
0140   if (command == fNuclRadiusCmd) {
0141     fDetector->SetNuclRadius(fNuclRadiusCmd->GetNewDoubleValue(newValue));
0142   }
0143 
0144   if (command == fCytoThicknessCmd) {
0145     fDetector->SetCytoThickness(fCytoThicknessCmd->GetNewDoubleValue(newValue));
0146   }
0147 
0148   if (command == fTrackingCutCmd) {
0149     fDetector->SetTrackingCut(fTrackingCutCmd->GetNewDoubleValue(newValue));
0150   }
0151 }