Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:22:40

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 //....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 "G4UIcmdWithoutParameter.hh"
0040 #include "G4UIcommand.hh"
0041 #include "G4UIdirectory.hh"
0042 #include "G4UIparameter.hh"
0043 
0044 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0045 
0046 DetectorMessenger::DetectorMessenger(DetectorConstruction* det) : fDetector(det)
0047 {
0048   fTestemDir = new G4UIdirectory("/testhadr/");
0049   fTestemDir->SetGuidance("commands specific to this example");
0050 
0051   G4bool broadcast = false;
0052   fDetDir = new G4UIdirectory("/testhadr/det/", broadcast);
0053   fDetDir->SetGuidance("detector construction commands");
0054 
0055   fMaterCmd = new G4UIcmdWithAString("/testhadr/det/setMat", this);
0056   fMaterCmd->SetGuidance("Select material of the box.");
0057   fMaterCmd->SetParameterName("choice", false);
0058   fMaterCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0059 
0060   fThickCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/det/setThickness", this);
0061   fThickCmd->SetGuidance("Set thickness of the absor");
0062   fThickCmd->SetParameterName("Thickness", false);
0063   fThickCmd->SetRange("Thickness>0.");
0064   fThickCmd->SetUnitCategory("Length");
0065   fThickCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0066 
0067   fSizeYZCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/det/setSizeYZ", this);
0068   fSizeYZCmd->SetGuidance("Set transverse size of the absor");
0069   fSizeYZCmd->SetParameterName("Size", false);
0070   fSizeYZCmd->SetRange("Size>0.");
0071   fSizeYZCmd->SetUnitCategory("Length");
0072   fSizeYZCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0073 
0074   fIsotopeCmd = new G4UIcommand("/testhadr/det/setIsotopeMat", this);
0075   fIsotopeCmd->SetGuidance("Build and select a material with single isotope");
0076   fIsotopeCmd->SetGuidance("  symbol of isotope, Z, A, density of material");
0077   //
0078   G4UIparameter* symbPrm = new G4UIparameter("isotope", 's', false);
0079   symbPrm->SetGuidance("isotope symbol");
0080   fIsotopeCmd->SetParameter(symbPrm);
0081   //
0082   G4UIparameter* ZPrm = new G4UIparameter("Z", 'i', false);
0083   ZPrm->SetGuidance("Z");
0084   ZPrm->SetParameterRange("Z>0");
0085   fIsotopeCmd->SetParameter(ZPrm);
0086   //
0087   G4UIparameter* APrm = new G4UIparameter("A", 'i', false);
0088   APrm->SetGuidance("A");
0089   APrm->SetParameterRange("A>0");
0090   fIsotopeCmd->SetParameter(APrm);
0091   //
0092   G4UIparameter* densityPrm = new G4UIparameter("density", 'd', false);
0093   densityPrm->SetGuidance("density of material");
0094   densityPrm->SetParameterRange("density>0.");
0095   fIsotopeCmd->SetParameter(densityPrm);
0096   //
0097   G4UIparameter* unitPrm = new G4UIparameter("unit", 's', false);
0098   unitPrm->SetGuidance("unit of density");
0099   G4String unitList = G4UIcommand::UnitsList(G4UIcommand::CategoryOf("g/cm3"));
0100   unitPrm->SetParameterCandidates(unitList);
0101   fIsotopeCmd->SetParameter(unitPrm);
0102   //
0103   fIsotopeCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0104 }
0105 
0106 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0107 
0108 DetectorMessenger::~DetectorMessenger()
0109 {
0110   delete fMaterCmd;
0111   delete fThickCmd;
0112   delete fSizeYZCmd;
0113   delete fIsotopeCmd;
0114   delete fDetDir;
0115   delete fTestemDir;
0116 }
0117 
0118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0119 
0120 void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0121 {
0122   if (command == fMaterCmd) {
0123     fDetector->SetAbsorMaterial(newValue);
0124   }
0125 
0126   if (command == fThickCmd) {
0127     fDetector->SetAbsorThickness(fThickCmd->GetNewDoubleValue(newValue));
0128   }
0129 
0130   if (command == fSizeYZCmd) {
0131     fDetector->SetAbsorSizeYZ(fSizeYZCmd->GetNewDoubleValue(newValue));
0132   }
0133 
0134   if (command == fIsotopeCmd) {
0135     G4int Z;
0136     G4int A;
0137     G4double dens;
0138     G4String name, unt;
0139     std::istringstream is(newValue);
0140     is >> name >> Z >> A >> dens >> unt;
0141     dens *= G4UIcommand::ValueOf(unt);
0142     fDetector->MaterialWithSingleIsotope(name, name, dens, Z, A);
0143     fDetector->SetAbsorMaterial(name);
0144   }
0145 }
0146 
0147 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......