Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4CollisionComposite Class Reference

#include <G4CollisionComposite.hh>

Inheritance diagram for G4CollisionComposite:
Collaboration 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
G4VCrossSectionSource
GetCrossSectionSource () const
 
virtual const
G4VAngularDistribution
GetAngularDistribution () 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 58 of file G4CollisionComposite.hh.

Constructor & Destructor Documentation

G4CollisionComposite::G4CollisionComposite ( )

Definition at line 45 of file G4CollisionComposite.cc.

46 {
47  G4MUTEXINIT( bufferMutex );
48 }
#define G4MUTEXINIT(mutex)
Definition: G4Threading.hh:177
G4CollisionComposite::~G4CollisionComposite ( )
virtual

Definition at line 51 of file G4CollisionComposite.cc.

52 {
53  G4MUTEXDESTROY(bufferMutex);
54  std::for_each(components.begin(), components.end(), G4Delete());
55 }
#define G4MUTEXDESTROY(mutex)
Definition: G4Threading.hh:178

Member Function Documentation

void G4CollisionComposite::AddComponent ( G4VCollision aC)
inline

Definition at line 73 of file G4CollisionComposite.hh.

73 {components.push_back(aC);}

Here is the caller graph for this function:

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

Reimplemented from G4VCollision.

Reimplemented in G4CollisionNN.

Definition at line 58 of file G4CollisionComposite.cc.

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

Here is the call graph for this function:

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

Implements G4VCollision.

Definition at line 80 of file G4CollisionComposite.cc.

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

Here is the call graph for this function:

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

Implements G4VCollision.

Reimplemented in G4CollisionPN, and G4CollisionNN.

Definition at line 77 of file G4CollisionComposite.hh.

77 { return 0; }
virtual const G4VCrossSectionSource* G4CollisionComposite::GetCrossSectionSource ( ) const
inlinevirtual

Implements G4VCollision.

Reimplemented in G4CollisionPN, and G4CollisionNN.

Definition at line 76 of file G4CollisionComposite.hh.

76 { return 0; }

Here is the caller graph for this function:

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

Implements G4VCollision.

Reimplemented in G4GeneralNNCollision.

Definition at line 122 of file G4CollisionComposite.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:


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