G4SampleResonance Class Reference

#include <G4SampleResonance.hh>


Public Types

typedef std::map< const G4ParticleDefinition *,
G4double, std::less< const
G4ParticleDefinition
* > >::const_iterator 
minMassMapIterator
typedef std::map< const G4ParticleDefinition *,
G4double, std::less< const
G4ParticleDefinition * > > 
minMassMapType

Public Member Functions

G4double GetMinimumMass (const G4ParticleDefinition *p) const
G4double SampleMass (const G4double poleMass, const G4double gamma, const G4double minMass, const G4double maxMass) const
G4double SampleMass (const G4ParticleDefinition *p, const G4double maxMass) const


Detailed Description

Definition at line 45 of file G4SampleResonance.hh.


Member Typedef Documentation

typedef std::map<const G4ParticleDefinition*, G4double, std::less<const G4ParticleDefinition*> >::const_iterator G4SampleResonance::minMassMapIterator

Definition at line 69 of file G4SampleResonance.hh.

typedef std::map<const G4ParticleDefinition*, G4double, std::less<const G4ParticleDefinition*> > G4SampleResonance::minMassMapType

Definition at line 70 of file G4SampleResonance.hh.


Member Function Documentation

G4double G4SampleResonance::GetMinimumMass ( const G4ParticleDefinition p  )  const

Definition at line 46 of file G4SampleResonance.cc.

References DBL_MAX, G4DecayTable::entries(), G4DecayTable::GetDecayChannel(), G4ParticleDefinition::GetPDGMass(), and G4ParticleDefinition::IsShortLived().

Referenced by G4KineticTrack::Decay(), G4KineticTrack::G4KineticTrack(), and SampleMass().

00047 {
00048 
00049         G4double minResonanceMass = DBL_MAX;
00050 
00051         if ( p->IsShortLived() )
00052         {
00053                 minMassMapIterator iter = minMassCache.find(p);
00054                 if ( iter!=minMassCache.end() )
00055                 {
00056                         minResonanceMass = (*iter).second;
00057                 }
00058                 else
00059                 {
00060                         // G4cout << "--> request for " << p->GetParticleName() << G4endl;
00061 
00062                         const G4DecayTable* theDecays = const_cast<G4ParticleDefinition*>(p)->GetDecayTable();
00063                         const G4int nDecays = theDecays->entries();
00064 
00065                         for (G4int i=0; i<nDecays; i++)
00066                         {
00067                                 const G4VDecayChannel* aDecay = theDecays->GetDecayChannel(i);
00068                                 const G4int nDaughters = aDecay->GetNumberOfDaughters();
00069 
00070                                 G4double minChannelMass = 0;
00071 
00072                                 for (G4int j=0; j<nDaughters; j++)
00073                                 {
00074                                         const G4ParticleDefinition* aDaughter = const_cast<G4VDecayChannel*>(aDecay)->GetDaughter(j);
00075                                         G4double minMass = GetMinimumMass(aDaughter);
00076                                         if (!minMass) minMass = DBL_MAX; // exclude gamma channel;
00077                                         minChannelMass+=minMass;
00078                                 }
00079                                 // G4cout << "channel mass for the above is " << minChannelMass/MeV << G4endl;
00080                                 if (minChannelMass < minResonanceMass) minResonanceMass = minChannelMass;
00081 
00082                         }
00083                         // replace this as soon as the compiler supports mutable!!
00084                         G4SampleResonance* self = const_cast<G4SampleResonance*>(this);
00085                         (self->minMassCache)[p] = minResonanceMass;
00086 
00087                 }
00088         } 
00089         else
00090         {
00091 
00092                 minResonanceMass = p->GetPDGMass();
00093 
00094         }
00095         // G4cout << "minimal mass for " << p->GetParticleName() << " is " << minResonanceMass/MeV << G4endl;
00096 
00097         return minResonanceMass;
00098 } 

G4double G4SampleResonance::SampleMass ( const G4ParticleDefinition p,
const G4double  maxMass 
) const

Definition at line 102 of file G4SampleResonance.cc.

References GetMinimumMass(), G4ParticleDefinition::GetPDGMass(), G4ParticleDefinition::GetPDGWidth(), and SampleMass().

00103 {
00104         return SampleMass(p->GetPDGMass(), p->GetPDGWidth(), GetMinimumMass(p), maxMass);
00105 }

G4double G4SampleResonance::SampleMass ( const G4double  poleMass,
const G4double  gamma,
const G4double  minMass,
const G4double  maxMass 
) const

Definition at line 108 of file G4SampleResonance.cc.

References DBL_EPSILON, and G4UniformRand.

Referenced by G4KineticTrack::Decay(), and SampleMass().

00112 {
00113         // Chooses a mass randomly between minMass and maxMass
00114         //     according to a Breit-Wigner function with constant
00115         //     width gamma and pole poleMass
00116 
00117         if ( minMass > maxMass )
00118         {
00119                 throw G4HadronicException(__FILE__, __LINE__,
00120                                 "SampleResonanceMass: mass range negative (minMass>maxMass)");
00121         }
00122 
00123         G4double returnMass;
00124 
00125         if ( gamma < DBL_EPSILON )
00126         {
00127                 returnMass = std::max(minMass, std::min(maxMass, poleMass));
00128         }
00129         else
00130         {
00131                 double fmin = BrWigInt0(minMass, gamma, poleMass);
00132                 double fmax = BrWigInt0(maxMass, gamma, poleMass);
00133                 double f = fmin + (fmax-fmin)*G4UniformRand();
00134                 returnMass = BrWigInv(f, gamma, poleMass);
00135         }
00136 
00137         return returnMass;
00138 }


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:53:20 2013 for Geant4 by  doxygen 1.4.7