Geant4-11
Data Structures | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
G4CollisionComposite Class Referenceabstract

#include <G4CollisionComposite.hh>

Inheritance diagram for G4CollisionComposite:
G4VCollision G4CollisionMesonBaryon G4CollisionMesonBaryonToResonance G4CollisionPN G4GeneralNNCollision G4CollisionNN G4CollisionNNToDeltaDelta G4CollisionNNToDeltaDelta1600 G4CollisionNNToDeltaDelta1620 G4CollisionNNToDeltaDelta1700 G4CollisionNNToDeltaDelta1900 G4CollisionNNToDeltaDelta1905 G4CollisionNNToDeltaDelta1910 G4CollisionNNToDeltaDelta1920 G4CollisionNNToDeltaDelta1930 G4CollisionNNToDeltaDelta1950 G4CollisionNNToDeltaDeltastar G4CollisionNNToDeltaNstar G4CollisionNNToNDelta G4CollisionNNToNDelta1600 G4CollisionNNToNDelta1620 G4CollisionNNToNDelta1700 G4CollisionNNToNDelta1900 G4CollisionNNToNDelta1905 G4CollisionNNToNDelta1910 G4CollisionNNToNDelta1920 G4CollisionNNToNDelta1930 G4CollisionNNToNDelta1950 G4CollisionNNToNDeltastar G4CollisionNNToNNstar G4CollisionNStarNToNN

Data Structures

struct  Register
 
struct  Resolve
 

Public Member Functions

void AddComponent (G4VCollision *aC)
 
virtual G4double CrossSection (const G4KineticTrack &trk1, const G4KineticTrack &trk2) const
 
void establish_G4MT_TLS_G4VCollision ()
 
virtual G4KineticTrackVectorFinalState (const G4KineticTrack &trk1, const G4KineticTrack &trk2) const
 
 G4CollisionComposite ()
 
virtual const G4VAngularDistributionGetAngularDistribution () const
 
virtual const G4CollisionVectorGetComponents () const
 
virtual const G4VCrossSectionSourceGetCrossSectionSource () const
 
virtual G4String GetName () const =0
 
virtual G4bool IsInCharge (const G4KineticTrack &trk1, const G4KineticTrack &trk2) const
 
G4bool operator!= (const G4VCollision &right) const
 
G4bool operator== (const G4VCollision &right) const
 
virtual void Print () const
 
virtual void Print (const G4KineticTrack &trk1, const G4KineticTrack &trk2) const
 
virtual ~G4CollisionComposite ()
 

Protected Member Functions

virtual const std::vector< G4String > & GetListOfColliders (G4int whichOne) const =0
 
G4int GetNumberOfPartons (const G4ParticleDefinition *aP) const
 

Private Member Functions

void BufferCrossSection (const G4ParticleDefinition *aP, const G4ParticleDefinition *bP)
 
G4double BufferedCrossSection (const G4KineticTrack &trk1, const G4KineticTrack &trk2) const
 
 G4CollisionComposite (const G4CollisionComposite &right)
 
const G4CollisionCompositeoperator= (const G4CollisionComposite &right)
 

Private Attributes

G4Mutex bufferMutex
 
G4CollisionVector components
 
std::vector< G4CrossSectionBuffertheBuffer
 

Static Private Attributes

static const G4int nPoints = 32
 
static const G4double theT []
 

Detailed Description

Definition at line 57 of file G4CollisionComposite.hh.

Constructor & Destructor Documentation

◆ G4CollisionComposite() [1/2]

G4CollisionComposite::G4CollisionComposite ( )

Definition at line 44 of file G4CollisionComposite.cc.

45{
47}
#define G4MUTEXINIT(mutex)
Definition: G4Threading.hh:87

References bufferMutex, and G4MUTEXINIT.

◆ ~G4CollisionComposite()

G4CollisionComposite::~G4CollisionComposite ( )
virtual

Definition at line 50 of file G4CollisionComposite.cc.

