Geant4-11
Public Member Functions | Private Member Functions | Private Attributes
G4CollisionManager Class Reference

#include <G4CollisionManager.hh>

Public Member Functions

void AddCollision (G4CollisionInitialState *collision)
 
void AddCollision (G4double time, G4KineticTrack *proj, G4KineticTrack *target=NULL)
 
void ClearAndDestroy ()
 
G4int Entries ()
 
 G4CollisionManager ()
 
G4CollisionInitialStateGetNextCollision ()
 
void Print ()
 
void RemoveCollision (G4CollisionInitialState *collision)
 
void RemoveTracksCollisions (G4KineticTrackVector *ktv)
 
 ~G4CollisionManager ()
 

Private Member Functions

 G4CollisionManager (const G4CollisionManager &)
 
G4CollisionManageroperator= (const G4CollisionManager &)
 

Private Attributes

G4ListOfCollisionstheCollisionList
 

Detailed Description

Definition at line 36 of file G4CollisionManager.hh.

Constructor & Destructor Documentation

◆ G4CollisionManager() [1/2]

G4CollisionManager::G4CollisionManager ( )

Definition at line 35 of file G4CollisionManager.cc.

36{
38}
std::vector< G4CollisionInitialState * > G4ListOfCollisions
G4ListOfCollisions * theCollisionList

References theCollisionList.

◆ ~G4CollisionManager()

G4CollisionManager::~G4CollisionManager ( )

Definition at line 41 of file G4CollisionManager.cc.

42{
44 delete theCollisionList;
45}

References ClearAndDestroy(), and theCollisionList.

◆ G4CollisionManager() [2/2]

G4CollisionManager::G4CollisionManager ( const G4CollisionManager )
private

Member Function Documentation

◆ AddCollision() [1/2]

void G4CollisionManager::AddCollision ( G4CollisionInitialState collision)
inline

Definition at line 45 of file G4CollisionManager.hh.

46 {
47 theCollisionList->push_back(collision);
48 }

References theCollisionList.

◆ AddCollision() [2/2]

void G4CollisionManager::AddCollision ( G4double  time,
G4KineticTrack proj,
G4KineticTrack target = NULL 
)

Definition at line 48 of file G4CollisionManager.cc.

51{
52 if ( time < DBL_MAX )
53 {
55 collision = new G4CollisionInitialState(time, proj, target);
56 theCollisionList->push_back(collision);
57 } else {
58 G4cerr << "G4Scatterer invalid TimeTo Interaction : " << time;
59 G4cerr <<" projectile "<<proj->Get4Momentum()<<" "
61 if (target) G4cerr <<" target "
62 <<target->Get4Momentum()<<" "
63 <<target->GetDefinition()->GetParticleName()<<G4endl;
64 G4cerr <<"G4Scatterer error message end"<< G4endl;
65 throw G4HadronicException(__FILE__, __LINE__, "G4Scatterer::AddCollision()");
66 }
67}
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
const G4ParticleDefinition * GetDefinition() const
const G4LorentzVector & Get4Momentum() const
const G4String & GetParticleName() const
#define DBL_MAX
Definition: templates.hh:62

References DBL_MAX, G4cerr, G4endl, G4KineticTrack::Get4Momentum(), G4KineticTrack::GetDefinition(), G4ParticleDefinition::GetParticleName(), and theCollisionList.

Referenced by G4BinaryCascade::FindCollisions(), G4BinaryCascade::FindDecayCollision(), and G4BinaryCascade::FindLateParticleCollision().

◆ ClearAndDestroy()

void G4CollisionManager::ClearAndDestroy ( )

Definition at line 131 of file G4CollisionManager.cc.

132{
133 std::vector<G4CollisionInitialState *>::iterator i;
134 for(i = theCollisionList->begin(); i != theCollisionList->end(); ++i)
135 delete *i;
136 theCollisionList->clear();
137}

References theCollisionList.

Referenced by G4BinaryCascade::ApplyYourself(), G4BinaryCascade::Propagate(), and ~G4CollisionManager().

◆ Entries()

G4int G4CollisionManager::Entries ( )
inline

◆ GetNextCollision()

G4CollisionInitialState * G4CollisionManager::GetNextCollision ( )

Definition at line 140 of file G4CollisionManager.cc.

141{
142 G4CollisionInitialState * theNext=0;
143 G4double nextTime = DBL_MAX;
144 std::vector<G4CollisionInitialState *>::iterator i;
145 for(i = theCollisionList->begin(); i != theCollisionList->end(); ++i)
146 {
147 if(nextTime > (*i)->GetCollisionTime())
148 {
149 nextTime = (*i)->GetCollisionTime();
150 theNext = *i;
151 }
152 }
153 #ifdef debug_G4CollisionManager
154 if(theNext == 0 && theCollisionList->size()!=0)
155 {
156 G4double debugTime = DBL_MAX;
157 G4cerr <<"G4CollisionManager::GetNextCollision - Fatal"<<G4endl;
158 G4cerr <<" number of collisions left "<<theCollisionList->size()<<G4endl;
159 for(i = theCollisionList->begin(); i != theCollisionList->end(); ++i)
160 {
161 G4cerr <<" Time to collision "<<(*i)->GetCollisionTime()<<" "<<G4endl;
162 G4cerr <<" projectile "<<(*i)->GetPrimary()->Get4Momentum()<<" "
163 <<(*i)->GetPrimary()->GetDefinition()->GetParticleName()<<G4endl;
164 if ((*i)->GetTarget()) G4cerr <<" target "<<(*i)->GetTarget()->Get4Momentum()<<" "
165 <<(*i)->GetTarget()->GetDefinition()->GetParticleName()<<G4endl;
166 }
167 G4cerr <<"G4CollisionManager::GetNextCollision - End of message"<<G4endl;
168 }
169 #endif
170
171 return theNext;
172}
double G4double
Definition: G4Types.hh:83

