Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-01 07:50:14

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 "G4UIcmdWithADoubleAndUnit.hh"
0034 #include "G4UIcmdWithAString.hh"
0035 #include "G4UIcmdWithAnInteger.hh"
0036 #include "G4UIcmdWithoutParameter.hh"
0037 #include "G4UIdirectory.hh"
0038 
0039 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0040 
0041 DetectorMessenger::DetectorMessenger(DetectorConstruction* Det) : fDetector(Det)
0042 {
0043   G4bool broadcast = false;
0044   fDetDir = new G4UIdirectory("/det/", broadcast);
0045   fDetDir->SetGuidance("Detector control");
0046 
0047   fAbsMaterCmd = new G4UIcmdWithAString("/det/setAbsMat", this);
0048   fAbsMaterCmd->SetGuidance("Select Material of the Absorber.");
0049   fAbsMaterCmd->SetParameterName("AbsMat", false);
0050   fAbsMaterCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0051 
0052   fGapMaterCmd = new G4UIcmdWithAString("/det/setGapMat", this);
0053   fGapMaterCmd->SetGuidance("Select Material of the Gap.");
0054   fGapMaterCmd->SetParameterName("GapMat", false);
0055   fGapMaterCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0056 
0057   fAbsThickCmd = new G4UIcmdWithADoubleAndUnit("/det/setAbsThick", this);
0058   fAbsThickCmd->SetGuidance("Set Thickness of the Absorber");
0059   fAbsThickCmd->SetParameterName("AbsThick", false);
0060   fAbsThickCmd->SetRange("AbsThick>=0.");
0061   fAbsThickCmd->SetUnitCategory("Length");
0062   fAbsThickCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0063 
0064   fGapThickCmd = new G4UIcmdWithADoubleAndUnit("/det/setGapThick", this);
0065   fGapThickCmd->SetGuidance("Set Thickness of the Gap");
0066   fGapThickCmd->SetParameterName("GapThick", false);
0067   fGapThickCmd->SetRange("GapThick>=0.");
0068   fGapThickCmd->SetUnitCategory("Length");
0069   fGapThickCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0070 
0071   fSizeYZCmd = new G4UIcmdWithADoubleAndUnit("/det/setSizeYZ", this);
0072   fSizeYZCmd->SetGuidance("Set tranverse size of the calorimeter");
0073   fSizeYZCmd->SetParameterName("SizeYZ", false);
0074   fSizeYZCmd->SetRange("SizeYZ>0.");
0075   fSizeYZCmd->SetUnitCategory("Length");
0076   fSizeYZCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0077 
0078   fNbLayersCmd = new G4UIcmdWithAnInteger("/det/setNbOfLayers", this);
0079   fNbLayersCmd->SetGuidance("Set number of layers.");
0080   fNbLayersCmd->SetParameterName("NbLayers", false);
0081   fNbLayersCmd->SetRange("NbLayers>0 && NbLayers<500");
0082   fNbLayersCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0083 }
0084 
0085 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0086 
0087 DetectorMessenger::~DetectorMessenger()
0088 {
0089   delete fNbLayersCmd;
0090   delete fAbsMaterCmd;
0091   delete fGapMaterCmd;
0092   delete fAbsThickCmd;
0093   delete fGapThickCmd;
0094   delete fSizeYZCmd;
0095   delete fDetDir;
0096 }
0097 
0098 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0099 
0100 void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0101 {
0102   if (command == fAbsMaterCmd) {
0103     fDetector->SetAbsorberMaterial(newValue);
0104     return;
0105   }
0106 
0107   if (command == fGapMaterCmd) {
0108     fDetector->SetGapMaterial(newValue);
0109     return;
0110   }
0111 
0112   if (command == fAbsThickCmd) {
0113     fDetector->SetAbsorberThickness(fAbsThickCmd->GetNewDoubleValue(newValue));
0114     return;
0115   }
0116 
0117   if (command == fGapThickCmd) {
0118     fDetector->SetGapThickness(fGapThickCmd->GetNewDoubleValue(newValue));
0119     return;
0120   }
0121 
0122   if (command == fSizeYZCmd) {
0123     fDetector->SetCalorSizeYZ(fSizeYZCmd->GetNewDoubleValue(newValue));
0124     return;
0125   }
0126 
0127   if (command == fNbLayersCmd) {
0128     fDetector->SetNbOfLayers(fNbLayersCmd->GetNewIntValue(newValue));
0129     return;
0130   }
0131 }
0132 
0133 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......