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.13 2010-08-10 15:47:42 kurasige Exp $ >> 28 // GEANT4 tag $Name: not supported by cvs2svn $ 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 = "", 110 << 65 const G4String& theDaughterName3 = "", 111 // Set a daughter particle (by name or by << 66 const G4String& theDaughterName4 = "" ); 112 void SetDaughter(G4int anIndex, const G4Pa << 113 void SetDaughter(G4int anIndex, const G4St << 114 << 115 inline void SetVerboseLevel(G4int value); << 116 inline G4int GetVerboseLevel() const; << 117 void DumpInfo(); << 118 << 119 inline G4double GetRangeMass() const; << 120 inline void SetRangeMass(G4double val); << 121 virtual G4bool IsOKWithParentMass(G4double << 122 67 123 void SetPolarization(const G4ThreeVector&) << 68 // Destructor 124 inline const G4ThreeVector& GetPolarizatio << 69 virtual ~G4VDecayChannel(); 125 70 126 protected: 71 protected: 127 // Default constructor << 72 // default constructor 128 G4VDecayChannel(); << 73 G4VDecayChannel(); >> 74 // copy constructor and assignment operatotr >> 75 G4VDecayChannel(const G4VDecayChannel &); >> 76 G4VDecayChannel & operator=(const G4VDecayChannel &); 129 77 130 // Copy constructor and assignment operato << 78 public: 131 G4VDecayChannel(const G4VDecayChannel&); << 79 // equality operators 132 G4VDecayChannel& operator=(const G4VDecayC << 80 G4int operator==(const G4VDecayChannel &right) const {return (this == &right);}; >> 81 G4int operator!=(const G4VDecayChannel &right) const {return (this != &right);}; >> 82 >> 83 // less-than operator is defined for G4DecayTable >> 84 G4int operator<(const G4VDecayChannel &right) const; >> 85 >> 86 public: // With Description >> 87 virtual G4DecayProducts* DecayIt(G4double parentMass = -1.0) = 0; >> 88 >> 89 public: // With Description >> 90 //get kinematics name >> 91 const G4String& GetKinematicsName() const; >> 92 //get branching ratio >> 93 G4double GetBR() const; >> 94 //get number of daughter particles >> 95 G4int GetNumberOfDaughters() const; >> 96 >> 97 //get the pointer to the parent particle >> 98 G4ParticleDefinition * GetParent(); >> 99 //get the pointer to a daughter particle >> 100 G4ParticleDefinition * GetDaughter(G4int anIndex); >> 101 >> 102 //get the angular momentum of the decay >> 103 G4int GetAngularMomentum(); >> 104 //get the name of the parent particle >> 105 const G4String& GetParentName() const; >> 106 //get the name of a daughter particle >> 107 const G4String& GetDaughterName(G4int anIndex) const; >> 108 >> 109 // get mass of parent >> 110 G4double GetParentMass() const; >> 111 G4double GetDaughterMass(G4int anIndex) const; >> 112 >> 113 //set the parent particle (by name or by pointer) >> 114 void SetParent(const G4ParticleDefinition * particle_type); >> 115 void SetParent(const G4String &particle_name); >> 116 //set branching ratio >> 117 void SetBR(G4double value); >> 118 //set number of daughter particles >> 119 void SetNumberOfDaughters(G4int value); >> 120 //set a daughter particle (by name or by pointer) >> 121 void SetDaughter(G4int anIndex, >> 122 const G4ParticleDefinition * particle_type); >> 123 void SetDaughter(G4int anIndex, >> 124 const G4String &particle_name); >> 125 >> 126 protected: >> 127 // kinematics name >> 128 G4String kinematics_name; >> 129 // branching ratio [0.0 - 1.0] >> 130 G4double rbranch; >> 131 // number of daughters >> 132 G4int numberOfDaughters; >> 133 // parent particle >> 134 G4String* parent_name; >> 135 //daughter particles >> 136 G4String** daughters_name; 133 137 134 // Clear daughters array << 138 protected: // With Description >> 139 // celar daughters array 135 void ClearDaughtersName(); 140 void ClearDaughtersName(); 136 141 137 inline void CheckAndFillDaughters(); << 142 protected: 138 inline void CheckAndFillParent(); << 143 // pointer to particle table >> 144 G4ParticleTable* particletable; 139 145 140 G4double DynamicalMass(G4double massPDG, G << 146 // temporary buffers of pointers to G4ParticleDefinition >> 147 G4ParticleDefinition* parent; >> 148 G4ParticleDefinition** daughters; >> 149 >> 150 // parent mass >> 151 G4double parent_mass; >> 152 G4double* daughters_mass; >> 153 141 154 142 protected: << 155 // fill daughters array 143 // Kinematics name << 156 void FillDaughters(); 144 G4String kinematics_name = ""; << 157 // fill parent 145 // Branching ratio [0.0 - 1.0] << 158 void FillParent(); 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 159 171 // Number of daughters << 160 public: // With Description 172 G4int numberOfDaughters = 0; << 161 void SetVerboseLevel(G4int value); >> 162 G4int GetVerboseLevel() const; >> 163 void DumpInfo(); 173 164 174 // Control flag for output message << 165 private: >> 166 const G4String& GetNoName() const; >> 167 >> 168 protected: >> 169 // controle flag for output message >> 170 G4int verboseLevel; 175 // 0: Silent 171 // 0: Silent 176 // 1: Warning message 172 // 1: Warning message 177 // 2: More 173 // 2: More 178 G4int verboseLevel = 1; << 179 << 180 private: << 181 // Fill daughters array << 182 void FillDaughters(); << 183 174 184 // Fill parent << 175 static const G4String noName; 185 void FillParent(); << 186 << 187 const G4String& GetNoName() const; << 188 }; 176 }; 189 177 190 // ------------------------------------------- << 178 inline 191 // Inline methods << 179 G4int G4VDecayChannel::operator<(const G4VDecayChannel &right) const 192 // ------------------------------------------- << 193 << 194 inline G4bool G4VDecayChannel::operator<(const << 195 { 180 { 196 return (this->rbranch < right.rbranch); 181 return (this->rbranch < right.rbranch); 197 } 182 } 198 183 199 inline G4ParticleDefinition* G4VDecayChannel:: << 184 inline 200 { << 185 G4ParticleDefinition* G4VDecayChannel::GetDaughter(G4int anIndex) 201 // pointers to daughter particles are filled << 186 { 202 CheckAndFillDaughters(); << 187 //pointers to daughter particles are filled, if they are not set yet 203 << 188 if (daughters == 0) FillDaughters(); 204 // get the pointer to a daughter particle << 189 205 if ((anIndex >= 0) && (anIndex < numberOfDau << 190 //get the pointer to a daughter particle 206 return G4MT_daughters[anIndex]; << 191 if ( (anIndex>=0) && (anIndex<numberOfDaughters) ) { >> 192 return daughters[anIndex]; >> 193 } else { >> 194 if (verboseLevel>0) >> 195 G4cout << "G4VDecayChannel::GetDaughter index out of range "<<anIndex<<G4endl; >> 196 return 0; 207 } 197 } 208 << 209 if (verboseLevel > 0) << 210 G4cout << "G4VDecayChannel::GetDaughter i << 211 return nullptr; << 212 } 198 } 213 199 214 inline const G4String& G4VDecayChannel::GetDau << 200 inline >> 201 const G4String& G4VDecayChannel::GetDaughterName(G4int anIndex) const 215 { 202 { 216 if ((anIndex >= 0) && (anIndex < numberOfDau << 203 if ( (anIndex>=0) && (anIndex<numberOfDaughters) ) { 217 return *daughters_name[anIndex]; 204 return *daughters_name[anIndex]; >> 205 } else { >> 206 if (verboseLevel>0){ >> 207 G4cout << "G4VDecayChannel::GetDaughterName "; >> 208 G4cout << "index out of range " << anIndex << G4endl; >> 209 } >> 210 return GetNoName(); 218 } 211 } 219 << 220 if (verboseLevel > 0) { << 221 G4cout << "G4VDecayChannel::GetDaughterNam << 222 G4cout << "index out of range " << anIndex << 223 } << 224 return GetNoName(); << 225 } 212 } 226 213 227 inline G4double G4VDecayChannel::GetDaughterMa << 214 inline >> 215 G4double G4VDecayChannel::GetDaughterMass(G4int anIndex) const 228 { 216 { 229 if ((anIndex >= 0) && (anIndex < numberOfDau << 217 if ( (anIndex>=0) && (anIndex<numberOfDaughters) ) { 230 return G4MT_daughters_mass[anIndex]; << 218 return daughters_mass[anIndex]; 231 } << 219 } else { 232 << 220 if (verboseLevel>0){ 233 if (verboseLevel > 0) { << 221 G4cout << "G4VDecayChannel::GetDaughterMass "; 234 G4cout << "G4VDecayChannel::GetDaughterMas << 222 G4cout << "index out of range " << anIndex << G4endl; 235 G4cout << "index out of range " << anIndex << 223 } >> 224 return 0.0; 236 } 225 } 237 return 0.0; << 238 } 226 } 239 227 240 inline G4ParticleDefinition* G4VDecayChannel:: << 228 inline 241 { << 229 G4ParticleDefinition* G4VDecayChannel::GetParent() 242 // the pointer to the parent particle is fil << 230 { 243 CheckAndFillParent(); << 231 //the pointer to the parent particle is filled, if it is not set yet 244 // get the pointer to the parent particle << 232 if (parent == 0) FillParent(); 245 return G4MT_parent; << 233 //get the pointer to the parent particle >> 234 return parent; 246 } 235 } 247 236 248 inline const G4String& G4VDecayChannel::GetPar << 237 inline >> 238 const G4String& G4VDecayChannel::GetParentName() const 249 { 239 { 250 return *parent_name; 240 return *parent_name; 251 } 241 } 252 242 253 inline G4double G4VDecayChannel::GetParentMass << 243 inline >> 244 G4double G4VDecayChannel::GetParentMass() const 254 { 245 { 255 return G4MT_parent_mass; << 246 return parent_mass; 256 } 247 } 257 248 258 inline void G4VDecayChannel::SetParent(const G << 249 >> 250 inline >> 251 void G4VDecayChannel::SetParent(const G4String &particle_name) 259 { 252 { 260 delete parent_name; << 253 if (parent_name != 0) delete parent_name; 261 parent_name = new G4String(particle_name); 254 parent_name = new G4String(particle_name); 262 G4MT_parent = nullptr; << 255 parent = 0; 263 } 256 } 264 257 265 inline G4int G4VDecayChannel::GetNumberOfDaugh << 258 inline 266 { << 259 G4int G4VDecayChannel::GetNumberOfDaughters() const 267 return numberOfDaughters; << 260 { >> 261 return numberOfDaughters; 268 } 262 } 269 263 270 inline const G4String& G4VDecayChannel::GetKin << 264 inline 271 { << 265 const G4String& G4VDecayChannel::GetKinematicsName() const { return kinematics_name; } 272 return kinematics_name; << 273 } << 274 266 275 inline G4double G4VDecayChannel::GetBR() const << 267 inline 276 { << 268 void G4VDecayChannel::SetBR(G4double value){ rbranch = value; } 277 return rbranch; << 278 } << 279 269 280 inline void G4VDecayChannel::SetVerboseLevel(G << 270 inline 281 { << 271 G4double G4VDecayChannel::GetBR() const { return rbranch; } 282 verboseLevel = value; << 283 } << 284 272 285 inline G4int G4VDecayChannel::GetVerboseLevel( << 273 inline 286 { << 274 void G4VDecayChannel::SetVerboseLevel(G4int value){ verboseLevel = value; } 287 return verboseLevel; << 288 } << 289 275 290 inline G4double G4VDecayChannel::GetRangeMass( << 276 inline 291 { << 277 G4int G4VDecayChannel::GetVerboseLevel() const { return verboseLevel; } 292 return rangeMass; << 278 293 } << 279 >> 280 >> 281 #endif 294 282 295 inline void G4VDecayChannel::SetRangeMass(G4do << 296 { << 297 if (val >= 0.) rangeMass = val; << 298 } << 299 283 300 inline void G4VDecayChannel::SetPolarization(c << 301 { << 302 parent_polarization = polar; << 303 } << 304 284 305 inline const G4ThreeVector& G4VDecayChannel::G << 306 { << 307 return parent_polarization; << 308 } << 309 285 310 inline void G4VDecayChannel::CheckAndFillDaugh << 311 { << 312 G4AutoLock l(&daughtersMutex); << 313 if (G4MT_daughters == nullptr) { << 314 l.unlock(); << 315 FillDaughters(); << 316 } << 317 } << 318 286 319 inline void G4VDecayChannel::CheckAndFillParen << 320 { << 321 G4AutoLock l(&parentMutex); << 322 if (G4MT_parent == nullptr) { << 323 l.unlock(); << 324 FillParent(); << 325 } << 326 } << 327 287 328 #endif << 329 288