Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-18 08:32:09

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 "G4UIcmdWithoutParameter.hh"
0036 #include "G4UIdirectory.hh"
0037 #include "globals.hh"
0038 
0039 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0040 
0041 DetectorMessenger::DetectorMessenger(DetectorConstruction* myDet) : fDetector(myDet)
0042 {
0043   fDetectorDir = new G4UIdirectory("/mydet/");
0044   fDetectorDir->SetGuidance("Detector control.");
0045 
0046   fMaterialTracker = new G4UIcmdWithAString("/mydet/material_tracker", this);
0047   fMaterialTracker->SetGuidance("Choice of the material for the Tracker:");
0048   fMaterialTracker->SetGuidance("   a Geant4 NIST material, e.g. G4_Si ");
0049   fMaterialTracker->SetParameterName("choiceMaterial", true);
0050   fMaterialTracker->SetDefaultValue("G4_Si");
0051   fMaterialTracker->AvailableForStates(G4State_PreInit, G4State_Idle);
0052 
0053   fMaterialEmCalo = new G4UIcmdWithAString("/mydet/material_emCalo", this);
0054   fMaterialEmCalo->SetGuidance("Choice of the material for the EM calo:");
0055   fMaterialEmCalo->SetGuidance("   a Geant4 NIST material, e.g. G4_Pb ");
0056   fMaterialEmCalo->SetParameterName("choiceMaterial", true);
0057   fMaterialEmCalo->SetDefaultValue("G4_Pb");
0058   fMaterialEmCalo->AvailableForStates(G4State_PreInit, G4State_Idle);
0059 
0060   fMaterialHadCalo = new G4UIcmdWithAString("/mydet/material_hadCalo", this);
0061   fMaterialHadCalo->SetGuidance("Choice of the material for the HAD calo:");
0062   fMaterialHadCalo->SetGuidance("   a Geant4 NIST material, e.g. G4_Fe ");
0063   fMaterialHadCalo->SetParameterName("choiceMaterial", true);
0064   fMaterialHadCalo->SetDefaultValue("G4_Fe");
0065   fMaterialHadCalo->AvailableForStates(G4State_PreInit, G4State_Idle);
0066 
0067   fInnerRadiusTracker = new G4UIcmdWithADoubleAndUnit("/mydet/inner_radius_tracker", this);
0068   fInnerRadiusTracker->SetParameterName("choiceInnerRadiusTracker", true);
0069   fInnerRadiusTracker->SetGuidance("Inner radius of the Tracker");
0070   fInnerRadiusTracker->SetDefaultValue(100.0);  // default: 10 cm.
0071   fInnerRadiusTracker->AvailableForStates(G4State_PreInit, G4State_Idle);
0072 
0073   fOuterRadiusTracker = new G4UIcmdWithADoubleAndUnit("/mydet/outer_radius_tracker", this);
0074   fOuterRadiusTracker->SetParameterName("choiceOuterRadiusTracker", true);
0075   fOuterRadiusTracker->SetGuidance("Outer radius of the Tracker");
0076   fOuterRadiusTracker->SetDefaultValue(200.0);  // default: 20 cm.
0077   fOuterRadiusTracker->AvailableForStates(G4State_PreInit, G4State_Idle);
0078 
0079   fInnerRadiusEmCalo = new G4UIcmdWithADoubleAndUnit("/mydet/inner_radius_emCalo", this);
0080   fInnerRadiusEmCalo->SetParameterName("choiceInnerRadiusEmCalo", true);
0081   fInnerRadiusEmCalo->SetGuidance("Inner radius of the EM Calo");
0082   fInnerRadiusEmCalo->SetDefaultValue(300.0);  // default: 30 cm.
0083   fInnerRadiusEmCalo->AvailableForStates(G4State_PreInit, G4State_Idle);
0084 
0085   fOuterRadiusEmCalo = new G4UIcmdWithADoubleAndUnit("/mydet/outer_radius_emCalo", this);
0086   fOuterRadiusEmCalo->SetParameterName("choiceOuterRadiusEmCalo", true);
0087   fOuterRadiusEmCalo->SetGuidance("Outer radius of the EM Calo");
0088   fOuterRadiusEmCalo->SetDefaultValue(600.0);  // default: 60 cm.
0089   fOuterRadiusEmCalo->AvailableForStates(G4State_PreInit, G4State_Idle);
0090 
0091   fInnerRadiusHadCalo = new G4UIcmdWithADoubleAndUnit("/mydet/inner_radius_hadCalo", this);
0092   fInnerRadiusHadCalo->SetParameterName("choiceInnerRadiusHadCalo", true);
0093   fInnerRadiusHadCalo->SetGuidance("Inner radius of the HAD Calo");
0094   fInnerRadiusHadCalo->SetDefaultValue(700.0);  // default: 70 cm.
0095   fInnerRadiusHadCalo->AvailableForStates(G4State_PreInit, G4State_Idle);
0096 
0097   fOuterRadiusHadCalo = new G4UIcmdWithADoubleAndUnit("/mydet/outer_radius_hadCalo", this);
0098   fOuterRadiusHadCalo->SetParameterName("choiceOuterRadiusHadCalo", true);
0099   fOuterRadiusHadCalo->SetGuidance("Outer radius of the HAD Calo");
0100   fOuterRadiusHadCalo->SetDefaultValue(1700.0);  // default: 170 cm.
0101   fOuterRadiusHadCalo->AvailableForStates(G4State_PreInit, G4State_Idle);
0102 
0103   fUpdateCommand = new G4UIcmdWithoutParameter("/mydet/update", this);
0104   fUpdateCommand->SetGuidance("Update geometry.");
0105   fUpdateCommand->SetGuidance("This command MUST be applied before \"beamOn\" ");
0106   fUpdateCommand->SetGuidance("if you changed geometrical value(s).");
0107   fUpdateCommand->AvailableForStates(G4State_Idle);
0108 }
0109 
0110 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0111 
0112 DetectorMessenger::~DetectorMessenger()
0113 {
0114   delete fDetectorDir;
0115   delete fMaterialTracker;
0116   delete fMaterialEmCalo;
0117   delete fMaterialHadCalo;
0118   delete fInnerRadiusTracker;
0119   delete fOuterRadiusTracker;
0120   delete fInnerRadiusEmCalo;
0121   delete fOuterRadiusEmCalo;
0122   delete fInnerRadiusHadCalo;
0123   delete fOuterRadiusHadCalo;
0124   delete fUpdateCommand;
0125 }
0126 
0127 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0128 
0129 void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0130 {
0131   if (command == fMaterialTracker) {
0132     fDetector->SetMaterialTracker(newValue);
0133   }
0134   if (command == fMaterialEmCalo) {
0135     fDetector->SetMaterialEmCalo(newValue);
0136   }
0137   if (command == fMaterialHadCalo) {
0138     fDetector->SetMaterialHadCalo(newValue);
0139   }
0140   if (command == fInnerRadiusTracker) {
0141     fDetector->SetInnerRadiusTracker(fInnerRadiusTracker->GetNewDoubleValue(newValue));
0142   }
0143   if (command == fOuterRadiusTracker) {
0144     fDetector->SetOuterRadiusTracker(fOuterRadiusTracker->GetNewDoubleValue(newValue));
0145   }
0146   if (command == fInnerRadiusEmCalo) {
0147     fDetector->SetInnerRadiusEmCalo(fInnerRadiusEmCalo->GetNewDoubleValue(newValue));
0148   }
0149   if (command == fOuterRadiusEmCalo) {
0150     fDetector->SetOuterRadiusEmCalo(fOuterRadiusEmCalo->GetNewDoubleValue(newValue));
0151   }
0152   if (command == fInnerRadiusHadCalo) {
0153     fDetector->SetInnerRadiusHadCalo(fInnerRadiusHadCalo->GetNewDoubleValue(newValue));
0154   }
0155   if (command == fOuterRadiusHadCalo) {
0156     fDetector->SetOuterRadiusHadCalo(fOuterRadiusHadCalo->GetNewDoubleValue(newValue));
0157   }
0158   if (command == fUpdateCommand) {
0159     fDetector->UpdateGeometry();
0160   }
0161 }
0162 
0163 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......