Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-28 07:17: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 F04DetectorMessenger.cc
0027 /// \brief Implementation of the F04DetectorMessenger class
0028 
0029 #include "F04DetectorMessenger.hh"
0030 
0031 #include "G4UIcmdWithADoubleAndUnit.hh"
0032 #include "G4UIcmdWithAString.hh"
0033 #include "G4UIcmdWithAnInteger.hh"
0034 #include "G4UIcmdWithoutParameter.hh"
0035 #include "G4UIdirectory.hh"
0036 
0037 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0038 
0039 F04DetectorMessenger::F04DetectorMessenger(F04DetectorConstruction* detector) : fDetector(detector)
0040 {
0041   fDetDir = new G4UIdirectory("/field04/");
0042   fDetDir->SetGuidance(" field04 Simulation ");
0043 
0044   fWorldMaterCmd = new G4UIcmdWithAString("/field04/SetWorldMat", this);
0045   fWorldMaterCmd->SetGuidance("Select Material of the World");
0046   fWorldMaterCmd->SetParameterName("wchoice", true);
0047   fWorldMaterCmd->SetDefaultValue("Air");
0048   fWorldMaterCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0049   fWorldMaterCmd->SetToBeBroadcasted(false);
0050 
0051   fWorldRCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetWorldR", this);
0052   fWorldRCmd->SetGuidance("Set Radius of the World");
0053   fWorldRCmd->SetParameterName("WSizeR", false, false);
0054   fWorldRCmd->SetDefaultUnit("cm");
0055   fWorldRCmd->SetRange("WSizeR>0.");
0056   fWorldRCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0057   fWorldRCmd->SetToBeBroadcasted(false);
0058 
0059   fWorldZCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetWorldZ", this);
0060   fWorldZCmd->SetGuidance("Set Length of the World");
0061   fWorldZCmd->SetParameterName("WSizeZ", false, false);
0062   fWorldZCmd->SetDefaultUnit("cm");
0063   fWorldZCmd->SetRange("WSizeZ>0.");
0064   fWorldZCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0065   fWorldZCmd->SetToBeBroadcasted(false);
0066 
0067   fCaptureRCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetCaptureR", this);
0068   fCaptureRCmd->SetGuidance("Set Radius of the Capture Magnet");
0069   fCaptureRCmd->SetParameterName("CSizeR", false, false);
0070   fCaptureRCmd->SetDefaultUnit("cm");
0071   fCaptureRCmd->SetRange("CSizeR>0.");
0072   fCaptureRCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0073   fCaptureRCmd->SetToBeBroadcasted(false);
0074 
0075   fCaptureZCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetCaptureZ", this);
0076   fCaptureZCmd->SetGuidance("Set Length of the Capture Magnet");
0077   fCaptureZCmd->SetParameterName("CSizeZ", false, false);
0078   fCaptureZCmd->SetDefaultUnit("cm");
0079   fCaptureZCmd->SetRange("CSizeZ>0.");
0080   fCaptureZCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0081   fCaptureZCmd->SetToBeBroadcasted(false);
0082 
0083   fTransferRCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetTransferR", this);
0084   fTransferRCmd->SetGuidance("Set Radius of the Transfer Magnet");
0085   fTransferRCmd->SetParameterName("TSizeR", false, false);
0086   fTransferRCmd->SetDefaultUnit("cm");
0087   fTransferRCmd->SetRange("TSizeR>0.");
0088   fTransferRCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0089   fTransferRCmd->SetToBeBroadcasted(false);
0090 
0091   fTransferZCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetTransferZ", this);
0092   fTransferZCmd->SetGuidance("Set Length of the Transfer Magnet");
0093   fTransferZCmd->SetParameterName("TSizeZ", false, false);
0094   fTransferZCmd->SetDefaultUnit("cm");
0095   fTransferZCmd->SetRange("TSizeZ>0.");
0096   fTransferZCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0097   fTransferZCmd->SetToBeBroadcasted(false);
0098 
0099   fTransferPCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetTransferP", this);
0100   fTransferPCmd->SetGuidance("Set Z pos of the T-Mgnt from end of C-Mgnt");
0101   fTransferPCmd->SetParameterName("TSizeP", false, false);
0102   fTransferPCmd->SetDefaultUnit("cm");
0103   fTransferPCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0104   fTransferPCmd->SetToBeBroadcasted(false);
0105 
0106   fTgtMaterCmd = new G4UIcmdWithAString("/field04/SetTgtMat", this);
0107   fTgtMaterCmd->SetGuidance("Select Material of the Target");
0108   fTgtMaterCmd->SetParameterName("tchoice", true);
0109   fTgtMaterCmd->SetDefaultValue("Tungsten");
0110   fTgtMaterCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0111   fTgtMaterCmd->SetToBeBroadcasted(false);
0112 
0113   fTgtRadCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetTgtRad", this);
0114   fTgtRadCmd->SetGuidance("Set Radius of the Target");
0115   fTgtRadCmd->SetParameterName("TgtSizeR", false, false);
0116   fTgtRadCmd->SetDefaultUnit("cm");
0117   fTgtRadCmd->SetRange("TgtSizeR>0.");
0118   fTgtRadCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0119   fTgtRadCmd->SetToBeBroadcasted(false);
0120 
0121   fTgtThickCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetTgtThick", this);
0122   fTgtThickCmd->SetGuidance("Set Thickness of the Target");
0123   fTgtThickCmd->SetParameterName("TgtSizeZ", false, false);
0124   fTgtThickCmd->SetDefaultUnit("cm");
0125   fTgtThickCmd->SetRange("TgtSizeZ>0.");
0126   fTgtThickCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0127   fTgtThickCmd->SetToBeBroadcasted(false);
0128 
0129   fTgtPosCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetTgtPos", this);
0130   fTgtPosCmd->SetGuidance("Set Z pos of the tgt relative to C-Mgnt centre");
0131   fTgtPosCmd->SetParameterName("TgtSizeP", false, false);
0132   fTgtPosCmd->SetDefaultUnit("cm");
0133   fTgtPosCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0134   fTgtPosCmd->SetToBeBroadcasted(false);
0135 
0136   fTgtAngCmd = new G4UIcmdWithAnInteger("/field04/SetTgtAng", this);
0137   fTgtAngCmd->SetGuidance("Set the angle [in deg] of the Tgt relative to C-Mgnt centre");
0138   fTgtAngCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0139   fTgtAngCmd->SetToBeBroadcasted(false);
0140 
0141   fDgrMaterCmd = new G4UIcmdWithAString("/field04/SetDgrMat", this);
0142   fDgrMaterCmd->SetGuidance("Select Material of the Degrader");
0143   fDgrMaterCmd->SetParameterName("dchoice", true);
0144   fDgrMaterCmd->SetDefaultValue("Lead");
0145   fDgrMaterCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0146   fDgrMaterCmd->SetToBeBroadcasted(false);
0147 
0148   fDgrRadCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetDgrRad", this);
0149   fDgrRadCmd->SetGuidance("Set Radius of the Degrader");
0150   fDgrRadCmd->SetParameterName("DrgSizeR", false, false);
0151   fDgrRadCmd->SetDefaultUnit("cm");
0152   fDgrRadCmd->SetRange("DrgSizeR>0.");
0153   fDgrRadCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0154   fDgrRadCmd->SetToBeBroadcasted(false);
0155 
0156   fDgrThickCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetDgrThick", this);
0157   fDgrThickCmd->SetGuidance("Set Thickness of the Degrader");
0158   fDgrThickCmd->SetParameterName("DgrSizeZ", false, false);
0159   fDgrThickCmd->SetDefaultUnit("cm");
0160   fDgrThickCmd->SetRange("DgrSizeZ>0.");
0161   fDgrThickCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0162   fDgrThickCmd->SetToBeBroadcasted(false);
0163 
0164   fDgrPosCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetDgrPos", this);
0165   fDgrPosCmd->SetGuidance("Set Z pos of the Dgr relative to T-Mgnt centre");
0166   fDgrPosCmd->SetParameterName("DgrSizeP", false, false);
0167   fDgrPosCmd->SetDefaultUnit("cm");
0168   fDgrPosCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0169   fDgrPosCmd->SetToBeBroadcasted(false);
0170 }
0171 
0172 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0173 
0174 F04DetectorMessenger::~F04DetectorMessenger()
0175 {
0176   delete fDetDir;
0177 
0178   delete fWorldMaterCmd;
0179   delete fWorldRCmd;
0180   delete fWorldZCmd;
0181 
0182   delete fCaptureRCmd;
0183   delete fCaptureZCmd;
0184 
0185   delete fTransferRCmd;
0186   delete fTransferZCmd;
0187   delete fTransferPCmd;
0188 
0189   delete fTgtMaterCmd;
0190   delete fTgtRadCmd;
0191   delete fTgtThickCmd;
0192   delete fTgtPosCmd;
0193   delete fTgtAngCmd;
0194 
0195   delete fDgrMaterCmd;
0196   delete fDgrRadCmd;
0197   delete fDgrThickCmd;
0198   delete fDgrPosCmd;
0199 }
0200 
0201 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0202 
0203 void F04DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0204 {
0205   if (command == fWorldMaterCmd) {
0206     fDetector->SetWorldMaterial(newValue);
0207   }
0208 
0209   if (command == fTgtMaterCmd) {
0210     fDetector->SetTargetMaterial(newValue);
0211   }
0212 
0213   if (command == fDgrMaterCmd) {
0214     fDetector->SetDegraderMaterial(newValue);
0215   }
0216 
0217   if (command == fWorldRCmd) {
0218     fDetector->SetWorldSizeR(fWorldRCmd->GetNewDoubleValue(newValue));
0219   }
0220 
0221   if (command == fWorldZCmd) {
0222     fDetector->SetWorldSizeZ(fWorldZCmd->GetNewDoubleValue(newValue));
0223   }
0224 
0225   if (command == fCaptureRCmd)
0226     fDetector->SetCaptureMgntRadius(fCaptureRCmd->GetNewDoubleValue(newValue));
0227 
0228   if (command == fCaptureZCmd)
0229     fDetector->SetCaptureMgntLength(fCaptureZCmd->GetNewDoubleValue(newValue));
0230 
0231   if (command == fTransferRCmd)
0232     fDetector->SetTransferMgntRadius(fTransferRCmd->GetNewDoubleValue(newValue));
0233 
0234   if (command == fTransferZCmd)
0235     fDetector->SetTransferMgntLength(fTransferZCmd->GetNewDoubleValue(newValue));
0236 
0237   if (command == fTransferPCmd)
0238     fDetector->SetTransferMgntPos(fTransferPCmd->GetNewDoubleValue(newValue));
0239 
0240   if (command == fTgtRadCmd) fDetector->SetTargetRadius(fTgtRadCmd->GetNewDoubleValue(newValue));
0241 
0242   if (command == fTgtThickCmd)
0243     fDetector->SetTargetThickness(fTgtThickCmd->GetNewDoubleValue(newValue));
0244 
0245   if (command == fTgtPosCmd) fDetector->SetTargetPos(fTgtPosCmd->GetNewDoubleValue(newValue));
0246 
0247   if (command == fTgtAngCmd) fDetector->SetTargetAngle(fTgtAngCmd->GetNewIntValue(newValue));
0248 
0249   if (command == fDgrRadCmd) fDetector->SetDegraderRadius(fDgrRadCmd->GetNewDoubleValue(newValue));
0250 
0251   if (command == fDgrThickCmd)
0252     fDetector->SetDegraderThickness(fDgrThickCmd->GetNewDoubleValue(newValue));
0253 
0254   if (command == fDgrPosCmd) fDetector->SetDegraderPos(fDgrPosCmd->GetNewDoubleValue(newValue));
0255 
0256   if (command == fWorldZCmd) fDetector->SetWorldSizeZ(fWorldZCmd->GetNewDoubleValue(newValue));
0257 
0258   if (command == fWorldRCmd) fDetector->SetWorldSizeR(fWorldRCmd->GetNewDoubleValue(newValue));
0259 }