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 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /event/include/G4SPSRandomGenerator.hh (Version 11.3.0) and /event/include/G4SPSRandomGenerator.hh (Version 9.6.p3)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // G4SPSRandomGenerator                        <<  26 ///////////////////////////////////////////////////////////////////////////////
                                                   >>  27 //
                                                   >>  28 // MODULE:        G4SPSRandomGenerator.hh
                                                   >>  29 //
                                                   >>  30 // Version:      1.0
                                                   >>  31 // Date:         5/02/04
                                                   >>  32 // Author:       Fan Lei 
                                                   >>  33 // Organisation: QinetiQ ltd.
                                                   >>  34 // Customer:     ESA/ESTEC
                                                   >>  35 //
                                                   >>  36 ///////////////////////////////////////////////////////////////////////////////
                                                   >>  37 //
                                                   >>  38 // CHANGE HISTORY
                                                   >>  39 // --------------
                                                   >>  40 //
                                                   >>  41 // 26/10/2004 F Lei
                                                   >>  42 //    Created separated the theta, phi generators for position distributions.
                                                   >>  43 //
                                                   >>  44 // Version 1.0, 05/02/2004, Fan Lei, Created.
                                                   >>  45 //    Based on the G4GeneralParticleSource class in Geant4 v6.0
                                                   >>  46 //
                                                   >>  47 ///////////////////////////////////////////////////////////////////////////////
 27 //                                                 48 //
 28 // Class Description:                              49 // Class Description:
 29 //                                                 50 //
 30 // Special random number generator used by G4G     51 // Special random number generator used by G4GeneralParticleSource to allow 
 31 // biasing applied at the lowest level for all     52 // biasing applied at the lowest level for all distributions.
 32 // This is a shared class between threads.     <<  53 //
 33 // Only one thread should use the set-methods  <<  54 ///////////////////////////////////////////////////////////////////////////////
 34 // Note that this is exactly what is achieved  <<  55 //
 35 // If you use the set methods to set defaults  <<  56 // MEMBER FUNCTIONS
 36 // application take care that only one thread  <<  57 // ----------------
 37 // In addition take care of calling these meth <<  58 //
 38 // Do not use the setters during the event loo <<  59 // G4SPSRandomGenerator ()
 39                                                <<  60 //    Constructor: Initializes variables
 40 // Author: Fan Lei, QinetiQ ltd.               <<  61 //
 41 // Customer: ESA/ESTEC                         <<  62 // ~G4SPSRandomGenerator ()
 42 // History:                                    <<  63 //    Destructor: 
 43 // - 05/02/2004, Fan Lei - Created.            <<  64 //
 44 //     Based on the G4GeneralParticleSource cl <<  65 // void SetXBias(G4ThreeVector)
 45 // - 06/06/2014, Andrea Dotti                  <<  66 //    Allows the user to re-distribute the random
 46 //     Added a mutex to protect access to shar <<  67 //    numbers used to generate x co-ordinates.
 47 //     Getters and Setters are mutex'd but not <<  68 //
 48 //     because it is assumed these are called  <<  69 // void SetYBias(G4ThreeVector)
 49 //     during which the status of this class i <<  70 //    Allows the user to re-distribute the random
 50 // ------------------------------------------- <<  71 //    numbers used to generate y co-ordinates.
 51 #ifndef G4SPSRandomGenerator_hh                <<  72 //
 52 #define G4SPSRandomGenerator_hh 1              <<  73 // void SetZBias(G4ThreeVector)
                                                   >>  74 //    Allows the user to re-distribute the random
                                                   >>  75 //    numbers used to generate z co-ordinates.
                                                   >>  76 //
                                                   >>  77 // void SetThetaBias(G4ThreeVector)
                                                   >>  78 //    Allows the user to re-distribute the random
                                                   >>  79 //    numbers used to generate values of theta.
                                                   >>  80 //
                                                   >>  81 // void SetPhiBias(G4ThreeVector)
                                                   >>  82 //    Allows the user to re-distribute the random
                                                   >>  83 //    numbers used to generate values of phi.
                                                   >>  84 //
                                                   >>  85 // void SetPosThetaBias(G4ThreeVector)
                                                   >>  86 //    Allows the user to re-distribute the random
                                                   >>  87 //    numbers used to generate values of theta for position distribution.
                                                   >>  88 //
                                                   >>  89 // void SetPosPhiBias(G4ThreeVector)
                                                   >>  90 //    Allows the user to re-distribute the random
                                                   >>  91 //    numbers used to generate values of phi for position distribution.
                                                   >>  92 //
                                                   >>  93 // void SetEnergyBias(G4ThreeVector)
                                                   >>  94 //    Allows the user to re-distribute the random
                                                   >>  95 //    numbers used to generate the energies.
                                                   >>  96 //
                                                   >>  97 // G4double GenRandX()
                                                   >>  98 //    Generates the random number for x, with or without biasing.
                                                   >>  99 //
                                                   >> 100 // G4double GenRandY()
                                                   >> 101 //    Generates the random number for y, with or without biasing.
                                                   >> 102 //
                                                   >> 103 // G4double GenRandZ()
                                                   >> 104 //    Generates the random number for z, with or without biasing.
                                                   >> 105 //
                                                   >> 106 // G4double GenRandTheta()
                                                   >> 107 //    Generates the random number for theta, with or without biasing.
                                                   >> 108 //
                                                   >> 109 // G4double GenRandPhi()
                                                   >> 110 //    Generates the random number for phi, with or without biasing.
                                                   >> 111 //
                                                   >> 112 // G4double GenRandEnergy()
                                                   >> 113 //    Generates the random number for energy, with or without biasing.
                                                   >> 114 //
                                                   >> 115 // G4double GenRandPosTheta()
                                                   >> 116 //    Generates the random number for theta, with or without biasing for position distribution.
                                                   >> 117 //
                                                   >> 118 // G4double GenRandPosPhi()
                                                   >> 119 //    Generates the random number for phi, with or without biasing for position distribution.
                                                   >> 120 //
                                                   >> 121 //  inline G4double GetBiasWeight()
                                                   >> 122 //    Returns the weight change after biasing
                                                   >> 123 // 
                                                   >> 124 //  void ReSetHist(G4String);
                                                   >> 125 //    Re-sets the histogram for user defined distribution
                                                   >> 126 //
                                                   >> 127 // void SetVerbosity(G4int)
                                                   >> 128 //    Sets the verbosity level.
                                                   >> 129 //
                                                   >> 130 ///////////////////////////////////////////////////////////////////////////////
                                                   >> 131 //
                                                   >> 132 #ifndef G4SPSRandomGenerator_h
                                                   >> 133 #define G4SPSRandomGenerator_h 1
 53                                                   134 
 54 #include "G4PhysicsFreeVector.hh"              << 135 #include "G4PhysicsOrderedFreeVector.hh"
 55 #include "G4DataInterpolation.hh"                 136 #include "G4DataInterpolation.hh"
 56 #include "G4ThreeVector.hh"                    << 137 
 57 #include "G4Threading.hh"                      << 138 class G4SPSRandomGenerator {
 58 #include "G4Cache.hh"                          << 139 public:
 59                                                << 140   G4SPSRandomGenerator();
 60 class G4SPSRandomGenerator                     << 141   ~G4SPSRandomGenerator();
 61 {                                              << 142 
 62   public:                                      << 143   //  static G4SPSRandomGenerator* getInstance ();
 63                                                << 144 
 64     G4SPSRandomGenerator();                    << 145   // Biasing Methods
 65       // Constructor: initializes variables    << 146   void SetXBias(G4ThreeVector);
 66                                                << 147   void SetYBias(G4ThreeVector);
 67    ~G4SPSRandomGenerator();                    << 148   void SetZBias(G4ThreeVector);
 68       // Destructor                            << 149   void SetThetaBias(G4ThreeVector);
 69                                                << 150   void SetPhiBias(G4ThreeVector);
 70     // Biasing Methods                         << 151   void SetEnergyBias(G4ThreeVector);
 71                                                << 152   void SetPosThetaBias(G4ThreeVector);
 72     void SetXBias(const G4ThreeVector&);       << 153   void SetPosPhiBias(G4ThreeVector);
 73       // Allows the user to re-distribute the  << 154   G4double GenRandX();
 74       // numbers used to generate x co-ordinat << 155   G4double GenRandY();
 75                                                << 156   G4double GenRandZ();
 76     void SetYBias(const G4ThreeVector&);       << 157   G4double GenRandTheta();
 77       // Allows the user to re-distribute the  << 158   G4double GenRandPhi();
 78       // numbers used to generate y co-ordinat << 159   G4double GenRandEnergy();
 79                                                << 160   G4double GenRandPosTheta();
 80     void SetZBias(const G4ThreeVector&);       << 161   G4double GenRandPosPhi();
 81       // Allows the user to re-distribute the  << 162 
 82       // numbers used to generate z co-ordinat << 163   inline void SetIntensityWeight(G4double weight) {
 83                                                << 164     bweights[8] = weight;
 84     void SetThetaBias(const G4ThreeVector&);   << 165   }
 85       // Allows the user to re-distribute the  << 166   ;
 86       // numbers used to generate values of th << 167 
 87                                                << 168   inline G4double GetBiasWeight() {
 88     void SetPhiBias(const G4ThreeVector&);     << 169     return bweights[0] * bweights[1] * bweights[2] * bweights[3]
 89       // Allows the user to re-distribute the  << 170         * bweights[4] * bweights[5] * bweights[6] * bweights[7]
 90       // numbers used to generate values of ph << 171         * bweights[8];
 91                                                << 172   }
 92     void SetEnergyBias(const G4ThreeVector&);  << 173   ;
 93     // Allows the user to re-distribute the ra << 174 
 94     // numbers used to generate the energies   << 175   // method to re-set the histograms
 95                                                << 176   void ReSetHist(G4String);
 96     void SetPosThetaBias(const G4ThreeVector&) << 177 
 97       // Allows the user to re-distribute the  << 178   // Set the verbosity level.
 98       // numbers used to generate values of th << 179   void SetVerbosity(G4int a) {
 99                                                << 180     verbosityLevel = a;
