Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-18 07:41:50

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 "G4UIcmdWith3VectorAndUnit.hh"
0034 #include "G4UIcmdWithADoubleAndUnit.hh"
0035 #include "G4UIcmdWithAString.hh"
0036 #include "G4UIcmdWithoutParameter.hh"
0037 #include "G4UIdirectory.hh"
0038 
0039 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0040 
0041 DetectorMessenger::DetectorMessenger(DetectorConstruction* det)
0042   : G4UImessenger(),
0043     fDetector(det),
0044     fDetDir(0),
0045     fMaterCmd(0),
0046     fSizeXCmd(0),
0047     fSizeYZCmd(0),
0048     fStepSizeCmd(0)
0049 
0050 {
0051   fDetDir = new G4UIdirectory("/testex/det/");
0052   fDetDir->SetGuidance("detector construction commands");
0053 
0054   fMaterCmd = new G4UIcmdWithAString("/testex/det/setMat", this);
0055   fMaterCmd->SetGuidance("Select material of the box.");
0056   fMaterCmd->SetParameterName("choice", false);
0057   fMaterCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0058 
0059   fSizeXCmd = new G4UIcmdWithADoubleAndUnit("/testex/det/setSizeX", this);
0060   fSizeXCmd->SetGuidance("Set sizeX of the absorber");
0061   fSizeXCmd->SetParameterName("SizeX", false);
0062   fSizeXCmd->SetRange("SizeX>0.");
0063   fSizeXCmd->SetUnitCategory("Length");
0064   fSizeXCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0065 
0066   fSizeYZCmd = new G4UIcmdWithADoubleAndUnit("/testex/det/setSizeYZ", this);
0067   fSizeYZCmd->SetGuidance("Set sizeYZ of the absorber");
0068   fSizeYZCmd->SetParameterName("SizeYZ", false);
0069   fSizeYZCmd->SetRange("SizeYZ>0.");
0070   fSizeYZCmd->SetUnitCategory("Length");
0071   fSizeYZCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0072 
0073   fStepSizeCmd = new G4UIcmdWithADoubleAndUnit("/testex/det/setStepSize", this);
0074   fStepSizeCmd->SetGuidance("Set maxStepSize in the absorber");
0075   fStepSizeCmd->SetParameterName("StepSize", false);
0076   fStepSizeCmd->SetRange("StepSize>0.");
0077   fStepSizeCmd->SetUnitCategory("Length");
0078   fStepSizeCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0079 }
0080 
0081 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0082 
0083 DetectorMessenger::~DetectorMessenger()
0084 {
0085   delete fMaterCmd;
0086   delete fSizeXCmd;
0087   delete fSizeYZCmd;
0088   delete fStepSizeCmd;
0089   delete fDetDir;
0090 }
0091 
0092 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0093 
0094 void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0095 {
0096   if (command == fMaterCmd) {
0097     fDetector->SetMaterial(newValue);
0098   }
0099 
0100   if (command == fSizeXCmd) {
0101     fDetector->SetSizeX(fSizeXCmd->GetNewDoubleValue(newValue));
0102   }
0103 
0104   if (command == fSizeYZCmd) {
0105     fDetector->SetSizeYZ(fSizeYZCmd->GetNewDoubleValue(newValue));
0106   }
0107 
0108   if (command == fStepSizeCmd) {
0109     fDetector->SetMaxStepSize(fStepSizeCmd->GetNewDoubleValue(newValue));
0110   }
0111 }
0112 
0113 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......