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