100     void SetPosPhiBias(const G4ThreeVector&);  << 181   }
101       // Allows the user to re-distribute the  << 182   ;
102       // numbers used to generate values of ph << 183 
103                                                << 184 private:
104     G4double GenRandX();                       << 185 
105       // Generates the random number for x, wi << 186   //  static G4SPSRandomGenerator  *instance;
106                                                << 187 
107     G4double GenRandY();                       << 188   G4bool XBias, IPDFXBias;
108       // Generates the random number for y, wi << 189   G4PhysicsOrderedFreeVector XBiasH;
109                                                << 190   G4PhysicsOrderedFreeVector IPDFXBiasH;
110     G4double GenRandZ();                       << 191   G4bool YBias, IPDFYBias;
111       // Generates the random number for z, wi << 192   G4PhysicsOrderedFreeVector YBiasH;
112                                                << 193   G4PhysicsOrderedFreeVector IPDFYBiasH;
113     G4double GenRandTheta();                   << 194   G4bool ZBias, IPDFZBias;
114       // Generates the random number for theta << 195   G4PhysicsOrderedFreeVector ZBiasH;
115                                                << 196   G4PhysicsOrderedFreeVector IPDFZBiasH;
116     G4double GenRandPhi();                     << 197   G4bool ThetaBias, IPDFThetaBias;
117       // Generates the random number for phi,  << 198   G4PhysicsOrderedFreeVector ThetaBiasH;
118                                                << 199   G4PhysicsOrderedFreeVector IPDFThetaBiasH;
119     G4double GenRandEnergy();                  << 200   G4bool PhiBias, IPDFPhiBias;
120       // Generates the random number for energ << 201   G4PhysicsOrderedFreeVector PhiBiasH;
121                                                << 202   G4PhysicsOrderedFreeVector IPDFPhiBiasH;
122     G4double GenRandPosTheta();                << 203   G4bool EnergyBias, IPDFEnergyBias;
123       // Generates the random number for theta << 204   G4PhysicsOrderedFreeVector EnergyBiasH;
124       // for position distribution             << 205   G4PhysicsOrderedFreeVector IPDFEnergyBiasH;
125                                                << 206   G4bool PosThetaBias, IPDFPosThetaBias;
126     G4double GenRandPosPhi();                  << 207   G4PhysicsOrderedFreeVector PosThetaBiasH;
127       // Generates the random number for phi,  << 208   G4PhysicsOrderedFreeVector IPDFPosThetaBiasH;
128       // for position distribution             << 209   G4bool PosPhiBias, IPDFPosPhiBias;
129                                                << 210   G4PhysicsOrderedFreeVector PosPhiBiasH;
130     void SetIntensityWeight(G4double weight);  << 211   G4PhysicsOrderedFreeVector IPDFPosPhiBiasH;
131                                                << 212 
132     G4double GetBiasWeight() const ;           << 213   //G4double alpha;   // for biasing energy
133       // Returns the weight change after biasi << 214 
134                                                << 215   G4double bweights[9]; //record x,y,z,theta,phi,energy,posThet,posPhi,intensity weights
135         // method to re-set the histograms     << 216 
136     void ReSetHist(const G4String&);           << 217   // Verbosity
137       // Resets the histogram for user defined << 218   G4int verbosityLevel;
138                                                << 219 
139     void SetVerbosity(G4int a);                << 220   G4PhysicsOrderedFreeVector ZeroPhysVector; // for re-set only
140       // Sets the verbosity level              << 221 
141                                                << 
142   private:                                     << 
143                                                << 
144     // Encapsulate in a struct to guarantee th << 
145     // initial state is set via constructor    << 
146     //                                         << 
147     struct a_check                             << 
148     {                                          << 
149       G4bool val;                              << 
150       a_check() { val = false; }               << 
151     };                                         << 
152                                                << 
153     // See .cc for an explanation of this in m << 
154     //                                         << 
155     G4Cache<a_check> local_IPDFXBias;          << 
156     G4bool XBias, IPDFXBias;                   << 
157     G4PhysicsFreeVector XBiasH;                << 
158     G4PhysicsFreeVector IPDFXBiasH;            << 
159     G4Cache<a_check> local_IPDFYBias;          << 
160     G4bool YBias, IPDFYBias;                   << 
161     G4PhysicsFreeVector YBiasH;                << 
162     G4PhysicsFreeVector IPDFYBiasH;            << 
163     G4Cache<a_check> local_IPDFZBias;          << 
164     G4bool ZBias, IPDFZBias;                   << 
165     G4PhysicsFreeVector ZBiasH;                << 
166     G4PhysicsFreeVector IPDFZBiasH;            << 
167     G4Cache<a_check> local_IPDFThetaBias;      << 
168     G4bool ThetaBias, IPDFThetaBias;           << 
169     G4PhysicsFreeVector ThetaBiasH;            << 
170     G4PhysicsFreeVector IPDFThetaBiasH;        << 
171     G4Cache<a_check> local_IPDFPhiBias;        << 
172     G4bool PhiBias, IPDFPhiBias;               << 
173     G4PhysicsFreeVector PhiBiasH;              << 
174     G4PhysicsFreeVector IPDFPhiBiasH;          << 
175     G4Cache<a_check> local_IPDFEnergyBias;     << 
176     G4bool EnergyBias, IPDFEnergyBias;         << 
177     G4PhysicsFreeVector EnergyBiasH;           << 
178     G4PhysicsFreeVector IPDFEnergyBiasH;       << 
179     G4Cache<a_check> local_IPDFPosThetaBias;   << 
180     G4bool PosThetaBias, IPDFPosThetaBias;     << 
181     G4PhysicsFreeVector PosThetaBiasH;         << 
182     G4PhysicsFreeVector IPDFPosThetaBiasH;     << 
183     G4Cache<a_check> local_IPDFPosPhiBias;     << 
184     G4bool PosPhiBias, IPDFPosPhiBias;         << 
185     G4PhysicsFreeVector PosPhiBiasH;           << 
186     G4PhysicsFreeVector IPDFPosPhiBiasH;       << 
187                                                << 
188     struct bweights_t                          << 
189     {                                          << 
190       G4double w[9];                           << 
191       bweights_t();                            << 
192       G4double& operator[] (const int i);      << 
193     };                                         << 
194     G4Cache<bweights_t> bweights;              << 
195       // record x,y,z,theta,phi,energy,posThet << 
196                                                << 
197     G4int verbosityLevel;                      << 
198       // Verbosity                             << 
199                                                << 
200     G4Mutex mutex;                             << 
201       // Protect shared resources              << 
202 };                                                222 };
203                                                   223 
204 #endif                                            224 #endif
                                                   >> 225 
205                                                   226