51{
53 std::for_each(components.begin(), components.end(), G4Delete());
54}
#define G4MUTEXDESTROY(mutex)
Definition: G4Threading.hh:90
G4CollisionVector components

References bufferMutex, components, and G4MUTEXDESTROY.

◆ G4CollisionComposite() [2/2]

G4CollisionComposite::G4CollisionComposite ( const G4CollisionComposite right)
private

Member Function Documentation

◆ AddComponent()

void G4CollisionComposite::AddComponent ( G4VCollision aC)
inline

◆ BufferCrossSection()

void G4CollisionComposite::BufferCrossSection ( const G4ParticleDefinition aP,
const G4ParticleDefinition bP 
)
private

Definition at line 141 of file G4CollisionComposite.cc.

143{
144 // check if already buffered
145 size_t i;
146 for(i=0; i<theBuffer.size(); i++)
147 {
148 if(theBuffer[i].InCharge(aP, bP)) return;
149 }
150// G4cerr << "Buffering for "<<aP->GetParticleName()<<" "<<bP->GetParticleName()<<G4endl;
151
152 // buffer the new one.
153 G4CrossSectionBuffer aNewBuff(aP, bP);
154 size_t maxE=nPoints;
155 for(size_t tt=0; tt<maxE; tt++)
156 {
157 G4double aT = theT[tt]*GeV;
158 G4double crossSect = 0;
159 // The total cross-section is summed over all the component channels
160
161 //A.R. 28-Sep-2012 Fix reproducibility problem
162 // Assign the kinetic energy to the lightest of the
163 // two particles, instead to the first one always.
164 G4double atime = 0;
165 G4double btime = 0;
166 G4ThreeVector aPosition(0,0,0);
167 G4ThreeVector bPosition(0,0,0);
168 G4double aM = aP->GetPDGMass();
169 G4double bM = bP->GetPDGMass();
170 G4double aE = aM;
171 G4double bE = bM;
172 G4ThreeVector aMom(0,0,0);
173 G4ThreeVector bMom(0,0,0);
174 if ( aM <= bM ) {
175 aE += aT;
176 aMom = G4ThreeVector(0,0,std::sqrt(aE*aE-aM*aM));
177 } else {
178 bE += aT;
179 bMom = G4ThreeVector(0,0,std::sqrt(bE*bE-bM*bM));
180 }
181 G4LorentzVector a4Momentum(aE, aMom);
182 G4LorentzVector b4Momentum(bE, bMom);
183 G4KineticTrack a(aP, atime, aPosition, a4Momentum);
184 G4KineticTrack b(bP, btime, bPosition, b4Momentum);
185
186 for (i=0; i<components.size(); i++)
187 {
188 if(components[i]->IsInCharge(a,b))
189 {
190 crossSect += components[i]->CrossSection(a,b);
191 }
192 }
193 G4double sqrts = (a4Momentum+b4Momentum).mag();
194 aNewBuff.push_back(sqrts, crossSect);
195 }
196 theBuffer.push_back(aNewBuff);
197// theBuffer.back().Print();
198}
static constexpr double GeV
Definition: G4SIunits.hh:203
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition: G4Types.hh:83
std::vector< G4CrossSectionBuffer > theBuffer
virtual G4bool IsInCharge(const G4KineticTrack &trk1, const G4KineticTrack &trk2) const
static const G4int nPoints
static const G4double theT[]

References components, G4ParticleDefinition::GetPDGMass(), GeV, IsInCharge(), nPoints, G4CrossSectionBuffer::push_back(), theBuffer, and theT.

Referenced by CrossSection().

◆ BufferedCrossSection()

G4double G4CollisionComposite::BufferedCrossSection ( const G4KineticTrack trk1,
const G4KineticTrack trk2 
) const
private

Definition at line 201 of file G4CollisionComposite.cc.

