source: trunk/source/processes/hadronic/models/incl/src/G4InclCascadeInterface.cc@ 1344

Last change on this file since 1344 was 1340, checked in by garnier, 15 years ago

update ti head

File size: 18.3 KB
RevLine 
[819]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//
[1340]26// $Id: G4InclCascadeInterface.cc,v 1.12 2010/10/26 02:47:59 kaitanie Exp $
[819]27// Translation of INCL4.2/ABLA V3
28// Pekka Kaitaniemi, HIP (translation)
29// Christelle Schmidt, IPNL (fission code)
30// Alain Boudard, CEA (contact person INCL/ABLA)
31// Aatos Heikkinen, HIP (project coordination)
32
33//#define DEBUGINCL 1
34
35#include "G4InclCascadeInterface.hh"
36#include "math.h"
37#include "G4GenericIon.hh"
38#include "CLHEP/Random/Random.h"
39
40G4InclCascadeInterface::G4InclCascadeInterface()
41{
42 hazard = new G4Hazard();
43 const G4long* table_entry = CLHEP::HepRandom::getTheSeeds(); // Get random seed from CLHEP.
44 hazard->ial = (*table_entry);
45
46 varntp = new G4VarNtp();
[1340]47 inclInput = 0;
[819]48 ws = new G4Ws();
49 mat = new G4Mat();
[1340]50 incl = new G4Incl(hazard, inclInput, ws, mat, varntp);
[819]51
52 verboseLevel = 0;
53}
54
55G4InclCascadeInterface::~G4InclCascadeInterface()
56{
57 delete hazard;
58 delete varntp;
[1340]59 delete inclInput;
[819]60 delete ws;
61 delete mat;
62 delete incl;
63}
64
65G4HadFinalState* G4InclCascadeInterface::ApplyYourself(const G4HadProjectile& aTrack, G4Nucleus& theNucleus)
66{
67 G4int maxTries = 200;
68
[1340]69 G4int particleI;
[819]70
71 // Print diagnostic messages: 0 = silent, 1 and 2 = verbose
72 verboseLevel = 0;
73
74 // Increase the event number:
75 eventNumber++;
76
77 if (verboseLevel > 1) {
78 G4cout << " >>> G4InclCascadeInterface::ApplyYourself called" << G4endl;
79 }
80
81 if(verboseLevel > 1) {
82 G4cout <<"G4InclCascadeInterface: Now processing INCL4 event number:" << eventNumber << G4endl;
83 }
84
85#ifdef DEBUGINCL
86 G4cout <<"Bullet energy = " << bulletE / MeV << G4endl;
87#endif
88
89 G4double eKin;
90 G4double momx = 0.0, momy = 0.0, momz = 0.0;
91 G4DynamicParticle *cascadeParticle = 0;
92 G4ParticleDefinition *aParticleDefinition = 0;
93
94 // INCL assumes the projectile particle is going in the direction of
95 // the Z-axis. Here we construct proper rotation to convert the
96 // momentum vectors of the outcoming particles to the original
97 // coordinate system.
98 G4LorentzVector projectileMomentum = aTrack.Get4Momentum();
99 G4LorentzRotation toZ;
100 toZ.rotateZ(-projectileMomentum.phi());
101 toZ.rotateY(-projectileMomentum.theta());
102 G4LorentzRotation toLabFrame = toZ.inverse();
103
[1340]104 inclInput = new G4InclInput(aTrack, theNucleus, false);
105
[819]106 theResult.Clear(); // Make sure the output data structure is clean.
107
108#ifdef DEBUGINCL
109 G4int baryonBullet = 0, chargeBullet = 0;
110 if(bulletType == proton || bulletType == neutron) baryonBullet = 1;
111 if(bulletType == proton || bulletType == pionPlus) chargeBullet = 1;
112 if(bulletType == pionMinus) chargeBullet = -1;
113 G4int baryonNumber = int(std::floor(targetA)) + baryonBullet;
114 G4int chargeNumber = int(std::floor(targetZ)) + chargeBullet;
115 G4double mass = aTrack.GetDefinition()->GetPDGMass();
116 G4double amass = theNucleus.AtomicMass(targetA, targetZ);
117 G4double eKinSum = bulletE;
118 G4LorentzVector labv = G4LorentzVector(0.0, 0.0, std::sqrt(bulletE*(bulletE + 2.*mass)), bulletE + mass + amass);
119 G4cout <<"Energy in the beginning = " << labv.e() / MeV << G4endl;
120#endif
121
122 // Check wheter the input is acceptable.
[1340]123 if((inclInput->bulletType() != 0) && ((inclInput->targetA() != 1) && (inclInput->targetZ() != 1))) {
[819]124 ws->nosurf = -2; // Nucleus surface, -2 = Woods-Saxon
125 ws->xfoisa = 8;
126 ws->npaulstr = 0;
127
128 int nTries = 0;
129 varntp->ntrack = 0;
130
131 mat->nbmat = 1;
[1340]132 mat->amat[0] = int(inclInput->targetA());
133 mat->zmat[0] = int(inclInput->targetZ());
[819]134
135 incl->initIncl(true);
136
137 while((varntp->ntrack <= 0) && (nTries < maxTries)) { // Loop until we produce real cascade
138 nTries++;
139 if(verboseLevel > 1) {
140 G4cout <<"G4InclCascadeInterface: Try number = " << nTries << G4endl;
141 }
[1340]142 incl->processEventIncl(inclInput);
[819]143
144 if(verboseLevel > 1) {
145 G4cout <<"G4InclCascadeInterface: number of tracks = " << varntp->ntrack <<G4endl;
146 }
147 }
148
149 if(verboseLevel > 1) {
150 /**
151 * Diagnostic output
152 */
[1340]153 G4cout <<"G4InclCascadeInterface: Bullet type: " << inclInput->bulletType() << G4endl;
154 G4cout <<"G4Incl4AblaCascadeInterface: Bullet energy: " << inclInput->bulletE() << " MeV" << G4endl;
[819]155
[1340]156 G4cout <<"G4InclCascadeInterface: Target A: " << inclInput->targetA() << G4endl;
157 G4cout <<"G4InclCascadeInterface: Target Z: " << inclInput->targetZ() << G4endl;
[819]158
159 if(verboseLevel > 3) {
[1340]160 diagdata <<"G4InclCascadeInterface: Bullet type: " << inclInput->bulletType() << G4endl;
161 diagdata <<"G4InclCascadeInterface: Bullet energy: " << inclInput->bulletE() << " MeV" << G4endl;
[819]162
[1340]163 diagdata <<"G4InclCascadeInterface: Target A: " << inclInput->targetA() << G4endl;
164 diagdata <<"G4InclCascadeInterface: Target Z: " << inclInput->targetZ() << G4endl;
[819]165 }
166
[1340]167 // for(particleI = 0; particleI < varntp->ntrack; particleI++) {
168 // G4cout << n << " " << inclInput->f[6] << " " << inclInput->f[2] << " ";
169 // G4cout << varntp->massini << " " << varntp->mzini << " ";
170 // G4cout << varntp->exini << " " << varntp->mulncasc << " " << varntp->mulnevap << " " << varntp->mulntot << " ";
171 // G4cout << varntp->bimpact << " " << varntp->jremn << " " << varntp->kfis << " " << varntp->estfis << " ";
172 // G4cout << varntp->izfis << " " << varntp->iafis << " " << varntp->ntrack << " " << varntp->itypcasc[particleI] << " ";
173 // G4cout << varntp->avv[particleI] << " " << varntp->zvv[particleI] << " " << varntp->enerj[particleI] << " ";
174 // G4cout << varntp->plab[particleI] << " " << varntp->tetlab[particleI] << " " << varntp->philab[particleI] << G4endl;
175 // // For diagnostic output
176 // if(verboseLevel > 3) {
177 // diagdata << n << " " << inclInput->f[6] << " " << inclInput->f[2] << " ";
178 // diagdata << varntp->massini << " " << varntp->mzini << " ";
179 // diagdata << varntp->exini << " " << varntp->mulncasc << " " << varntp->mulnevap << " " << varntp->mulntot << " ";
180 // diagdata << varntp->bimpact << " " << varntp->jremn << " " << varntp->kfis << " " << varntp->estfis << " ";
181 // diagdata << varntp->izfis << " " << varntp->iafis << " " << varntp->ntrack << " ";
182 // diagdata << varntp->itypcasc[particleI] << " ";
183 // diagdata << varntp->avv[particleI] << " " << varntp->zvv[particleI] << " " << varntp->enerj[particleI] << " ";
184 // diagdata << varntp->plab[particleI] << " " << varntp->tetlab[particleI] << " " << varntp->philab[particleI] << G4endl;
185 // }
186 // }
[819]187 }
188
189 // Check whether a valid cascade was produced.
190 // If not return the original bullet particle with the same momentum.
191 if(varntp->ntrack <= 0) {
192 if(verboseLevel > 1) {
193 G4cout <<"WARNING G4InclCascadeInterface: No cascade. Returning original particle with original momentum." << G4endl;
194 G4cout <<"\t Reached maximum trials of 200 to produce inelastic scattering." << G4endl;
195 }
196
197 theResult.SetStatusChange(stopAndKill);
[1340]198 aParticleDefinition = G4InclInput::getParticleDefinition(inclInput->bulletType());
[819]199
200 cascadeParticle = new G4DynamicParticle();
201 cascadeParticle->SetDefinition(aParticleDefinition);
202 cascadeParticle->Set4Momentum(aTrack.Get4Momentum());
203 theResult.AddSecondary(cascadeParticle);
204 }
205
206 // Convert INCL4 output to Geant4 compatible data structures.
207 // Elementary particles are converted to G4DynamicParticle.
208 theResult.SetStatusChange(stopAndKill);
209
210#ifdef DEBUGINCL
211 G4cout << "E [MeV]" << std::setw(12) << " Ekin [MeV]" << std::setw(12) << " E* [MeV]" << std::setw(12) << "Px [MeV]" << std::setw(12) << " Py [MeV]" << std::setw(12) << "Pz [MeV]" << std::setw(12) << "Pt [MeV]" << std::setw(12) << "A" << std::setw(12) << "Z" << G4endl;
212#endif
213
214 for(particleI = 0; particleI < varntp->ntrack; particleI++) { // Loop through the INCL4+ABLA output.
215 // Get energy/momentum and construct momentum vector in INCL4 coordinates.
216 momx = varntp->plab[particleI]*std::sin(varntp->tetlab[particleI]*CLHEP::pi/180.0)*std::cos(varntp->philab[particleI]*CLHEP::pi/180.0)*MeV;
217 momy = varntp->plab[particleI]*std::sin(varntp->tetlab[particleI]*CLHEP::pi/180.0)*std::sin(varntp->philab[particleI]*CLHEP::pi/180.0)*MeV;
218 momz = varntp->plab[particleI]*std::cos(varntp->tetlab[particleI]*CLHEP::pi/180.0)*MeV;
219
220 eKin = varntp->enerj[particleI] * MeV;
221
222 G4ThreeVector momDirection(momx, momy, momz); // Direction of the particle.
223 momDirection = momDirection.unit();
224 if(verboseLevel > 2) {
225 G4cout <<"G4InclCascadeInterface: " << G4endl;
226 G4cout <<"A = " << varntp->avv[particleI] << " Z = " << varntp->zvv[particleI] << G4endl;
227 G4cout <<"eKin = " << eKin << " MeV" << G4endl;
228 G4cout <<"px = " << momDirection.x() << " py = " << momDirection.y() <<" pz = " << momDirection.z() << G4endl;
229 }
230
231 G4int particleIdentified = 0; // Check particle ID.
232
233 if((varntp->avv[particleI] == 1) && (varntp->zvv[particleI] == 1)) { // Proton
234 cascadeParticle =
235 new G4DynamicParticle(G4Proton::ProtonDefinition(), momDirection, eKin);
236 particleIdentified++;
237#ifdef DEBUGINCL
238 baryonNumber--;
239 chargeNumber--;
240#endif
241 }
242
243 if((varntp->avv[particleI] == 1) && (varntp->zvv[particleI] == 0)) { // Neutron
244 cascadeParticle =
245 new G4DynamicParticle(G4Neutron::NeutronDefinition(), momDirection, eKin);
246 particleIdentified++;
247#ifdef DEBUGINCL
248 baryonNumber--;
249#endif
250 }
251
252 if((varntp->avv[particleI] == -1) && (varntp->zvv[particleI] == 1)) { // PionPlus
253 cascadeParticle =
254 new G4DynamicParticle(G4PionPlus::PionPlusDefinition(), momDirection, eKin);
255 particleIdentified++;
256#ifdef DEBUGINCL
257 chargeNumber--;
258#endif
259 }
260
261 if((varntp->avv[particleI] == -1) && (varntp->zvv[particleI] == 0)) { // PionZero
262 cascadeParticle =
263 new G4DynamicParticle(G4PionZero::PionZeroDefinition(), momDirection, eKin);
264 particleIdentified++;
265 }
266
267 if((varntp->avv[particleI] == -1) && (varntp->zvv[particleI] == -1)) { // PionMinus
268 cascadeParticle =
269 new G4DynamicParticle(G4PionMinus::PionMinusDefinition(), momDirection, eKin);
270 particleIdentified++;
271#ifdef DEBUGINCL
272 chargeNumber++;
273#endif
274 }
275
276 if((varntp->avv[particleI] > 1) && (varntp->zvv[particleI] >= 1)) { // Nucleus fragment
277 G4ParticleDefinition * aIonDef = 0;
278 G4ParticleTable *theTableOfParticles = G4ParticleTable::GetParticleTable();
279
280 G4int A = G4int(varntp->avv[particleI]);
281 G4int Z = G4int(varntp->zvv[particleI]);
282 G4double excitationE = G4double(varntp->exini) * MeV;
283
284 if(verboseLevel > 1) {
285 G4cout <<"Finding ion: A = " << A << " Z = " << Z << " E* = " << excitationE/MeV << G4endl;
286 }
287 aIonDef = theTableOfParticles->GetIon(Z, A, excitationE);
288
289 if(aIonDef == 0) {
290 if(verboseLevel > 1) {
291 G4cout <<"G4InclCascadeInterface: " << G4endl;
292 G4cout <<"FATAL ERROR: aIonDef = 0" << G4endl;
293 G4cout <<"A = " << A << " Z = " << Z << " E* = " << excitationE << G4endl;
294 }
295 }
296
297 if(aIonDef != 0) { // If the ion was identified add it to output.
298 cascadeParticle =
299 new G4DynamicParticle(aIonDef, momDirection, eKin);
300 particleIdentified++;
301#ifdef DEBUGINCL
302 baryonNumber = baryonNumber - A;
303 chargeNumber = chargeNumber - Z;
304#endif
305 }
306 }
307
308 if(particleIdentified == 1) { // Particle identified properly.
309 cascadeParticle->Set4Momentum(cascadeParticle->Get4Momentum()*=toLabFrame);
310#ifdef DEBUGINCL
311 G4ParticleDefinition *pd = cascadeParticle->GetDefinition();
312 G4LorentzVector fm = cascadeParticle->Get4Momentum();
313 G4ThreeVector mom = cascadeParticle->GetMomentum();
314 G4double m = pd->GetPDGMass();
315 G4double p = mom.mag();
316 labv -= fm;
317 G4double px = mom.x() * MeV;
318 G4double py = mom.y() * MeV;
319 G4double pz = mom.z() * MeV;
320 G4double pt = std::sqrt(px*px+py*py);
321 G4double e = fm.e();
322 eKinSum -= cascadeParticle->GetKineticEnergy() * MeV;
323 G4double exE;
324 if(varntp->avv[particleI] > 1) {
325 exE = varntp->exini;
326 }
327 else {
328 exE = 0.0;
329 }
330 G4cout << fm.e() / MeV
331 << std::setw(12) << cascadeParticle->GetKineticEnergy() / MeV
332 << std::setw(12) << exE / MeV
333 << std::setw(12) << mom.x() / MeV
334 << std::setw(12) << mom.y() / MeV
335 << std::setw(12) << mom.z() / MeV
336 << std::setw(12) << pt / MeV
337 << std::setw(12) << varntp->avv[particleI]
338 << std::setw(12) << varntp->zvv[particleI] << G4endl;
339#endif
340 theResult.AddSecondary(cascadeParticle); // Put data into G4HadFinalState.
341 }
342 else { // Particle identification failed.
343 if(particleIdentified > 1) { // Particle was identified as more than one particle type.
344 if(verboseLevel > 1) {
345 G4cout <<"G4InclCascadeInterface: One outcoming particle was identified as";
346 G4cout <<"more than one particle type. This is probably due to a bug in the interface." << G4endl;
347 G4cout <<"Particle A:" << varntp->avv[particleI] << "Z: " << varntp->zvv[particleI] << G4endl;
348 G4cout << "(particleIdentified =" << particleIdentified << ")" << G4endl;
349 }
350 }
351 }
352 }
353#ifdef DEBUGINCL
354 G4cout <<"--------------------------------------------------------------------------------" << G4endl;
355 G4double pt = std::sqrt(std::pow(labv.x(), 2) + std::pow(labv.y(), 2));
356 G4cout << labv.e() / MeV << std::setw(12) << eKinSum / MeV << std::setw(12) << labv.x() << std::setw(12) << labv.y() << std::setw(12) << labv.z() << std::setw(12) << pt / MeV << std::setw(12) << baryonNumber << std::setw(12) << chargeNumber << " totals" << G4endl;
357 G4cout << G4endl;
358
359 if(verboseLevel > 3) {
360 if(baryonNumber != 0) {
361 G4cout <<"WARNING G4InclCascadeInterface: Baryon number conservation violated." << G4endl;
362 G4cout <<"Baryon number balance after the event: " << baryonNumber << G4endl;
363 if(baryonNumber < 0) {
364 G4cout <<"Too many baryons produced." << G4endl;
365 } else {
366 G4cout <<"Too few baryons produced." << G4endl;
367 }
368 }
369 }
370#endif
371
372 varntp->ntrack = 0; // Clean up the number of generated particles in the event.
373 }
374 /**
375 * Report unsupported features.
376 * (Check bullet, target, energy range)
377 */
378 else { // If the bullet type was not recognized by the interface, it will be returned back without any interaction.
379 theResult.SetStatusChange(stopAndKill);
380
381 G4ParticleTable *theTableOfParticles = G4ParticleTable::GetParticleTable();
382 cascadeParticle = new G4DynamicParticle(theTableOfParticles->FindParticle(aTrack.GetDefinition()), aTrack.Get4Momentum());
383
384 theResult.AddSecondary(cascadeParticle);
385
386 if(verboseLevel > 1) {
387 G4cout <<"ERROR G4InclCascadeInterface: Processing event number (internal) failed " << eventNumber << G4endl;
388 }
389 if(verboseLevel > 3) {
390 diagdata <<"ERROR G4InclCascadeInterface: Processing event number (internal) failed " << eventNumber << G4endl;
391 }
392
[1340]393 if(inclInput->bulletType() == 0) {
[819]394 if(verboseLevel > 1) {
395 G4cout <<"G4InclCascadeInterface: Unknown bullet type" << G4endl;
396 G4cout <<"Bullet particle name: " << cascadeParticle->GetDefinition()->GetParticleName() << G4endl;
397 }
398 if(verboseLevel > 3) {
399 diagdata <<"G4InclCascadeInterface: Unknown bullet type" << G4endl;
400 diagdata <<"Bullet particle name: " << cascadeParticle->GetDefinition()->GetParticleName() << G4endl;
401 }
402 }
403
[1340]404 if((inclInput->targetA() == 1) && (inclInput->targetZ() == 1)) { // Unsupported target
[819]405 if(verboseLevel > 1) {
406 G4cout <<"Unsupported target: " << G4endl;
[1340]407 G4cout <<"Target A: " << inclInput->targetA() << G4endl;
408 G4cout <<"TargetZ: " << inclInput->targetZ() << G4endl;
[819]409 }
410 if(verboseLevel > 3) {
411 diagdata <<"Unsupported target: " << G4endl;
[1340]412 diagdata <<"Target A: " << inclInput->targetA() << G4endl;
413 diagdata <<"TargetZ: " << inclInput->targetZ() << G4endl;
[819]414 }
415 }
416
[1340]417 if(inclInput->bulletE() < 100) { // INCL does not support E < 100 MeV.
[819]418 if(verboseLevel > 1) {
[1340]419 G4cout <<"Unsupported bullet energy: " << inclInput->bulletE() << " MeV. (Lower limit is 100 MeV)." << G4endl;
[819]420 G4cout <<"WARNING: Returning the original bullet with original energy back to Geant4." << G4endl;
421 }
422 if(verboseLevel > 3) {
[1340]423 diagdata <<"Unsupported bullet energy: " << inclInput->bulletE() << " MeV. (Lower limit is 100 MeV)." << G4endl;
[819]424 }
425 }
426
427 if(verboseLevel > 3) {
428 diagdata <<"WARNING: returning the original bullet with original energy back to Geant4." << G4endl;
429 }
430 }
431
432 return &theResult;
433}
434
435G4ReactionProductVector* G4InclCascadeInterface::Propagate(G4KineticTrackVector* , G4V3DNucleus* ) {
436 return 0;
437}
438
439
Note: See TracBrowser for help on using the repository browser.