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