Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4FTFParticipants.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27//
28
29// ------------------------------------------------------------
30// GEANT 4 class implementation file
31//
32// ---------------- G4FTFParticipants----------------
33// by Gunter Folger, June 1998.
34// class finding colliding particles in FTFPartonStringModel
35// Changed in a part by V. Uzhinsky in oder to put in correcpondence
36// with original FRITIOF mode. November - December 2006.
37// Ajusted for (anti) nucleus - nucleus interactions by V. Uzhinsky.
38// (February 2011)
39// ------------------------------------------------------------
40
41#include <utility>
42#include <vector>
43#include <algorithm>
44
45#include "G4FTFParticipants.hh"
46#include "G4ios.hh"
47#include "Randomize.hh"
48#include "G4SystemOfUnits.hh"
49#include "G4FTFParameters.hh"
51#include "G4VSplitableHadron.hh"
52
53
54//============================================================================
55
56//#define debugFTFparticipant
57
58
59//============================================================================
60
61G4FTFParticipants::G4FTFParticipants() : currentInteraction( -1 ) {}
62
63//============================================================================
64
66
67//============================================================================
68
70 G4FTFParameters* theParameters ) {
71
72 #ifdef debugFTFparticipant
73 G4cout << "Participants::GetList" << G4endl
74 << "thePrimary " << thePrimary.GetMomentum() << G4endl << G4endl;
75 #endif
76
77 G4double betta_z = thePrimary.GetMomentum().z() / thePrimary.GetTotalEnergy();
78 if ( betta_z < 1.0e-10 ) betta_z = 1.0e-10;
79
80 StartLoop(); // reset Loop over Interactions
81
82 for ( unsigned int i = 0; i < theInteractions.size(); i++ ) delete theInteractions[i];
83 theInteractions.clear();
84
85 G4double deltaxy = 2.0 * fermi; // Extra nuclear radius
86
87 if ( theProjectileNucleus == nullptr ) { // Hadron-nucleus or anti-baryon-nucleus interactions
88
89 G4double impactX( 0.0 ), impactY( 0.0 );
90
91 G4VSplitableHadron* primarySplitable = new G4DiffractiveSplitableHadron( thePrimary );
92
93 #ifdef debugFTFparticipant
94 G4cout << "Hadron-nucleus or anti-baryon-nucleus interactions" << G4endl;
95 #endif
96
97 G4double xyradius;
98 xyradius = theNucleus->GetOuterRadius() + deltaxy; // Range of impact parameter sampling
99
100 const G4int maxNumberOfLoops = 1000;
101 G4int loopCounter = 0;
102 do {
103
104 std::pair< G4double, G4double > theImpactParameter;
105 theImpactParameter = theNucleus->ChooseImpactXandY( xyradius );
106 impactX = theImpactParameter.first;
107 impactY = theImpactParameter.second;
108
109 #ifdef debugFTFparticipant
110 G4cout << "New interaction list," << " b= "
111 << std::sqrt( sqr(impactX ) + sqr( impactY ) )/fermi << G4endl;
112 #endif
113
114 G4ThreeVector thePosition( impactX, impactY, 0.0 );
115 primarySplitable->SetPosition( thePosition );
116
118 G4Nucleon* nucleon;
119
120 #ifdef debugFTFparticipant
121 G4int TrN( 0 );
122 #endif
123
124 while ( ( nucleon = theNucleus->GetNextNucleon() ) ) { /* Loop checking, 10.08.2015, A.Ribon */
125
126 G4double impact2 = sqr( impactX - nucleon->GetPosition().x() ) +
127 sqr( impactY - nucleon->GetPosition().y() );
128
129 if ( theParameters->GetProbabilityOfInteraction( impact2/fermi/fermi ) >
130 G4UniformRand() ) {
131 primarySplitable->SetStatus( 1 ); // It takes part in the interaction
132 G4VSplitableHadron* targetSplitable = 0;
133 if ( ! nucleon->AreYouHit() ) {
134 targetSplitable = new G4DiffractiveSplitableHadron( *nucleon );
135 nucleon->Hit( targetSplitable );
136 targetSplitable->SetStatus( 1 ); // It takes part in the interaction
137
138 #ifdef debugFTFparticipant
139 G4cout << "Participated nucleons #, " << TrN << " " << "Splitable Pr* Tr* "
140 << primarySplitable << " " << targetSplitable << G4endl;
141 #endif
142
143 }
144 G4InteractionContent* aInteraction = new G4InteractionContent( primarySplitable );
145 G4Nucleon* PrNucleon = 0;
146 aInteraction->SetProjectileNucleon( PrNucleon );
147 aInteraction->SetTarget( targetSplitable );
148 aInteraction->SetTargetNucleon( nucleon );
149 aInteraction->SetStatus( 1 );
150 aInteraction->SetInteractionTime( ( primarySplitable->GetPosition().z() +
151 nucleon->GetPosition().z() ) / betta_z );
152 theInteractions.push_back( aInteraction );
153 }
154
155 #ifdef debugFTFparticipant
156 TrN++;
157 #endif
158
159 }
160
161 } while ( ( theInteractions.size() == 0 ) &&
162 ++loopCounter < maxNumberOfLoops ); /* Loop checking, 10.08.2015, A.Ribon */
163 if ( loopCounter >= maxNumberOfLoops ) {
164 #ifdef debugFTFparticipant
165 G4cout << "BAD situation: forced exit from the while loop!" << G4endl;
166 #endif
167 return;
168 }
169
170 #ifdef debugFTFparticipant
171 G4cout << "Number of Hit nucleons " << theInteractions.size() << "\t Bx " << impactX/fermi
172 << "\t By " << impactY/fermi << "\t B "
173 << std::sqrt( sqr( impactX ) + sqr( impactY ) )/fermi << G4endl << G4endl;
174 #endif
175
176 //SortInteractionsIncT(); // Not need because nucleons are sorted in increasing z-coordinates.
177 ShiftInteractionTime(); // To put correct times and z-coordinates
178 return;
179
180 } // end of if ( theProjectileNucleus == 0 )
181
182 // Projectile and target are nuclei
183
184 #ifdef debugFTFparticipant
185 G4cout << "Projectile and target are nuclei" << G4endl;
186 #endif
187
188 //G4cout<<theProjectileNucleus->GetOuterRadius()/fermi<<" "<<theNucleus->GetOuterRadius()/fermi<<" "<<deltaxy/fermi<<G4endl;
189
190 G4double xyradius;
191 xyradius = theProjectileNucleus->GetOuterRadius() + // Range of impact parameter sampling
192 theNucleus->GetOuterRadius() + deltaxy;
193
194 G4double impactX( 0.0 ), impactY( 0.0 );
195
196 const G4int maxNumberOfLoops = 1000;
197 G4int loopCounter = 0;
198 do {
199
200 std::pair< G4double, G4double > theImpactParameter;
201 theImpactParameter = theNucleus->ChooseImpactXandY( xyradius );
202 impactX = theImpactParameter.first;
203 impactY = theImpactParameter.second;
204
205 #ifdef debugFTFparticipant
206 G4cout << "New interaction list, " << "b "
207 << std::sqrt( sqr( impactX ) + sqr( impactY ) )/fermi << G4endl;
208 #endif
209
210 G4ThreeVector theBeamPosition( impactX, impactY, 0.0 );
211
213 G4Nucleon* ProjectileNucleon;
214
215 #ifdef debugFTFparticipant
216 G4int PrNuclN( 0 );
217 #endif
218
219 while ( ( ProjectileNucleon = theProjectileNucleus->GetNextNucleon() ) ) { /* Loop checking, 10.08.2015, A.Ribon */
220
221 G4VSplitableHadron* ProjectileSplitable = 0;
223 G4Nucleon* TargetNucleon = 0;
224
225 #ifdef debugFTFparticipant
226 G4int TrNuclN( 0 );
227 #endif
228
229 while ( ( TargetNucleon = theNucleus->GetNextNucleon() ) ) { /* Loop checking, 10.08.2015, A.Ribon */
230
231 G4double impact2 = sqr( impactX + ProjectileNucleon->GetPosition().x() -
232 TargetNucleon->GetPosition().x() ) +
233 sqr( impactY + ProjectileNucleon->GetPosition().y() -
234 TargetNucleon->GetPosition().y() );
235 G4VSplitableHadron* TargetSplitable = 0;
236 if ( theParameters->GetProbabilityOfInteraction( impact2/fermi/fermi ) >
237 G4UniformRand() ) { // An interaction has happend!
238
239 #ifdef debugFTFparticipant
240 G4cout << G4endl << "An Interaction has happend" << G4endl << "Proj N mom " << PrNuclN
241 << " " << ProjectileNucleon->Get4Momentum() << "-------------" << G4endl
242 << "Targ N mom " << TrNuclN << " " << TargetNucleon->Get4Momentum() << G4endl
243 << "PrN TrN Z coords " << ProjectileNucleon->GetPosition().z()/fermi
244 << " " << TargetNucleon->GetPosition().z()/fermi
245 << " " << ProjectileNucleon->GetPosition().z()/fermi +
246 TargetNucleon->GetPosition().z()/fermi << G4endl;
247 #endif
248
249 if ( ! ProjectileNucleon->AreYouHit() ) {
250 // Projectile nucleon was not involved until now.
251 ProjectileSplitable = new G4DiffractiveSplitableHadron( *ProjectileNucleon );
252 ProjectileNucleon->Hit( ProjectileSplitable );
253 ProjectileSplitable->SetStatus( 1 ); // It takes part in the interaction
254 } else { // Projectile nucleon was involved before.
255 ProjectileSplitable = ProjectileNucleon->GetSplitableHadron();
256 }
257
258 if ( ! TargetNucleon->AreYouHit() ) { // Target nucleon was not involved until now
259 TargetSplitable = new G4DiffractiveSplitableHadron( *TargetNucleon );
260 TargetNucleon->Hit( TargetSplitable );
261 TargetSplitable->SetStatus( 1 ); // It takes part in the interaction
262 } else { // Target nucleon was involved before.
263 TargetSplitable = TargetNucleon->GetSplitableHadron();
264 }
265
266 G4InteractionContent* anInteraction = new G4InteractionContent( ProjectileSplitable );
267 anInteraction->SetTarget( TargetSplitable );
268 anInteraction->SetProjectileNucleon( ProjectileNucleon );
269 anInteraction->SetTargetNucleon( TargetNucleon );
270 anInteraction->SetInteractionTime( ( ProjectileNucleon->GetPosition().z() +
271 TargetNucleon->GetPosition().z() ) / betta_z );
272 anInteraction->SetStatus( 1 );
273
274 #ifdef debugFTFparticipant
275 G4cout << "Part anInteraction->GetInteractionTime() "
276 << anInteraction->GetInteractionTime()/fermi << G4endl
277 << "Splitable Pr* Tr* " << ProjectileSplitable << " "
278 << TargetSplitable << G4endl;
279 #endif
280
281 theInteractions.push_back( anInteraction );
282
283 } // End of an Interaction has happend!
284
285 #ifdef debugFTFparticipant
286 TrNuclN++;
287 #endif
288
289 } // End of while ( ( TargetNucleon = theNucleus->GetNextNucleon() ) )
290
291 #ifdef debugFTFparticipant
292 PrNuclN++;
293 #endif
294
295 } // End of while ( ( ProjectileNucleon = theProjectileNucleus->GetNextNucleon() ) )
296
297 if ( theInteractions.size() != 0 ) theProjectileNucleus->DoTranslation( theBeamPosition );
298
299 } while ( ( theInteractions.size() == 0 ) &&
300 ++loopCounter < maxNumberOfLoops ); /* Loop checking, 10.08.2015, A.Ribon */
301 if ( loopCounter >= maxNumberOfLoops ) {
302 #ifdef debugFTFparticipant
303 G4cout << "BAD situation: forced exit from the while loop!" << G4endl;
304 #endif
305 return;
306 }
307
310
311 #ifdef debugFTFparticipant
312 G4cout << G4endl << "Number of primary collisions " << theInteractions.size()
313 << "\t Bx " << impactX/fermi << "\t By " << impactY/fermi
314 << "\t B " << std::sqrt( sqr( impactX ) + sqr( impactY ) )/fermi << G4endl
315 << "FTF participant End. #######################" << G4endl << G4endl;
316 #endif
317 return;
318}
319
320
321//============================================================================
322
324 const G4InteractionContent* Int2 ) {
325 return Int1->GetInteractionTime() < Int2->GetInteractionTime();
326}
327
328
329//============================================================================
330
332 if ( theInteractions.size() < 2 ) return; // Avoid unnecesary work
333 std::sort( theInteractions.begin(), theInteractions.end(), G4FTFPartHelperForSortInT );
334}
335
336
337//============================================================================
338
340 G4double InitialTime = theInteractions[0]->GetInteractionTime();
341 for ( unsigned int i = 1; i < theInteractions.size(); i++ ) {
342 G4double InterTime = theInteractions[i]->GetInteractionTime() - InitialTime;
343 theInteractions[i]->SetInteractionTime( InterTime );
344 G4InteractionContent* aCollision = theInteractions[i];
345 G4VSplitableHadron* projectile = aCollision->GetProjectile();
346 G4VSplitableHadron* target = aCollision->GetTarget();
347 G4ThreeVector prPosition = projectile->GetPosition();
348 prPosition.setZ( target->GetPosition().z() );
349 projectile->SetPosition( prPosition );
350 projectile->SetTimeOfCreation( InterTime );
351 target->SetTimeOfCreation( InterTime );
352 }
353 return;
354}
355
356
357//============================================================================
358
360 for ( size_t i = 0; i < theInteractions.size(); i++ ) {
361 if ( theInteractions[ i ] ) {
362 delete theInteractions[ i ];
363 theInteractions[ i ] = 0;
364 }
365 }
366 theInteractions.clear();
367 currentInteraction = -1;
368}
369
bool G4FTFPartHelperForSortInT(const G4InteractionContent *Int1, const G4InteractionContent *Int2)
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
#define G4UniformRand()
Definition: Randomize.hh:52
double z() const
double x() const
double y() const
void setZ(double)
G4double GetProbabilityOfInteraction(const G4double impactsquare)
void GetList(const G4ReactionProduct &thePrimary, G4FTFParameters *theParameters)
G4double GetInteractionTime() const
void SetTargetNucleon(G4Nucleon *aNucleon)
G4VSplitableHadron * GetProjectile() const
void SetTarget(G4VSplitableHadron *aTarget)
void SetStatus(G4int aValue)
void SetInteractionTime(G4double aValue)
G4VSplitableHadron * GetTarget() const
void SetProjectileNucleon(G4Nucleon *aNucleon)
const G4ThreeVector & GetPosition() const
Definition: G4Nucleon.hh:138
G4bool AreYouHit() const
Definition: G4Nucleon.hh:96
G4VSplitableHadron * GetSplitableHadron() const
Definition: G4Nucleon.hh:95
virtual const G4LorentzVector & Get4Momentum() const
Definition: G4Nucleon.hh:72
void Hit(G4VSplitableHadron *aHit)
Definition: G4Nucleon.hh:89
G4double GetTotalEnergy() const
G4ThreeVector GetMomentum() const
virtual G4double GetOuterRadius()=0
virtual G4Nucleon * GetNextNucleon()=0
virtual G4bool StartLoop()=0
virtual void DoTranslation(const G4ThreeVector &theShift)=0
std::pair< G4double, G4double > ChooseImpactXandY(G4double maxImpact)
Definition: G4V3DNucleus.hh:86
G4V3DNucleus * theProjectileNucleus
G4V3DNucleus * theNucleus
void SetTimeOfCreation(G4double aTime)
void SetStatus(const G4int aStatus)
const G4ThreeVector & GetPosition() const
void SetPosition(const G4ThreeVector &aPosition)
T sqr(const T &x)
Definition: templates.hh:128