203{
204 for(size_t i=0; i<theBuffer.size(); i++)
205 {
206 if(theBuffer[i].InCharge(trk1.GetDefinition(), trk2.GetDefinition()))
207 {
208 return theBuffer[i].CrossSection(trk1, trk2);
209 }
210 }
211 throw G4HadronicException(__FILE__, __LINE__, "G4CollisionComposite::BufferedCrossSection - Blitz !!");
212 return 0;
213}
const G4ParticleDefinition * GetDefinition() const

References G4KineticTrack::GetDefinition(), and theBuffer.

Referenced by CrossSection().

◆ CrossSection()

G4double G4CollisionComposite::CrossSection ( const G4KineticTrack trk1,
const G4KineticTrack trk2 
) const
virtual

Reimplemented from G4VCollision.

Reimplemented in G4CollisionMesonBaryonToResonance, and G4CollisionNN.

Definition at line 57 of file G4CollisionComposite.cc.

59{
60 G4double crossSect = 0.;
62 if (xSource != 0)
63 // There is a total cross section for this Collision
64 {
65 crossSect = xSource->CrossSection(trk1,trk2);
66 }
67 else
68 {
70 // waiting for mutable to enable buffering.
71 const_cast<G4CollisionComposite *>(this)->BufferCrossSection(trk1.GetDefinition(), trk2.GetDefinition());
72// G4cerr << "Buffer filled, reying with sqrts = "<< (trk1.Get4Momentum()+trk2.Get4Momentum()).mag() <<G4endl;
73 crossSect = BufferedCrossSection(trk1,trk2);
74 }
75 return crossSect;
76}
void BufferCrossSection(const G4ParticleDefinition *aP, const G4ParticleDefinition *bP)
G4double BufferedCrossSection(const G4KineticTrack &trk1, const G4KineticTrack &trk2) const
virtual const G4VCrossSectionSource * GetCrossSectionSource() const
virtual G4double CrossSection(const G4KineticTrack &trk1, const G4KineticTrack &trk2) const =0

References BufferCrossSection(), BufferedCrossSection(), bufferMutex, G4VCrossSectionSource::CrossSection(), GetCrossSectionSource(), and G4KineticTrack::GetDefinition().

Referenced by G4CollisionMesonBaryonToResonance::CrossSection().

◆ establish_G4MT_TLS_G4VCollision()

void G4VCollision::establish_G4MT_TLS_G4VCollision ( )
inherited

◆ FinalState()

G4KineticTrackVector * G4CollisionComposite::FinalState ( const G4KineticTrack trk1,
const G4KineticTrack trk2 
) const
virtual

Implements G4VCollision.

Definition at line 79 of file G4CollisionComposite.cc.

81{
82 std::vector<G4double> cxCache;
83 G4double partialCxSum = 0.0;
84
85 size_t i;
86 for (i=0; i<components.size(); i++)
87 {
88 G4double partialCx;
89// cout << "comp" << i << " " << components[i]()->GetName();
90 if (components[i]->IsInCharge(trk1,trk2))
91 {
92 partialCx = components[i]->CrossSection(trk1,trk2);
93 }
94 else
95 {
96 partialCx = 0.0;
97 }
98// cout << " cx=" << partialCx << endl;
99 partialCxSum += partialCx;
100 cxCache.push_back(partialCx);
101 }
102
103 G4double random = G4UniformRand()*partialCxSum;
104 G4double running = 0;
105 for (i=0; i<cxCache.size(); i++)
106 {
107 running += cxCache[i];
108 if (running > random)
109 {
110 return components[i]->FinalState(trk1, trk2);
111 }
112 }
113// G4cerr <<"in charge = "<<IsInCharge(trk1, trk2)<<G4endl;
114// G4cerr <<"Cross-section = "<<CrossSection(trk1, trk2)/millibarn<<" "<<running<<" "<<cxCache.size()<<G4endl;
115// G4cerr <<"Names = "<<trk1.GetDefinition()->GetParticleName()<<", "<<trk2.GetDefinition()->GetParticleName()<<G4endl;
116// throw G4HadronicException(__FILE__, __LINE__, "G4CollisionComposite: no final state found!");
117 return NULL;
118}
#define G4UniformRand()
Definition: Randomize.hh:52

References components, G4UniformRand, and IsInCharge().

◆ GetAngularDistribution()

virtual const G4VAngularDistribution * G4CollisionComposite::GetAngularDistribution ( ) const
inlinevirtual

Implements G4VCollision.

Reimplemented in G4CollisionNN, and G4CollisionPN.

Definition at line 76 of file G4CollisionComposite.hh.

76{ return 0; }

◆ GetComponents()

virtual const G4CollisionVector * G4CollisionComposite::GetComponents ( ) const
inlinevirtual

◆ GetCrossSectionSource()

virtual const G4VCrossSectionSource * G4CollisionComposite::GetCrossSectionSource ( ) const
inlinevirtual

Implements G4VCollision.

Reimplemented in G4CollisionNN, and G4CollisionPN.

Definition at line 75 of file G4CollisionComposite.hh.

75{ return 0; }

Referenced by CrossSection().

◆ GetListOfColliders()

virtual const std::vector< G4String > & G4VCollision::GetListOfColliders ( G4int  whichOne) const
protectedpure virtualinherited

◆ GetName()

virtual G4String G4VCollision::GetName ( ) const
pure virtualinherited

◆ GetNumberOfPartons()

G4int G4VCollision::GetNumberOfPartons ( const G4ParticleDefinition aP) const
inlineprotectedinherited

Definition at line 68 of file G4VCollision.hh.

69 {
70 G4int result = 0;
71 for(G4int i=0; i<6; i++)
72 {
73 result += aP->GetQuarkContent(i+1);
74 result += aP->GetAntiQuarkContent(i+1);
75 }
76 return result;
77 }
int G4int
Definition: G4Types.hh:85
G4int GetQuarkContent(G4int flavor) const
G4int GetAntiQuarkContent(G4int flavor) const

References G4ParticleDefinition::GetAntiQuarkContent(), and G4ParticleDefinition::GetQuarkContent().

Referenced by G4CollisionMesonBaryonElastic::IsInCharge().

◆ IsInCharge()

G4bool G4CollisionComposite::IsInCharge ( const G4KineticTrack trk1,
const G4KineticTrack trk2 
) const
virtual

Implements G4VCollision.

Reimplemented in G4GeneralNNCollision.

Definition at line 121 of file G4CollisionComposite.cc.

123{
124 G4bool isInCharge = false;
125
126 // The composite is in charge if any of its components is in charge
127
128 const G4CollisionVector* comps = GetComponents();
129 if (comps)
130 {
131 G4CollisionVector::const_iterator iter;
132 for (iter = comps->begin(); iter != comps->end(); ++iter)
133 {
134 if ( ((*iter))->IsInCharge(trk1,trk2) ) isInCharge = true;
135 }
136 }
137
138 return isInCharge;
139}
std::vector< G4VCollision * > G4CollisionVector
bool G4bool
Definition: G4Types.hh:86
virtual const G4CollisionVector * GetComponents() const

References GetComponents(), and IsInCharge().

Referenced by BufferCrossSection(), FinalState(), and IsInCharge().

◆ operator!=()

G4bool G4VCollision::operator!= ( const G4VCollision right) const
inherited

Definition at line 48 of file G4VCollision.cc.

49{
50 return (this != (G4VCollision *) &right);
51}

◆ operator=()

const G4CollisionComposite & G4CollisionComposite::operator= ( const G4CollisionComposite right)
private

◆ operator==()

G4bool G4VCollision::operator== ( const G4VCollision right) const
inherited

Definition at line 42 of file G4VCollision.cc.

43{
44 return (this == (G4VCollision *) &right);
45}

◆ Print() [1/2]

void G4VCollision::Print ( ) const
virtualinherited

Definition at line 70 of file G4VCollision.cc.

