Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/Geant4/G4GeneralParticleSourceMessenger.hh was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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 // G4GeneralParticleSourceMessenger
0027 //
0028 // Class Description:
0029 //
0030 // The function of the G4GeneralParticleSourceMessenger is to allow the user to
0031 // enter commands either in interactive command line mode or through macros to
0032 // control the G4GeneralParticleSource. 
0033 
0034 // Author: Fan Lei, QinetiQ ltd.
0035 // Customer: ESA/ESTEC
0036 // History:
0037 // - Version 2.0, 05/02/2004, Fan Lei - Created.
0038 //     Multiple particle source definition
0039 // - Version 2.1, 20/03/2014, Andrew Green - Modifications for MT
0040 //     Added a check to force only one thread to parse the macro file.
0041 //     This information is fed into the GPS which now has a split mechanism
0042 //     for the large data (hence need to only read in 1 thread)
0043 // - Version 3.0, Aug-Oct 2014, Andrea Dotti
0044 //   Transformations for thread safety and use in MT application
0045 //   Messenger is now a singleton w/ explicit Destroy() method for deletion
0046 //   Note the following: the class should be instantiated only once
0047 //   by a worker thread. It relies on a new feature of basic messenger class
0048 //   that allows for UI commands to be created by worker threads but being
0049 //   executed by master thread. For this reason the messenger itself should
0050 //   be created once, form here the singleton pattern
0051 // --------------------------------------------------------------------
0052 #ifndef G4GeneralParticleSourceMessenger_hh
0053 #define G4GeneralParticleSourceMessenger_hh 1
0054 
0055 #include "G4UImessenger.hh"
0056 #include "globals.hh"
0057 
0058 class G4ParticleTable;
0059 class G4UIcommand;
0060 class G4UIdirectory;
0061 class G4UIcmdWithoutParameter;
0062 class G4UIcmdWithAString;
0063 class G4UIcmdWithADoubleAndUnit;
0064 class G4UIcmdWith3Vector;
0065 class G4UIcmdWith3VectorAndUnit;
0066 class G4UIcmdWithAnInteger;
0067 class G4UIcmdWithADouble;
0068 class G4UIcmdWithABool;
0069 class G4UIcmdWithoutParameter;
0070 
0071 class G4SingleParticleSource;
0072 class G4GeneralParticleSource;
0073 
0074 class G4GeneralParticleSourceMessenger: public G4UImessenger
0075 {
0076   public:
0077 
0078     void SetParticleGun(G4SingleParticleSource *fpg) { fParticleGun = fpg; } ;
0079       // Select the particle gun to be defined/modified
0080    
0081     void SetNewValue(G4UIcommand* command, G4String newValues) override;
0082       // Identifies the command which has been invoked by the user, extracts the
0083       // parameters associated with that command (held in newValues), and uses
0084       // these values with the appropriate member function of
0085       // G4GeneralParticleSource
0086 
0087     G4String GetCurrentValue(G4UIcommand* command) override;
0088       // Allows the user to retrieve the current values of parameters.
0089       // NOT yet implemented!
0090 
0091     static G4GeneralParticleSourceMessenger* GetInstance(G4GeneralParticleSource*);
0092     static void Destroy();
0093 
0094  private:
0095 
0096     explicit G4GeneralParticleSourceMessenger(G4GeneralParticleSource*);
0097       // Constructor: sets up commands
0098     ~G4GeneralParticleSourceMessenger() override;
0099       // Destructor: deletes commands
0100 
0101     void IonCommand(G4String newValues);
0102     void IonLvlCommand(G4String newValues);
0103 
0104   private:
0105 
0106     G4GeneralParticleSource* fGPS = nullptr;
0107     G4SingleParticleSource* fParticleGun = nullptr;
0108     G4ParticleTable* particleTable = nullptr;
0109     G4String histtype;
0110     
0111     G4UIdirectory* gpsDirectory;
0112 
0113     // Multiple source control commands
0114     //
0115     G4UIdirectory              *sourceDirectory;
0116     G4UIcmdWithADouble         *addsourceCmd;
0117     G4UIcmdWithoutParameter    *listsourceCmd;
0118     G4UIcmdWithoutParameter    *clearsourceCmd;
0119     G4UIcmdWithoutParameter    *getsourceCmd;
0120     G4UIcmdWithAnInteger       *setsourceCmd;  
0121     G4UIcmdWithADouble         *setintensityCmd;
0122     G4UIcmdWithAnInteger       *deletesourceCmd;
0123     G4UIcmdWithABool           *multiplevertexCmd;
0124     G4UIcmdWithABool           *flatsamplingCmd;
0125 
0126     // Positional commands
0127     //
0128     G4UIdirectory              *positionDirectory;
0129     G4UIcmdWithAString         *typeCmd1;
0130     G4UIcmdWithAString         *shapeCmd1;
0131     G4UIcmdWith3VectorAndUnit  *centreCmd1;
0132     G4UIcmdWith3Vector         *posrot1Cmd1;
0133     G4UIcmdWith3Vector         *posrot2Cmd1;
0134     G4UIcmdWithADoubleAndUnit  *halfxCmd1;
0135     G4UIcmdWithADoubleAndUnit  *halfyCmd1;
0136     G4UIcmdWithADoubleAndUnit  *halfzCmd1;
0137     G4UIcmdWithADoubleAndUnit  *radiusCmd1;
0138     G4UIcmdWithADoubleAndUnit  *radius0Cmd1;
0139     G4UIcmdWithADoubleAndUnit  *possigmarCmd1;
0140     G4UIcmdWithADoubleAndUnit  *possigmaxCmd1;
0141     G4UIcmdWithADoubleAndUnit  *possigmayCmd1;
0142     G4UIcmdWithADoubleAndUnit  *paralpCmd1;
0143     G4UIcmdWithADoubleAndUnit  *partheCmd1;
0144     G4UIcmdWithADoubleAndUnit  *parphiCmd1;  
0145     G4UIcmdWithAString         *confineCmd1;
0146     
0147     // Angular commands
0148     //
0149     G4UIdirectory* angularDirectory;
0150     G4UIcmdWithAString         *angtypeCmd1;
0151     G4UIcmdWith3Vector         *angrot1Cmd1;
0152     G4UIcmdWith3Vector         *angrot2Cmd1;
0153     G4UIcmdWithADoubleAndUnit  *minthetaCmd1;
0154     G4UIcmdWithADoubleAndUnit  *maxthetaCmd1;
0155     G4UIcmdWithADoubleAndUnit  *minphiCmd1;
0156     G4UIcmdWithADoubleAndUnit  *maxphiCmd1;
0157     G4UIcmdWithADoubleAndUnit  *angsigmarCmd1;
0158     G4UIcmdWithADoubleAndUnit  *angsigmaxCmd1;
0159     G4UIcmdWithADoubleAndUnit  *angsigmayCmd1;
0160     G4UIcmdWith3VectorAndUnit  *angfocusCmd;
0161     G4UIcmdWithABool           *useuserangaxisCmd1;
0162     G4UIcmdWithABool           *surfnormCmd1;
0163 
0164     // Energy commands
0165     //
0166     G4UIdirectory* energyDirectory;
0167     G4UIcmdWithAString         *energytypeCmd1;
0168     G4UIcmdWithADoubleAndUnit  *eminCmd1;
0169     G4UIcmdWithADoubleAndUnit  *emaxCmd1;
0170     G4UIcmdWithADoubleAndUnit  *monoenergyCmd1;
0171     G4UIcmdWithADoubleAndUnit  *engsigmaCmd1;
0172     G4UIcmdWithADouble         *alphaCmd1;
0173     G4UIcmdWithADouble         *tempCmd1;
0174     G4UIcmdWithADouble         *ezeroCmd1;
0175     G4UIcmdWithADouble         *gradientCmd1;
0176     G4UIcmdWithADouble         *interceptCmd1;
0177     G4UIcmdWithADouble         *arbeintCmd1;
0178     G4UIcmdWithoutParameter    *calculateCmd1;
0179     G4UIcmdWithABool           *energyspecCmd1;
0180     G4UIcmdWithABool           *diffspecCmd1;
0181     G4UIcmdWithABool           *applyEnergyWeightCmd1;
0182 
0183     // Histogram commands
0184     //
0185     G4UIdirectory              *histDirectory;
0186     G4UIcmdWith3Vector         *histpointCmd1;
0187     G4UIcmdWithAString         *histfileCmd1;
0188     G4UIcmdWithAString         *histnameCmd1;
0189     G4UIcmdWithAString         *arbintCmd1;
0190     G4UIcmdWithAString         *resethistCmd1;
0191 
0192     G4UIcmdWithAnInteger* verbosityCmd;
0193 
0194     // Commands from G4ParticleGun
0195     //
0196     G4UIcommand* ionCmd;
0197     G4UIcommand* ionLvlCmd;
0198     G4UIcmdWithAString* particleCmd;
0199     G4UIcmdWithADoubleAndUnit* timeCmd;
0200     G4UIcmdWith3Vector* polCmd;
0201     G4UIcmdWithAnInteger* numberCmd;
0202     G4UIcmdWith3VectorAndUnit* positionCmd;
0203     G4UIcmdWith3Vector* directionCmd;
0204     G4UIcmdWithADoubleAndUnit* energyCmd;
0205     G4UIcmdWithoutParameter* listCmd;
0206 
0207     // For ion shooting
0208     //
0209     G4bool   fShootIon = false; 
0210 
0211     G4int    fAtomicNumber = 0;
0212     G4int    fAtomicMass = 0;
0213     G4int    fIonCharge = 0;
0214     G4double fIonExciteEnergy = 0.0;
0215 
0216     G4int    fAtomicNumberL = 0;
0217     G4int    fAtomicMassL = 0;
0218     G4int    fIonChargeL = 0;
0219     G4int    fIonEnergyLevel = 0;
0220 
0221 /** Andrea Dotti Feb 2015
0222  * GPS messenger design requires some explanation for what distributions
0223  * parameters are concerned : Each thread has its own GPS
0224  * since primary generation is a user action.
0225  * However to save memory the underlying structures that provide the
0226  * GPS functionalities ( the G4SPS*Distribution classes and the
0227  * G4SPSRandomGenerator class)
0228  * are shared among threads. This implies that modifying parameters of sources
0229  * requires some attention:
0230  * 1- Only one thread should change source parameters.
0231  * 2- Changing of parameters can happen only between runs, when is guaranteed
0232  *    that no thread is accessing them
0233  * 2- UI commands require that even if messenger is instantiated in a thread
0234  *    the commands are executed in the master (this is possible since V10.1)
0235  * The simplest solution is to use UI commands to change GPS parameters and
0236  * avoid C++ APIs. If this is inevitable a simple solution is to instantiate
0237  * an instance of G4GeneralParticleSource explicitly in the master thread
0238  * (for example in G4VUserActionInitialization::BuildForMaster() and set the
0239  * defaults parameter there).
0240  */
0241 
0242 };
0243 
0244 #endif