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