Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:21:00

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