Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-09 08:28:41

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 // DetectorMessenger
0032 //
0033 // Created: 31.01.03 V.Ivanchenko
0034 //
0035 // Modified:
0036 // 04.06.2006 Adoptation of hadr01 (V.Ivanchenko)
0037 // 16.11.2006 Add beamCmd (V.Ivanchenko)
0038 //
0039 ////////////////////////////////////////////////////////////////////////
0040 //
0041 
0042 #include "DetectorMessenger.hh"
0043 
0044 #include "DetectorConstruction.hh"
0045 #include "HistoManager.hh"
0046 
0047 #include "G4PhysicalConstants.hh"
0048 #include "G4SystemOfUnits.hh"
0049 #include "G4UIcmdWith3Vector.hh"
0050 #include "G4UIcmdWithABool.hh"
0051 #include "G4UIcmdWithADoubleAndUnit.hh"
0052 #include "G4UIcmdWithAString.hh"
0053 #include "G4UIcmdWithAnInteger.hh"
0054 #include "G4UIcmdWithoutParameter.hh"
0055 #include "G4UIdirectory.hh"
0056 
0057 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0058 
0059 DetectorMessenger::DetectorMessenger(DetectorConstruction* det)
0060   : G4UImessenger(),
0061     fDetector(det),
0062     fTestDir(0),
0063     fMatCmd(0),
0064     fMat1Cmd(0),
0065     fIonCmd(0),
0066     fRCmd(0),
0067     fLCmd(0),
0068     fEdepCmd(0),
0069     fBinCmd(0),
0070     fNOfAbsCmd(0),
0071     fVerbCmd(0),
0072     fBeamCmd(0)
0073 {
0074   fTestDir = new G4UIdirectory("/testhadr/");
0075   fTestDir->SetGuidance(" Hadronic Extended Example.");
0076 
0077   fMatCmd = new G4UIcmdWithAString("/testhadr/TargetMat", this);
0078   fMatCmd->SetGuidance("Select Material for the target");
0079   fMatCmd->SetParameterName("tMaterial", false);
0080   fMatCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0081 
0082   fMat1Cmd = new G4UIcmdWithAString("/testhadr/WorldMat", this);
0083   fMat1Cmd->SetGuidance("Select Material for world");
0084   fMat1Cmd->SetParameterName("wMaterial", false);
0085   fMat1Cmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0086 
0087   fIonCmd = new G4UIcmdWithAString("/testhadr/ionPhysics", this);
0088   fIonCmd->SetGuidance("Select ion Physics");
0089   fIonCmd->SetParameterName("DPMJET", false);
0090   fIonCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0091 
0092   fRCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/TargetRadius", this);
0093   fRCmd->SetGuidance("Set radius of the target");
0094   fRCmd->SetParameterName("radius", false);
0095   fRCmd->SetUnitCategory("Length");
0096   fRCmd->SetRange("radius>0");
0097   fRCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0098 
0099   fLCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/TargetLength", this);
0100   fLCmd->SetGuidance("Set length of the target");
0101   fLCmd->SetParameterName("length", false);
0102   fLCmd->SetUnitCategory("Length");
0103   fLCmd->SetRange("length>0");
0104   fLCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0105 
0106   fBinCmd = new G4UIcmdWithAnInteger("/testhadr/NumberOfBinsE", this);
0107   fBinCmd->SetGuidance("Set number of bins for Energy");
0108   fBinCmd->SetParameterName("NEbins", false);
0109   fBinCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0110 
0111   fNOfAbsCmd = new G4UIcmdWithAnInteger("/testhadr/NumberDivZ", this);
0112   fNOfAbsCmd->SetGuidance("Set number of slices");
0113   fNOfAbsCmd->SetParameterName("NZ", false);
0114   fNOfAbsCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0115 
0116   fEdepCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/MaxEdep", this);
0117   fEdepCmd->SetGuidance("Set max energy in histogram");
0118   fEdepCmd->SetParameterName("edep", false);
0119   fEdepCmd->SetUnitCategory("Energy");
0120   fEdepCmd->SetRange("edep>0");
0121   fEdepCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0122 
0123   fBeamCmd = new G4UIcmdWithABool("/testhadr/DefaultBeamPosition", this);
0124   fBeamCmd->SetGuidance("show inelastic and elastic cross sections");
0125 
0126   fVerbCmd = new G4UIcmdWithAnInteger("/testhadr/Verbose", this);
0127   fVerbCmd->SetGuidance("Set verbose for ");
0128   fVerbCmd->SetParameterName("verb", false);
0129   fVerbCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0130 }
0131 
0132 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0133 
0134 DetectorMessenger::~DetectorMessenger()
0135 {
0136   delete fMatCmd;
0137   delete fMat1Cmd;
0138   delete fIonCmd;
0139   delete fRCmd;
0140   delete fLCmd;
0141   delete fNOfAbsCmd;
0142   delete fTestDir;
0143   delete fBeamCmd;
0144   delete fVerbCmd;
0145   delete fEdepCmd;
0146 }
0147 
0148 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0149 
0150 void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0151 {
0152   HistoManager* h = HistoManager::GetPointer();
0153   if (command == fMatCmd) {
0154     fDetector->SetTargetMaterial(newValue);
0155   }
0156   else if (command == fMat1Cmd) {
0157     fDetector->SetWorldMaterial(newValue);
0158   }
0159   else if (command == fIonCmd) {
0160     h->SetIonPhysics(newValue);
0161   }
0162   else if (command == fRCmd) {
0163     fDetector->SetTargetRadius(fRCmd->GetNewDoubleValue(newValue));
0164   }
0165   else if (command == fLCmd) {
0166     h->SetTargetLength(fLCmd->GetNewDoubleValue(newValue));
0167   }
0168   else if (command == fNOfAbsCmd) {
0169     h->SetNumberOfSlices(fNOfAbsCmd->GetNewIntValue(newValue));
0170   }
0171   else if (command == fBinCmd) {
0172     h->SetNumberOfBinsE(fBinCmd->GetNewIntValue(newValue));
0173   }
0174   else if (command == fVerbCmd) {
0175     h->SetVerbose(fVerbCmd->GetNewIntValue(newValue));
0176   }
0177   else if (command == fBeamCmd) {
0178     h->SetDefaultBeamPositionFlag(fBeamCmd->GetNewBoolValue(newValue));
0179   }
0180   else if (command == fEdepCmd) {
0181     h->SetMaxEnergyDeposit(fEdepCmd->GetNewDoubleValue(newValue));
0182   }
0183 }
0184 
0185 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......