Back to home page

EIC code displayed by LXR

 
 

    


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

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 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 "G4UIcmdWithAnInteger.hh"
0039 #include "G4UIcmdWithoutParameter.hh"
0040 #include "G4UIcommand.hh"
0041 #include "G4UIdirectory.hh"
0042 #include "G4UIparameter.hh"
0043 
0044 #include <sstream>
0045 
0046 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0047 
0048 DetectorMessenger::DetectorMessenger(DetectorConstruction* Det) : G4UImessenger(), fDetector(Det)
0049 {
0050   fDetDir.reset(new G4UIdirectory("/det/"));
0051   fDetDir->SetGuidance("detector construction commands");
0052 
0053   fSizeYZCmd.reset(new G4UIcmdWithADoubleAndUnit("/det/setSizeYZ", this));
0054   fSizeYZCmd->SetGuidance("Set tranverse size of the calorimeter");
0055   fSizeYZCmd->SetParameterName("Size", false);
0056   fSizeYZCmd->SetRange("Size>0.");
0057   fSizeYZCmd->SetUnitCategory("Length");
0058   fSizeYZCmd->AvailableForStates(G4State_PreInit);
0059   fSizeYZCmd->SetToBeBroadcasted(false);
0060 
0061   fNbLayersCmd.reset(new G4UIcmdWithAnInteger("/det/setNbOfLayers", this));
0062   fNbLayersCmd->SetGuidance("Set number of layers.");
0063   fNbLayersCmd->SetParameterName("NbLayers", false);
0064   fNbLayersCmd->SetRange("NbLayers>0");
0065   fNbLayersCmd->AvailableForStates(G4State_PreInit);
0066   fNbLayersCmd->SetToBeBroadcasted(false);
0067 
0068   fNbAbsorCmd.reset(new G4UIcmdWithAnInteger("/det/setNbOfAbsor", this));
0069   fNbAbsorCmd->SetGuidance("Set number of Absorbers.");
0070   fNbAbsorCmd->SetParameterName("NbAbsor", false);
0071   fNbAbsorCmd->SetRange("NbAbsor>0");
0072   fNbAbsorCmd->AvailableForStates(G4State_PreInit);
0073   fNbAbsorCmd->SetToBeBroadcasted(false);
0074 
0075   fAbsorCmd.reset(new G4UIcommand("/det/setAbsor", this));
0076   fAbsorCmd->SetGuidance("Set the absor nb, the material, the thickness.");
0077   fAbsorCmd->SetGuidance("  absor number : from 1 to NbOfAbsor");
0078   fAbsorCmd->SetGuidance("  material name");
0079   fAbsorCmd->SetGuidance("  thickness (with unit) : t>0.");
0080   //
0081   G4UIparameter* AbsNbPrm = new G4UIparameter("AbsorNb", 'i', false);
0082   AbsNbPrm->SetGuidance("absor number : from 1 to NbOfAbsor");
0083   AbsNbPrm->SetParameterRange("AbsorNb>0");
0084   fAbsorCmd->SetParameter(AbsNbPrm);
0085   //
0086   G4UIparameter* MatPrm = new G4UIparameter("material", 's', false);
0087   MatPrm->SetGuidance("material name");
0088   fAbsorCmd->SetParameter(MatPrm);
0089   //
0090   G4UIparameter* ThickPrm = new G4UIparameter("thickness", 'd', false);
0091   ThickPrm->SetGuidance("thickness of absorber");
0092   ThickPrm->SetParameterRange("thickness>0.");
0093   fAbsorCmd->SetParameter(ThickPrm);
0094   //
0095   G4UIparameter* unitPrm = new G4UIparameter("unit", 's', false);
0096   unitPrm->SetGuidance("unit of thickness");
0097   G4String unitList = G4UIcommand::UnitsList(G4UIcommand::CategoryOf("mm"));
0098   unitPrm->SetParameterCandidates(unitList);
0099   fAbsorCmd->SetParameter(unitPrm);
0100   //
0101   fAbsorCmd->AvailableForStates(G4State_PreInit);
0102   fAbsorCmd->SetToBeBroadcasted(false);
0103 }
0104 
0105 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0106 
0107 DetectorMessenger::~DetectorMessenger() = default;
0108 
0109 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0110 
0111 void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0112 {
0113   if (command == fSizeYZCmd.get()) {
0114     fDetector->SetCalorSizeYZ(fSizeYZCmd->GetNewDoubleValue(newValue));
0115   }
0116   else if (command == fNbLayersCmd.get()) {
0117     fDetector->SetNbOfLayers(fNbLayersCmd->GetNewIntValue(newValue));
0118   }
0119   else if (command == fNbAbsorCmd.get()) {
0120     fDetector->SetNbOfAbsor(fNbAbsorCmd->GetNewIntValue(newValue));
0121   }
0122   else if (command == fAbsorCmd.get()) {
0123     G4int num;
0124     G4double tick;
0125     G4String unt, mat;
0126     std::istringstream is(newValue);
0127     is >> num >> mat >> tick >> unt;
0128     G4String material = mat;
0129     tick *= G4UIcommand::ValueOf(unt);
0130     fDetector->SetAbsorMaterial(num, material);
0131     fDetector->SetAbsorThickness(num, tick);
0132   }
0133 }
0134 
0135 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......