Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:20:41

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