Back to home page

EIC code displayed by LXR

 
 

    


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

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 //
0027 /// \file VG01DetectorMessenger.cc
0028 /// \brief Implementation of the VG01DetectorMessenger class
0029 
0030 //  Authors: J. Apostolakis & S. Wenzel (CERN)  2018-2021
0031 //
0032 //  Started from FullCMS code by Mihaly Novak (CERN) 2017
0033 
0034 #include "VG01DetectorMessenger.hh"
0035 
0036 #include "VG01DetectorConstruction.hh"
0037 
0038 #include "G4UIcmdWithADoubleAndUnit.hh"
0039 #include "G4UIcmdWithAString.hh"
0040 #include "G4UIdirectory.hh"
0041 #include "globals.hh"
0042 
0043 VG01DetectorMessenger::VG01DetectorMessenger(VG01DetectorConstruction* myDet)
0044   : G4UImessenger(), fDetector(myDet)
0045 {
0046   fDetectorDir = new G4UIdirectory("/mydet/");
0047   fDetectorDir->SetGuidance("Detector control.");
0048 
0049   fFieldCommand = new G4UIcmdWithADoubleAndUnit("/mydet/setField", this);
0050   fFieldCommand->SetGuidance("Define uniform magnetic field along Z.");
0051   fFieldCommand->SetGuidance(" -> in unit of  [Tesla]");
0052   fFieldCommand->SetParameterName("By", false);
0053   fFieldCommand->SetDefaultValue(0.0);
0054   fFieldCommand->SetUnitCategory("Magnetic flux density");
0055   fFieldCommand->AvailableForStates(G4State_PreInit, G4State_Idle);
0056 
0057   fGDMLCommand = new G4UIcmdWithAString("/mydet/setGdmlFile", this);
0058   fGDMLCommand->SetGuidance("Set the GDML file.");
0059   fGDMLCommand->SetDefaultValue("TestNTST.gdml");
0060   fGDMLCommand->AvailableForStates(G4State_PreInit, G4State_Idle);
0061 }
0062 
0063 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0064 
0065 VG01DetectorMessenger::~VG01DetectorMessenger()
0066 {
0067   delete fFieldCommand;
0068   delete fDetectorDir;
0069 }
0070 
0071 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0072 
0073 void VG01DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0074 {
0075   if (command == fFieldCommand) {
0076     fDetector->SetMagFieldValue(fFieldCommand->GetNewDoubleValue(newValue));
0077   }
0078   else {
0079     if (command == fGDMLCommand) {
0080       fDetector->SetGDMLFileName(newValue);
0081     }
0082     else {
0083       G4cerr << "VG01DetectorMessenger: ERROR> Unknown command " << G4endl;
0084     }
0085   }
0086 }