Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:22:46

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