Geant4 9.6.0
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 ()
 
virtual ~G4VCollision ()
 
G4bool operator== (const G4VCollision &right) const
 
G4bool operator!= (const G4VCollision &right) const
 
virtual G4double CrossSection (const G4KineticTrack &trk1, const G4KineticTrack &trk2) const
 
virtual G4KineticTrackVectorFinalState (const G4KineticTrack &trk1, const G4KineticTrack &trk2) const =0
 
virtual G4bool IsInCharge (const G4KineticTrack &trk1, const G4KineticTrack &trk2) const =0
 
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 (G4ParticleDefinition *aP) const
 
virtual const G4CollisionVectorGetComponents () const
 
virtual const G4VCrossSectionSourceGetCrossSectionSource () const =0
 
virtual const G4VAngularDistributionGetAngularDistribution () const =0
 
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}

◆ ~G4CollisionComposite()

G4CollisionComposite::~G4CollisionComposite ( )
virtual

Definition at line 49 of file G4CollisionComposite.cc.

50{
51 std::for_each(components.begin(), components.end(), G4Delete());
52}

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 55 of file G4CollisionComposite.cc.

57{
58 G4double crossSect = 0.;
60 if (xSource != 0)
61 // There is a total cross section for this Collision
62 {
63 crossSect = xSource->CrossSection(trk1,trk2);
64 }
65 else
66 {
67 // waiting for mutable to enable buffering.
68 const_cast<G4CollisionComposite *>(this)->BufferCrossSection(trk1.GetDefinition(), trk2.GetDefinition());
69// G4cerr << "Buffer filled, reying with sqrts = "<< (trk1.Get4Momentum()+trk2.Get4Momentum()).mag() <<G4endl;
70 crossSect = BufferedCrossSection(trk1,trk2);
71 }
72 return crossSect;
73}
double G4double
Definition: G4Types.hh:64
virtual const G4VCrossSectionSource * GetCrossSectionSource() 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 76 of file G4CollisionComposite.cc.

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

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

Referenced by FinalState(), and IsInCharge().


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