Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-23 07:41:13

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 F04FieldMessenger.cc
0027 /// \brief Implementation of the F04FieldMessenger class
0028 
0029 #include "F04FieldMessenger.hh"
0030 
0031 #include "F04DetectorConstruction.hh"
0032 #include "F04GlobalField.hh"
0033 
0034 #include "G4UIcmdWithADoubleAndUnit.hh"
0035 #include "G4UIcmdWithAString.hh"
0036 #include "G4UIcmdWithAnInteger.hh"
0037 #include "G4UIcmdWithoutParameter.hh"
0038 #include "G4UIdirectory.hh"
0039 
0040 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0041 
0042 F04FieldMessenger::F04FieldMessenger(F04GlobalField* pEMfield, F04DetectorConstruction* detector)
0043   : fGlobalField(pEMfield)
0044 {
0045   fDetector = detector;
0046 
0047   fDetDir = new G4UIdirectory("/field/");
0048   fDetDir->SetGuidance(" Field tracking control ");
0049 
0050   fCaptureB1Cmd = new G4UIcmdWithADoubleAndUnit("/field/SetCaptureB1", this);
0051   fCaptureB1Cmd->SetGuidance("Set B1 of the Capture Magnet");
0052   fCaptureB1Cmd->SetParameterName("CSizeB1", false, false);
0053   fCaptureB1Cmd->SetDefaultUnit("tesla");
0054   fCaptureB1Cmd->SetRange("CSizeB1>0.");
0055   fCaptureB1Cmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0056 
0057   fCaptureB2Cmd = new G4UIcmdWithADoubleAndUnit("/field/SetCaptureB2", this);
0058   fCaptureB2Cmd->SetGuidance("Set B2 of the Capture Magnet");
0059   fCaptureB2Cmd->SetParameterName("CSizeB2", false, false);
0060   fCaptureB2Cmd->SetDefaultUnit("tesla");
0061   fCaptureB2Cmd->SetRange("CSizeB2>0.");
0062   fCaptureB2Cmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0063 
0064   fTransferBCmd = new G4UIcmdWithADoubleAndUnit("/field/SetTransferB", this);
0065   fTransferBCmd->SetGuidance("Set B of the Transfer Magnet");
0066   fTransferBCmd->SetParameterName("TSizeB", false, false);
0067   fTransferBCmd->SetDefaultUnit("tesla");
0068   fTransferBCmd->SetRange("TSizeB>0.");
0069   fTransferBCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0070 
0071   fStepperCMD = new G4UIcmdWithAnInteger("/field/setStepperType", this);
0072   fStepperCMD->SetGuidance("Select stepper type for field");
0073   fStepperCMD->SetParameterName("choice", true);
0074   fStepperCMD->SetDefaultValue(4);
0075   fStepperCMD->AvailableForStates(G4State_PreInit, G4State_Idle);
0076 
0077   fMinStepCMD = new G4UIcmdWithADoubleAndUnit("/field/setMinStep", this);
0078   fMinStepCMD->SetGuidance("Define minimal step");
0079   fMinStepCMD->SetParameterName("min step", false, false);
0080   fMinStepCMD->SetDefaultUnit("mm");
0081   fMinStepCMD->AvailableForStates(G4State_PreInit, G4State_Idle);
0082 
0083   fDeltaChordCMD = new G4UIcmdWithADoubleAndUnit("/field/setDeltaChord", this);
0084   fDeltaChordCMD->SetGuidance("Define delta chord");
0085   fDeltaChordCMD->SetParameterName("delta chord", false, false);
0086   fDeltaChordCMD->SetDefaultUnit("mm");
0087   fDeltaChordCMD->AvailableForStates(G4State_PreInit, G4State_Idle);
0088 
0089   fDeltaOneStepCMD = new G4UIcmdWithADoubleAndUnit("/field/setDeltaOneStep", this);
0090   fDeltaOneStepCMD->SetGuidance("Define delta one step");
0091   fDeltaOneStepCMD->SetParameterName("delta one step", false, false);
0092   fDeltaOneStepCMD->SetDefaultUnit("mm");
0093   fDeltaOneStepCMD->AvailableForStates(G4State_PreInit, G4State_Idle);
0094 
0095   fDeltaIntersectionCMD = new G4UIcmdWithADoubleAndUnit("/field/setDeltaIntersection", this);
0096   fDeltaIntersectionCMD->SetGuidance("Define delta intersection");
0097   fDeltaIntersectionCMD->SetParameterName("delta intersection", false, false);
0098   fDeltaIntersectionCMD->SetDefaultUnit("mm");
0099   fDeltaIntersectionCMD->AvailableForStates(G4State_PreInit, G4State_Idle);
0100 
0101   fEpsMinCMD = new G4UIcmdWithADoubleAndUnit("/field/setEpsMin", this);
0102   fEpsMinCMD->SetGuidance("Define eps min");
0103   fEpsMinCMD->SetParameterName("eps min", false, false);
0104   fEpsMinCMD->SetDefaultUnit("mm");
0105   fEpsMinCMD->AvailableForStates(G4State_PreInit, G4State_Idle);
0106 
0107   fEpsMaxCMD = new G4UIcmdWithADoubleAndUnit("/field/setEpsMax", this);
0108   fEpsMaxCMD->SetGuidance("Define eps max");
0109   fEpsMaxCMD->SetParameterName("eps max", false, false);
0110   fEpsMaxCMD->SetDefaultUnit("mm");
0111   fEpsMaxCMD->AvailableForStates(G4State_PreInit, G4State_Idle);
0112 }
0113 
0114 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0115 
0116 F04FieldMessenger::~F04FieldMessenger()
0117 {
0118   delete fDetDir;
0119 
0120   delete fCaptureB1Cmd;
0121   delete fCaptureB2Cmd;
0122   delete fTransferBCmd;
0123 
0124   delete fStepperCMD;
0125   delete fMinStepCMD;
0126   delete fDeltaChordCMD;
0127   delete fDeltaOneStepCMD;
0128   delete fDeltaIntersectionCMD;
0129   delete fEpsMinCMD;
0130   delete fEpsMaxCMD;
0131 }
0132 
0133 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0134 
0135 void F04FieldMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0136 {
0137   if (command == fCaptureB1Cmd)
0138     fDetector->SetCaptureMgntB1(fCaptureB1Cmd->GetNewDoubleValue(newValue));
0139 
0140   if (command == fCaptureB2Cmd)
0141     fDetector->SetCaptureMgntB2(fCaptureB2Cmd->GetNewDoubleValue(newValue));
0142 
0143   if (command == fTransferBCmd)
0144     fDetector->SetTransferMgntB(fTransferBCmd->GetNewDoubleValue(newValue));
0145 
0146   if (command == fStepperCMD) {
0147     fGlobalField->SetStepperType(fStepperCMD->GetNewIntValue(newValue));
0148   }
0149   if (command == fMinStepCMD) {
0150     fGlobalField->SetMinStep(fMinStepCMD->GetNewDoubleValue(newValue));
0151   }
0152   if (command == fDeltaChordCMD) {
0153     fGlobalField->SetDeltaChord(fDeltaChordCMD->GetNewDoubleValue(newValue));
0154   }
0155   if (command == fDeltaOneStepCMD) {
0156     fGlobalField->SetDeltaOneStep(fDeltaOneStepCMD->GetNewDoubleValue(newValue));
0157   }
0158   if (command == fDeltaIntersectionCMD) {
0159     fGlobalField->SetDeltaIntersection(fDeltaIntersectionCMD->GetNewDoubleValue(newValue));
0160   }
0161   if (command == fEpsMinCMD) {
0162     fGlobalField->SetEpsMin(fEpsMinCMD->GetNewDoubleValue(newValue));
0163   }
0164   if (command == fEpsMaxCMD) {
0165     fGlobalField->SetEpsMax(fEpsMaxCMD->GetNewDoubleValue(newValue));
0166   }
0167 }