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