Back to home page

EIC code displayed by LXR

 
 

    


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

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 GB03/src/GB03DetectorMessenger.cc
0028 /// \brief Implementation of the GB03DetectorMessenger class
0029 
0030 #include "GB03DetectorMessenger.hh"
0031 
0032 #include "GB03DetectorConstruction.hh"
0033 
0034 #include "G4Material.hh"
0035 #include "G4UIcmdWithAString.hh"
0036 #include "G4UIcmdWithAnInteger.hh"
0037 #include "G4UIdirectory.hh"
0038 
0039 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0040 
0041 GB03DetectorMessenger::GB03DetectorMessenger(GB03DetectorConstruction* det)
0042   : G4UImessenger(), fDetector(det)
0043 {
0044   fDirectory = new G4UIdirectory("/GB03/");
0045   fDirectory->SetGuidance("UI commands of this example");
0046 
0047   G4String matList;
0048   const G4MaterialTable* matTbl = G4Material::GetMaterialTable();
0049   for (size_t i = 0; i < G4Material::GetNumberOfMaterials(); i++) {
0050     matList += (*matTbl)[i]->GetName();
0051     matList += " ";
0052   }
0053 
0054   fAbsMaterialCmd = new G4UIcmdWithAString("/GB03/setAbsMat", this);
0055   fAbsMaterialCmd->SetGuidance("Select Material of the Absorber.");
0056   fAbsMaterialCmd->SetParameterName("choice", false);
0057   fAbsMaterialCmd->AvailableForStates(G4State_Idle);
0058   fAbsMaterialCmd->SetCandidates(matList);
0059 
0060   fGapMaterialCmd = new G4UIcmdWithAString("/GB03/setGapMat", this);
0061   fGapMaterialCmd->SetGuidance("Select Material of the Gap.");
0062   fGapMaterialCmd->SetParameterName("choice", false);
0063   fGapMaterialCmd->AvailableForStates(G4State_Idle);
0064   fGapMaterialCmd->SetCandidates(matList);
0065 
0066   fNumLayerCmd = new G4UIcmdWithAnInteger("/GB03/numberOfLayers", this);
0067   fNumLayerCmd->SetGuidance("Set number of layers.");
0068   fNumLayerCmd->SetParameterName("nl", false);
0069   fNumLayerCmd->AvailableForStates(G4State_Idle);
0070   fNumLayerCmd->SetRange("nl>0");
0071 
0072   fVerboseCmd = new G4UIcmdWithAnInteger("/GB03/verbose", this);
0073   fVerboseCmd->SetGuidance("Set verbosity level");
0074   fVerboseCmd->SetParameterName("verbose", false);
0075   fVerboseCmd->AvailableForStates(G4State_Idle);
0076   fVerboseCmd->SetRange("verbose>=0");
0077 }
0078 
0079 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0080 
0081 GB03DetectorMessenger::~GB03DetectorMessenger()
0082 {
0083   delete fAbsMaterialCmd;
0084   delete fGapMaterialCmd;
0085   delete fNumLayerCmd;
0086   delete fVerboseCmd;
0087   delete fDirectory;
0088 }
0089 
0090 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0091 
0092 void GB03DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0093 {
0094   if (command == fAbsMaterialCmd) {
0095     fDetector->SetAbsorberMaterial(newValue);
0096   }
0097   else if (command == fGapMaterialCmd) {
0098     fDetector->SetGapMaterial(newValue);
0099   }
0100   else if (command == fNumLayerCmd) {
0101     fDetector->SetNumberOfLayers(fNumLayerCmd->GetNewIntValue(newValue));
0102   }
0103   else if (command == fVerboseCmd) {
0104     fDetector->SetVerboseLevel(fVerboseCmd->GetNewIntValue(newValue));
0105   }
0106 }
0107 
0108 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0109 
0110 G4String GB03DetectorMessenger::GetCurrentValue(G4UIcommand* command)
0111 {
0112   G4String ans;
0113   if (command == fAbsMaterialCmd) {
0114     ans = fDetector->GetAbsorberMaterial();
0115   }
0116   else if (command == fGapMaterialCmd) {
0117     ans = fDetector->GetGapMaterial();
0118   }
0119   else if (command == fNumLayerCmd) {
0120     ans = fNumLayerCmd->ConvertToString(GB03DetectorConstruction::GetNumberOfLayers());
0121   }
0122   else if (command == fVerboseCmd) {
0123     ans = fVerboseCmd->ConvertToString(fDetector->GetVerboseLevel());
0124   }
0125   return ans;
0126 }
0127 
0128 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......