|
||||
File indexing completed on 2025-01-18 09:58: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 // G4GeneralParticleSourceData 0027 // 0028 // Class Description: 0029 // 0030 // This class uses the singleton pattern to create a single copy of the data 0031 // needed for the G4GPS class. As yet, only the largest parts have been split 0032 // off. 0033 // 0034 // Thread Safety considerations: 0035 // Singleton creation (G4GeneralParticleSourceData::Instance()) is thread safe. 0036 // Getters are thread-safe if no other thread is adding/deleting a source or 0037 // normalizing. However, please note that the setters are usually accessed via 0038 // messenger. This should be instantiated in master thread. 0039 // 0040 // For convenience Lock and Unlock methods are provided that can be used to 0041 // serialize calls. 0042 // For example: 0043 // gpsdata=G4GeneralParticleSourceData::Instance(); 0044 // gpsdata->Lock(); 0045 // gpsdata->AddASource(1.0); 0046 // gpsdata->Unlock(); 0047 0048 // Author: Andrew Green, 20.03.2014 0049 // -------------------------------------------------------------------- 0050 #ifndef G4GPS_DATA_HH 0051 #define G4GPS_DATA_HH 1 0052 0053 #include "G4SingleParticleSource.hh" 0054 #include "G4Threading.hh" 0055 0056 class G4GeneralParticleSourceData 0057 { 0058 public: 0059 0060 static G4GeneralParticleSourceData* Instance(); 0061 0062 void AddASource(G4double intensity); 0063 void DeleteASource(G4int idx); 0064 void ClearSources(); 0065 0066 void IntensityNormalise(); 0067 0068 inline G4bool Normalised() const 0069 { return normalised; } 0070 0071 G4SingleParticleSource* GetCurrentSource(G4int idx); 0072 inline G4SingleParticleSource* GetCurrentSource() const 0073 { return currentSource; } 0074 0075 inline G4int GetSourceVectorSize() const 0076 { return G4int(sourceVector.size()); } 0077 inline G4int GetIntensityVectorSize() const 0078 { return G4int(sourceIntensity.size()); } 0079 inline G4double GetIntensity(G4int idx) const 0080 { return sourceIntensity.at(idx); } 0081 inline G4double GetSourceProbability(G4int idx) const 0082 { return sourceProbability.at(idx); } 0083 0084 void SetCurrentSourceIntensity(G4double); 0085 0086 inline void SetFlatSampling(G4bool fSamp) 0087 { flat_sampling = fSamp; } 0088 inline G4bool GetFlatSampling() const 0089 { return flat_sampling; } 0090 0091 inline void SetMultipleVertex(G4bool flag) 0092 { multiple_vertex = flag; } 0093 inline G4bool GetMultipleVertex() const 0094 { return multiple_vertex; } 0095 0096 inline G4int GetCurrentSourceIdx() const 0097 { return currentSourceIdx; } 0098 0099 void SetVerbosityAllSources(G4int vl); 0100 0101 void Lock(); 0102 void Unlock(); 0103 //Lock/Unlock shared mutex 0104 0105 private: 0106 0107 G4GeneralParticleSourceData(); 0108 ~G4GeneralParticleSourceData(); 0109 0110 private: 0111 0112 std::vector<G4SingleParticleSource*> sourceVector; 0113 std::vector <G4double> sourceIntensity; 0114 std::vector <G4double> sourceProbability; 0115 0116 G4bool multiple_vertex = false; 0117 G4bool flat_sampling = false; 0118 G4bool normalised = false; 0119 0120 G4int currentSourceIdx = 0; 0121 G4SingleParticleSource* currentSource = nullptr; 0122 G4Mutex mutex; 0123 }; 0124 0125 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |