Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4CollisionComposite Class Reference

#include <G4CollisionComposite.hh>

+ Inheritance diagram for G4CollisionComposite:

Classes

struct  Register
 
struct  Resolve
 

Public Member Functions

 G4CollisionComposite ()
 
virtual ~G4CollisionComposite ()
 
virtual G4double CrossSection (const G4KineticTrack &trk1, const G4KineticTrack &trk2) const
 
virtual G4KineticTrackVectorFinalState (const G4KineticTrack &trk1, const G4KineticTrack &trk2) const
 
virtual G4bool IsInCharge (const G4KineticTrack &trk1, const G4KineticTrack &trk2) const
 
void AddComponent (G4VCollision *aC)
 
virtual const G4VCrossSectionSourceGetCrossSectionSource () const
 
virtual const G4VAngularDistributionGetAngularDistribution () const
 
virtual const G4CollisionVectorGetComponents () const
 
- Public Member Functions inherited from G4VCollision
 G4VCollision ()
 
void establish_G4MT_TLS_G4VCollision ()
 
 G4VCollision (void *s1, void *s2, void *s3, void *s4, void *s5, void *s6, void *s7)
 
virtual ~G4VCollision ()
 
G4bool operator== (const G4VCollision &right) const
 
G4bool operator!= (const G4VCollision &right) const
 
virtual G4String GetName () const =0
 
virtual void Print () const
 
virtual void Print (const G4KineticTrack &trk1, const G4KineticTrack &trk2) const
 

Additional Inherited Members

- Protected Member Functions inherited from G4VCollision
G4int GetNumberOfPartons (const G4ParticleDefinition *aP) const
 
virtual const std::vector< G4String > & GetListOfColliders (G4int whichOne) const =0
 

Detailed Description

Definition at line 57 of file G4CollisionComposite.hh.

Constructor & Destructor Documentation

◆ G4CollisionComposite()

G4CollisionComposite::G4CollisionComposite ( )

Definition at line 44 of file G4CollisionComposite.cc.

45{
46 G4MUTEXINIT( bufferMutex );
47}
#define G4MUTEXINIT(mutex)

◆ ~G4CollisionComposite()

G4CollisionComposite::~G4CollisionComposite ( )
virtual

Definition at line 50 of file G4CollisionComposite.cc.

51{
52 G4MUTEXDESTROY(bufferMutex);
53 std::for_each(components.begin(), components.end(), G4Delete());
54}
#define G4MUTEXDESTROY(mutex)

Member Function Documentation

◆ AddComponent()

◆ CrossSection()

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

Reimplemented from G4VCollision.

Reimplemented in 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 {
69 G4AutoLock l(&bufferMutex);
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}
double G4double
Definition G4Types.hh:83
virtual const G4VCrossSectionSource * GetCrossSectionSource() const
const G4ParticleDefinition * GetDefinition() const
virtual G4double CrossSection(const G4KineticTrack &trk1, const G4KineticTrack &trk2) const =0

◆ 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
virtual G4bool IsInCharge(const G4KineticTrack &trk1, const G4KineticTrack &trk2) const

◆ 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()

◆ 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().

◆ 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

Referenced by FinalState(), and IsInCharge().


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