Geant4  10.01
G4GeneralParticleSourceData.hh
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // -------------------------------------------------------------------
28 //
29 // GEANT4 Class file
30 //
31 //
32 // File name: G4GeneralParticleSourceData.hh
33 //
34 // Author: Andrew Green
35 //
36 // Creation date: 20 Mar 2014
37 //
38 // Class Description:
39 // This class uses the singleton pattern to create a single copy of the data
40 // needed for the G4GPS class. As yet, only the largest parts have been split
41 // off.
42 //
43 // Thread Safety:
44 // Singleton creation (G4GeneralParticleSourceData::Instance()) is thread safe.
45 // Getters are thread-safe if no other thread is adding/deleting a source or normalizing
46 // However please note that the setters are usually accessed via messenger. This should be
47 // instantiated in master thread.
48 //
49 // For convinience Lock and Unlock methods are provided that can be used to serialize calls.
50 // For example:
51 // gpsdata=G4GeneralParticleSourceData::Instance();
52 // gpsdata->Lock();
53 // gpsdata->AddASource(1.0);
54 // gpsdata->Unlock();
55 
56 
57 #ifndef G4GPS_DATA_HH
58 #define G4GPS_DATA_HH 1
59 
61 #include "G4Threading.hh"
62 
64 {
65  public:
67 
68  void AddASource(G4double intensity);
69  void DeleteASource(G4int idx);
70  void ClearSources();
71  void SetSourceVerbosity(G4int verb);
72 
73  void IntensityNormalise();
74 
75  G4bool Normalised() const {return normalised;}
76 
79 
80  G4int GetSourceVectorSize() const {return G4int(sourceVector.size());}
82  G4double GetIntensity(G4int idx)const {return sourceIntensity.at(idx);}
84 
86  void SetFlatSampling(G4bool fSamp){flat_sampling = fSamp;}
87 
88  //Lock/Unlock shared mutex
89  void Lock();
90  void Unlock();
91 
92  private:
95 
96 
97  private:
98 
99  //static G4GeneralParticleSourceData* theInstance;
100 
101  std::vector<G4SingleParticleSource*> sourceVector;
102  std::vector <G4double> sourceIntensity;
103  std::vector <G4double> sourceProbability;
104 
107 
111 };
112 
113 #endif
void SetSourceVerbosity(G4int verb)
G4SingleParticleSource * GetCurrentSource() const
int G4int
Definition: G4Types.hh:78
G4double GetSourceProbability(G4int idx) const
bool G4bool
Definition: G4Types.hh:79
G4double GetIntensity(G4int idx) const
G4int G4Mutex
Definition: G4Threading.hh:161
double G4double
Definition: G4Types.hh:76
std::vector< G4SingleParticleSource * > sourceVector
static G4GeneralParticleSourceData * Instance()