Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-21 08:29:23

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 "G4HadronicParameters.hh"
0048 #include "G4UIcmdWith3Vector.hh"
0049 #include "G4UIcmdWithABool.hh"
0050 #include "G4UIcmdWithADoubleAndUnit.hh"
0051 #include "G4UIcmdWithAString.hh"
0052 #include "G4UIcmdWithAnInteger.hh"
0053 #include "G4UIcmdWithoutParameter.hh"
0054 #include "G4UIdirectory.hh"
0055 
0056 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0057 
0058 DetectorMessenger::DetectorMessenger(DetectorConstruction* Det)
0059   : G4UImessenger(),
0060     fDetector(Det),
0061     fTestDir(0),
0062     fMatCmd(0),
0063     fMat1Cmd(0),
0064     fRCmd(0),
0065     fLCmd(0),
0066     fEdepCmd(0),
0067     fBinCmd(0),
0068     fNOfAbsCmd(0),
0069     fVerbCmd(0),
0070     fBeamCmd(0)
0071 {
0072   fTestDir = new G4UIdirectory("/testhadr/");
0073   fTestDir->SetGuidance(" Hadronic Extended Example.");
0074 
0075   fMatCmd = new G4UIcmdWithAString("/testhadr/TargetMat", this);
0076   fMatCmd->SetGuidance("Select Material for the target");
0077   fMatCmd->SetParameterName("tMaterial", false);
0078   fMatCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0079 
0080   fMat1Cmd = new G4UIcmdWithAString("/testhadr/WorldMat", this);
0081   fMat1Cmd->SetGuidance("Select Material for world");
0082   fMat1Cmd->SetParameterName("wMaterial", false);
0083   fMat1Cmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0084 
0085   fRCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/TargetRadius", this);
0086   fRCmd->SetGuidance("Set radius of the target");
0087   fRCmd->SetParameterName("radius", false);
0088   fRCmd->SetUnitCategory("Length");
0089   fRCmd->SetRange("radius>0");
0090   fRCmd->AvailableForStates(G4State_PreInit);
0091 
0092   fLCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/TargetLength", this);
0093   fLCmd->SetGuidance("Set length of the target");
0094   fLCmd->SetParameterName("length", false);
0095   fLCmd->SetUnitCategory("Length");
0096   fLCmd->SetRange("length>0");
0097   fLCmd->AvailableForStates(G4State_PreInit);
0098 
0099   fBinCmd = new G4UIcmdWithAnInteger("/testhadr/NumberOfBinsE", this);
0100   fBinCmd->SetGuidance("Set number of bins for Energy");
0101   fBinCmd->SetParameterName("NEbins", false);
0102   fBinCmd->AvailableForStates(G4State_PreInit);
0103 
0104   fNOfAbsCmd = new G4UIcmdWithAnInteger("/testhadr/NumberDivZ", this);
0105   fNOfAbsCmd->SetGuidance("Set number of slices");
0106   fNOfAbsCmd->SetParameterName("NZ", false);
0107   fNOfAbsCmd->AvailableForStates(G4State_PreInit);
0108 
0109   fEdepCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/MaxEdep", this);
0110   fEdepCmd->SetGuidance("Set max energy in histogram");
0111   fEdepCmd->SetParameterName("edep", false);
0112   fEdepCmd->SetUnitCategory("Energy");
0113   fEdepCmd->SetRange("edep>0");
0114   fEdepCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0115 
0116   fBeamCmd = new G4UIcmdWithABool("/testhadr/DefaultBeamPosition", this);
0117   fBeamCmd->SetGuidance("Use default beam position");
0118   fBeamCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0119 
0120   fVerbCmd = new G4UIcmdWithAnInteger("/testhadr/Verbose", this);
0121   fVerbCmd->SetGuidance("Set verbose for ");
0122   fVerbCmd->SetParameterName("verb", false);
0123   fVerbCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0124 
0125   fBertCmd = new G4UIcmdWithAnInteger("/testhadr/printBertiniXS", this);
0126   fBertCmd->SetGuidance("Set printout of Bertini crosss ections");
0127   fBertCmd->SetParameterName("bert", false);
0128   fBertCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0129 
0130   fBCCmd = new G4UIcmdWithABool("/testhadr/BCParticles", this);
0131   fBCCmd->SetGuidance("Enable b-, c- hadronic physics");
0132   fBCCmd->SetParameterName("BCparticles", false);
0133   fBCCmd->AvailableForStates(G4State_PreInit);
0134 
0135   fHNCmd = new G4UIcmdWithABool("/testhadr/HyperNuclei", this);
0136   fHNCmd->SetGuidance("Enable hyper-nuclei hadronic physics");
0137   fHNCmd->SetParameterName("HyperNuclei", false);
0138   fHNCmd->AvailableForStates(G4State_PreInit);
0139 
0140   fNGPCmd = new G4UIcmdWithABool("/testhadr/NeutronGeneralProcess", this);
0141   fNGPCmd->SetGuidance("Enable neutron general process");
0142   fNGPCmd->SetParameterName("NeutronGeneralProcess", false);
0143   fNGPCmd->AvailableForStates(G4State_PreInit);
0144 }
0145 
0146 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0147 
0148 DetectorMessenger::~DetectorMessenger()
0149 {
0150   delete fMatCmd;
0151   delete fMat1Cmd;
0152   delete fRCmd;
0153   delete fLCmd;
0154   delete fBinCmd;
0155   delete fNOfAbsCmd;
0156   delete fTestDir;
0157   delete fBeamCmd;
0158   delete fVerbCmd;
0159   delete fBertCmd;
0160   delete fEdepCmd;
0161   delete fBCCmd;
0162   delete fHNCmd;
0163   delete fNGPCmd;
0164 }
0165 
0166 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0167 
0168 void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0169 {
0170   HistoManager* h = HistoManager::GetPointer();
0171   if (command == fMatCmd) {
0172     fDetector->SetTargetMaterial(newValue);
0173   }
0174   else if (command == fMat1Cmd) {
0175     fDetector->SetWorldMaterial(newValue);
0176   }
0177   else if (command == fRCmd) {
0178     h->SetTargetRadius(fRCmd->GetNewDoubleValue(newValue));
0179   }
0180   else if (command == fLCmd) {
0181     h->SetTargetLength(fLCmd->GetNewDoubleValue(newValue));
0182   }
0183   else if (command == fNOfAbsCmd) {
0184     h->SetNumberOfSlices(fNOfAbsCmd->GetNewIntValue(newValue));
0185   }
0186   else if (command == fBinCmd) {
0187     h->SetNumberOfBinsE(fBinCmd->GetNewIntValue(newValue));
0188   }
0189   else if (command == fVerbCmd) {
0190     h->SetVerbose(fVerbCmd->GetNewIntValue(newValue));
0191   }
0192   else if (command == fBertCmd) {
0193     h->SetPrintBertiniXS(fBertCmd->GetNewIntValue(newValue));
0194   }
0195   else if (command == fBeamCmd) {
0196     h->SetDefaultBeamPositionFlag(fBeamCmd->GetNewBoolValue(newValue));
0197   }
0198   else if (command == fEdepCmd) {
0199     h->SetMaxEnergyDeposit(fEdepCmd->GetNewDoubleValue(newValue));
0200   }
0201   else if (command == fBCCmd) {
0202     G4HadronicParameters::Instance()->SetEnableBCParticles(fBCCmd->GetNewBoolValue(newValue));
0203   }
0204   else if (command == fHNCmd) {
0205     G4HadronicParameters::Instance()->SetEnableHyperNuclei(fHNCmd->GetNewBoolValue(newValue));
0206   }
0207   else if (command == fNGPCmd) {
0208     G4HadronicParameters::Instance()->SetEnableNeutronGeneralProcess(
0209       fNGPCmd->GetNewBoolValue(newValue));
0210   }
0211 }
0212 
0213 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......