Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-10 08:06:17

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