Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-03-31 07:49:55

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 #include "DetectorMessenger.hh"
0030 
0031 #include "DetectorConstruction.hh"
0032 
0033 #include "G4UIcmdWithADoubleAndUnit.hh"
0034 #include "G4UIcmdWithAString.hh"
0035 #include "G4UIcmdWithAnInteger.hh"
0036 #include "G4UIcmdWithoutParameter.hh"
0037 #include "G4UIdirectory.hh"
0038 
0039 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0040 
0041 DetectorMessenger::DetectorMessenger(DetectorConstruction* Det) : fDetector(Det)
0042 {
0043   fTestemDir = new G4UIdirectory("/testem/");
0044   fTestemDir->SetGuidance("UI commands specific to this example.");
0045 
0046   fDetDir = new G4UIdirectory("/testem/det/", false);
0047   fDetDir->SetGuidance("detector construction commands");
0048 
0049   fAbsMaterCmd = new G4UIcmdWithAString("/testem/det/setAbsMat", this);
0050   fAbsMaterCmd->SetGuidance("Select Material of the Absorber.");
0051   fAbsMaterCmd->SetParameterName("choice", false);
0052   fAbsMaterCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0053   fAbsMaterCmd->SetToBeBroadcasted(false);
0054 
0055   fWorldMaterCmd = new G4UIcmdWithAString("/testem/det/setWorldMat", this);
0056   fWorldMaterCmd->SetGuidance("Select Material of the World.");
0057   fWorldMaterCmd->SetParameterName("wchoice", false);
0058   fWorldMaterCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0059   fWorldMaterCmd->SetToBeBroadcasted(false);
0060 
0061   fAbsThickCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setAbsThick", this);
0062   fAbsThickCmd->SetGuidance("Set Thickness of the Absorber");
0063   fAbsThickCmd->SetParameterName("SizeZ", false);
0064   fAbsThickCmd->SetRange("SizeZ>0.");
0065   fAbsThickCmd->SetUnitCategory("Length");
0066   fAbsThickCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0067   fAbsThickCmd->SetToBeBroadcasted(false);
0068 
0069   fAbsSizYZCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setAbsYZ", this);
0070   fAbsSizYZCmd->SetGuidance("Set sizeYZ of the Absorber");
0071   fAbsSizYZCmd->SetParameterName("SizeYZ", false);
0072   fAbsSizYZCmd->SetRange("SizeYZ>0.");
0073   fAbsSizYZCmd->SetUnitCategory("Length");
0074   fAbsSizYZCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0075   fAbsSizYZCmd->SetToBeBroadcasted(false);
0076 
0077   fAbsXposCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setAbsXpos", this);
0078   fAbsXposCmd->SetGuidance("Set X pos. of the Absorber");
0079   fAbsXposCmd->SetParameterName("Xpos", false);
0080   fAbsXposCmd->SetUnitCategory("Length");
0081   fAbsXposCmd->AvailableForStates(G4State_PreInit);
0082   fAbsXposCmd->SetToBeBroadcasted(false);
0083 
0084   fWorldXCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setWorldX", this);
0085   fWorldXCmd->SetGuidance("Set X size of the World");
0086   fWorldXCmd->SetParameterName("WSizeX", false);
0087   fWorldXCmd->SetRange("WSizeX>0.");
0088   fWorldXCmd->SetUnitCategory("Length");
0089   fWorldXCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0090   fWorldXCmd->SetToBeBroadcasted(false);
0091 
0092   fWorldYZCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setWorldYZ", this);
0093   fWorldYZCmd->SetGuidance("Set sizeYZ of the World");
0094   fWorldYZCmd->SetParameterName("WSizeYZ", false);
0095   fWorldYZCmd->SetRange("WSizeYZ>0.");
0096   fWorldYZCmd->SetUnitCategory("Length");
0097   fWorldYZCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0098   fWorldYZCmd->SetToBeBroadcasted(false);
0099 }
0100 
0101 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0102 
0103 DetectorMessenger::~DetectorMessenger()
0104 {
0105   delete fAbsMaterCmd;
0106   delete fAbsThickCmd;
0107   delete fAbsSizYZCmd;
0108   delete fAbsXposCmd;
0109   delete fWorldMaterCmd;
0110   delete fWorldXCmd;
0111   delete fWorldYZCmd;
0112   delete fDetDir;
0113   delete fTestemDir;
0114 }
0115 
0116 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0117 
0118 void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0119 {
0120   if (command == fAbsMaterCmd) {
0121     fDetector->SetAbsorberMaterial(newValue);
0122   }
0123 
0124   if (command == fWorldMaterCmd) {
0125     fDetector->SetWorldMaterial(newValue);
0126   }
0127 
0128   if (command == fAbsThickCmd) {
0129     fDetector->SetAbsorberThickness(fAbsThickCmd->GetNewDoubleValue(newValue));
0130   }
0131 
0132   if (command == fAbsSizYZCmd) {
0133     fDetector->SetAbsorberSizeYZ(fAbsSizYZCmd->GetNewDoubleValue(newValue));
0134   }
0135 
0136   if (command == fAbsXposCmd) {
0137     fDetector->SetAbsorberXpos(fAbsXposCmd->GetNewDoubleValue(newValue));
0138   }
0139 
0140   if (command == fWorldXCmd) {
0141     fDetector->SetWorldSizeX(fWorldXCmd->GetNewDoubleValue(newValue));
0142   }
0143 
0144   if (command == fWorldYZCmd) {
0145     fDetector->SetWorldSizeYZ(fWorldYZCmd->GetNewDoubleValue(newValue));
0146   }
0147 }
0148 
0149 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......