Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // 26 // G4VDecayChannel << 27 // 23 // 28 // Class description: << 24 // $Id: G4VDecayChannel.hh,v 1.10 2002/11/20 15:05:55 gcosmo Exp $ >> 25 // GEANT4 tag $Name: geant4-06-00 $ 29 // 26 // 30 // Abstract class to describe decay kinematics << 27 // >> 28 // ------------------------------------------------------------ >> 29 // GEANT 4 class header file >> 30 // >> 31 // History: first implementation, based on object model of >> 32 // 27 July 1996 H.Kurashige >> 33 // 30 May 1997 H.Kurashige >> 34 // 23 Mar. 2000 H.Weber : add GetAngularMomentum() >> 35 // ------------------------------------------------------------ >> 36 #ifndef G4VDecayChannel_h >> 37 #define G4VDecayChannel_h 1 31 38 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" 39 #include "G4ios.hh" 41 #include "globals.hh" 40 #include "globals.hh" 42 41 43 #include <cmath> << 42 class G4ParticleDefinition; 44 << 43 class G4DecayProducts; 45 class G4ParticleDefinition; << 44 class G4ParticleTable; 46 class G4DecayProducts; << 47 class G4ParticleTable; << 48 45 49 class G4VDecayChannel 46 class G4VDecayChannel 50 { 47 { 51 public: << 48 // Class Description 52 // Constructors << 49 // This class is a abstract class to describe decay kinematics 53 G4VDecayChannel(const G4String& aName, G4i << 50 // 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 51 101 // Set the parent particle (by name or by << 52 public: 102 void SetParent(const G4ParticleDefinition* << 53 //Constructors 103 inline void SetParent(const G4String& part << 54 G4VDecayChannel(const G4String &aName, G4int Verbose = 1); 104 << 55 G4VDecayChannel(const G4String &aName, 105 // Set branching ratio << 56 const G4String& theParentName, 106 void SetBR(G4double value); << 57 G4double theBR, 107 << 58 G4int theNumberOfDaughters, 108 // Set number of daughter particles << 59 const G4String& theDaughterName1, 109 void SetNumberOfDaughters(G4int value); << 60 const G4String& theDaughterName2 = "", >> 61 const G4String& theDaughterName3 = "", >> 62 const G4String& theDaughterName4 = "" ); 110 63 111 // Set a daughter particle (by name or by << 64 // Destructor 112 void SetDaughter(G4int anIndex, const G4Pa << 65 virtual ~G4VDecayChannel(); 113 void SetDaughter(G4int anIndex, const G4St << 114 66 115 inline void SetVerboseLevel(G4int value); << 67 private: 116 inline G4int GetVerboseLevel() const; << 68 // copy constructor and assignment operatotr 117 void DumpInfo(); << 69 G4VDecayChannel(const G4VDecayChannel &); >> 70 G4VDecayChannel & operator=(const G4VDecayChannel &); 118 71 119 inline G4double GetRangeMass() const; << 72 public: 120 inline void SetRangeMass(G4double val); << 73 // equality operators 121 virtual G4bool IsOKWithParentMass(G4double << 74 G4int operator==(const G4VDecayChannel &right) const {return (this == &right);}; >> 75 G4int operator!=(const G4VDecayChannel &right) const {return (this != &right);}; >> 76 >> 77 // less-than operator is defined for G4DecayTable >> 78 G4int operator<(const G4VDecayChannel &right) const; >> 79 >> 80 public: // With Description >> 81 virtual G4DecayProducts* DecayIt(G4double parentMass = -1.0) = 0; >> 82 >> 83 public: // With Description >> 84 //get kinematics name >> 85 G4String GetKinematicsName() const; >> 86 //get branching ratio >> 87 G4double GetBR() const; >> 88 //get number of daughter particles >> 89 G4int GetNumberOfDaughters() const; >> 90 >> 91 //get the pointer to the parent particle >> 92 G4ParticleDefinition * GetParent(); >> 93 //get the pointer to a daughter particle >> 94 G4ParticleDefinition * GetDaughter(G4int anIndex); >> 95 >> 96 //get the angular momentum of the decay >> 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 protected: >> 121 // kinematics name >> 122 G4String kinematics_name; >> 123 // branching ratio [0.0 - 1.0] >> 124 G4double rbranch; >> 125 // number of daughters >> 126 G4int numberOfDaughters; >> 127 // parent particle >> 128 G4String* parent_name; >> 129 //daughter particles >> 130 G4String** daughters_name; 122 131 123 void SetPolarization(const G4ThreeVector&) << 132 protected: // With Description 124 inline const G4ThreeVector& GetPolarizatio << 133 // celar daughters array >> 134 void ClearDaughtersName(); 125 135 126 protected: 136 protected: 127 // Default constructor << 137 // pointer to particle table 128 G4VDecayChannel(); << 138 G4ParticleTable* particletable; 129 << 130 // Copy constructor and assignment operato << 131 G4VDecayChannel(const G4VDecayChannel&); << 132 G4VDecayChannel& operator=(const G4VDecayC << 133 139 134 // Clear daughters array << 140 // temporary buffers of pointers to G4ParticleDefinition 135 void ClearDaughtersName(); << 141 G4ParticleDefinition* parent; >> 142 G4ParticleDefinition** daughters; >> 143 >> 144 // parent mass >> 145 G4double parent_mass; >> 146 G4double* daughters_mass; >> 147 136 148 137 inline void CheckAndFillDaughters(); << 149 // fill daughters array 138 inline void CheckAndFillParent(); << 150 void FillDaughters(); 139 << 151 // fill parent 140 G4double DynamicalMass(G4double massPDG, G << 152 void FillParent(); 141 153 142 protected: << 154 public: // With Description 143 // Kinematics name << 155 void SetVerboseLevel(G4int value); 144 G4String kinematics_name = ""; << 156 G4int GetVerboseLevel() const; 145 // Branching ratio [0.0 - 1.0] << 157 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 158 171 // Number of daughters << 159 private: 172 G4int numberOfDaughters = 0; << 160 const G4String& GetNoName() const; 173 161 174 // Control flag for output message << 162 private: >> 163 // controle flag for output message >> 164 G4int verboseLevel; 175 // 0: Silent 165 // 0: Silent 176 // 1: Warning message 166 // 1: Warning message 177 // 2: More 167 // 2: More 178 G4int verboseLevel = 1; << 179 << 180 private: << 181 // Fill daughters array << 182 void FillDaughters(); << 183 168 184 // Fill parent << 169 static const G4String noName; 185 void FillParent(); << 186 << 187 const G4String& GetNoName() const; << 188 }; 170 }; 189 171 190 // ------------------------------------------- << 172 inline 191 // Inline methods << 173 G4int G4VDecayChannel::operator<(const G4VDecayChannel &right) const 192 // ------------------------------------------- << 193 << 194 inline G4bool G4VDecayChannel::operator<(const << 195 { 174 { 196 return (this->rbranch < right.rbranch); 175 return (this->rbranch < right.rbranch); 197 } 176 } 198 177 199 inline G4ParticleDefinition* G4VDecayChannel:: << 178 inline 200 { << 179 G4ParticleDefinition* G4VDecayChannel::GetDaughter(G4int anIndex) 201 // pointers to daughter particles are filled << 180 { 202 CheckAndFillDaughters(); << 181 //pointers to daughter particles are filled, if they are not set yet 203 << 182 if (daughters == 0) FillDaughters(); 204 // get the pointer to a daughter particle << 183 205 if ((anIndex >= 0) && (anIndex < numberOfDau << 184 //get the pointer to a daughter particle 206 return G4MT_daughters[anIndex]; << 185 if ( (anIndex>=0) && (anIndex<numberOfDaughters) ) { >> 186 return daughters[anIndex]; >> 187 } else { >> 188 if (verboseLevel>0) >> 189 G4cout << "G4VDecayChannel::GetDaughter index out of range "<<anIndex<<G4endl; >> 190 return 0; 207 } 191 } 208 << 209 if (verboseLevel > 0) << 210 G4cout << "G4VDecayChannel::GetDaughter i << 211 return nullptr; << 212 } 192 } 213 193 214 inline const G4String& G4VDecayChannel::GetDau << 194 inline >> 195 const G4String& G4VDecayChannel::GetDaughterName(G4int anIndex) const 215 { 196 { 216 if ((anIndex >= 0) && (anIndex < numberOfDau << 197 if ( (anIndex>=0) && (anIndex<numberOfDaughters) ) { 217 return *daughters_name[anIndex]; 198 return *daughters_name[anIndex]; >> 199 } else { >> 200 if (verboseLevel>0){ >> 201 G4cout << "G4VDecayChannel::GetDaughterName "; >> 202 G4cout << "index out of range " << anIndex << G4endl; >> 203 } >> 204 return GetNoName(); 218 } 205 } 219 << 220 if (verboseLevel > 0) { << 221 G4cout << "G4VDecayChannel::GetDaughterNam << 222 G4cout << "index out of range " << anIndex << 223 } << 224 return GetNoName(); << 225 } 206 } 226 207 227 inline G4double G4VDecayChannel::GetDaughterMa << 208 inline >> 209 G4double G4VDecayChannel::GetDaughterMass(G4int anIndex) const 228 { 210 { 229 if ((anIndex >= 0) && (anIndex < numberOfDau << 211 if ( (anIndex>=0) && (anIndex<numberOfDaughters) ) { 230 return G4MT_daughters_mass[anIndex]; << 212 return daughters_mass[anIndex]; 231 } << 213 } else { 232 << 214 if (verboseLevel>0){ 233 if (verboseLevel > 0) { << 215 G4cout << "G4VDecayChannel::GetDaughterMass "; 234 G4cout << "G4VDecayChannel::GetDaughterMas << 216 G4cout << "index out of range " << anIndex << G4endl; 235 G4cout << "index out of range " << anIndex << 217 } >> 218 return 0.0; 236 } 219 } 237 return 0.0; << 238 } 220 } 239 221 240 inline G4ParticleDefinition* G4VDecayChannel:: << 222 inline 241 { << 223 G4ParticleDefinition* G4VDecayChannel::GetParent() 242 // the pointer to the parent particle is fil << 224 { 243 CheckAndFillParent(); << 225 //the pointer to the parent particle is filled, if it is not set yet 244 // get the pointer to the parent particle << 226 if (parent == 0) FillParent(); 245 return G4MT_parent; << 227 //get the pointer to the parent particle >> 228 return parent; 246 } 229 } 247 230 248 inline const G4String& G4VDecayChannel::GetPar << 231 inline >> 232 const G4String& G4VDecayChannel::GetParentName() const 249 { 233 { 250 return *parent_name; 234 return *parent_name; 251 } 235 } 252 236 253 inline G4double G4VDecayChannel::GetParentMass << 237 inline >> 238 G4double G4VDecayChannel::GetParentMass() const 254 { 239 { 255 return G4MT_parent_mass; << 240 return parent_mass; 256 } 241 } 257 242 258 inline void G4VDecayChannel::SetParent(const G << 243 >> 244 inline >> 245 void G4VDecayChannel::SetParent(const G4String &particle_name) 259 { 246 { 260 delete parent_name; << 247 if (parent_name != 0) delete parent_name; 261 parent_name = new G4String(particle_name); 248 parent_name = new G4String(particle_name); 262 G4MT_parent = nullptr; << 249 parent = 0; 263 } 250 } 264 251 265 inline G4int G4VDecayChannel::GetNumberOfDaugh << 252 inline 266 { << 253 G4int G4VDecayChannel::GetNumberOfDaughters() const 267 return numberOfDaughters; << 254 { >> 255 return numberOfDaughters; 268 } 256 } 269 257 270 inline const G4String& G4VDecayChannel::GetKin << 258 inline 271 { << 259 G4String G4VDecayChannel::GetKinematicsName() const { return kinematics_name; } 272 return kinematics_name; << 273 } << 274 260 275 inline G4double G4VDecayChannel::GetBR() const << 261 inline 276 { << 262 void G4VDecayChannel::SetBR(G4double value){ rbranch = value; } 277 return rbranch; << 278 } << 279 263 280 inline void G4VDecayChannel::SetVerboseLevel(G << 264 inline 281 { << 265 G4double G4VDecayChannel::GetBR() const { return rbranch; } 282 verboseLevel = value; << 283 } << 284 266 285 inline G4int G4VDecayChannel::GetVerboseLevel( << 267 inline 286 { << 268 void G4VDecayChannel::SetVerboseLevel(G4int value){ verboseLevel = value; } 287 return verboseLevel; << 288 } << 289 269 290 inline G4double G4VDecayChannel::GetRangeMass( << 270 inline 291 { << 271 G4int G4VDecayChannel::GetVerboseLevel() const { return verboseLevel; } 292 return rangeMass; << 272 293 } << 273 >> 274 >> 275 #endif 294 276 295 inline void G4VDecayChannel::SetRangeMass(G4do << 296 { << 297 if (val >= 0.) rangeMass = val; << 298 } << 299 277 300 inline void G4VDecayChannel::SetPolarization(c << 301 { << 302 parent_polarization = polar; << 303 } << 304 278 305 inline const G4ThreeVector& G4VDecayChannel::G << 306 { << 307 return parent_polarization; << 308 } << 309 279 310 inline void G4VDecayChannel::CheckAndFillDaugh << 311 { << 312 G4AutoLock l(&daughtersMutex); << 313 if (G4MT_daughters == nullptr) { << 314 l.unlock(); << 315 FillDaughters(); << 316 } << 317 } << 318 280 319 inline void G4VDecayChannel::CheckAndFillParen << 320 { << 321 G4AutoLock l(&parentMutex); << 322 if (G4MT_parent == nullptr) { << 323 l.unlock(); << 324 FillParent(); << 325 } << 326 } << 327 281 328 #endif << 329 282