Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:51:48

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 /////////////////////////////////////////////////////////////////////////
0030 //
0031 // TestEm8: Gaseous detector
0032 //
0033 // Created: 31.08.2010 V.Ivanchenko
0034 //
0035 // Modified:
0036 //
0037 ////////////////////////////////////////////////////////////////////////
0038 //
0039 
0040 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0041 
0042 #include "DetectorMessenger.hh"
0043 
0044 #include "DetectorConstruction.hh"
0045 
0046 #include "G4UIcmdWithADoubleAndUnit.hh"
0047 #include "G4UIcmdWithAString.hh"
0048 #include "G4UIcmdWithoutParameter.hh"
0049 #include "G4UIdirectory.hh"
0050 
0051 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0052 
0053 DetectorMessenger::DetectorMessenger(DetectorConstruction* det) : fDetector(det)
0054 {
0055   fDetDir = new G4UIdirectory("/testem/");
0056   fDetDir->SetGuidance("Detector control.");
0057 
0058   fGasMaterCmd = new G4UIcmdWithAString("/testem/setGasMat", this);
0059   fGasMaterCmd->SetGuidance("Select material of the detector.");
0060   fGasMaterCmd->SetParameterName("gmat", true);
0061   fGasMaterCmd->SetDefaultValue("Argon");
0062   fGasMaterCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0063 
0064   fWindowMaterCmd = new G4UIcmdWithAString("/testem/setWindowMat", this);
0065   fWindowMaterCmd->SetGuidance("Select material of the window.");
0066   fWindowMaterCmd->SetParameterName("wmat", true);
0067   fWindowMaterCmd->SetDefaultValue("Mylar");
0068   fWindowMaterCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0069 
0070   fWorldMaterCmd = new G4UIcmdWithAString("/testem/setWorldMat", this);
0071   fWorldMaterCmd->SetGuidance("Select material of the world.");
0072   fWorldMaterCmd->SetParameterName("worldmat", true);
0073   fWorldMaterCmd->SetDefaultValue("empty");
0074   fWorldMaterCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0075 
0076   fGasThickCmd = new G4UIcmdWithADoubleAndUnit("/testem/setGasThick", this);
0077   fGasThickCmd->SetGuidance("Set thickness of the detector");
0078   fGasThickCmd->SetParameterName("SizeZ", false, false);
0079   fGasThickCmd->SetUnitCategory("Length");
0080   fGasThickCmd->SetDefaultUnit("mm");
0081   fGasThickCmd->SetRange("SizeZ>0.");
0082   fGasThickCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0083 
0084   fGasRadCmd = new G4UIcmdWithADoubleAndUnit("/testem/setGasRad", this);
0085   fGasRadCmd->SetGuidance("Set radius of the detector");
0086   fGasRadCmd->SetParameterName("SizeR", false, false);
0087   fGasRadCmd->SetUnitCategory("Length");
0088   fGasRadCmd->SetDefaultUnit("mm");
0089   fGasRadCmd->SetRange("SizeR>0.");
0090   fGasRadCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0091 
0092   fWinThickCmd = new G4UIcmdWithADoubleAndUnit("/testem/setWindowThick", this);
0093   fWinThickCmd->SetGuidance("Set thickness of the window");
0094   fWinThickCmd->SetParameterName("delta", false, false);
0095   fWinThickCmd->SetUnitCategory("Length");
0096   fWinThickCmd->SetDefaultUnit("mm");
0097   fWinThickCmd->SetRange("delta>0.");
0098   fWinThickCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0099 
0100   fIonCmd = new G4UIcmdWithADoubleAndUnit("/testem/setPairEnergy", this);
0101   fIonCmd->SetGuidance("Set energy per electron-ion pair for detector");
0102   fIonCmd->SetParameterName("en", false, false);
0103   fIonCmd->SetUnitCategory("Energy");
0104   fIonCmd->SetDefaultUnit("MeV");
0105   fIonCmd->SetRange("en>0.");
0106   fIonCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0107 
0108   fStepMaxCmd = new G4UIcmdWithADoubleAndUnit("/testem/stepMax", this);
0109   fStepMaxCmd->SetGuidance("Set max allowed step length for charged particles");
0110   fStepMaxCmd->SetParameterName("mxStep", false);
0111   fStepMaxCmd->SetRange("mxStep>0.");
0112   fStepMaxCmd->SetUnitCategory("Length");
0113   fStepMaxCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0114 }
0115 
0116 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0117 
0118 DetectorMessenger::~DetectorMessenger()
0119 {
0120   delete fGasMaterCmd;
0121   delete fGasThickCmd;
0122   delete fGasRadCmd;
0123   delete fWinThickCmd;
0124   delete fWindowMaterCmd;
0125   delete fWorldMaterCmd;
0126   delete fIonCmd;
0127   delete fStepMaxCmd;
0128   delete fDetDir;
0129 }
0130 
0131 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0132 
0133 void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0134 {
0135   if (command == fGasMaterCmd) {
0136     fDetector->SetGasMaterial(newValue);
0137   }
0138   else if (command == fWindowMaterCmd) {
0139     fDetector->SetContainerMaterial(newValue);
0140   }
0141   else if (command == fWorldMaterCmd) {
0142     fDetector->SetWorldMaterial(newValue);
0143   }
0144   else if (command == fGasThickCmd) {
0145     fDetector->SetGasThickness(fGasThickCmd->GetNewDoubleValue(newValue));
0146   }
0147   else if (command == fGasRadCmd) {
0148     fDetector->SetGasRadius(fGasRadCmd->GetNewDoubleValue(newValue));
0149   }
0150   else if (command == fWinThickCmd) {
0151     fDetector->SetContainerThickness(fWinThickCmd->GetNewDoubleValue(newValue));
0152   }
0153   else if (command == fStepMaxCmd) {
0154     fDetector->SetMaxChargedStep(fStepMaxCmd->GetNewDoubleValue(newValue));
0155   }
0156   else if (command == fIonCmd) {
0157     fDetector->SetPairEnergy(fIonCmd->GetNewDoubleValue(newValue));
0158   }
0159 }
0160 
0161 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......