Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-03 07:53:14

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 RE06DetectorMessenger.cc
0027 /// \brief Implementation of the RE06DetectorMessenger class
0028 
0029 #include "RE06DetectorMessenger.hh"
0030 
0031 #include "RE06DetectorConstruction.hh"
0032 
0033 #include "G4Material.hh"
0034 #include "G4UIcmdWithABool.hh"
0035 #include "G4UIcmdWithAString.hh"
0036 #include "G4UIcmdWithAnInteger.hh"
0037 #include "G4UIdirectory.hh"
0038 
0039 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0040 
0041 RE06DetectorMessenger::RE06DetectorMessenger(RE06DetectorConstruction* det)
0042   : G4UImessenger(),
0043     fDetector(det),
0044     fDirectory(0),
0045     fAbsMaterialCmd(0),
0046     fGapMaterialCmd(0),
0047     fNumLayerCmd(0),
0048     fSerialCmd(0),
0049     fVerboseCmd(0),
0050     fAddMaterialCmd(0)
0051 {
0052   fDirectory = new G4UIdirectory("/RE06/");
0053   fDirectory->SetGuidance("UI commands of this example");
0054 
0055   G4String matList;
0056   const G4MaterialTable* matTbl = G4Material::GetMaterialTable();
0057   for (size_t i = 0; i < G4Material::GetNumberOfMaterials(); i++) {
0058     matList += (*matTbl)[i]->GetName();
0059     matList += " ";
0060   }
0061 
0062   fAbsMaterialCmd = new G4UIcmdWithAString("/RE06/setAbsMat", this);
0063   fAbsMaterialCmd->SetGuidance("Select Material of the Absorber.");
0064   fAbsMaterialCmd->SetParameterName("choice", false);
0065   fAbsMaterialCmd->AvailableForStates(G4State_Idle);
0066   fAbsMaterialCmd->SetCandidates(matList);
0067 
0068   fGapMaterialCmd = new G4UIcmdWithAString("/RE06/setGapMat", this);
0069   fGapMaterialCmd->SetGuidance("Select Material of the Gap.");
0070   fGapMaterialCmd->SetParameterName("choice", false);
0071   fGapMaterialCmd->AvailableForStates(G4State_Idle);
0072   fGapMaterialCmd->SetCandidates(matList);
0073 
0074   fNumLayerCmd = new G4UIcmdWithAnInteger("/RE06/numberOfLayers", this);
0075   fNumLayerCmd->SetGuidance("Set number of layers.");
0076   fNumLayerCmd->SetParameterName("nl", false);
0077   fNumLayerCmd->AvailableForStates(G4State_Idle);
0078   fNumLayerCmd->SetRange("nl>0");
0079 
0080   fSerialCmd = new G4UIcmdWithABool("/RE06/serialGeometry", this);
0081   fSerialCmd->SetGuidance("Select calorimeters to be placed in serial or parallel.");
0082   fSerialCmd->SetParameterName("serialize", false);
0083   fSerialCmd->AvailableForStates(G4State_Idle);
0084 
0085   fVerboseCmd = new G4UIcmdWithAnInteger("/RE06/verbose", this);
0086   fVerboseCmd->SetGuidance("Set verbosity level");
0087   fVerboseCmd->SetParameterName("verbose", false);
0088   fVerboseCmd->AvailableForStates(G4State_Idle);
0089   fVerboseCmd->SetRange("verbose>=0");
0090 
0091   fAddMaterialCmd = new G4UIcmdWithABool("/RE06/AddMaterial", this);
0092   fAddMaterialCmd->SetGuidance("Add materials ");
0093   fAddMaterialCmd->SetParameterName("dummy", true);
0094   fAddMaterialCmd->AvailableForStates(G4State_Idle);
0095 }
0096 
0097 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0098 
0099 RE06DetectorMessenger::~RE06DetectorMessenger()
0100 {
0101   delete fAbsMaterialCmd;
0102   delete fGapMaterialCmd;
0103   delete fNumLayerCmd;
0104   delete fSerialCmd;
0105   delete fDirectory;
0106 }
0107 
0108 void RE06DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0109 {
0110   if (command == fAbsMaterialCmd) {
0111     fDetector->SetAbsorberMaterial(newValue);
0112   }
0113   else if (command == fGapMaterialCmd) {
0114     fDetector->SetGapMaterial(newValue);
0115   }
0116   else if (command == fNumLayerCmd) {
0117     fDetector->SetNumberOfLayers(fNumLayerCmd->GetNewIntValue(newValue));
0118   }
0119   else if (command == fSerialCmd) {
0120     fDetector->SetSerialGeometry(fSerialCmd->GetNewBoolValue(newValue));
0121   }
0122   else if (command == fVerboseCmd) {
0123     fDetector->SetVerboseLevel(fVerboseCmd->GetNewIntValue(newValue));
0124   }
0125   else if (command == fAddMaterialCmd) {
0126     fDetector->AddMaterial();
0127     UpdateMaterialList();
0128   }
0129 }
0130 
0131 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0132 
0133 G4String RE06DetectorMessenger::GetCurrentValue(G4UIcommand* command)
0134 {
0135   G4String ans;
0136   if (command == fAbsMaterialCmd) {
0137     ans = fDetector->GetAbsorberMaterial();
0138   }
0139   else if (command == fGapMaterialCmd) {
0140     ans = fDetector->GetGapMaterial();
0141   }
0142   else if (command == fNumLayerCmd) {
0143     ans = fNumLayerCmd->ConvertToString(fDetector->GetNumberOfLayers());
0144   }
0145   else if (command == fSerialCmd) {
0146     ans = fSerialCmd->ConvertToString(fDetector->IsSerial());
0147   }
0148   else if (command == fSerialCmd) {
0149     ans = fSerialCmd->ConvertToString(fDetector->IsSerial());
0150   }
0151   else if (command == fVerboseCmd) {
0152     ans = fVerboseCmd->ConvertToString(fDetector->GetVerboseLevel());
0153   }
0154   return ans;
0155 }
0156 
0157 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0158 
0159 void RE06DetectorMessenger::UpdateMaterialList()
0160 {
0161   G4String matList;
0162   const G4MaterialTable* matTbl = G4Material::GetMaterialTable();
0163   for (size_t i = 0; i < G4Material::GetNumberOfMaterials(); i++) {
0164     matList += (*matTbl)[i]->GetName();
0165     matList += " ";
0166   }
0167 
0168   if (fAbsMaterialCmd != 0) {
0169     fAbsMaterialCmd->SetCandidates(matList);
0170   }
0171   if (fGapMaterialCmd != 0) {
0172     fGapMaterialCmd->SetCandidates(matList);
0173   }
0174 }
0175 
0176 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......