Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-22 08:51:15

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 // G4GlobalMagFieldMessenger
0027 //
0028 // Class description:
0029 //
0030 // Global uniform magnetic field messenger class. 
0031 //
0032 // It defines UI commands:
0033 // - /globalField/setValue vx vy vz unit
0034 // - /globalField/verbose level
0035 //
0036 // It creates/deletes the global uniform magnetic field and
0037 // activates/inactivates it according to the set field value.
0038 // The field value can be changed either interactively via 
0039 // the UI command or via SetFieldValue() function.
0040 
0041 // Author: Ivana Hrivnacova (IN2P3/IJCLab Orsay), 28 August 2013
0042 // --------------------------------------------------------------------
0043 #ifndef G4GlobalMagFieldMessenger_hh
0044 #define G4GlobalMagFieldMessenger_hh 1
0045 
0046 #include "globals.hh"
0047 #include "G4UImessenger.hh"
0048 
0049 class G4UniformMagField;
0050 class G4UIdirectory;
0051 class G4UIcmdWith3VectorAndUnit;
0052 class G4UIcmdWithAnInteger;
0053 
0054 /**
0055  * @brief G4GlobalMagFieldMessenger, a global uniform magnetic field messenger
0056  * class. It creates/deletes the global uniform magnetic field and
0057  * activates/inactivates it according to the set field value.
0058  * The field value can be changed either interactively via the UI command or
0059  * via the SetFieldValue() function.
0060  */
0061 
0062 class G4GlobalMagFieldMessenger : public G4UImessenger
0063 {
0064   public:
0065 
0066     /**
0067      * Constructor and Destructor.
0068      */
0069     G4GlobalMagFieldMessenger(const G4ThreeVector& value = G4ThreeVector());
0070     ~G4GlobalMagFieldMessenger() override;
0071     
0072     /**
0073      * Setter for UI command.
0074      */
0075     void SetNewValue(G4UIcommand*, G4String) override;
0076 
0077     /**
0078      * Setter and accessor for the field value.
0079      */
0080     void SetFieldValue(const G4ThreeVector& value);
0081     G4ThreeVector GetFieldValue() const;
0082     
0083     /**
0084      * Verbosity control.
0085      */
0086     inline void SetVerboseLevel(G4int verboseLevel);
0087     inline G4int GetVerboseLevel() const;
0088     
0089   private:
0090 
0091     void SetField(const G4ThreeVector& value, const G4String& inFunction);
0092     
0093     G4UniformMagField* fMagField = nullptr;
0094     G4int fVerboseLevel = 0;
0095 
0096     G4UIdirectory* fDirectory = nullptr;
0097     G4UIcmdWith3VectorAndUnit* fSetValueCmd = nullptr;
0098     G4UIcmdWithAnInteger* fSetVerboseCmd = nullptr;
0099 };
0100 
0101 // --------------------------------------------------------------------
0102 // inline functions
0103 // --------------------------------------------------------------------
0104 
0105 inline void G4GlobalMagFieldMessenger::SetVerboseLevel(G4int verboseLevel)
0106 {
0107   fVerboseLevel = verboseLevel;
0108 }
0109 
0110 inline G4int G4GlobalMagFieldMessenger::GetVerboseLevel() const
0111 {
0112   return fVerboseLevel;
0113 }
0114     
0115 #endif