Back to home page

EIC code displayed by LXR

 
 

    


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

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 //
0027 /// \file optical/LXe/src/LXeDetectorMessenger.cc
0028 /// \brief Implementation of the LXeDetectorMessenger class
0029 //
0030 //
0031 #include "LXeDetectorMessenger.hh"
0032 
0033 #include "LXeDetectorConstruction.hh"
0034 
0035 #include "G4RunManager.hh"
0036 #include "G4Scintillation.hh"
0037 #include "G4UIcmdWith3VectorAndUnit.hh"
0038 #include "G4UIcmdWithABool.hh"
0039 #include "G4UIcmdWithADouble.hh"
0040 #include "G4UIcmdWithADoubleAndUnit.hh"
0041 #include "G4UIcmdWithAnInteger.hh"
0042 #include "G4UIcommand.hh"
0043 #include "G4UIdirectory.hh"
0044 
0045 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0046 
0047 LXeDetectorMessenger::LXeDetectorMessenger(LXeDetectorConstruction* detector)
0048   : fLXeDetector(detector)
0049 {
0050   // Setup a command directory for detector controls with guidance
0051   fDetectorDir = new G4UIdirectory("/LXe/detector/");
0052   fDetectorDir->SetGuidance("Detector geometry control");
0053 
0054   fVolumesDir = new G4UIdirectory("/LXe/detector/volumes/");
0055   fVolumesDir->SetGuidance("Enable/disable volumes");
0056 
0057   // Various commands for modifying detector geometry
0058   fDimensionsCmd = new G4UIcmdWith3VectorAndUnit("/LXe/detector/dimensions", this);
0059   fDimensionsCmd->SetGuidance("Set the dimensions of the detector volume.");
0060   fDimensionsCmd->SetParameterName("scint_x", "scint_y", "scint_z", false);
0061   fDimensionsCmd->SetDefaultUnit("cm");
0062   fDimensionsCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0063   fDimensionsCmd->SetToBeBroadcasted(false);
0064 
0065   fHousingThicknessCmd = new G4UIcmdWithADoubleAndUnit("/LXe/detector/housingThickness", this);
0066   fHousingThicknessCmd->SetGuidance("Set the thickness of the housing.");
0067   fHousingThicknessCmd->SetParameterName("d_mtl", false);
0068   fHousingThicknessCmd->SetDefaultUnit("cm");
0069   fHousingThicknessCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0070   fHousingThicknessCmd->SetToBeBroadcasted(false);
0071 
0072   fPmtRadiusCmd = new G4UIcmdWithADoubleAndUnit("/LXe/detector/pmtRadius", this);
0073   fPmtRadiusCmd->SetGuidance("Set the radius of the PMTs.");
0074   fPmtRadiusCmd->SetParameterName("radius", false);
0075   fPmtRadiusCmd->SetDefaultUnit("cm");
0076   fPmtRadiusCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0077   fPmtRadiusCmd->SetToBeBroadcasted(false);
0078 
0079   fNxCmd = new G4UIcmdWithAnInteger("/LXe/detector/nx", this);
0080   fNxCmd->SetGuidance("Set the number of PMTs along the x-dimension.");
0081   fNxCmd->SetParameterName("nx", false);
0082   fNxCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0083   fNxCmd->SetToBeBroadcasted(false);
0084 
0085   fNyCmd = new G4UIcmdWithAnInteger("/LXe/detector/ny", this);
0086   fNyCmd->SetGuidance("Set the number of PMTs along the y-dimension.");
0087   fNyCmd->SetParameterName("ny", false);
0088   fNyCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0089   fNyCmd->SetToBeBroadcasted(false);
0090 
0091   fNzCmd = new G4UIcmdWithAnInteger("/LXe/detector/nz", this);
0092   fNzCmd->SetGuidance("Set the number of PMTs along the z-dimension.");
0093   fNzCmd->SetParameterName("nz", false);
0094   fNzCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0095   fNzCmd->SetToBeBroadcasted(false);
0096 
0097   fSphereCmd = new G4UIcmdWithABool("/LXe/detector/volumes/sphere", this);
0098   fSphereCmd->SetGuidance("Enable/Disable the sphere.");
0099   fSphereCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0100   fSphereCmd->SetToBeBroadcasted(false);
0101 
0102   fReflectivityCmd = new G4UIcmdWithADouble("/LXe/detector/reflectivity", this);
0103   fReflectivityCmd->SetGuidance("Set the reflectivity of the housing.");
0104   fReflectivityCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0105   fReflectivityCmd->SetToBeBroadcasted(false);
0106 
0107   fWlsCmd = new G4UIcmdWithABool("/LXe/detector/volumes/wls", this);
0108   fWlsCmd->SetGuidance("Enable/Disable the WLS slab");
0109   fWlsCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0110   fWlsCmd->SetToBeBroadcasted(false);
0111 
0112   fLxeCmd = new G4UIcmdWithABool("/LXe/detector/volumes/lxe", this);
0113   fLxeCmd->SetGuidance("Enable/Disable the main detector volume.");
0114   fLxeCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0115   fLxeCmd->SetToBeBroadcasted(false);
0116 
0117   fNFibersCmd = new G4UIcmdWithAnInteger("/LXe/detector/nfibers", this);
0118   fNFibersCmd->SetGuidance("Set the number of WLS fibers in the WLS slab.");
0119   fNFibersCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0120   fNFibersCmd->SetToBeBroadcasted(false);
0121 
0122   fMainScintYield = new G4UIcmdWithADouble("/LXe/detector/MainScintYield", this);
0123   fMainScintYield->SetGuidance("Set scinitillation yield of main volume.");
0124   fMainScintYield->SetGuidance("Specified in photons/MeV");
0125   fMainScintYield->AvailableForStates(G4State_PreInit, G4State_Idle);
0126   fMainScintYield->SetToBeBroadcasted(false);
0127 
0128   fWLSScintYield = new G4UIcmdWithADouble("/LXe/detector/WLSScintYield", this);
0129   fWLSScintYield->SetGuidance("Set scintillation yield of WLS Slab");
0130   fWLSScintYield->SetGuidance("Specified in photons/MeV");
0131   fWLSScintYield->AvailableForStates(G4State_PreInit, G4State_Idle);
0132   fWLSScintYield->SetToBeBroadcasted(false);
0133 
0134   fSaveThresholdCmd = new G4UIcmdWithAnInteger("/LXe/saveThreshold", this);
0135   fSaveThresholdCmd->SetGuidance(
0136     "Set the photon count threshold for saving the random number seed");
0137   fSaveThresholdCmd->SetParameterName("photons", true);
0138   fSaveThresholdCmd->SetDefaultValue(4500);
0139   fSaveThresholdCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0140 
0141   fDefaultsCmd = new G4UIcommand("/LXe/detector/defaults", this);
0142   fDefaultsCmd->SetGuidance("Set all detector geometry values to defaults.");
0143   fDefaultsCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0144   fDefaultsCmd->SetToBeBroadcasted(false);
0145 }
0146 
0147 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0148 
0149 LXeDetectorMessenger::~LXeDetectorMessenger()
0150 {
0151   delete fDimensionsCmd;
0152   delete fHousingThicknessCmd;
0153   delete fPmtRadiusCmd;
0154   delete fNxCmd;
0155   delete fNyCmd;
0156   delete fNzCmd;
0157   delete fSphereCmd;
0158   delete fWlsCmd;
0159   delete fLxeCmd;
0160   delete fNFibersCmd;
0161   delete fReflectivityCmd;
0162   delete fMainScintYield;
0163   delete fWLSScintYield;
0164   delete fSaveThresholdCmd;
0165   delete fDefaultsCmd;
0166   delete fDetectorDir;
0167   delete fVolumesDir;
0168 }
0169 
0170 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0171 
0172 void LXeDetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0173 {
0174   if (command == fDimensionsCmd) {
0175     fLXeDetector->SetDimensions(fDimensionsCmd->GetNew3VectorValue(newValue));
0176   }
0177   else if (command == fHousingThicknessCmd) {
0178     fLXeDetector->SetHousingThickness(fHousingThicknessCmd->GetNewDoubleValue(newValue));
0179   }
0180   else if (command == fPmtRadiusCmd) {
0181     fLXeDetector->SetPMTRadius(fPmtRadiusCmd->GetNewDoubleValue(newValue));
0182   }
0183   else if (command == fNxCmd) {
0184     fLXeDetector->SetNX(fNxCmd->GetNewIntValue(newValue));
0185   }
0186   else if (command == fNyCmd) {
0187     fLXeDetector->SetNY(fNyCmd->GetNewIntValue(newValue));
0188   }
0189   else if (command == fNzCmd) {
0190     fLXeDetector->SetNZ(fNzCmd->GetNewIntValue(newValue));
0191   }
0192   else if (command == fSphereCmd) {
0193     fLXeDetector->SetSphereOn(fSphereCmd->GetNewBoolValue(newValue));
0194   }
0195   else if (command == fReflectivityCmd) {
0196     fLXeDetector->SetHousingReflectivity(fReflectivityCmd->GetNewDoubleValue(newValue));
0197   }
0198   else if (command == fWlsCmd) {
0199     fLXeDetector->SetWLSSlabOn(fWlsCmd->GetNewBoolValue(newValue));
0200   }
0201   else if (command == fLxeCmd) {
0202     fLXeDetector->SetMainVolumeOn(fLxeCmd->GetNewBoolValue(newValue));
0203   }
0204   else if (command == fNFibersCmd) {
0205     fLXeDetector->SetNFibers(fNFibersCmd->GetNewIntValue(newValue));
0206   }
0207   else if (command == fMainScintYield) {
0208     fLXeDetector->SetMainScintYield(fMainScintYield->GetNewDoubleValue(newValue));
0209   }
0210   else if (command == fWLSScintYield) {
0211     fLXeDetector->SetWLSScintYield(fWLSScintYield->GetNewDoubleValue(newValue));
0212   }
0213   else if (command == fSaveThresholdCmd) {
0214     fLXeDetector->SetSaveThreshold(fSaveThresholdCmd->GetNewIntValue(newValue));
0215   }
0216   else if (command == fDefaultsCmd) {
0217     fLXeDetector->SetDefaults();
0218     G4RunManager::GetRunManager()->ReinitializeGeometry();
0219   }
0220 }