71{
73
74 G4cout << "---- " << name << "---- Cross section" << G4endl;
75
77 if (xSource) xSource->Print();
78
79 G4int nComponents = 0;
80 const G4CollisionVector* components = GetComponents();
81 if (components)
82 {
83 nComponents = components->size();
84 }
85 G4cout << "---- " << name << "---- has " << nComponents << " components" <<G4endl;
86 G4int i = 0;
87 G4CollisionVector::const_iterator iter;
88 if (components)
89 {
90 for (iter = components->begin(); iter != components->end(); ++iter)
91 {
92 G4cout << "---- " << name << " ---- Component " << i << G4endl;
93 ((*iter))->Print();
94 i++;
95 }
96 }
97
98}
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
virtual const G4CollisionVector * GetComponents() const
Definition: G4VCollision.hh:79
virtual void Print() const
Definition: G4VCollision.cc:70
virtual const G4VCrossSectionSource * GetCrossSectionSource() const =0
virtual G4String GetName() const =0
virtual void Print() const
const char * name(G4int ptype)

References G4cout, G4endl, G4VCollision::GetComponents(), G4VCollision::GetCrossSectionSource(), G4VCollision::GetName(), G4InuclParticleNames::name(), G4VCollision::Print(), and G4VCrossSectionSource::Print().

Referenced by G4VCollision::Print().

◆ Print() [2/2]

void G4VCollision::Print ( const G4KineticTrack trk1,
const G4KineticTrack trk2 
) const
virtualinherited

Definition at line 101 of file G4VCollision.cc.

103{
105
106 if (IsInCharge(trk1,trk2))
107 {
108 G4cout << "---- " << name << "is in charge ---- " << G4endl;
109 }
110 else
111 {
112 G4cout << "---- " << name << "is not in charge ---- " << G4endl;
113 }
114
115 G4cout << "---- " << name << "---- Cross section" << G4endl;
116
118 if (xSource) xSource->Print();
119 G4cout << "Cross section = " << CrossSection(trk1,trk2) << G4endl;
120
121 G4int nComponents = 0;
122 const G4CollisionVector* components = GetComponents();
123 if (components)
124 {
125 nComponents = components->size();
126 }
127 G4cout << "---- " << name << "has " << nComponents << " components" <<G4endl;
128
129 G4int i = 0;
130 G4CollisionVector::const_iterator iter;
131 if (components)
132 {
133 for (iter = components->begin(); iter != components->end(); ++iter)
134 {
135 G4cout << "Component " << i << G4endl;
136 ((*iter))->Print();
137 i++;
138 }
139 }
140}
virtual G4double CrossSection(const G4KineticTrack &trk1, const G4KineticTrack &trk2) const
Definition: G4VCollision.cc:54
virtual G4bool IsInCharge(const G4KineticTrack &trk1, const G4KineticTrack &trk2) const =0

References G4VCollision::CrossSection(), G4cout, G4endl, G4VCollision::GetComponents(), G4VCollision::GetCrossSectionSource(), G4VCollision::GetName(), G4VCollision::IsInCharge(), G4InuclParticleNames::name(), G4VCollision::Print(), and G4VCrossSectionSource::Print().

Field Documentation

◆ bufferMutex

G4Mutex G4CollisionComposite::bufferMutex
mutableprivate

◆ components

G4CollisionVector G4CollisionComposite::components
private

◆ nPoints

const G4int G4CollisionComposite::nPoints = 32
staticprivate

Definition at line 123 of file G4CollisionComposite.hh.

Referenced by BufferCrossSection().

◆ theBuffer

std::vector<G4CrossSectionBuffer> G4CollisionComposite::theBuffer
private

Definition at line 121 of file G4CollisionComposite.hh.

Referenced by BufferCrossSection(), and BufferedCrossSection().

◆ theT

const G4double G4CollisionComposite::theT
staticprivate
Initial value:
=
{.01, .03, .05, .1, .15, .2, .3, .4, .5, .6, .7, .8, .9, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.2, 2.5, 3.0, 3.5, 4.0, 5.0, 6.0, 8.0, 10., 15, 20, 50, 100}

Definition at line 124 of file G4CollisionComposite.hh.

Referenced by BufferCrossSection().


The documentation for this class was generated from the following files: