Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-13 08:28:02

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 // This example is provided by the Geant4-DNA collaboration
0027 // Any report or published results obtained using the Geant4-DNA software
0028 // shall cite the following Geant4-DNA collaboration publications:
0029 // Med. Phys. 51 (2024) 5873-5889
0030 // Med. Phys. 45 (2018) e722-e739
0031 // Phys. Med. 31 (2015) 861-874
0032 // Med. Phys. 37 (2010) 4692-4708
0033 // Int. J. Model. Simul. Sci. Comput. 1 (2010) 157–178
0034 //
0035 // The Geant4-DNA web site is available at http://geant4-dna.org
0036 //
0037 /// \file DetectorMessenger.cc
0038 /// \brief Implementation of the DetectorMessenger class
0039 
0040 #include "DetectorMessenger.hh"
0041 #include "DetectorConstruction.hh"
0042 #include "PhysicsList.hh"
0043 
0044 #include "G4UIcmdWithABool.hh"
0045 #include "G4UIcmdWithAString.hh"
0046 #include "G4UIcmdWithADoubleAndUnit.hh"
0047 
0048 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0049 
0050 DetectorMessenger::DetectorMessenger(DetectorConstruction* det, PhysicsList* pl)
0051 :fDetector(det), fPhysList(pl)
0052 {
0053   fDetDir = new G4UIdirectory("/radial/");
0054   fDetDir->SetGuidance("radial commands");
0055 
0056   fMatCmd = new G4UIcmdWithAString("/radial/setMat", this);
0057   fMatCmd->SetGuidance("Select material of the world.");
0058   fMatCmd->SetParameterName("Material", false);
0059   fMatCmd->AvailableForStates(G4State_PreInit);
0060   fMatCmd->SetToBeBroadcasted(false);
0061 
0062   fPhysCmd = new G4UIcmdWithAString("/radial/addPhysics", this);
0063   fPhysCmd->SetGuidance("Added Physics List");
0064   fPhysCmd->SetParameterName("Physics", false);
0065   fPhysCmd->AvailableForStates(G4State_PreInit);
0066   fPhysCmd->SetToBeBroadcasted(false);
0067 
0068   fTrackingCutCmd = new G4UIcmdWithABool("/radial/addIonsTrackingCut", this);
0069   fTrackingCutCmd->SetGuidance("Added Ions Tracking Cut");
0070   fTrackingCutCmd->SetDefaultValue(false);
0071   fTrackingCutCmd->AvailableForStates(G4State_PreInit);
0072   fTrackingCutCmd->SetToBeBroadcasted(false);
0073 
0074   fWorldRadiusCmd = new G4UIcmdWithADoubleAndUnit("/radial/setWorldRadius",this);
0075   fWorldRadiusCmd->SetGuidance("Set size of the World");
0076   fWorldRadiusCmd->SetParameterName("Size",false);
0077   fWorldRadiusCmd->SetRange("Size>0.");
0078   fWorldRadiusCmd->SetUnitCategory("Length");
0079   fWorldRadiusCmd->AvailableForStates(G4State_PreInit);
0080 
0081   fWorldLengthCmd = new G4UIcmdWithADoubleAndUnit("/radial/setWorldLength",this);
0082   fWorldLengthCmd->SetGuidance("Set size of the World");
0083   fWorldLengthCmd->SetParameterName("Size",false);
0084   fWorldLengthCmd->SetRange("Size>0.");
0085   fWorldLengthCmd->SetUnitCategory("Length");
0086   fWorldLengthCmd->AvailableForStates(G4State_PreInit);
0087 
0088   fThicknessCylindersCmd = new G4UIcmdWithADoubleAndUnit("/radial/setThicknessCylinders",this);
0089   fThicknessCylindersCmd->SetGuidance("Set thickness of cylinders");
0090   fThicknessCylindersCmd->SetParameterName("Size",false);
0091   fThicknessCylindersCmd->SetRange("Size>0.");
0092   fThicknessCylindersCmd->SetUnitCategory("Length");
0093   fThicknessCylindersCmd->AvailableForStates(G4State_PreInit);
0094 
0095   fMinRadiusCylindersCmd = new G4UIcmdWithADoubleAndUnit("/radial/setMinRadiusCylinders",this);
0096   fMinRadiusCylindersCmd->SetGuidance("Set minimum radius of the cylinders");
0097   fMinRadiusCylindersCmd->SetParameterName("Size",false);
0098   fMinRadiusCylindersCmd->SetRange("Size>0.");
0099   fMinRadiusCylindersCmd->SetUnitCategory("Length");
0100   fMinRadiusCylindersCmd->AvailableForStates(G4State_PreInit);
0101 }
0102 
0103 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0104 
0105 DetectorMessenger::~DetectorMessenger()
0106 {
0107   delete fDetDir;
0108 
0109   delete fMatCmd;
0110   delete fPhysCmd;
0111   delete fTrackingCutCmd;
0112   delete fWorldRadiusCmd;
0113   delete fWorldLengthCmd;
0114   delete fThicknessCylindersCmd;
0115   delete fMinRadiusCylindersCmd;
0116 }
0117 
0118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0119 
0120 void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0121 {
0122   if (command == fMatCmd) fDetector->SetMaterial(newValue);
0123 
0124   if (command == fPhysCmd) fPhysList->AddPhysics(newValue);
0125 
0126   if (command == fTrackingCutCmd)
0127     fPhysList->SetTrackingCut(fTrackingCutCmd->GetNewBoolValue(newValue));
0128 
0129   if (command == fWorldRadiusCmd)
0130     fDetector->SetWorldRadius(fWorldRadiusCmd->GetNewDoubleValue(newValue));
0131 
0132   if (command == fWorldLengthCmd)
0133     fDetector->SetWorldLength(fWorldLengthCmd->GetNewDoubleValue(newValue));
0134 
0135   if (command == fThicknessCylindersCmd)
0136     fDetector->SetThicknessCylinders(fThicknessCylindersCmd->GetNewDoubleValue(newValue));
0137 
0138   if (command == fMinRadiusCylindersCmd)
0139     fDetector->SetMinRadiusCylinders(fMinRadiusCylindersCmd->GetNewDoubleValue(newValue));
0140 }