References DBL_MAX, G4cerr, G4endl, and theCollisionList.

Referenced by G4BinaryCascade::DoTimeStep(), G4BinaryCascade::FillVoidNucleusProducts(), G4BinaryCascade::Propagate(), and G4BinaryCascade::StepParticlesOut().

◆ operator=()

G4CollisionManager & G4CollisionManager::operator= ( const G4CollisionManager )
private

◆ Print()

void G4CollisionManager::Print ( )

Definition at line 175 of file G4CollisionManager.cc.

176{
177 std::vector<G4CollisionInitialState *>::iterator i;
178
179 G4cout << "CollisionManager: " << theCollisionList->size()
180 << " entries at " << theCollisionList << G4endl;
181 G4CollisionInitialState * collision;
182 for(i = theCollisionList->begin(); i != theCollisionList->end(); ++i)
183 {
184 collision = *i;
185 G4int tgtPdg=collision->GetTarget() ?
186 collision->GetTarget()->GetDefinition()->GetPDGEncoding() : 0;
187 const G4BCAction &action= *collision->GetGenerator();
188 G4cout << " collision " << collision << " time: "
189 << collision->GetCollisionTime()/second << " proj: "
190 << collision->GetPrimary() << "/pdg="
191 << collision->GetPrimary()->GetDefinition()->GetPDGEncoding()
192 << " trgt: "
193 << collision->GetTarget() << "/pdg="
194 << tgtPdg
195 << " Collision type: "<< typeid(action).name()
196 << G4endl;
197 }
198}
static constexpr double second
Definition: G4SIunits.hh:137
int G4int
Definition: G4Types.hh:85
G4GLOB_DLL std::ostream G4cout
const G4BCAction * GetGenerator()
G4KineticTrack * GetTarget(void)
G4KineticTrack * GetPrimary(void)
const char * name(G4int ptype)

References geant4_check_module_cycles::action, G4cout, G4endl, G4CollisionInitialState::GetCollisionTime(), G4KineticTrack::GetDefinition(), G4CollisionInitialState::GetGenerator(), G4ParticleDefinition::GetPDGEncoding(), G4CollisionInitialState::GetPrimary(), G4CollisionInitialState::GetTarget(), G4InuclParticleNames::name(), second, and theCollisionList.

Referenced by G4BinaryCascade::ApplyCollision().

◆ RemoveCollision()

void G4CollisionManager::RemoveCollision ( G4CollisionInitialState collision)

Definition at line 70 of file G4CollisionManager.cc.

71{
72 theCollisionList->erase(std::find(theCollisionList->begin(),
73 theCollisionList->end(),
74 collision));
75 delete collision;
76 collision = NULL; // prevent future use of the pointer
77}

References theCollisionList.

Referenced by G4BinaryCascade::FillVoidNucleusProducts(), G4BinaryCascade::Propagate(), and G4BinaryCascade::StepParticlesOut().

◆ RemoveTracksCollisions()

void G4CollisionManager::RemoveTracksCollisions ( G4KineticTrackVector ktv)

Definition at line 80 of file G4CollisionManager.cc.

81{
82 if(toBeCaned == NULL)
83 return;
84 if(toBeCaned->empty())
85 return;
86
87 G4CollisionInitialState * collision;
88 std::vector<G4CollisionInitialState *>::iterator collIter, collIter2;
89 std::vector<G4KineticTrack *>::iterator trackIter;
90 G4ListOfCollisions toRemove;
91
92 for(collIter = theCollisionList->begin();
93 collIter != theCollisionList->end(); collIter++)
94 {
95 collision = *collIter;
96 G4KineticTrackVector & targets = collision->GetTargetCollection();
97 G4bool getNextCollision = false;
98 for(trackIter = toBeCaned->begin(); trackIter != toBeCaned->end(); ++trackIter)
99 {
100 if((collision->GetTarget() == *trackIter) ||
101 (collision->GetPrimary() == *trackIter))
102 { // cannot remove the collision from the list inside the loop. Save and do it later
103 toRemove.push_back(collision);
104 break; // exit from the "trackIter" loop
105 }
106 for(size_t tcount=0; tcount<targets.size(); tcount++)
107 {
108 if(targets[tcount] == *trackIter)
109 {
110 toRemove.push_back(collision);
111 getNextCollision = true;
112 break;
113 }
114 }
115 if(getNextCollision) break;
116 }
117 }
118
119 // now remove the collisions
120 for(collIter = toRemove.begin(); collIter != toRemove.end(); ++collIter)
121 {
122 collision = *collIter;
123 collIter2 = std::find(theCollisionList->begin(),
124 theCollisionList->end(), collision);
125 theCollisionList->erase(collIter2); // remove from list...
126 delete collision; // ...and delete the collision
127 }
128}
bool G4bool
Definition: G4Types.hh:86
G4KineticTrackVector & GetTargetCollection(void)

References G4CollisionInitialState::GetPrimary(), G4CollisionInitialState::GetTarget(), G4CollisionInitialState::GetTargetCollection(), and theCollisionList.

Referenced by G4BinaryCascade::ApplyCollision(), and G4BinaryCascade::UpdateTracksAndCollisions().

Field Documentation

◆ theCollisionList

G4ListOfCollisions* G4CollisionManager::theCollisionList
private

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