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