Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-18 07:42:19

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 "G4UIcmdWithADoubleAndUnit.hh"
0032 #include "G4UIcmdWithAString.hh"
0033 #include "globals.hh"
0034 
0035 #include "DetectorConstruction.hh"
0036 
0037 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0038 
0039 DetectorMessenger::DetectorMessenger(DetectorConstruction* myDet)
0040   : fDetector(myDet)
0041 {
0042   fDetectorDir = std::make_unique<G4UIdirectory>("/mygeom/");
0043   fDetectorDir->SetGuidance("Detector control.");
0044 
0045   fMaxRangeCmd =
0046     std::make_unique<G4UIcmdWithADoubleAndUnit>("/mygeom/maxRange", this);
0047   fMaxRangeCmd->SetGuidance("Maximum range of secondary electrons.");
0048   fMaxRangeCmd->SetGuidance("This is considered to set the z-size of ");
0049   fMaxRangeCmd->SetGuidance("the world volume.");
0050   fMaxRangeCmd->SetParameterName("range", false);
0051   fMaxRangeCmd->SetDefaultUnit("mm");
0052   fMaxRangeCmd->SetUnitCandidates("um mm cm");
0053   fMaxRangeCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0054 
0055   fHitSelRegZCmd =
0056     std::make_unique<G4UIcmdWithADoubleAndUnit>("/mygeom/hitSelRegZ", this);
0057   fHitSelRegZCmd->SetGuidance("Size of the hit selection region in Z");
0058   fHitSelRegZCmd->SetParameterName("side", false);
0059   fHitSelRegZCmd->SetDefaultUnit("mm");
0060   fHitSelRegZCmd->SetUnitCandidates("um mm cm");
0061   fHitSelRegZCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0062 
0063   fMatNameCmd = std::make_unique<G4UIcmdWithAString>("/mygeom/material", this);
0064   fMatNameCmd->SetGuidance("Name of the material.");
0065   fMatNameCmd->SetParameterName("name", false);
0066   fMatNameCmd->AvailableForStates(G4State_PreInit);
0067 
0068   fHitSelRegXYCmd =
0069     std::make_unique<G4UIcmdWithADoubleAndUnit>("/mygeom/hitSelRegXY", this);
0070   fHitSelRegXYCmd->SetGuidance("Size of the hit selection region in XY");
0071   fHitSelRegXYCmd->SetParameterName("side", false);
0072   fHitSelRegXYCmd->SetDefaultUnit("mm");
0073   fHitSelRegXYCmd->SetUnitCandidates("um mm cm");
0074   fHitSelRegXYCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0075 
0076   fSiteRadiusCmd =
0077     std::make_unique<G4UIcmdWithADoubleAndUnit>("/mygeom/siteRadius", this);
0078   fSiteRadiusCmd->SetGuidance("Radius of the Site");
0079   fSiteRadiusCmd->SetParameterName("radius", false);
0080   fSiteRadiusCmd->SetDefaultUnit("um");
0081   fSiteRadiusCmd->SetUnitCandidates("nm um mm cm");
0082   fSiteRadiusCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0083 }
0084 
0085 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0086 
0087 DetectorMessenger::~DetectorMessenger() = default;
0088 
0089 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0090 
0091 void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0092 {
0093   if (command == fMaxRangeCmd.get()) {
0094     fDetector->SetMaxRange(fMaxRangeCmd->GetNewDoubleValue(newValue));
0095   }
0096   else if (command == fMatNameCmd.get()) {
0097     fDetector->SetMaterial(newValue);
0098   }
0099   else if (command == fHitSelRegZCmd.get()) {
0100     fDetector->SetHitSelRegZ(fHitSelRegZCmd->GetNewDoubleValue(newValue));
0101   }
0102   else if (command == fHitSelRegXYCmd.get()) {
0103     fDetector->SetHitSelRegXY(fHitSelRegXYCmd->GetNewDoubleValue(newValue));
0104   }
0105   else if (command == fSiteRadiusCmd.get()) {
0106     fDetector->SetSiteRadius(fSiteRadiusCmd->GetNewDoubleValue(newValue));
0107   }
0108 }
0109 
0110 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......