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