Geant4 Cross Reference |
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 // G4VDecayChannel << 27 // 26 // 28 // Class description: << 27 // $Id: G4VDecayChannel.hh,v 1.12 2006/06/29 19:24:50 gunter Exp $ >> 28 // GEANT4 tag $Name: geant4-08-01-patch-01 $ 29 // 29 // 30 // Abstract class to describe decay kinematics << 30 // >> 31 // ------------------------------------------------------------ >> 32 // GEANT 4 class header file >> 33 // >> 34 // History: first implementation, based on object model of >> 35 // 27 July 1996 H.Kurashige >> 36 // 30 May 1997 H.Kurashige >> 37 // 23 Mar. 2000 H.Weber : add GetAngularMomentum() >> 38 // ------------------------------------------------------------ >> 39 #ifndef G4VDecayChannel_h >> 40 #define G4VDecayChannel_h 1 31 41 32 // Author: H.Kurashige, 27 July 1996 << 33 // ------------------------------------------- << 34 #ifndef G4VDecayChannel_hh << 35 #define G4VDecayChannel_hh 1 << 36 << 37 #include "G4AutoLock.hh" << 38 #include "G4Threading.hh" << 39 #include "G4ThreeVector.hh" << 40 #include "G4ios.hh" 42 #include "G4ios.hh" 41 #include "globals.hh" 43 #include "globals.hh" 42 << 43 #include <cmath> 44 #include <cmath> 44 45 45 class G4ParticleDefinition; << 46 class G4ParticleDefinition; 46 class G4DecayProducts; << 47 class G4DecayProducts; 47 class G4ParticleTable; << 48 class G4ParticleTable; 48 49 49 class G4VDecayChannel 50 class G4VDecayChannel 50 { 51 { 51 public: << 52 // Class Description 52 // Constructors << 53 // This class is a abstract class to describe decay kinematics 53 G4VDecayChannel(const G4String& aName, G4i << 54 // 54 G4VDecayChannel(const G4String& aName, con << 55 G4int theNumberOfDaughters << 56 const G4String& theDaughte << 57 const G4String& theDaughte << 58 << 59 // Destructor << 60 virtual ~G4VDecayChannel(); << 61 << 62 // Equality operators << 63 G4bool operator==(const G4VDecayChannel& r << 64 G4bool operator!=(const G4VDecayChannel& r << 65 << 66 // Less-than operator is defined for G4Dec << 67 inline G4bool operator<(const G4VDecayChan << 68 << 69 virtual G4DecayProducts* DecayIt(G4double << 70 << 71 // Get kinematics name << 72 inline const G4String& GetKinematicsName() << 73 << 74 // Get branching ratio << 75 inline G4double GetBR() const; << 76 << 77 // Get number of daughter particles << 78 inline G4int GetNumberOfDaughters() const; << 79 << 80 // Get the pointer to the parent particle << 81 inline G4ParticleDefinition* GetParent(); << 82 << 83 // Get the pointer to a daughter particle << 84 inline G4ParticleDefinition* GetDaughter(G << 85 << 86 // Get the angular momentum of the decay << 87 G4int GetAngularMomentum(); << 88 << 89 // Get the name of the parent particle << 90 inline const G4String& GetParentName() con << 91 << 92 // Get the name of a daughter particle << 93 inline const G4String& GetDaughterName(G4i << 94 << 95 // Get mass of parent << 96 inline G4double GetParentMass() const; << 97 << 98 // Get mass of daughter << 99 inline G4double GetDaughterMass(G4int anIn << 100 55 101 // Set the parent particle (by name or by << 56 public: 102 void SetParent(const G4ParticleDefinition* << 57 //Constructors 103 inline void SetParent(const G4String& part << 58 G4VDecayChannel(const G4String &aName, G4int Verbose = 1); 104 << 59 G4VDecayChannel(const G4String &aName, 105 // Set branching ratio << 60 const G4String& theParentName, 106 void SetBR(G4double value); << 61 G4double theBR, 107 << 62 G4int theNumberOfDaughters, 108 // Set number of daughter particles << 63 const G4String& theDaughterName1, 109 void SetNumberOfDaughters(G4int value); << 64 const G4String& theDaughterName2 = "", >> 65 const G4String& theDaughterName3 = "", >> 66 const G4String& theDaughterName4 = "" ); 110 67 111 // Set a daughter particle (by name or by << 68 // Destructor 112 void SetDaughter(G4int anIndex, const G4Pa << 69 virtual ~G4VDecayChannel(); 113 void SetDaughter(G4int anIndex, const G4St << 114 70 115 inline void SetVerboseLevel(G4int value); << 71 private: 116 inline G4int GetVerboseLevel() const; << 72 // copy constructor and assignment operatotr 117 void DumpInfo(); << 73 G4VDecayChannel(const G4VDecayChannel &); >> 74 G4VDecayChannel & operator=(const G4VDecayChannel &); 118 75 119 inline G4double GetRangeMass() const; << 76 public: 120 inline void SetRangeMass(G4double val); << 77 // equality operators 121 virtual G4bool IsOKWithParentMass(G4double << 78 G4int operator==(const G4VDecayChannel &right) const {return (this == &right);}; >> 79 G4int operator!=(const G4VDecayChannel &right) const {return (this != &right);}; >> 80 >> 81 // less-than operator is defined for G4DecayTable >> 82 G4int operator<(const G4VDecayChannel &right) const; >> 83 >> 84 public: // With Description >> 85 virtual G4DecayProducts* DecayIt(G4double parentMass = -1.0) = 0; >> 86 >> 87 public: // With Description >> 88 //get kinematics name >> 89 G4String GetKinematicsName() const; >> 90 //get branching ratio >> 91 G4double GetBR() const; >> 92 //get number of daughter particles >> 93 G4int GetNumberOfDaughters() const; >> 94 >> 95 //get the pointer to the parent particle >> 96 G4ParticleDefinition * GetParent(); >> 97 //get the pointer to a daughter particle >> 98 G4ParticleDefinition * GetDaughter(G4int anIndex); >> 99 >> 100 //get the angular momentum of the decay >> 101 G4int GetAngularMomentum(); >> 102 //get the name of the parent particle >> 103 const G4String& GetParentName() const; >> 104 //get the name of a daughter particle >> 105 const G4String& GetDaughterName(G4int anIndex) const; >> 106 >> 107 // get mass of parent >> 108 G4double GetParentMass() const; >> 109 G4double GetDaughterMass(G4int anIndex) const; >> 110 >> 111 //set the parent particle (by name or by pointer) >> 112 void SetParent(const G4ParticleDefinition * particle_type); >> 113 void SetParent(const G4String &particle_name); >> 114 //set branching ratio >> 115 void SetBR(G4double value); >> 116 //set number of daughter particles >> 117 void SetNumberOfDaughters(G4int value); >> 118 //set a daughter particle (by name or by pointer) >> 119 void SetDaughter(G4int anIndex, >> 120 const G4ParticleDefinition * particle_type); >> 121 void SetDaughter(G4int anIndex, >> 122 const G4String &particle_name); >> 123 >> 124 protected: >> 125 // kinematics name >> 126 G4String kinematics_name; >> 127 // branching ratio [0.0 - 1.0] >> 128 G4double rbranch; >> 129 // number of daughters >> 130 G4int numberOfDaughters; >> 131 // parent particle >> 132 G4String* parent_name; >> 133 //daughter particles >> 134 G4String** daughters_name; 122 135 123 void SetPolarization(const G4ThreeVector&) << 136 protected: // With Description 124 inline const G4ThreeVector& GetPolarizatio << 137 // celar daughters array >> 138 void ClearDaughtersName(); 125 139 126 protected: 140 protected: 127 // Default constructor << 141 // pointer to particle table 128 G4VDecayChannel(); << 142 G4ParticleTable* particletable; 129 << 130 // Copy constructor and assignment operato << 131 G4VDecayChannel(const G4VDecayChannel&); << 132 G4VDecayChannel& operator=(const G4VDecayC << 133 143 134 // Clear daughters array << 144 // temporary buffers of pointers to G4ParticleDefinition 135 void ClearDaughtersName(); << 145 G4ParticleDefinition* parent; >> 146 G4ParticleDefinition** daughters; >> 147 >> 148 // parent mass >> 149 G4double parent_mass; >> 150 G4double* daughters_mass; >> 151 136 152 137 inline void CheckAndFillDaughters(); << 153 // fill daughters array 138 inline void CheckAndFillParent(); << 154 void FillDaughters(); 139 << 155 // fill parent 140 G4double DynamicalMass(G4double massPDG, G << 156 void FillParent(); 141 157 142 protected: << 158 public: // With Description 143 // Kinematics name << 159 void SetVerboseLevel(G4int value); 144 G4String kinematics_name = ""; << 160 G4int GetVerboseLevel() const; 145 // Branching ratio [0.0 - 1.0] << 161 void DumpInfo(); 146 G4double rbranch = 0.0; << 147 // Parent particle << 148 G4String* parent_name = nullptr; << 149 // Daughter particles << 150 G4String** daughters_name = nullptr; << 151 << 152 // Range of mass allowed in decay << 153 G4double rangeMass = 2.5; << 154 << 155 // Polarization of the parent particle << 156 G4ThreeVector parent_polarization; << 157 << 158 // Pointer to particle table << 159 G4ParticleTable* particletable = nullptr; << 160 << 161 static const G4String noName; << 162 << 163 G4ParticleDefinition* G4MT_parent = nullpt << 164 G4ParticleDefinition** G4MT_daughters = nu << 165 G4double G4MT_parent_mass = 0.0; << 166 G4double* G4MT_daughters_mass = nullptr; << 167 G4double* G4MT_daughters_width = nullptr; << 168 G4Mutex daughtersMutex; << 169 G4Mutex parentMutex; << 170 162 171 // Number of daughters << 163 private: 172 G4int numberOfDaughters = 0; << 164 const G4String& GetNoName() const; 173 165 174 // Control flag for output message << 166 private: >> 167 // controle flag for output message >> 168 G4int verboseLevel; 175 // 0: Silent 169 // 0: Silent 176 // 1: Warning message 170 // 1: Warning message 177 // 2: More 171 // 2: More 178 G4int verboseLevel = 1; << 179 << 180 private: << 181 // Fill daughters array << 182 void FillDaughters(); << 183 172 184 // Fill parent << 173 static const G4String noName; 185 void FillParent(); << 186 << 187 const G4String& GetNoName() const; << 188 }; 174 }; 189 175 190 // ------------------------------------------- << 176 inline 191 // Inline methods << 177 G4int G4VDecayChannel::operator<(const G4VDecayChannel &right) const 192 // ------------------------------------------- << 193 << 194 inline G4bool G4VDecayChannel::operator<(const << 195 { 178 { 196 return (this->rbranch < right.rbranch); 179 return (this->rbranch < right.rbranch); 197 } 180 } 198 181 199 inline G4ParticleDefinition* G4VDecayChannel:: << 182 inline 200 { << 183 G4ParticleDefinition* G4VDecayChannel::GetDaughter(G4int anIndex) 201 // pointers to daughter particles are filled << 184 { 202 CheckAndFillDaughters(); << 185 //pointers to daughter particles are filled, if they are not set yet 203 << 186 if (daughters == 0) FillDaughters(); 204 // get the pointer to a daughter particle << 187 205 if ((anIndex >= 0) && (anIndex < numberOfDau << 188 //get the pointer to a daughter particle 206 return G4MT_daughters[anIndex]; << 189 if ( (anIndex>=0) && (anIndex<numberOfDaughters) ) { >> 190 return daughters[anIndex]; >> 191 } else { >> 192 if (verboseLevel>0) >> 193 G4cout << "G4VDecayChannel::GetDaughter index out of range "<<anIndex<<G4endl; >> 194 return 0; 207 } 195 } 208 << 209 if (verboseLevel > 0) << 210 G4cout << "G4VDecayChannel::GetDaughter i << 211 return nullptr; << 212 } 196 } 213 197 214 inline const G4String& G4VDecayChannel::GetDau << 198 inline >> 199 const G4String& G4VDecayChannel::GetDaughterName(G4int anIndex) const 215 { 200 { 216 if ((anIndex >= 0) && (anIndex < numberOfDau << 201 if ( (anIndex>=0) && (anIndex<numberOfDaughters) ) { 217 return *daughters_name[anIndex]; 202 return *daughters_name[anIndex]; >> 203 } else { >> 204 if (verboseLevel>0){ >> 205 G4cout << "G4VDecayChannel::GetDaughterName "; >> 206 G4cout << "index out of range " << anIndex << G4endl; >> 207 } >> 208 return GetNoName(); 218 } 209 } 219 << 220 if (verboseLevel > 0) { << 221 G4cout << "G4VDecayChannel::GetDaughterNam << 222 G4cout << "index out of range " << anIndex << 223 } << 224 return GetNoName(); << 225 } 210 } 226 211 227 inline G4double G4VDecayChannel::GetDaughterMa << 212 inline >> 213 G4double G4VDecayChannel::GetDaughterMass(G4int anIndex) const 228 { 214 { 229 if ((anIndex >= 0) && (anIndex < numberOfDau << 215 if ( (anIndex>=0) && (anIndex<numberOfDaughters) ) { 230 return G4MT_daughters_mass[anIndex]; << 216 return daughters_mass[anIndex]; 231 } << 217 } else { 232 << 218 if (verboseLevel>0){ 233 if (verboseLevel > 0) { << 219 G4cout << "G4VDecayChannel::GetDaughterMass "; 234 G4cout << "G4VDecayChannel::GetDaughterMas << 220 G4cout << "index out of range " << anIndex << G4endl; 235 G4cout << "index out of range " << anIndex << 221 } >> 222 return 0.0; 236 } 223 } 237 return 0.0; << 238 } 224 } 239 225 240 inline G4ParticleDefinition* G4VDecayChannel:: << 226 inline 241 { << 227 G4ParticleDefinition* G4VDecayChannel::GetParent() 242 // the pointer to the parent particle is fil << 228 { 243 CheckAndFillParent(); << 229 //the pointer to the parent particle is filled, if it is not set yet 244 // get the pointer to the parent particle << 230 if (parent == 0) FillParent(); 245 return G4MT_parent; << 231 //get the pointer to the parent particle >> 232 return parent; 246 } 233 } 247 234 248 inline const G4String& G4VDecayChannel::GetPar << 235 inline >> 236 const G4String& G4VDecayChannel::GetParentName() const 249 { 237 { 250 return *parent_name; 238 return *parent_name; 251 } 239 } 252 240 253 inline G4double G4VDecayChannel::GetParentMass << 241 inline >> 242 G4double G4VDecayChannel::GetParentMass() const 254 { 243 { 255 return G4MT_parent_mass; << 244 return parent_mass; 256 } 245 } 257 246 258 inline void G4VDecayChannel::SetParent(const G << 247 >> 248 inline >> 249 void G4VDecayChannel::SetParent(const G4String &particle_name) 259 { 250 { 260 delete parent_name; << 251 if (parent_name != 0) delete parent_name; 261 parent_name = new G4String(particle_name); 252 parent_name = new G4String(particle_name); 262 G4MT_parent = nullptr; << 253 parent = 0; 263 } 254 } 264 255 265 inline G4int G4VDecayChannel::GetNumberOfDaugh << 256 inline 266 { << 257 G4int G4VDecayChannel::GetNumberOfDaughters() const 267 return numberOfDaughters; << 258 { >> 259 return numberOfDaughters; 268 } 260 } 269 261 270 inline const G4String& G4VDecayChannel::GetKin << 262 inline 271 { << 263 G4String G4VDecayChannel::GetKinematicsName() const { return kinematics_name; } 272 return kinematics_name; << 273 } << 274 264 275 inline G4double G4VDecayChannel::GetBR() const << 265 inline 276 { << 266 void G4VDecayChannel::SetBR(G4double value){ rbranch = value; } 277 return rbranch; << 278 } << 279 267 280 inline void G4VDecayChannel::SetVerboseLevel(G << 268 inline 281 { << 269 G4double G4VDecayChannel::GetBR() const { return rbranch; } 282 verboseLevel = value; << 283 } << 284 270 285 inline G4int G4VDecayChannel::GetVerboseLevel( << 271 inline 286 { << 272 void G4VDecayChannel::SetVerboseLevel(G4int value){ verboseLevel = value; } 287 return verboseLevel; << 288 } << 289 273 290 inline G4double G4VDecayChannel::GetRangeMass( << 274 inline 291 { << 275 G4int G4VDecayChannel::GetVerboseLevel() const { return verboseLevel; } 292 return rangeMass; << 276 293 } << 277 >> 278 >> 279 #endif 294 280 295 inline void G4VDecayChannel::SetRangeMass(G4do << 296 { << 297 if (val >= 0.) rangeMass = val; << 298 } << 299 281 300 inline void G4VDecayChannel::SetPolarization(c << 301 { << 302 parent_polarization = polar; << 303 } << 304 282 305 inline const G4ThreeVector& G4VDecayChannel::G << 306 { << 307 return parent_polarization; << 308 } << 309 283 310 inline void G4VDecayChannel::CheckAndFillDaugh << 311 { << 312 G4AutoLock l(&daughtersMutex); << 313 if (G4MT_daughters == nullptr) { << 314 l.unlock(); << 315 FillDaughters(); << 316 } << 317 } << 318 284 319 inline void G4VDecayChannel::CheckAndFillParen << 320 { << 321 G4AutoLock l(&parentMutex); << 322 if (G4MT_parent == nullptr) { << 323 l.unlock(); << 324 FillParent(); << 325 } << 326 } << 327 285 328 #endif << 329 286