Ignore:
Timestamp:
Nov 5, 2010, 3:45:55 PM (15 years ago)
Author:
garnier
Message:

update ti head

Location:
trunk/source/processes/hadronic/models/incl/src
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/processes/hadronic/models/incl/src/G4Abla.cc

    r1196 r1340  
    2424// ********************************************************************
    2525//
    26 // $Id: G4Abla.cc,v 1.20 2009/11/18 10:43:14 kaitanie Exp $
     26// $Id: G4Abla.cc,v 1.22 2010/10/26 02:47:59 kaitanie Exp $
    2727// Translation of INCL4.2/ABLA V3
    2828// Pekka Kaitaniemi, HIP (translation)
     
    9898}
    9999
     100void G4Abla::setVerboseLevel(G4int level)
     101{
     102  verboseLevel = level;
     103  if(verboseLevel > G4InclUtils::silent) {
     104    G4cout <<";; G4Abla: Setting verbose level to " << verboseLevel << G4endl;
     105  }
     106  fissionModel->setVerboseLevel(verboseLevel);
     107}
     108
    100109G4Abla::~G4Abla()
    101110{
     
    111120}
    112121
     122void G4Abla::registerLogger(G4VInclLogger *theLogger) {
     123  if(theLogger != NULL) {
     124    this->theLogger = theLogger;
     125  }
     126}
     127
    113128// Main interface to the evaporation
    114129
     
    118133// G4Fragment?
    119134
    120 void G4Abla::breakItUp(G4double nucleusA, G4double nucleusZ, G4double nucleusMass, G4double excitationEnergy,
     135void G4Abla::breakItUp(G4int nucleusA, G4int nucleusZ, G4double nucleusMass, G4double excitationEnergy,
    121136                       G4double angularMomentum, G4double recoilEnergy, G4double momX, G4double momY, G4double momZ,
    122137                       G4int eventnumber)
     
    187202  G4double esrem = excitationEnergy;
    188203 
    189   G4double aprf = nucleusA;
    190   G4double zprf = nucleusZ;
     204  G4double aprf = (double) nucleusA;
     205  G4double zprf = (double) nucleusZ;
    191206  G4double mcorem = nucleusMass;
    192207  G4double ee = excitationEnergy;
     
    208223 
    209224  G4double pcorem = std::sqrt(erecrem*(erecrem +2.*938.2796*nucleusA));
     225#ifdef G4INCLDEBUG
     226  theLogger->fillHistogram1D("pcorem", pcorem);
     227#endif
    210228    // G4double pcorem = std::sqrt(std::pow(momX,2) + std::pow(momY,2) + std::pow(momZ,2));
    211229  if(pcorem != 0) { // Guard against division by zero.
  • trunk/source/processes/hadronic/models/incl/src/G4AblaEvaporation.cc

    r962 r1340  
    2424// ********************************************************************
    2525//
    26 // $Id: G4AblaEvaporation.cc,v 1.4 2008/10/24 21:07:40 dennis Exp $
     26// $Id: G4AblaEvaporation.cc,v 1.6 2010/10/26 02:47:59 kaitanie Exp $
    2727//
    2828#include <numeric>
     
    8282  hazard->igraine[17] = 33759;
    8383  hazard->igraine[18] = 13227;
     84
     85  G4VarNtp *evaporationResult = new G4VarNtp();
     86  G4Volant *volant = new G4Volant();
     87
     88  // Initialize evaporation.
     89  abla = new G4Abla(hazard, volant, evaporationResult);
     90  abla->initEvapora();
    8491}
    8592
     
    108115}
    109116
    110 G4FragmentVector * G4AblaEvaporation::BreakItUp(const G4Fragment &theNucleus) {
    111  
    112 
    113   G4VarNtp *varntp = new G4VarNtp();
    114   G4Volant *volant = new G4Volant();
    115 
    116   G4Abla *abla = new G4Abla(hazard, volant, varntp);
    117   G4cout <<"Initializing evaporation..." << G4endl;
    118   abla->initEvapora();
    119   G4cout <<"Initialization complete!" << G4endl;
    120  
    121   G4double nucleusA = theNucleus.GetA();
    122   G4double nucleusZ = theNucleus.GetZ();
     117G4FragmentVector * G4AblaEvaporation::BreakItUp(const G4Fragment &theNucleus) { 
     118  G4int nucleusA = theNucleus.GetA_asInt();
     119  G4int nucleusZ = theNucleus.GetZ_asInt();
    123120  G4double nucleusMass = G4NucleiProperties::GetNuclearMass(nucleusA, nucleusZ);
    124121  G4double excitationEnergy = theNucleus.GetExcitationEnergy();
     
    137134
    138135  varntp->ntrack = -1;
    139   varntp->massini = theNucleus.GetA();
    140   varntp->mzini = theNucleus.GetZ();
     136  varntp->massini = theNucleus.GetA_asInt();
     137  varntp->mzini = theNucleus.GetZ_asInt();
    141138
    142139  std::vector<G4DynamicParticle*> cascadeParticles;
  • trunk/source/processes/hadronic/models/incl/src/G4Incl.cc

    r1315 r1340  
    2424// ********************************************************************
    2525//
    26 // $Id: G4Incl.cc,v 1.30 2010/04/27 16:02:37 kaitanie Exp $
     26// $Id: G4Incl.cc,v 1.33 2010/10/29 06:48:43 gunter Exp $
    2727// Translation of INCL4.2/ABLA V3
    2828// Pekka Kaitaniemi, HIP (translation)
     
    4949  densFunction = 5;
    5050
     51  // Default: no Fermi break-up
     52  useFermiBreakup = false;
     53
     54  // Default: no projectile spectators
     55  useProjSpect = false;
     56
    5157  randomGenerator = new G4InclGeant4Random();
    52   //randomGenerator = new G4Ranecu();
     58  //  randomGenerator = new G4Ranecu();
    5359}
    5460
     
    5662{
    5763  verboseLevel = 0;
     64
     65  // Default: no Fermi break-up
     66  useFermiBreakup = false;
     67
     68  // Default: no projectile spectators
     69  useProjSpect = false;
    5870
    5971  // Set functions to be used for integration routine. 
     
    7183  ws = aWs;
    7284
    73   //randomGenerator = new G4Ranecu();
     85  //  randomGenerator = new G4Ranecu();
    7486  randomGenerator = new G4InclGeant4Random();
    7587}
    7688
    77 G4Incl::G4Incl(G4Hazard *aHazard, G4Calincl *aCalincl, G4Ws *aWs, G4Mat *aMat, G4VarNtp *aVarntp)
     89G4Incl::G4Incl(G4Hazard *aHazard, G4InclInput *aCalincl, G4Ws *aWs, G4Mat *aMat, G4VarNtp *aVarntp)
    7890{
    7991  verboseLevel = 0;
     92
     93  // Default: no Fermi break-up
     94  useFermiBreakup = false;
     95
     96  // Default: no projectile spectators
     97  useProjSpect = false;
    8098
    8199  // Set functions to be used for integration routine.   
     
    95113
    96114  randomGenerator = new G4InclGeant4Random();
    97   // randomGenerator = new G4Ranecu();
     115  //  randomGenerator = new G4Ranecu();
    98116  light_gaus_nuc = new G4LightGausNuc();
    99117  light_nuc = new G4LightNuc();
     
    111129  bl10 = new G4Bl10();
    112130  kindstruct = new G4Kind();
     131  bev = new G4Bev();
    113132  paul = new G4Paul();
    114133  varavat = new G4VarAvat();
    115134  varavat->kveux = 0;
     135
     136  be = new G4VBe();
     137  ps = new G4InclProjSpect();
     138  fermi = new G4InclFermi();
     139  qvp = new G4QuadvectProjo();
    116140
    117141  volant = new G4Volant();
     
    123147  abla = new G4Abla(hazard, volant, evaporationResult);
    124148  abla->initEvapora();
     149
     150  theLogger = 0;
    125151}
    126152
     
    143169  delete bl10;
    144170  delete kindstruct;
     171  delete bev;
    145172  delete paul;
    146173  delete varavat;
     
    149176  delete evaporationResult;
    150177  delete volant;
     178}
     179
     180void G4Incl::setUseFermiBreakUp(G4bool useIt)
     181{
     182  useFermiBreakup = useIt;
     183}
     184
     185void G4Incl::setUseProjectileSpectators(G4bool useIt)
     186{
     187  useProjSpect = useIt;
    151188}
    152189
     
    236273{
    237274  verboseLevel = level;
     275  if(verboseLevel > G4InclUtils::silent) {
     276    G4cout <<";; G4Incl: Setting verbose level to " << verboseLevel << G4endl;
     277  }
     278  abla->setVerboseLevel(level);
    238279}
    239280
     
    268309}
    269310
    270 void G4Incl::setCalinclData(G4Calincl *newCalincl)
     311void G4Incl::setInput(G4InclInput *newCalincl)
    271312{
    272313  calincl = newCalincl;
     
    342383 */
    343384
    344 void G4Incl::processEventIncl()
    345 {
     385void G4Incl::processEventIncl(G4InclInput *input)
     386{
     387  if(input == 0) {
     388    G4cerr <<"G4Incl fatal error: NULL pointer passed as input!" << G4endl;
     389    return;
     390  }
     391  calincl = input;
     392
    346393  const G4double uma = 931.4942;
    347394  const G4double melec = 0.511;
     
    355402
    356403  varntp->clear();
    357   if(calincl->f[6] == 3.0) { // pi+
     404  if(calincl->bulletType() == 3) { // pi+
    358405    mprojo = 139.56995;
    359406    ap = 0.0;
     
    361408  }
    362409
    363   if(calincl->f[6] == 4.0) { // pi0
     410  if(calincl->bulletType() == 4) { // pi0
    364411    mprojo = 134.9764;
    365412    ap = 0.0;
     
    367414  }
    368415
    369   if(calincl->f[6] == 5.0) { // pi-
     416  if(calincl->bulletType() == 5) { // pi-
    370417    mprojo = 139.56995;
    371418    ap = 0.0;
     
    374421
    375422  // Coulomb en entree seulement pour les particules ci-dessous.
    376   if(calincl->f[6] == 1.0) { // proton
     423  if(calincl->bulletType() == 1) { // proton
    377424    mprojo = 938.27231;
    378425    ap = 1.0;
     
    380427  }
    381428 
    382   if(calincl->f[6] == 2.0) { // neutron 
     429  if(calincl->bulletType() == 2) { // neutron 
    383430    mprojo = 939.56563;
    384431    ap = 1.0;
     
    386433  }
    387434 
    388   if(calincl->f[6] == 6.0) { // deuteron
     435  if(calincl->bulletType() == 6) { // deuteron
    389436    mprojo = 1875.61276;
    390437    ap = 2.0;
     
    392439  }
    393440 
    394   if(calincl->f[6] == 7.0) { // triton
     441  if(calincl->bulletType() == 7) { // triton
    395442    mprojo = 2808.95;
    396443    ap = 3.0;
     
    398445  }
    399446 
    400   if(calincl->f[6] == 8.0) { // He3
     447  if(calincl->bulletType() == 8) { // He3
    401448    mprojo = 2808.42;
    402449    ap = 3.0;
     
    404451  }
    405452
    406   if(calincl->f[6] == 9.0) { // Alpha
     453  if(calincl->bulletType() == 9) { // Alpha
    407454    mprojo = 3727.42;
    408455    ap = 4.0;
     
    410457  }
    411458
    412   pbeam = std::sqrt(calincl->f[2]*(calincl->f[2] + 2.0*mprojo));         
    413 
    414   G4double at = calincl->f[0];
     459  if(calincl->bulletType() == -12) { // Carbon
     460    mprojo = 12.0 * 938.27231;
     461    ap = 12.0;
     462    zp = 6.0;
     463  } else if(calincl->bulletType() == -666) { // Generic extended ion projectile
     464    mprojo = calincl->extendedProjectileA() * 938.27231;
     465    ap = calincl->extendedProjectileA();
     466    zp = calincl->extendedProjectileZ();
     467  }
     468
     469  pbeam = std::sqrt(calincl->bulletE()*(calincl->bulletE() + 2.0*mprojo));         
     470
     471  G4double at = calincl->targetA();
    415472       
    416   calincl->f[3] = 0.0;    // seuil sortie proton
    417   calincl->f[7] = 0.0;    // seuil sortie neutron
    418 
    419473  G4int ibert = 1;
    420474
     
    435489  G4double probaTrans = 0.0;
    436490  G4double rndm = 0.0;
    437   if((calincl->f[6] == 1.0) || (calincl->f[6] >= 6.0)) {
    438     probaTrans = coulombTransm(calincl->f[2],ap,zp,calincl->f[0],calincl->f[1]);
     491
     492  if((calincl->bulletType() == 1) || (calincl->bulletType() >= 6)) {
     493    probaTrans = coulombTransm(calincl->bulletE(),ap,zp,calincl->targetA(),calincl->targetZ());
    439494    standardRandom(&rndm, &(hazard->ial));
    440495    if(rndm <= (1.0 - probaTrans)) {
     
    447502   * Call the actual INCL routine.
    448503   */
    449   pnu(&ibert, &nopart,&izrem,&iarem,&esrem,&erecrem,&alrem,&berem,&garem,&bimpac,&jrem);
     504
     505  //  randomGenerator->printSeeds();
     506  G4double jremx, jremy, jremz;
     507  pnu(&ibert, &nopart,&izrem,&iarem,&esrem,&erecrem,&alrem,&berem,&garem,&bimpac,&jrem,
     508      &jremx, &jremy, &jremz);
    450509  forceAbsor(&nopart, &iarem, &izrem, &esrem, &erecrem, &alrem, &berem, &garem, &jrem);
    451510  G4double aprf = double(iarem); // mass number of the prefragment
     
    480539   * -following the approximations of the cugnon code (esrem...)
    481540   */
    482   G4double f0 = calincl->f[0];
    483   G4double f1 = calincl->f[1];
    484   G4double f2 = calincl->f[2];
     541  G4double f0 = calincl->targetA();
     542  G4double f1 = calincl->targetZ();
     543  G4double f2 = calincl->bulletE();
    485544  G4double mcorem = mprojo + f2 + abla->pace2(f0, f1) + f0 * uma - f1 * melec;
    486545
     
    680739
    681740
    682 void G4Incl::processEventInclAbla(G4int eventnumber)
    683 {
     741void G4Incl::processEventInclAbla(G4InclInput *input, G4int eventnumber)
     742{
     743  //G4cout <<"Starting event " << eventnumber << G4endl;
     744  if(input == 0) {
     745    G4cerr <<"G4Incl fatal error: NULL pointer passed as input!" << G4endl;
     746    return;
     747  }
     748  calincl = input;
     749
    684750  const G4double uma = 931.4942;
    685751  const G4double melec = 0.511;
     752  const G4double fmp = 938.2796;
    686753
    687754  G4double pcorem = 0.0;
     
    694761  varntp->clear();
    695762
     763  if(calincl->bulletType() == -12) {
     764    be->ia_be = std::abs(calincl->bulletType());
     765    be->iz_be = 6;
     766  } else if(calincl->bulletType() == -666) {
     767    be->iz_be = calincl->extendedProjectileZ();
     768    be->ia_be = calincl->extendedProjectileA();
     769  }
     770
     771  if(calincl->isExtendedProjectile() == false && calincl->bulletType() < -max_a_proj) {
     772  //  if(calincl->bulletType() < -max_a_proj) {
     773    G4cout <<"max a of composite projectile is: " << max_a_proj << G4endl;
     774    exit(0);
     775  }
     776  if(calincl->bulletType() < 0) {
     777    //    calincl->bulletType() = std::floor(calincl->bulletType() + 0.1); WTF???
     778    be->pms_be=100.;
     779    G4int i_tabled=0;
     780    if(be->iz_be == 3 && be->ia_be == 6) {
     781      be->rms_be=2.56;
     782      be->bind_be=32.0;
     783      i_tabled=1;
     784    } else if(be->iz_be == 3 && be->ia_be == 7) { // TODO: Check the values!
     785      be->rms_be=2.56;
     786      be->bind_be=32.0;
     787      i_tabled=1;
     788    } else if(be->iz_be == 3 && be->ia_be == 8) {
     789      be->rms_be=2.40;
     790      be->bind_be=39.25;
     791      i_tabled=1;
     792    } else if(be->iz_be == 4 && be->ia_be == 7) {
     793      be->rms_be=2.51;
     794      be->bind_be=58.17;
     795      i_tabled=1;
     796    } else if(be->iz_be == 4 && be->ia_be == 9) {
     797      be->rms_be=2.51;
     798      be->bind_be=58.17;
     799      i_tabled=1;
     800    } else if(be->iz_be == 4 && be->ia_be == 10) {
     801      be->rms_be=2.45;
     802      be->bind_be=64.75;
     803      i_tabled=1;
     804    } else if(be->iz_be == 5 && be->ia_be == 10) {
     805      be->rms_be=2.45;
     806      be->bind_be=64.75;
     807      i_tabled=1;
     808    } else if(be->iz_be == 5 && be->ia_be == 11) {
     809      be->rms_be=2.40;
     810      be->bind_be=76.21;
     811      i_tabled=1;
     812    } else if(be->iz_be == 6 && be->ia_be == 9) { // TODO: Check the values!
     813      be->rms_be=2.44;
     814      be->bind_be=92.17;
     815      i_tabled=1;
     816    } else if(be->iz_be == 6 && be->ia_be == 10) { // TODO: Check the values!
     817      be->rms_be=2.44;
     818      be->bind_be=92.17;
     819      i_tabled=1;
     820    } else if(be->iz_be == 6 && be->ia_be == 11) { // TODO: Check the values!
     821      be->rms_be=2.44;
     822      be->bind_be=92.17;
     823      i_tabled=1;
     824    } else if(be->iz_be == 6 && calincl->bulletType() == -12) { // Special Carbon case
     825      G4cout <<"Carbon 12 (special) selected." << G4endl;
     826      be->rms_be=2.44;
     827      be->bind_be=92.17;
     828      i_tabled=1;
     829    } else if(be->iz_be == 6 && be->ia_be == 12) {
     830      be->rms_be=2.44;
     831      be->bind_be=92.17;
     832      i_tabled=1;
     833    } else if(be->iz_be == 7 && be->ia_be == 16) {
     834      be->rms_be=2.73;
     835      be->bind_be=127.62;
     836      i_tabled=1;
     837    } else {
     838      G4cout <<"Warning: No rms and binding for projectile ion A = " << be->ia_be << " Z = " << be->iz_be << G4endl;
     839      be->rms_be=2.44;
     840      be->bind_be=92.17;
     841      G4cout <<"Warning: Using probably bad values rms = " << be->rms_be << " binding = " << be->bind_be << G4endl;
     842      i_tabled=1;     
     843    }
     844     
     845    if(i_tabled == 0) {
     846      G4cout <<"This heavy ion (a,z)= " << be->ia_be << " " << be->iz_be << " is not defined as beam in INCL" << G4endl;
     847      exit(0);
     848    }
     849     
     850    //    G4cout <<"z projectile, rms_r, rms_p (gaussian model)" << be->iz_be << " " << be->rms_be << " " << be->pms_be << G4endl;
     851    //    G4cout <<"binding energy (mev):" << be->bind_be << G4endl;
     852    //    G4cout <<"fermi-breakup dresner below a=" << calincl->f[11] << G4endl;
     853  }     
     854  //  G4cout <<"Target Mass and Charge: " << calincl->targetA() << " " << calincl->targetZ() << G4endl;
     855  //  calincl->f[10] = 0; // No clusters
     856
     857  if(calincl->bulletType() == -12) {  // C12 special case
     858    mprojo=fmp*std::abs(calincl->bulletType()) - be->bind_be;
     859    pbeam=std::sqrt(calincl->bulletE()*(calincl->bulletE()+2.*mprojo));
     860    ap=std::abs(calincl->bulletType());
     861    zp=be->iz_be;
     862  } else if(calincl->bulletType() == -666) { // Generic extended projectile
     863    mprojo=fmp*be->ia_be - be->bind_be;
     864    pbeam=std::sqrt(calincl->bulletE()*(calincl->bulletE()+2.*mprojo));
     865    ap=be->ia_be;
     866    zp=be->iz_be;
     867  }
    696868  // pi+
    697   if(calincl->f[6] == 3.0) {
     869  if(calincl->bulletType() == 3) {
    698870    mprojo = 139.56995;
    699871    ap = 0.0;
     
    702874
    703875  // pi0
    704   if(calincl->f[6] == 4.0) {
     876  if(calincl->bulletType() == 4) {
    705877    mprojo = 134.9764;
    706878    ap = 0.0;
     
    709881
    710882  // pi-
    711   if(calincl->f[6] == 5.0) {
     883  if(calincl->bulletType() == 5) {
    712884    mprojo = 139.56995;
    713885    ap = 0.0;
     
    718890
    719891  // proton
    720   if(calincl->f[6] == 1.0) {
     892  if(calincl->bulletType() == 1) {
    721893    mprojo = 938.27231;
    722894    ap = 1.0;
     
    725897
    726898  // neutron 
    727   if(calincl->f[6] == 2.0) {
     899  if(calincl->bulletType() == 2) {
    728900    mprojo = 939.56563;
    729901    ap = 1.0;
     
    732904
    733905  // deuteron
    734   if(calincl->f[6] == 6.0) {
     906  if(calincl->bulletType() == 6) {
    735907    mprojo = 1875.61276;
    736908    ap = 2.0;
     
    739911
    740912  // triton
    741   if(calincl->f[6] == 7.0) {
     913  if(calincl->bulletType() == 7) {
    742914    mprojo = 2808.95;
    743915    ap = 3.0;
     
    746918
    747919  // He3
    748   if(calincl->f[6] == 8.0) {
     920  if(calincl->bulletType() == 8) {
    749921    mprojo = 2808.42;
    750922    ap = 3.0;
     
    753925
    754926  // Alpha
    755   if(calincl->f[6] == 9.0) {
     927  if(calincl->bulletType() == 9) {
    756928    mprojo = 3727.42;
    757929    ap = 4.0;
     
    759931  }
    760932
    761   pbeam = std::sqrt(calincl->f[2]*(calincl->f[2] + 2.0*mprojo));         
    762 
    763   G4double at = calincl->f[0];
     933  // Carbon
     934  if(calincl->bulletType() == -12) {
     935    mprojo = 6.0*938.27231 + 6.0*939.56563;
     936    ap = 12.0;
     937    zp = 6.0;
     938  }
     939
     940  pbeam = std::sqrt(calincl->bulletE()*(calincl->bulletE() + 2.0*mprojo));         
     941
     942  G4double at = calincl->targetA();
    764943       
    765   calincl->f[3] = 0.0;    //     !seuil sortie proton
    766   calincl->f[7] = 0.0;  //       !seuil sortie neutron
    767 
    768944  G4int ibert = 1;
    769945
     
    777953  G4double bimpac = 0.0;
    778954  G4int jrem = 0;
     955  G4double xjrem = 0.0, yjrem = 0.0, zjrem = 0.0;
    779956  G4double alrem = 0.0;
    780957
     
    784961  G4double rndm = 0.0;
    785962
    786   if((calincl->f[6] == 1.0) || (calincl->f[6] >= 6.0)) {
    787     //    probaTrans = coulombTransm(calincl->f[2],apro,zpro,calincl->f[0],calincl->f[1]);
    788     probaTrans = coulombTransm(calincl->f[2],ap,zp,calincl->f[0],calincl->f[1]);
     963  if((calincl->bulletType() == 1) || (calincl->bulletType() >= 6)) {
     964    //    probaTrans = coulombTransm(calincl->bulletE(),apro,zpro,calincl->targetA(),calincl->targetZ());
     965    probaTrans = coulombTransm(calincl->bulletE(),ap,zp,calincl->targetA(),calincl->targetZ());
    789966    standardRandom(&rndm, &(hazard->ial));
    790967    if(rndm <= (1.0 - probaTrans)) {
     
    794971  }
    795972
     973  //  G4cout <<"Before PNU:" << G4endl;
     974  //  randomGenerator->printSeeds();
    796975  // Call the actual INCL routine:
    797   pnu(&ibert, &nopart,&izrem,&iarem,&esrem,&erecrem,&alrem,&berem,&garem,&bimpac,&jrem);
     976  pnu(&ibert, &nopart,&izrem,&iarem,&esrem,&erecrem,&alrem,&berem,&garem,&bimpac,
     977      &jrem, &xjrem, &yjrem, &zjrem);
     978  //  G4cout <<"After PNU:" << G4endl;
     979  //  randomGenerator->printSeeds();
     980  G4double mrem = int(zjrem/197.328); // CHECK
     981  if (mrem > jrem) mrem=jrem;
     982  if (mrem < -jrem) mrem=-jrem;
     983
    798984//   nopart=1;
    799985//   kind[0]=1;
     
    8461032  //                -from energy balance (input - all emitted energies)
    8471033  //                -following the approximations of the cugnon code (esrem...)
    848   G4double mcorem = mprojo + calincl->f[2] + abla->pace2(double(calincl->f[0]),double(calincl->f[1]))
    849     + calincl->f[0]*uma - calincl->f[1]*melec;
     1034  G4double mcorem = mprojo + calincl->bulletE() + abla->pace2(double(calincl->targetA()),double(calincl->targetZ()))
     1035    + calincl->targetA()*uma - calincl->targetZ()*melec;
    8501036
    8511037  G4double pxbil = 0.0;
     
    8541040
    8551041  if(nopart > -1) {
    856     for(G4int j = 0; j < nopart; j++) {
    857       if(ep[j] < 0.0) continue; // Workaround to avoid negative energies (and taking std::sqrt of a negative number).
    858       varntp->itypcasc[j] = 1;
     1042    // Fill the projectile spectator variables
     1043    varntp->masp = ps->a_projspec;
     1044    varntp->mzsp = ps->z_projspec;
     1045    varntp->exsp = ps->ex_projspec;
     1046    varntp->spectatorP1 = ps->p1_projspec;
     1047    varntp->spectatorP2 = ps->p2_projspec;
     1048    varntp->spectatorP3 = ps->p3_projspec;
     1049    varntp->spectatorT = ps->t_projspec;
     1050    for(G4int j = 0; j <= nopart; j++) {
     1051      if(ep[j] < 0.0) { // Workaround to avoid negative energies (and taking std::sqrt of a negative number).
     1052        G4cout <<"G4Incl: Not registering particle with energy: " << ep[j] << G4endl;
     1053        continue;
     1054      }
     1055      if(kind[j] == 0) continue; // Empty particle rows are sometimes produced by lurking indexing problems. We can simply skip those "bad" entries...
     1056      if(gam[j] > CLHEP::pi) {
     1057        if(verboseLevel > 2) {
     1058          G4cout <<"G4Incl: Just avoided floating point exception by using an ugly hack..." << G4endl;
     1059        }
     1060        continue; // Avoid floating point exception
     1061      }
     1062
     1063      varntp->itypcasc[j] = 1; // Particle was produced by the cascade
     1064      // Spectators of composite projectiles (7/2006, AB)
     1065      // (kind is negative in that case)
     1066      if(kind[j] <= 0) { // Particle is a projectile spectator that comes directly from the cascade
     1067        kind[j] *= -1;
     1068        varntp->itypcasc[j]=-1;
     1069        //      G4cout <<"Spectator registered!" << G4endl;
     1070        //      continue;
     1071      }
     1072       
    8591073      // kind(): 1=proton, 2=neutron, 3=pi+, 4=pi0, 5=pi -     
    8601074      if(kind[j] == 1) {
     
    9981212    pzbil = pzbil + pzrem;
    9991213
     1214    // If on purpose, add here the spectator nuclei:   
     1215    if(calincl->bulletType() < 0 && ps->a_projspec != 0) {
     1216      pxbil=pxbil+ps->p1_projspec;
     1217      pybil=pybil+ps->p2_projspec;
     1218      pzbil=pzbil+ps->p3_projspec;
     1219    }
     1220
    10001221    if((std::fabs(pzbil - pbeam) > 5.0) || (std::sqrt(std::pow(pxbil,2) + std::pow(pybil,2)) >= 3.0)) {
    10011222      if(verboseLevel > 3) {
     
    10131234
    10141235    // on recopie le remnant dans le ntuple
    1015     // varntp->ntrack = varntp->ntrack + 1;
     1236    varntp->ntrack = varntp->ntrack + 1;
    10161237    varntp->massini = iarem;
    10171238    varntp->mzini = izrem;
    10181239    varntp->exini = esrem;
     1240    varntp->pxrem = pxrem;
     1241    varntp->pyrem = pyrem;
     1242    varntp->pzrem = pzrem;
     1243    varntp->mcorem = mcorem;
     1244    varntp->erecrem = pcorem;
     1245    varntp->erecrem = erecrem;
    10191246
    10201247    if(verboseLevel > 2) {
     
    10221249      varntp->dump();
    10231250    }
    1024     // Evaporation/fission:
    1025     evaporationResult->ntrack = 0;
    1026     abla->breakItUp(varntp->massini, varntp->mzini, mcorem, varntp->exini, varntp->jremn,
    1027                     erecrem, pxrem, pyrem, pzrem, eventnumber);
    1028 
    1029     if(verboseLevel > 2) {
    1030       G4cout << __FILE__ << ":" << __LINE__ << "Dump evaporationResult after evaporation: " << G4endl;
    1031       evaporationResult->dump();
    1032     }
    1033     for(G4int evaporatedParticle = 0; evaporatedParticle < evaporationResult->ntrack; evaporatedParticle++) {
    1034       if(evaporationResult->avv[evaporatedParticle] == 0 && evaporationResult->zvv[evaporatedParticle] == 0) { //Fix: Skip "empty" particles with A = 0 and Z = 0
    1035         // continue;
    1036       }
    1037       varntp->kfis = evaporationResult->kfis;
    1038       varntp->itypcasc[varntp->ntrack] = evaporationResult->itypcasc[evaporatedParticle];
    1039       varntp->avv[varntp->ntrack] = evaporationResult->avv[evaporatedParticle];
    1040       varntp->zvv[varntp->ntrack]= evaporationResult->zvv[evaporatedParticle];
    1041       varntp->plab[varntp->ntrack] = evaporationResult->plab[evaporatedParticle];
    1042       varntp->enerj[varntp->ntrack] = evaporationResult->enerj[evaporatedParticle];
    1043       varntp->tetlab[varntp->ntrack] = evaporationResult->tetlab[evaporatedParticle];
    1044       varntp->philab[varntp->ntrack] = evaporationResult->philab[evaporatedParticle];
    1045       varntp->ntrack++;
    1046       if(verboseLevel > 3) {
    1047         G4cout <<"G4Incl: Returning evaporation result"           << G4endl;
    1048         G4cout <<"G4Incl: A = " << varntp->avv[varntp->ntrack]    << " Z = " << varntp->zvv[varntp->ntrack] << G4endl;
    1049         G4cout <<"Energy: "     << varntp->enerj[varntp->ntrack]  << G4endl;
    1050         G4cout <<"Momentum: "   << varntp->plab[varntp->ntrack]   << G4endl;
    1051         G4cout <<"Theta: "      << varntp->tetlab[varntp->ntrack] << G4endl;
    1052         G4cout <<"Phi: "        << varntp->philab[varntp->ntrack] << G4endl;
    1053       }
    1054     }
    1055     if(verboseLevel > 2) {
    1056       G4cout <<"G4Incl: ntrack = "          << varntp->ntrack << G4endl;
    1057       G4cout <<"G4Incl: Done extracting..." << G4endl;
    1058     }
     1251    // Maximum remnant for Geant4 Fermi break-up: A = 17, Z = 8
     1252    if(varntp->massini < 17 && varntp->exini < 1000 && varntp->massini > 0 && varntp->mzini > 0 && useFermiBreakup) { // Choose between Fermi break-up and ABLA
     1253      varntp->needsFermiBreakup = true;
     1254    } else {
     1255      varntp->needsFermiBreakup = false;
     1256      // Evaporation/fission:
     1257      evaporationResult->ntrack = 0;
     1258      abla->breakItUp(G4int(varntp->massini), G4int(varntp->mzini), mcorem, varntp->exini, varntp->jremn,
     1259                      erecrem, pxrem, pyrem, pzrem, eventnumber);
     1260
     1261      if(verboseLevel > 2) {
     1262        G4cout << __FILE__ << ":" << __LINE__ << "Dump evaporationResult after evaporation: " << G4endl;
     1263        evaporationResult->dump();
     1264      }
     1265      for(G4int evaporatedParticle = 0; evaporatedParticle < evaporationResult->ntrack; evaporatedParticle++) {
     1266        if(evaporationResult->avv[evaporatedParticle] == 0 && evaporationResult->zvv[evaporatedParticle] == 0) { //Fix: Skip "empty" particles with A = 0 and Z = 0
     1267          // continue;
     1268        }
     1269        varntp->kfis = evaporationResult->kfis;
     1270        varntp->itypcasc[varntp->ntrack] = evaporationResult->itypcasc[evaporatedParticle];
     1271        varntp->avv[varntp->ntrack] = evaporationResult->avv[evaporatedParticle];
     1272        varntp->zvv[varntp->ntrack]= evaporationResult->zvv[evaporatedParticle];
     1273        varntp->plab[varntp->ntrack] = evaporationResult->plab[evaporatedParticle];
     1274        varntp->enerj[varntp->ntrack] = evaporationResult->enerj[evaporatedParticle];
     1275        varntp->tetlab[varntp->ntrack] = evaporationResult->tetlab[evaporatedParticle];
     1276        varntp->philab[varntp->ntrack] = evaporationResult->philab[evaporatedParticle];
     1277        varntp->ntrack++;
     1278        if(verboseLevel > 3) {
     1279          G4cout <<"G4Incl: Returning evaporation result"           << G4endl;
     1280          G4cout <<"G4Incl: A = " << varntp->avv[varntp->ntrack]    << " Z = " << varntp->zvv[varntp->ntrack] << G4endl;
     1281          G4cout <<"Energy: "     << varntp->enerj[varntp->ntrack]  << G4endl;
     1282          G4cout <<"Momentum: "   << varntp->plab[varntp->ntrack]   << G4endl;
     1283          G4cout <<"Theta: "      << varntp->tetlab[varntp->ntrack] << G4endl;
     1284          G4cout <<"Phi: "        << varntp->philab[varntp->ntrack] << G4endl;
     1285        }
     1286      }
     1287      if(verboseLevel > 2) {
     1288        G4cout <<"G4Incl: ntrack = "          << varntp->ntrack << G4endl;
     1289        G4cout <<"G4Incl: Done extracting..." << G4endl;
     1290      }
     1291    }
     1292    if(calincl->bulletType() < 0 && useProjSpect && !useFermiBreakup) { // If we use projectile spectators for carbon but no fermi breakup
     1293      // Evaporation/fission:
     1294      evaporationResult->ntrack = 0;
     1295      //      G4cout <<"Warning: Using ABLA to de-excite projectile spectator..." << G4endl;
     1296      abla->breakItUp(G4int(varntp->masp), G4int(varntp->mzsp), ps->m_projspec, varntp->exsp, 0.0,
     1297                      ps->t_projspec, ps->p1_projspec, ps->p1_projspec, ps->p1_projspec, eventnumber);
     1298
     1299      if(verboseLevel > 2) {
     1300        G4cout << __FILE__ << ":" << __LINE__ << "Dump evaporationResult after evaporation: " << G4endl;
     1301        evaporationResult->dump();
     1302      }
     1303      for(G4int evaporatedParticle = 0; evaporatedParticle < evaporationResult->ntrack; evaporatedParticle++) {
     1304        if(evaporationResult->avv[evaporatedParticle] == 0 && evaporationResult->zvv[evaporatedParticle] == 0) { //Fix: Skip "empty" particles with A = 0 and Z = 0
     1305        }
     1306        varntp->kfis = evaporationResult->kfis;
     1307        varntp->itypcasc[varntp->ntrack] = evaporationResult->itypcasc[evaporatedParticle];
     1308        varntp->avv[varntp->ntrack] = evaporationResult->avv[evaporatedParticle];
     1309        varntp->zvv[varntp->ntrack]= evaporationResult->zvv[evaporatedParticle];
     1310        varntp->plab[varntp->ntrack] = evaporationResult->plab[evaporatedParticle];
     1311        varntp->enerj[varntp->ntrack] = evaporationResult->enerj[evaporatedParticle];
     1312        varntp->tetlab[varntp->ntrack] = evaporationResult->tetlab[evaporatedParticle];
     1313        varntp->philab[varntp->ntrack] = evaporationResult->philab[evaporatedParticle];
     1314        varntp->ntrack++;
     1315        if(verboseLevel > 3) {
     1316          G4cout <<"G4Incl: Returning evaporation result"           << G4endl;
     1317          G4cout <<"G4Incl: A = " << varntp->avv[varntp->ntrack]    << " Z = " << varntp->zvv[varntp->ntrack] << G4endl;
     1318          G4cout <<"Energy: "     << varntp->enerj[varntp->ntrack]  << G4endl;
     1319          G4cout <<"Momentum: "   << varntp->plab[varntp->ntrack]   << G4endl;
     1320          G4cout <<"Theta: "      << varntp->tetlab[varntp->ntrack] << G4endl;
     1321          G4cout <<"Phi: "        << varntp->philab[varntp->ntrack] << G4endl;
     1322        }
     1323      }
     1324    }
     1325#ifdef G4INCLDEBUG
     1326    theLogger->fillHistogram1D("bimpact", varntp->bimpact);
     1327#endif
     1328
     1329#ifdef G4INCLDEBUG
     1330    theLogger->fillHistogram1D("mzini", varntp->mzini);
     1331#endif
    10591332  }
    10601333  if(nopart == -2) {
     
    14031676   
    14041677  if(tz < 0) {
     1678#ifdef G4INCLDEBUG
     1679  theLogger->fillHistogram1D("interpolationResult", (saxw->y[0][saxw->imat] + saxw->s[0][saxw->imat]*tz));
     1680  theLogger->fillHistogram2D("interpolationPoints", (saxw->y[0][saxw->imat] + saxw->s[0][saxw->imat]*tz), xv);
     1681#endif
    14051682    return (saxw->y[0][saxw->imat] + saxw->s[0][saxw->imat]*tz);
    14061683  }
    14071684  else if(tz == 0) {
    1408     return (saxw->y[0][saxw->imat]);
     1685#ifdef G4INCLDEBUG
     1686  theLogger->fillHistogram1D("interpolationResult", (saxw->y[0][saxw->imat]));
     1687  theLogger->fillHistogram2D("interpolationPoints", (saxw->y[0][saxw->imat]), xv);
     1688#endif
     1689  return (saxw->y[0][saxw->imat]);
    14091690  }
    14101691  else { // tz > 0
     
    14171698    }
    14181699    if(tz >= 0) {
     1700#ifdef G4INCLDEBUG
     1701      theLogger->fillHistogram1D("interpolationResult", saxw->y[j][saxw->imat]);
     1702      theLogger->fillHistogram2D("interpolationPoints", saxw->y[j][saxw->imat], xv);
     1703#endif
    14191704      return saxw->y[j][saxw->imat];
    14201705    } else if(tz < 0.0) {
    14211706      j = j - 1;
    14221707      G4double dgx = xv - saxw->x[j][saxw->imat];
     1708#ifdef G4INCLDEBUG
     1709      theLogger->fillHistogram1D("interpolationResult", (saxw->y[j][saxw->imat] + saxw->s[j][saxw->imat]*dgx));
     1710      theLogger->fillHistogram2D("interpolationPoints", (saxw->y[j][saxw->imat] + saxw->s[j][saxw->imat]*dgx), xv);
     1711#endif
    14231712      return(saxw->y[j][saxw->imat] + saxw->s[j][saxw->imat]*dgx);
    14241713    }
     
    16731962void G4Incl::pnu(G4int *ibert_p, G4int *nopart_p, G4int *izrem_p, G4int *iarem_p, G4double *esrem_p,
    16741963                 G4double *erecrem_p, G4double *alrem_p, G4double *berem_p, G4double *garem_p,
    1675                  G4double *bimpact_p, G4int *l_p)
    1676 {
     1964                 G4double *bimpact_p, G4int *l_p, G4double *xjrem, G4double *yjrem, G4double *zjrem)
     1965{
     1966  //  G4cout <<"Now in pnu..." << G4endl;
     1967  //  G4cout <<"(clean-up)" << G4endl;
     1968  G4int npenter = 0;
     1969  G4int nnenter = 0;
     1970  G4int n_enter_pot = 0;
     1971  G4int avatarCounter = 0;
     1972  ps->clear(); // For projectile spectators
     1973  //  G4int i_c = 0;
     1974  G4double p1spec=0.;
     1975  G4double p2spec=0.;
     1976  G4double p3spec=0.;
     1977  //  G4double p_spec2 = 0.0;
     1978  //  G4double s_spec = 0.0;
     1979  // G4double e_spec = 0.0;
     1980  G4double xl1_i, xl2_i, xl3_i;
     1981  G4int idq = 0;
     1982  G4double destar = 0.0;
     1983  //  G4cout <<"(checkpoint 'setipszero0)" << G4endl;
     1984  G4int ips = 0;
     1985  //  G4double p1_spec = 0.0;
     1986  //  G4double p2_spec = 0.0;
     1987  //  G4double p3_spec = 0.0;
     1988  G4int n_activnuc = 0;
    16771989  G4int ibert = (*ibert_p);
    16781990  //  float f[15]; // = (*f_p);
     
    17022014  G4double b3 = 0.0;
    17032015  G4double bb2 = 0.0;
    1704   G4double be = 0.0;
     2016  G4double bevar = 0.0;
    17052017  G4double bmass[2000];
    17062018  for(G4int init_i = 0; init_i < 2000; init_i++) {
     
    17362048  G4double ener_max = 0.0;
    17372049  G4double eout = 0.0;
    1738   G4double eps_c[BL1SIZE];
    1739   for(G4int init_i = 0; init_i < BL1SIZE; init_i++) {
    1740     eps_c[init_i] = 0.0;
    1741   }
     2050  //  G4double eps_c[BL1SIZE];
     2051  //  G4double p3_c[BL1SIZE];
     2052  //  for(G4int init_i = 0; init_i < BL1SIZE; init_i++) {
     2053    //    eps_c[init_i] = 0.0;
     2054    //    p3_c[init_i] = 0.0;
     2055  //  }
    17422056  G4double epsv = 0.0;
    17432057  G4double erecg = 0.0;
     
    17782092  G4int imin = 0;
    17792093  G4int indic[3000];
     2094  G4int nb_transprojo=0;
     2095  G4double v_proj = 0.0;
    17802096  for(G4int init_i = 0; init_i < 3000; init_i++) {
    17812097    indic[init_i] = 0;
     
    18252141  G4int nbtest = 0;
    18262142  G4int nc[300];
     2143  G4bool isPartOfSpectatorNucleus[300];
    18272144  G4int npproj[300];
    18282145  for(G4int init_i = 0; init_i < 300; init_i++) {
     
    19422259  G4double xleng = 0.0;
    19432260  G4double xlengm = 0.0;
    1944   G4double xmodp = 0.0;
    19452261  G4double xpb = 0.0;
    19462262  G4double xq = 0.0;
     
    19602276  G4double xye = 0.0;
    19612277  G4double y = 0.0;
    1962   G4double p3_c[BL1SIZE];
    19632278  G4double q1[BL1SIZE];
    19642279  G4double q2[BL1SIZE];
     
    22202535   for(G4int i = 0; i < 300; i++) {
    22212536     npproj[i] = 0;
     2537     isPartOfSpectatorNucleus[i] = false;
    22222538     nc[i] = 0;
    22232539   }
     
    22702586  //    427     c     k6=0 no angular momentum conservation                             p-n02070
    22712587  //    428     c     k6=1 angular momentum conservation                                p-n02080
     2588  //                  Kclst=F(10) Light clusters computed if not =0
    22722589  //    429     c                                                                       p-n02090
    22732590  //    430     c     b=impact parameter                                                p-n02100
     
    23122629  // end for logging
    23132630
     2631  G4int ia_breakup = 0;
    23142632  G4int jparticip[BL1SIZE];
    23152633  for(G4int i = 0; i < BL1SIZE; i++) {
     
    23182636
    23192637  G4double beproj = 0.;
    2320   bl3->ia2 = G4int(std::floor(calincl->f[0] + 0.1)); // f(1)->f[0] and so on..., calincl added
    2321   G4int iz2 = G4int(std::floor(calincl->f[1] + 0.1));
     2638  bl3->ia2 = calincl->targetA(); // f(1)->f[0] and so on..., calincl added
     2639  G4int iz2 = calincl->targetZ();
    23222640  G4double r02 = 1.12;
    2323   kindstruct->kindf7 = int(std::floor(calincl->f[6] + 0.1));
    2324 
    2325   bl3->ia1 = ia1t[G4int(kindstruct->kindf7)-1];
    2326   G4int iz1 = iz1t[G4int(kindstruct->kindf7)-1];
    2327   G4double fmpinc = fmpinct[G4int(kindstruct->kindf7)-1];
    2328   G4double rms1 = light_gaus_nuc->rms1t[G4int(kindstruct->kindf7)-1];
    2329   G4double pf1 = light_gaus_nuc->pf1t[G4int(kindstruct->kindf7)-1];
    2330   G4double tlab = calincl->f[2];
     2641  kindstruct->kindf7 = calincl->bulletType();
     2642  if(kindstruct->kindf7 < 0) kindstruct->kindf7 = kindstruct->kindf7-1;
     2643  G4int kclst = calincl->getClusterOption();
     2644
     2645  // G4cout <<"Projectile kind = " << kindstruct->kindf7 << G4endl;
     2646
     2647  G4int iz1 = 0;
     2648  G4double fmpinc = 0.0;
     2649  G4double rms1 = 0.0;
     2650  G4double pf1 = 0.0;
     2651  G4double tlab = calincl->bulletE();;
     2652
     2653  if(kindstruct->kindf7 > 0) {
     2654    bl3->ia1 = ia1t[G4int(kindstruct->kindf7)-1]; // In the C++ version indices start from 0
     2655    iz1 = iz1t[G4int(kindstruct->kindf7)-1];
     2656    fmpinc = fmpinct[G4int(kindstruct->kindf7)-1];
     2657    rms1 = light_gaus_nuc->rms1t[G4int(kindstruct->kindf7)-1];
     2658    pf1 = light_gaus_nuc->pf1t[G4int(kindstruct->kindf7)-1];
     2659
     2660  } else {
     2661   // Starting values for carbon beams:
     2662    if(kindstruct->kindf7 == -12) { // Handle Carbon-12 as a special case
     2663      bl3->ia1 = std::abs(kindstruct->kindf7 + 1);
     2664      // check here that kindf7 is -a and ia1 is a of the projectile.
     2665      //                        write(6,*) 'kindf7,ia1:',kindf7,ia1
     2666      be->ia_be=bl3->ia1;
     2667      iz1=be->iz_be;
     2668      fmpinc=bl3->ia1*fmp - be->bind_be;
     2669      rms1=be->rms_be;
     2670      pf1=be->pms_be;
     2671      ia_breakup = 10; // Stopping threshold for the cascade in case of light nuclei
     2672      //      ia_breakup=calincl->getCascadeStoppingAThreshold();
     2673    } else { // For extended projectiles
     2674      bl3->ia1 = calincl->extendedProjectileA();
     2675      be->ia_be = calincl->extendedProjectileA();
     2676      iz1=be->iz_be;
     2677      fmpinc=bl3->ia1*fmp - be->bind_be;
     2678      rms1=be->rms_be;
     2679      pf1=be->pms_be;
     2680      ia_breakup = 10; // Stopping threshold for the cascade in case of light nuclei
     2681      //      ia_breakup=calincl->getCascadeStoppingAThreshold();
     2682    }
     2683  }
     2684
     2685  if(verboseLevel > 1) {
     2686    G4cout <<"rms1 = " << rms1 << G4endl;
     2687    G4cout <<"pf1 = " << pf1 << G4endl;
     2688  }
    23312689
    23322690  G4int k2 = 0;
     
    23382696
    23392697  // material number:     
    2340   saxw->imat = G4int(std::floor(calincl->f[8] + 0.5)); // f(9) -> f[8]
     2698  saxw->imat = 0;
    23412699  // espace de phases test (r et p) pour pauli:
    23422700  // valeur recommandee par j.c. v-test=0.589 h**3:
     
    23562714  // temfin (time at which the inc is stopped), tmax5 defined after chosing b
    23572715
    2358   G4double v0 = calincl->f[4]; // f(5)->f[4]
     2716  G4double v0 = calincl->getPotential();
    23592717  G4double v1 = v0;
    23602718  bl8->rathr = 0.;
     
    24282786    G4cout <<"Radius bl3->r2 = " << bl3->r2 << G4endl;
    24292787  }
    2430  
     2788
    24312789  G4double tnr = tlab;
    24322790  G4double binc = std::sqrt(tnr*tnr + 2.0*tlab*fmpinc)/(tnr+fmpinc);
    2433   G4double ginc=1.0/std::sqrt(1.0 - binc*binc);
     2791  G4double ginc = 1.0/std::sqrt(1.0 - binc*binc);
    24342792  G4double pinc = fmpinc*binc*ginc;
    24352793
     
    24632821  //    710     c      if (kindf7.gt.2) bmax=bmax       ! a.b. (avec w.s., idem les nucleons)
    24642822  // deutons cv 22/01/2001
    2465   if (kindstruct->kindf7 <= 2)  { //then
     2823  if (kindstruct->kindf7 < 6 && kindstruct->kindf7 > 0)  { //then
    24662824    ws->bmax = ws->bmax;     // comme alain
    24672825  }
    24682826  else {
    2469     if (kindstruct->kindf7 < 6) { // then   
    2470       ws->bmax = ws->bmax;   // comme alain
    2471     }
    2472     else {
    2473       beproj = fmpinc - bl3->ia1*fmp;
    2474       ws->bmax = ws->rmaxws + rms1;     // maximum extension of the nucleus ( w.s.)
    2475     }
     2827    beproj = fmpinc - bl3->ia1*fmp;
     2828    ws->bmax = ws->rmaxws + rms1;     // maximum extension of the nucleus ( w.s.)
    24762829  }
    24772830
     
    24962849      bred = 0.;
    24972850    }
    2498     if (kindstruct->kindf7 <= 2) {
     2851    if (kindstruct->kindf7 <= 2 && kindstruct->kindf7 > 0) {
    24992852      if (tlab < 400.0) {
    25002853        cb0 = 6.86 - 0.0035 * tlab;
     
    25152868    }
    25162869    else {
    2517       if (kindstruct->kindf7 < 6) {
     2870      if (kindstruct->kindf7 < 6 && kindstruct->kindf7 > 0) {
    25182871        // here for pions:
    25192872        temfin = 30.0*std::pow((float(bl3->ia2)/208.0),0.25)*(1.0 - 0.2*bred)*(1.0 - tlab/1250.0);
     
    25572910      // temfin=60.*(float(ia2)/208.)**0.25*(1.-0.2*bred)*(1.-tlab/1250.)
    25582911      // modified in april 2003 (more reasonable but not yet checked!)
    2559       temfin = 25.5*std::pow(G4double(bl3->ia2),0.16);  // pb208->60fm/c
     2912      //      temfin = 25.5*std::pow(G4double(bl3->ia2),0.16);  // pb208->60fm/c
     2913
     2914      // c modified in June 2005 (function of A and TLAB)
     2915      temfin = 30.18*std::pow(bl3->ia2,0.17)*(1.0-5.7*std::pow(10.0,(-5))*tlab);
    25602916    }
    25612917    else {
     
    25672923  // deutons
    25682924  // a way to change stopping time f[5] not used here
    2569   factemp = calincl->f[5]; // f(6)->f[5]
     2925  factemp = calincl->getTimeScale();
    25702926  // attention !!! 30/04/2001 scaling time is now a multiplication factor
    25712927  temfin = temfin*factemp;
     
    26042960  else {
    26052961    npion = 1;
    2606     ipi[1] = 8 - 2*(kindstruct->kindf7);
     2962    if(kindstruct->kindf7 == -666) { // Extended projectile...
     2963      ipi[1] = 8 - 2*be->ia_be;
     2964    } else {
     2965      ipi[1] = 8 - 2*(kindstruct->kindf7);
     2966    }
    26072967    y1[1] = 0.0;
    26082968    y2[1] = 0.0;
     
    26172977  goto pnu9;
    26182978  //    850     
    2619  pnu7:
    2620   s1t1 = 0.0;
    2621   s2t1 = 0.0;
    2622   s3t1 = 0.0;
    2623   sp1t1 = 0.0;
    2624   sp2t1 = 0.0;
    2625   sp3t1 = 0.0;
    2626   for(G4int i = 1; i <= bl3->ia1; i++) {
    2627   //for(G4int i = 1; i <= (bl3->ia1-1); i++) {
    2628   //  for(G4int i = 1; i < (bl3->ia1-1); i++) {
    2629     bl9->hel[i] = 0;
    2630     bl5->nesc[i] = 0;
    2631     bl1->ind2[i] = 1;
    2632     if (i > iz1) {
    2633       bl1->ind2[i] = -1;
    2634     }
    2635     bl1->ind1[i] = 0;
    2636     // deutons
    2637     jparticip[i] = 1;
    2638 
    2639     // deutons
     2979 pnu7:
     2980  //  G4cout <<"(checkpoint 'pnu7)" << G4endl;
     2981  if(kindstruct->kindf7 == 6) { // Deuteron
    26402982    gaussianRandom(&xga);
    2641     bl3->x1[i] = xga*rms1*0.57735;
    2642     s1t1 = s1t1 + bl3->x1[i];
     2983    bl3->x1[1] = xga*rms1*0.5775;
    26432984    gaussianRandom(&xga);
    2644     bl3->x2[i] = xga*rms1*0.57735;
    2645     s2t1 = s2t1 + bl3->x2[i];
     2985    bl3->x2[1] = xga*rms1*0.5775;
    26462986    gaussianRandom(&xga);
    2647     bl3->x3[i] = xga*rms1*0.57735;
    2648     s3t1 = s3t1 + bl3->x3[i];
    2649 
    2650     if(kindstruct->kindf7 == 6) { //then
    2651       // deuteron density from paris potential in q space:     
    2652       standardRandom(&xq, &(hazard->igraine[9]));
    2653       qdeut = splineab(xq) * 197.3289;
    2654       standardRandom(&u, &(hazard->igraine[10]));
    2655       cstet = u*2 - 1;
    2656       sitet = std::sqrt(1.0 - std::pow(cstet,2));
    2657       standardRandom(&v, &(hazard->igraine[11]));
    2658       phi = 2.0*3.141592654*v;
    2659 
    2660       bl1->p1[i] = qdeut*sitet*std::cos(phi);
    2661       bl1->p2[i] = qdeut*sitet*std::sin(phi);
    2662       bl1->p3[i] = qdeut*cstet;
    2663     }
    2664     else {
    2665       // density of composite as a gaussien in q space:
     2987    bl3->x3[1] = xga*rms1*0.5775;
     2988
     2989    bl3->x1[2] = -bl3->x1[1];
     2990    bl3->x2[2] = -bl3->x2[1];
     2991    bl3->x3[2] = -bl3->x3[1];
     2992
     2993    // Deuteron density from Paris potential in q space:
     2994    standardRandom(&xq, &(hazard->igraine[9]));
     2995    qdeut = splineab(xq) * 197.3289;
     2996    standardRandom(&u, &(hazard->igraine[11]));
     2997    cstet = u * 2 - 1;
     2998    sitet = std::sqrt(1.0 - std::pow(cstet, 2));
     2999    standardRandom(&v, &(hazard->igraine[11]));
     3000    phi = 2.0 * 3.141592654 * v;
     3001    bl1->p1[1] = qdeut * sitet * std::cos(phi);
     3002    bl1->p2[1] = qdeut * sitet * std::sin(phi);
     3003    bl1->p3[1] = qdeut * cstet;
     3004    bl1->eps[1] = w(bl1->p1[1], bl1->p2[1], bl1->p3[1], fmp);
     3005    bl1->p1[2] = - bl1->p1[1];
     3006    bl1->p2[2] = - bl1->p2[1];
     3007    bl1->p3[2] = - bl1->p3[1];
     3008    bl1->eps[2] = bl1->eps[1];
     3009    //    bl1->eps[2] = w(bl1->p1[2], bl1->p2[2], bl1->p3[2], fmp);
     3010
     3011    jparticip[1] = 1;
     3012    bl9->hel[1] = 0;
     3013    bl5->nesc[1] = 0;
     3014    bl1->ind2[1] = 1;
     3015    bl1->ind1[1] = 0;
     3016    jparticip[2] = 1;
     3017    bl9->hel[2] = 0;
     3018    bl5->nesc[2] = 0;
     3019    bl1->ind2[2] = -1;
     3020    bl1->ind1[2] = 0;
     3021  } else {
     3022    // Composite heavier than a deuteron
     3023    s1t1 = 0.0;
     3024    s2t1 = 0.0;
     3025    s3t1 = 0.0;
     3026    sp1t1 = 0.0;
     3027    sp2t1 = 0.0;
     3028    sp3t1 = 0.0;
     3029    G4double sei = 0.0;
     3030
     3031    bl9->hel[0] = 0;
     3032    bl5->nesc[0] = 0;
     3033    for(G4int i = 1; i <= bl3->ia1; i++) {
     3034      bl9->hel[i] = 0;
     3035      bl5->nesc[i] = 0;
     3036      bl1->ind2[i] = 1;
     3037      if(i > iz1) {
     3038        bl1->ind2[i] = -1;
     3039      }
     3040      bl1->ind1[i] = 0;
     3041      jparticip[i] = 1;
    26663042      gaussianRandom(&xga);
    2667       bl1->p1[i] = xga*pf1*0.57735;
     3043      bl3->x1[i] = xga * rms1 * 0.57735;
     3044      s1t1 = s1t1 + bl3->x1[i];
    26683045      gaussianRandom(&xga);
    2669       bl1->p2[i] = xga*pf1*0.57735;
     3046      bl3->x2[i] = xga * rms1 * 0.57735;
     3047      s2t1 = s2t1 + bl3->x2[i];
    26703048      gaussianRandom(&xga);
    2671       bl1->p3[i] = xga*pf1*0.57735;
    2672     }
    2673 
    2674     bl1->eps[i] = w(bl1->p1[i],bl1->p2[i],bl1->p3[i],fmp);
    2675 
    2676     sp1t1 = sp1t1 + bl1->p1[i];
    2677     sp2t1 = sp2t1 + bl1->p2[i];
    2678     sp3t1 = sp3t1 + bl1->p3[i];
    2679   }
    2680 
    2681   bl9->hel[bl3->ia1] = 0;
    2682   bl5->nesc[bl3->ia1] = 0;
    2683   bl1->ind2[bl3->ia1] = -1;
    2684   bl1->ind1[bl3->ia1] = 0;
    2685   bl3->x1[bl3->ia1] = -s1t1;
    2686   bl3->x2[bl3->ia1] = -s2t1;
    2687   bl3->x3[bl3->ia1] = -s3t1;
    2688   bl1->p1[bl3->ia1] = -sp1t1;
    2689   bl1->p2[bl3->ia1] = -sp2t1;
    2690   bl1->p3[bl3->ia1] = -sp3t1;
    2691   bl1->eps[bl3->ia1] = w(bl1->p1[bl3->ia1],bl1->p2[bl3->ia1],bl1->p3[bl3->ia1],fmp);
    2692  
    2693   // deutons
    2694   jparticip[bl3->ia1] = 1;
    2695   if(verboseLevel > 3) {
    2696     G4cout <<"Particle " << bl3->ia1-1 << " is now participant." << G4endl;
    2697   }
     3049      bl3->x3[i] = xga * rms1 * 0.57735;
     3050      s3t1 = s3t1 + bl3->x3[i];
     3051
     3052      G4int igaussfermi = 2;
     3053      if(igaussfermi == 1) { // Gaussian
     3054        // Density of composite as a gaussian in q
     3055        // space:
     3056        gaussianRandom(&xga);
     3057        bl1->p1[i] = xga * pf1 * 0.57735;
     3058        gaussianRandom(&xga);
     3059        bl1->p2[i] = xga * pf1 * 0.57735;
     3060        gaussianRandom(&xga);
     3061        bl1->p3[i] = xga * pf1 * 0.57735;
     3062      } else { // Fermi
     3063        // Density of composite as a Fermi sphere in q space:
     3064        for(int iloc=1; iloc <= 3; iloc++) {
     3065          standardRandom(&t[iloc],&(hazard->igraine[11]));
     3066        }
     3067        t[2]=-1+2.*t[2];
     3068        t[3]=6.283185*t[3];
     3069        t2=t[2];
     3070        t3=std::sqrt(1.-t2*t2);
     3071        t4=std::cos(t[3]);
     3072        t5=std::sin(t[3]);
     3073        y=fermi->pf*std::pow(t[1],0.33333333);
     3074        bl1->p1[i]=y*t3*t4;
     3075        bl1->p2[i]=y*t3*t5;
     3076        bl1->p3[i]=y*t2;
     3077      }
     3078      bl1->eps[i] = w(bl1->p1[i], bl1->p2[i], bl1->p3[i], fmp);
     3079      sei = sei + bl1->eps[i];
     3080
     3081      if(verboseLevel > 1) {
     3082        G4cout <<"projectile nucleon = " << i << G4endl;
     3083        G4cout <<"x1 = " << bl3->x1[i] << G4endl;
     3084        G4cout <<"x2 = " << bl3->x2[i] << G4endl;
     3085        G4cout <<"x3 = " << bl3->x3[i] << G4endl;
     3086        G4cout <<"p1 = " << bl1->p1[i] << G4endl;
     3087        G4cout <<"p2 = " << bl1->p2[i] << G4endl;
     3088        G4cout <<"p3 = " << bl1->p3[i] << G4endl;
     3089        G4cout <<"eps = " << bl1->eps[i] << G4endl;
     3090      }
     3091      sp1t1 = sp1t1 + bl1->p1[i];
     3092      sp2t1 = sp2t1 + bl1->p2[i];
     3093      sp3t1 = sp3t1 + bl1->p3[i];
     3094    }
     3095
     3096    s1t1 = s1t1/double(bl3->ia1);
     3097    s2t1 = s2t1/double(bl3->ia1);
     3098    s3t1 = s3t1/double(bl3->ia1);
     3099    sp1t1 = sp1t1/double(bl3->ia1);
     3100    sp2t1 = sp2t1/double(bl3->ia1);
     3101    sp3t1 = sp3t1/double(bl3->ia1);
     3102    sei = 0.0;
     3103
     3104    for(G4int i = 1; i <= bl3->ia1; i++) {
     3105      bl3->x1[i] = bl3->x1[i] - s1t1;
     3106      bl3->x2[i] = bl3->x2[i] - s2t1;
     3107      bl3->x3[i] = bl3->x3[i] - s3t1;
     3108      bl1->p1[i] = bl1->p1[i] - sp1t1;
     3109      bl1->p2[i] = bl1->p2[i] - sp2t1;
     3110      bl1->p3[i] = bl1->p3[i] - sp3t1;
     3111      bl1->eps[i] = w(bl1->p1[i], bl1->p2[i], bl1->p3[i], fmp);
     3112      sei = sei + bl1->eps[i];
     3113    }
     3114    v_proj = 0.0;
     3115    if(bl3->ia1 > 4) v_proj = (sei - fmpinc)/bl3->ia1;
     3116
     3117    //    bl1->dump(26);
     3118    //    bl3->dump();
     3119    //    G4cout <<"(checkpoint 'endheavyprojinit)" << G4endl;
     3120  } // End of: Composites heavier than deuteron
     3121
     3122
    26983123 pnu9: // continue
     3124  //  G4cout <<"(checkpoint 'pnu9)" << G4endl;
    26993125  // deutons
    27003126  // target preparation for 1 < a < 5 (with sum of momentum =0)
     
    28603286  // random azimuthal direction of the impact parameter (sept 99)
    28613287
    2862   if (kindstruct->kindf7 <= 2) {
    2863     G4long testseed = hazard->igraine[13];
    2864     //    standardRandom(&tbid, &(hazard->igraine[13]));
    2865     standardRandom(&tbid, &testseed);
    2866     hazard->igraine[13] = testseed;
     3288  if (kindstruct->kindf7 <= 2 && kindstruct->kindf7 > 0) {
     3289    standardRandom(&tbid, &(hazard->igraine[13]));
    28673290    tbid = tbid*6.283185;
    28683291    bl3->x1[1] = bl3->x1[1] + b*std::cos(tbid);  //x1(1)->x1[1]                                       
    28693292    bl3->x2[1] = bl3->x2[1] + b*std::sin(tbid); //x2(1)->x2[1]
    28703293    bl3->x3[1] = bl3->x3[1] - z;
     3294    // Counter of p(n) entering the potential 4/2008 AB
     3295    if(bl1->ind2[1] == 1) { // then
     3296      npenter=1;
     3297      nnenter=0;
     3298    } else {
     3299      npenter=0;
     3300      nnenter=1;
     3301    } // endif
     3302
    28713303    // pour le ntuple des avatars:
    28723304    if(varavat->kveux == 1) {
     
    28773309  }
    28783310  else {
    2879     if (kindstruct->kindf7 < 6) { //then ! pour les pions on laisse
     3311    if (kindstruct->kindf7 < 6 && kindstruct->kindf7 > 0) { //then ! pour les pions on laisse
    28803312      //call standardRandom(tbid,iy14)
    28813313      standardRandom(&tbid, &(hazard->igraine[13]));
     
    29163348      //    pnu21:
    29173349      if (nmiss == bl3->ia1) { //then
     3350        //      G4cout <<"(checkpoint 'projectilemissedtarget)" << G4endl;
    29183351        nopart = -1;
    29193352        //      return;
     
    29253358      }
    29263359      else {
     3360        // Counter of p(n) entering the potential 4/2008 AB
     3361        if(bl1->ind2[ilm]==1) { //then
     3362          npenter=1;
     3363          nnenter=0;
     3364        } else {
     3365          npenter=0;
     3366          nnenter=1;
     3367        } // endif
     3368
    29273369        zshif = bl3->x3[ilm] - ztouch;
    29283370        standardRandom(&tbid, &(hazard->igraine[13]));
     
    29433385  }
    29443386
     3387  // for rho(r),rho(q) checking
     3388#ifdef G4INCLDEBUG
     3389  for(G4int rho_i = bl3->ia1 + 1; rho_i <= ia; rho_i++) { // DO I=IA1+1,IA
     3390    G4double r_dist = std::sqrt(bl3->x1[rho_i] * bl3->x1[rho_i] + bl3->x2[rho_i] * bl3->x2[rho_i] + bl3->x3[rho_i] * bl3->x3[rho_i]);
     3391    G4double p_mod = std::sqrt(std::pow(bl1->p1[rho_i],2)+std::pow(bl1->p2[rho_i],2) + std::pow(bl1->p3[rho_i],2));
     3392    theLogger->fillHistogram1D("r_distrib", r_dist);
     3393    theLogger->fillHistogram1D("p_distrib", p_mod);
     3394    theLogger->fillHistogram2D("r-p_correl", r_dist, p_mod);
     3395  }
     3396#endif
     3397
    29453398  // initial momentum for all type of incident particles:
    29463399  xl1 = b*pinc*std::sin(tbid);                                 
     
    29513404  // (here,=lab frame)
    29523405
    2953   be = 0.0;
     3406  bevar = 0.0;
    29543407  ge = 1.0;
    2955   b1 = (binc - be)/(1.0 - be*binc);
    2956   b2 = -be;
     3408  b1 = (binc - bevar)/(1.0 - bevar*binc);
     3409  b2 = -bevar;
    29573410  g1 = 1.0/std::sqrt(1.0 - b1*b1);
    29583411  g2 = 1.0;
    29593412  // deutons
    29603413  // here for nucleons
    2961   if (kindstruct->kindf7 <= 2) {
     3414  if (kindstruct->kindf7 <= 2 && kindstruct->kindf7 > 0) {
    29623415    bl1->eps[1] = g1*fmp + v0;
    29633416    bl1->p3[1] = std::sqrt(std::pow(bl1->eps[1],2) - std::pow(fmp,2));
     
    29653418  else {
    29663419    // here for pions
    2967     if (kindstruct->kindf7 < 6) { //then
     3420    if (kindstruct->kindf7 < 6 && kindstruct->kindf7 > 0) { //then
    29683421      q4[1] = g1*fmpi; // q4(1)->q4[0]
    29693422      q3[1] = b1*q4[1];
    29703423    }
    2971     else {
     3424    else { // Composite projectiles
    29723425      // here for composite projectiles:
    29733426      // the kinetic energy is below the threshold. put all
     
    29853438      // here the composit is above threshold
    29863439      for(G4int i = 1; i <= bl3->ia1; i++) { //do i=1,bl3->ia1  !save e,p in the composit rest frame
    2987         eps_c[i] = bl1->eps[i];
    2988         p3_c[i] = bl1->p3[i];
     3440        qvp->t_c[i] = bl1->eps[i] - fmp;
     3441        bl1->eps[i] = bl1->eps[i] - v_proj;
     3442        qvp->eps_c[i] = bl1->eps[i];
     3443        qvp->p3_c[i] = bl1->p3[i];
    29893444      } //enddo
    29903445
     
    29953450      iflag = 0;
    29963451    pnu1870:
     3452      //      G4cout <<"(checkpoint 'pnu1870)" << G4endl;
    29973453      sueps = 0.0;
    29983454
     
    30003456
    30013457      for(G4int i = 1; i <= bl3->ia1; i++) { //do i=1,bl3->ia1
    3002         tte = eps_c[i];
    3003         bl1->eps[i] = g1*(eps_c[i] + b1*p3_c[i]);
    3004         bl1->p3[i] = g1*(b1*tte + p3_c[i]);
     3458        tte = qvp->eps_c[i];
     3459        bl1->eps[i] = g1*(qvp->eps_c[i] + b1*qvp->p3_c[i]);
     3460        bl1->p3[i] = g1*(b1*tte + qvp->p3_c[i]);
    30053461        sueps = sueps + bl1->eps[i];
    30063462      } //enddo
    30073463
     3464      goto pnu987;
     3465      // With a potential for the projectile it is nonsens to search for
     3466      // nucleons ON shell  31/05/2010.     
     3467
    30083468      cobe = (tlab + fmpinc)/sueps;
    30093469
     
    30123472      if(iflag == nbtest) { // too much..all momentum to 0
    30133473        for(G4int klm = 1; klm <= bl3->ia1; klm++) { //do klm=1,bl3->ia1
    3014           eps_c[klm] = fmp;
     3474          qvp->eps_c[klm] = fmp;
    30153475          bl1->p1[klm] = 0.0;
    30163476          bl1->p2[klm] = 0.0;
    3017           p3_c[klm] = 0;
     3477          qvp->p3_c[klm] = 0;
    30183478        }
    30193479        goto pnu1870;
     
    30303490            }
    30313491          }
    3032           eps_c[i_emax] = fmp;
     3492          qvp->eps_c[i_emax] = fmp;
    30333493          bl1->p1[i_emax] = 0.0;
    30343494          bl1->p2[i_emax] = 0.0;
    3035           p3_c[i_emax] = 0.0;
     3495          qvp->p3_c[i_emax] = 0.0;
    30363496
    30373497          if(i_emax == bl3->ia1) { //    circular permut if the last one
    3038             epsv = eps_c[bl3->ia1]; //   permutation circulaire
     3498            epsv = qvp->eps_c[bl3->ia1]; //      permutation circulaire
    30393499            p1v = bl1->p1[bl3->ia1];
    30403500            p2v = bl1->p2[bl3->ia1];
    3041             p3v = p3_c[bl3->ia1];
     3501            p3v = qvp->p3_c[bl3->ia1];
    30423502            for(bl2->k = bl3->ia1-1; bl2->k >= 1; bl2->k = bl2->k - 1) { //do k=bl3->ia1-1,1,-1
    3043               eps_c[bl2->k+1] = eps_c[bl2->k];
     3503              qvp->eps_c[bl2->k+1] = qvp->eps_c[bl2->k];
    30443504              bl1->p1[bl2->k+1] = bl1->p1[bl2->k];
    30453505              bl1->p2[bl2->k+1] = bl1->p2[bl2->k];
    3046               p3_c[bl2->k+1] = p3_c[bl2->k];
     3506              qvp->p3_c[bl2->k+1] = qvp->p3_c[bl2->k];
    30473507            }
    3048             eps_c[1] = epsv;
     3508            qvp->eps_c[1] = epsv;
    30493509            bl1->p1[1] = p1v;
    30503510            bl1->p2[1] = p2v;
    3051             p3_c[1] = p3v;      // fin permut.
     3511            qvp->p3_c[1] = p3v;         // fin permut.
    30523512          }
    30533513          sp1t1 = 0.0;   // re-compute the last one
     
    30573517            sp1t1 = sp1t1 + bl1->p1[j];
    30583518            sp2t1 = sp2t1 + bl1->p2[j];
    3059             sp3t1 = sp3t1 + p3_c[j];
     3519            sp3t1 = sp3t1 + qvp->p3_c[j];
    30603520          }
    30613521          bl1->p1[bl3->ia1] = -sp1t1;
    30623522          bl1->p2[bl3->ia1] = -sp2t1;
    3063           p3_c[bl3->ia1] = -sp3t1;
    3064           eps_c[bl3->ia1] = w(bl1->p1[bl3->ia1],bl1->p2[bl3->ia1],p3_c[bl3->ia1],fmp); 
     3523          qvp->p3_c[bl3->ia1] = -sp3t1;
     3524          qvp->eps_c[bl3->ia1] = w(bl1->p1[bl3->ia1],bl1->p2[bl3->ia1],qvp->p3_c[bl3->ia1],fmp);       
    30653525
    30663526          goto pnu1870;  // ..and boost all of them.
     
    30833543      }
    30843544      bl1->eps[ilm] = bl1->eps[ilm] + v0; 
    3085     }
    3086   }
     3545
     3546 pnu987:
     3547      //  G4cout <<"(checkpoint 'pnu987)" << G4endl;
     3548  // ici sauvegarde des energies et impulsions des nucleons du projectile i.l.:
     3549  // (hors potentiel)
     3550  for(G4int i = 1; i <= bl3->ia1; i++) {
     3551    qvp->eps_c[i]=bl1->eps[i];
     3552    qvp->p1_s[i]=bl1->p1[i];
     3553    qvp->p2_s[i]=bl1->p2[i];
     3554    qvp->p3_s[i]=bl1->p3[i];
     3555  }
     3556
     3557  // first particle entering in the target potential:   
     3558  bl1->eps[ilm]=bl1->eps[ilm]+v0;
     3559         
     3560  // correction en test 16/04/2009 (pourquoi pas la correction aussi de l'impulsion
     3561  // comme pour un nucleon in ???? ....on essaye de traiter les nucleons hors couche?)
     3562  // 29/4/2009: je pense que c'est une erreur et je transforme aussi maintenant l'impulsion:
     3563  var_ab = std::pow(bl1->p1[ilm],2)
     3564    + std::pow(bl1->p2[ilm],2)
     3565    + std::pow(bl1->p3[ilm],2);
     3566  if(var_ab > 0.) {
     3567    gpsg=std::sqrt((std::pow(bl1->eps[ilm],2)
     3568                    -fmp*fmp)/var_ab);
     3569  }
     3570  bl1->p1[ilm]=bl1->p1[ilm]*gpsg;             
     3571  bl1->p2[ilm]=bl1->p2[ilm]*gpsg;
     3572  bl1->p3[ilm]=bl1->p3[ilm]*gpsg;       
     3573    } // For pion-in
     3574  } // For nucleon-in
    30873575
    30883576 pnu1871:
     3577  //  G4cout <<"(checkpoint 'pnu1871)" << G4endl;
     3578  //  bl1->dump(27);
     3579  //  bl3->dump();
     3580  //  randomGenerator->printSeeds();
    30893581  // evaluation of the times t(a,b)
    30903582  bl2->k = 0;
    30913583  kcol = 0;
    3092   if (kindstruct->kindf7 <= 2) {
     3584  if (kindstruct->kindf7 <= 2 && kindstruct->kindf7 > 0) {
    30933585    // modif s.vuillier tient compte propagation projectile,1e collision
    30943586    // imposee pour lui (c'est une maniere de faire!!)
     
    31553647  else {
    31563648    // deutons
    3157     if (kindstruct->kindf7 < 6) { //then
     3649    if (kindstruct->kindf7 < 6 && kindstruct->kindf7 > 0) { //then
    31583650      // here for incoming pions:
    31593651      for(G4int i = bl3->ia1+1; i <= ia; i++) { //do i=ia1+1,ia
     
    31763668    }
    31773669    else {
     3670      // Counting the spectators and transparents of composit projectiles:     
     3671      //      G4cout <<"(checkpoint 'setipszero1)" << G4endl;
     3672      ips=0;
     3673      nb_transprojo=0;
    31783674      for(G4int i = 1; i <= bl3->ia1; i++) { //do 38 i=1,ia1
    31793675        bl5->nesc[i] = 1;
     3676        // Spectators of composite projectiles (7/2006, AB)
     3677        // Pour garder trace des spectateurs du projectile:
     3678        npproj[i]=1;
     3679
    31803680        if (i != ilm) {
    31813681          goto pnu36;
     
    31933693        goto pnu37;
    31943694      pnu36:
     3695        //      G4cout <<"(checkpoint 'pnu36)" << G4endl;
    31953696        t1 = bl3->x1[i]*(bl1->p1[i])+bl3->x2[i]*(bl1->p2[i])+bl3->x3[i]*(bl1->p3[i]);                     
    31963697        t2 = bl1->p1[i]*(bl1->p1[i])+bl1->p2[i]*(bl1->p2[i])+bl1->p3[i]*(bl1->p3[i]);               
     
    31993700        //   1379       c incoming nucleons enter potential at maximum radius (modif. 13/06/01)
    32003701        t5 = t3*t3 + ((ws->rmaxws)*(ws->rmaxws) - t4)/t2;
     3702        if (t5 < 0.) {
     3703          // this is a projectile spectator:
     3704          //      G4cout <<"(checkpoint 'incripspnu36)" << G4endl;
     3705          ips=ips+1;
     3706          isPartOfSpectatorNucleus[i] = true;
     3707          ps->n_projspec[ips] = i;
     3708          continue;
     3709          //goto pnu38;
     3710        } // endif
     3711               
    32013712        if(verboseLevel > 3) {
    32023713          G4cout <<"x1 = " << bl3->x1[i] <<" x2 = " << bl3->x2[i] <<" x3 = " << bl3->x3[i] << G4endl;
     
    32083719          G4cout <<"t5 = " << t5 << G4endl;
    32093720        }
    3210         if (t5 < 0.) {
    3211           continue;
    3212         }
     3721        //      if (t5 < 0.) {
     3722        //        ips++;
     3723        //        ps->n_projspec[ips] = i;
     3724        //        continue;
     3725        //      }
    32133726        tref = (-1.0*t3 - std::sqrt(t5))*(bl1->eps[i]); 
    3214         if (tref > bl4->tmax5) {
    3215           continue;
    3216         }
     3727
     3728        // Drop reflection avatars with too large tref and the ones
     3729        // with negative tref (spectator, outside the nucleus)
     3730        //      if (tref > bl4->tmax5 || tref <= 0.0) {
     3731        //        continue;
     3732        //      }
     3733        if (tref > bl4->tmax5) { //then
     3734          // This is also a projectile spectator:
     3735          ips=ips+1;
     3736          ps->n_projspec[ips] = i;
     3737          continue; // go to 38
     3738        } // endif
     3739
     3740        // Test to avoid a nucleon entering in the past (3/06/2010 as in incl4.6 a.b.)
     3741        if(tref <= 0.0) { // then
     3742          // This is also a projectile spectator:
     3743          ips=ips+1;
     3744          ps->n_projspec[ips] = i;
     3745          continue; // go to 38
     3746        } // endif
     3747     
    32173748        npproj[i] = 1;
    32183749      pnu37:
     3750        //      G4cout <<"(checkpoint 'pnu37)" << G4endl;
    32193751        bl2->k = bl2->k + 1;
    32203752        bl2->crois[bl2->k] = tref;
    32213753        bl2->ind[bl2->k] = i;
    32223754        bl2->jnd[bl2->k] = -1;
    3223       }
     3755      //    pnu38:
     3756      }
     3757
     3758      // For composit beams, cannot decide that there is no interaction,
     3759      // (another nucleon can enter later at RMAX).
    32243760      kcol = 1;
    3225      
     3761      n_activnuc = ia-ips;  //number of active nucleons (not missing the target)
     3762      n_enter_pot = ia-ips; //number of projectile nucleons that can enter
     3763
     3764      /*
     3765      if(useProjSpect) { // Treat the projectile spectators:
     3766        n_activnuc = ia - ips; // number of active nucleons (not missing the target)
     3767        if(ips != 0) { //then
     3768          e_spec = 0.0;
     3769          p1_spec = 0.0;
     3770          p2_spec = 0.0;
     3771          p3_spec = 0.0;
     3772          z_projspec = 0;
     3773          for(G4int i_spec = 1; i_spec <= ips; i_spec++) { // do i_spec=1,ips
     3774            G4int i_c = n_projspec[i_spec];
     3775            e_spec = e_spec + bl1->eps[i_c];
     3776            p1_spec = p1_spec + bl1->p1[i_c];
     3777            p2_spec = p2_spec + bl1->p2[i_c];
     3778            p3_spec = p3_spec + bl1->p3[i_c];
     3779            if(bl1->ind2[i_c] == 1) z_projspec = z_projspec + 1;
     3780          }
     3781          G4double p_spec2 = std::pow(p1_spec,2) + std::pow(p2_spec,2) + std::pow(p3_spec,2);
     3782          G4double s_spec = std::sqrt(std::pow(e_spec,2) - p_spec2);
     3783          // write(6,*) 'e,p,sqs:',e_spec,sqrt(p_spec2),s_spec
     3784
     3785          // c masses from dresner code:
     3786          G4int fja = ips;                                                                   
     3787          G4int fjz = z_projspec;                                                                   
     3788          G4double ex2 = abla->eflmac(fja, fjz, 0, 0); // dnrgy(fja,fjz);
     3789          G4double rnmass = ex2+um*fja;
     3790
     3791          // c write(6,*) fja,fjz,ex2,um                                                         
     3792          ex_projspec = s_spec - rnmass;
     3793          if(ex_projspec <= 0.0) { //then
     3794            // c no spectator nucleus compatible with available energy:
     3795            ips = 0;
     3796            // c n_activnuc = ia-ips!number of active nucleons (not missing the target)
     3797            goto pnu239;
     3798          }
     3799          t_projspec = e_spec - s_spec;
     3800          G4double coef = std::sqrt(t_projspec*(t_projspec + 2.0*s_spec)/p_spec2);
     3801          p1_projspec = p1_spec*coef;
     3802          p2_projspec = p2_spec*coef;
     3803          p3_projspec = p3_spec*coef;
     3804          m_projspec = rnmass;
     3805
     3806          // c check module...     
     3807          //    c      write(6,*) 'projectile spectator a,z:',a_projspec,z_projspec
     3808          //    c      write(6,*) 'm,t,e*:',m_projspec,t_projspec,ex_projspec
     3809          //    c      write(6,*) 'p1,p2,p3:',p1_projspec,p2_projspec,p3_projspec
     3810          //    c      write(6,*) '   constituants:',ips
     3811          //    c      do i_spec=1,ips
     3812          //    c        i_c = n_projspec(i_spec)
     3813          //    c      write(6,*) i_c,eps(i_c),p1(i_c),p2(i_c),p3(i_c)       
     3814          // c      enddo
     3815          // c ...end check module
     3816        } // endif
     3817      pnu239:
     3818        a_projspec = ips; // number of nucleons in the spectator nucleus
     3819      } // End of projectile spectator treatment
     3820      */
     3821
    32263822      //      for(G4int i = bl3->ia1+1; i < ia; i++) { //do  39 i=ia1+1,ia
    32273823      for(G4int i = bl3->ia1+1; i <= ia; i++) { //do  39 i=ia1+1,ia
     
    32983894    goto pnu48;
    32993895  }
     3896  // Here transparent event (no interaction avatar found)
     3897  //  G4cout <<"(checkpoint 'heretransparent)" << G4endl;
    33003898  nopart = -1;
    33013899  // Pour eviter renvoi des resultats du run precedent cv 7/7/98
     
    33163914  // Initialization  at the beginning of the run
    33173915 pnu48:
     3916  //  G4cout <<"(checkpoint 'pnu48)" << G4endl;
    33183917  if(verboseLevel > 3) {
    33193918    G4cout <<"Beginning a run..." << G4endl;
     
    33643963  }
    33653964 pnu449:
     3965  //  G4cout <<"(checkpoint 'pnu449)" << G4endl;
    33663966  if(verboseLevel > 3) {
    33673967    G4cout <<"Now at 449" << G4endl;
     
    33723972
    33733973 pnu44:
     3974  //  G4cout <<"(checkpoint 'pnu44)" << G4endl;
    33743975  if(verboseLevel > 3) {
    33753976    G4cout <<"Now at 44" << G4endl;
     
    34064007  }
    34074008 pnu448:
     4009  //  G4cout <<"(checkpoint 'pnu448)" << G4endl;
     4010  //  bl2->dump();
    34084011  imin = indic[next];
    34094012  bl9->l1 = bl2->ind[imin]; //NOTE: l1 changed to bl9->l1.
     
    34194022  // test le 20/3/2003: tue sinon le dernier avatar?
    34204023  if (bl2->k == 0) {
    3421     if(verboseLevel > 2) {
     4024    if(verboseLevel > -2) {
    34224025      G4cout <<"k == 0. Going to the end of the avatar." << G4endl;
    34234026    }
     
    34384041  }
    34394042 pnu46:
     4043  //  G4cout <<"(checkpoint 'pnu46)" << G4endl;
    34404044  if(verboseLevel > 3) {
    34414045    G4cout <<"G4Incl: Now at pnu46." << G4endl;
    34424046  }
    34434047  tim = timi + tau;
     4048  avatarCounter++;
     4049  //  G4cout <<"FOUND AVATAR " <<  avatarCounter << " : tau = " << tau;
     4050  //  G4cout <<"  l1 = " << bl9->l1 << "   l2 = " << bl9->l2 << G4endl;
    34444051
    34454052  // tableau des energies a t=20,40,60 fm/c
     
    34964103    }
    34974104  }
     4105  //  G4cout <<"(checkpoint 'pnu645)" << G4endl;
     4106  // Here, stoping condition for heavy (light) ions:
     4107  if(kindstruct->kindf7 < 0) {
     4108    if(n_activnuc-nbquit <= ia_breakup) {
     4109      //      G4cout <<"stopped cascade for fermi breakup " << G4endl;
     4110      goto pnu255;
     4111    }
     4112  }
    34984113
    34994114  // modif: pas de reflexions avant au moins un avatar du (des) nucleon incident
    35004115  // celui-ci ne peut etre qu'une collision nn (ou pin)
    35014116
     4117  /*
    35024118  if((irst_avatar == 0) && (bl9->l2 == -1)) {
    35034119    if(verboseLevel > 3) {
     
    35084124
    35094125  irst_avatar = irst_avatar+1;
     4126  */
     4127  //  if((bl3->ia1 + bl3->ia2 - nbquit) <= 10) goto pnu255; // Stop the cascade if only very few nucleons are left.
    35104128
    35114129  if (tim < temfin) {
     
    35184136  goto pnu255;
    35194137 pnu49:
     4138  //  G4cout <<"(checkpoint 'pnu49)" << G4endl;
    35204139  if(verboseLevel > 3) {
    35214140    G4cout <<"G4Incl: Now at pnu49. " << G4endl;
     
    35514170  // l1 est un delta:
    35524171 pnu830:
     4172  //  G4cout <<"(checkpoint 'pnu830)" << G4endl;
    35534173  if(verboseLevel > 3) {
    35544174    G4cout <<"G4Incl: Now at pnu830." << G4endl;
     
    35664186  }
    35674187 pnu803:
     4188  //  G4cout <<"(checkpoint 'pnu803)" << G4endl;
    35684189  // pas de collision entre 2 non participants:
    35694190  if(jparticip[bl9->l1] == 0 && jparticip[bl9->l2] == 0) {
     
    36324253  goto pnu261;
    36334254 pnu260:
     4255  //  G4cout <<"(checkpoint 'pnu260)" << G4endl;
    36344256  bmax2 = totalCrossSection(sq,mg,isos)/31.41592;
    36354257 pnu261:
     4258  //  G4cout <<"(checkpoint 'pnu261)" << G4endl;
    36364259  if (bb2 < bmax2) {
    36374260    goto pnu220;
     
    36484271  // evaluation of the positions at time = tim
    36494272 pnu220:
     4273  //  G4cout <<"(checkpoint 'pnu220)" << G4endl;
    36504274  timi = tim;
    36514275   if(verboseLevel > 3) {
     
    36824306
    36834307  // gel des nucleons non participants sur le premier avatar (nn)=(l1,1)     
     4308  /*
    36844309  if (irst_avatar == 1) {
    36854310    for(G4int i = 1; i <= bl9->l1; i = i + bl9->l1 - 1) { // bugfix!
     
    36974322  }
    36984323  else {
     4324  */
    36994325    for(G4int i = 1; i <= ia; i++) {
    37004326      bl1->ta = tau/bl1->eps[i];
     
    37034329      bl3->x3[i] = bl3->x3[i] + bl1->p3[i]*(bl1->ta);
    37044330    }
    3705   }
     4331    //  }
    37064332
    37074333  //  if(npion != 0) {
     
    37144340    }
    37154341  }
     4342  //  G4cout <<"(checkpoint 'pnu840)" << G4endl;
    37164343
    37174344  if(bl9->l2 == 0) {
     
    38284455  }
    38294456 pnu243:
     4457  //  G4cout <<"(checkpoint 'pnu243)" << G4endl;
    38304458  if (bl1->ind1[bl9->l2] == 1) { // bugfix 1 -> 0
    38314459    goto pnu241;
     
    38384466  goto pnu241;
    38394467 pnu248:
     4468  //  G4cout <<"(checkpoint 'pnu248)" << G4endl;
    38404469  if(verboseLevel > 3) {
    38414470    G4cout <<"Pauli blocked transition!" << G4endl;
     
    38744503
    38754504 pnu241:
    3876 
     4505  //  G4cout <<"(checkpoint 'pnu241)" << G4endl;
    38774506  // la premiere collision a deux corps ne peut pas baisser l'energie
    38784507  // du nucleon de recul (bloque par pauli dans un noyau cible froid).
     
    39744603  q4[npion] = t[14]; //t(15)->t[14]
    39754604 pnu240:
     4605  //  G4cout <<"(checkpoint 'pnu240)" << G4endl;
    39764606  ncol = ncol + 1;
    39774607  if (bl9->l2 != 1) {
     
    40454675
    40464676  pnu870:
     4677  //  G4cout <<"(checkpoint 'pnu870)" << G4endl;
    40474678  bl5->tlg[bl9->l1] = th*(bl1->eps[bl9->l1])/std::sqrt(std::pow(bl1->eps[bl9->l1],2)-std::pow(bl1->p1[bl9->l1],2)-std::pow(bl1->p2[bl9->l1],2)-std::pow(bl1->p3[bl9->l1],2));
    40484679  bl5->tlg[bl9->l2] = th*(bl1->eps[bl9->l2])/std::sqrt(std::pow(bl1->eps[bl9->l2],2)-std::pow(bl1->p1[bl9->l2],2)-std::pow(bl1->p2[bl9->l2],2)-std::pow(bl1->p3[bl9->l2],2));
     
    42504881
    42514882 pnu848:
     4883  //  G4cout <<"(checkpoint 'pnu848)" << G4endl;
    42524884  if (npion == 0) {
    42534885    goto pnu844;
     
    42694901
    42704902 pnu843:
     4903  //  G4cout <<"(checkpoint 'pnu843)" << G4endl;
    42714904  if(bl1->ind1[bl9->l2] != 1) {
    42724905    for(G4int k20 = 1; k20 <= npion; k20++) {
     
    42764909  }
    42774910 pnu844:
    4278 
     4911  //  G4cout <<"(checkpoint 'pnu844)" << G4endl;
    42794912  if(bl1->ind1[bl9->l1]+bl1->ind1[bl9->l2] <= ich1+ich2) {
    42804913    goto pnu849;
     
    42864919  goto pnu821;
    42874920 pnu820:
     4921  //  G4cout <<"(checkpoint 'pnu820)" << G4endl;
    42884922  if(bl1->ind1[bl9->l2]-ich2 != 1) {
    42894923    goto pnu849;
     
    42924926
    42934927 pnu821:
     4928  //  G4cout <<"(checkpoint 'pnu821)" << G4endl;
    42944929  standardRandom(&rndm,&(hazard->igraine[16]));
    42954930  // largeur variable du delta (phase space factor G4introduced 4/2001)
     
    43204955  // decay of the delta particle                                       p-n09780
    43214956 pnu805:
     4957  //  G4cout <<"(checkpoint 'pnu805)" << G4endl;
    43224958  npion = npion + 1;
    43234959  ichd = bl1->ind2[bl9->l1];
     
    43725008
    43735009 pnu837:
     5010  //  G4cout <<"(checkpoint 'pnu837)" << G4endl;
    43745011  ipi[npion]=bl1->ind2[bl9->l1]*2;
    43755012  bl1->ind2[bl9->l1]=-1*(bl1->ind2[bl9->l1]);
    43765013  goto pnu809;
    43775014 pnu806:
     5015  //  G4cout <<"(checkpoint 'pnu806)" << G4endl;
    43785016  bl1->ind2[bl9->l1]=bl1->ind2[bl9->l1]/3;
    43795017  ipi[npion]=2*(bl1->ind2[bl9->l1]);
    43805018 pnu809: // continue
     5019  //  G4cout <<"(checkpoint 'pnu809)" << G4endl;
    43815020  bl1->ind1[bl9->l1]=0;
    43825021  bl5->tlg[bl9->l1]=0.;
     
    44225061  // it is blocked!     
    44235062 pnu1848:
     5063  //  G4cout <<"(checkpoint 'pnu1848)" << G4endl;
    44245064  mpaul2 = mpaul2 + 1;
    44255065  if(varavat->kveux == 1) {
     
    44675107  // valid decay of the delta
    44685108 pnu850:
     5109  //  G4cout <<"(checkpoint 'pnu850)" << G4endl;
    44695110  if(varavat->kveux == 1) {
    44705111    varavat->bloc_paul[iavat] = 0;
     
    45145155 
    45155156 pnu4047:
     5157  //  G4cout <<"(checkpoint 'pnu4047)" << G4endl;
    45165158  if (bl5->nesc[bl9->l1] != 0) {
    45175159    goto pnu845;
     
    45385180
    45395181 pnu845:
     5182  //  G4cout <<"(checkpoint 'pnu845)" << G4endl;
    45405183  new2(y1[npion], y2[npion], y3[npion], q1[npion], q2[npion], q3[npion], q4[npion], npion, bl9->l1);
    45415184  if(bl2->k == 0) {
     
    45505193  // pion-nucleon collision
    45515194 pnu801:
     5195  //  G4cout <<"(checkpoint 'pnu801)" << G4endl;
    45525196  if(verboseLevel > 3) {
    45535197    G4cout <<"Pion-nucleon collision!" << G4endl;
     
    45885232
    45895233 pnu832:
     5234  //  G4cout <<"(checkpoint 'pnu832)" << G4endl;
    45905235  if (bl2->k == 0) {
    45915236    goto pnu230;
     
    45975242  goto pnu44;
    45985243 pnu831:
     5244  //  G4cout <<"(checkpoint 'pnu831)" << G4endl;
    45995245  standardRandom(&rndm, &(hazard->igraine[18]));
    46005246  geff = t[9]/sq; //t(10)->t[9]
     
    47145360  // reflection on or transmission through the potential wall
    47155361 pnu600:
     5362  //  G4cout <<"(checkpoint 'pnu600)" << G4endl;
    47165363  // deutons pas bien compris ici cv ?
    47175364  if (npproj[bl9->l1] == 0) {
     
    47365383  }
    47375384 
     5385  if (bl1->ind2[bl9->l1] == 1) { //then
     5386    npenter=npenter+1;
     5387  } else {
     5388    nnenter=nnenter+1;
     5389  } // endif
     5390
    47385391  var_ab = std::pow(bl1->p1[bl9->l1],2) + std::pow(bl1->p2[bl9->l1],2) + std::pow(bl1->p3[bl9->l1],2);
    47395392  gpsg = 0.0;
     
    47565409  // pour un non participant la transmission est impossible:
    47575410 pnu608:
     5411  //  G4cout <<"(checkpoint 'pnu608)" << G4endl;
    47585412  if(varavat->kveux == 1) {
    47595413    varavat->del1avat[iavat] = bl1->ind1[bl9->l1];
     
    47775431
    47785432 pnu605:
     5433  //  G4cout <<"(checkpoint 'pnu605)" << G4endl;
    47795434  fm = fmp;
    47805435  pot = v0;
    47815436
    47825437 pnu606:
     5438  //  G4cout <<"(checkpoint 'pnu606)" << G4endl;
    47835439  if(verboseLevel > 3) {
    47845440    G4cout <<"G4Incl: Now at pnu606. Calculating transmission probability." << G4endl;
    47855441  }
    4786   tp = transmissionProb(bl1->eps[bl9->l1]-fm,bl1->ind2[bl9->l1],itch,bl3->r2,v0);
     5442  tp = transmissionProb(bl1->eps[bl9->l1]-fm,bl1->ind2[bl9->l1],1,itch,bl3->r2,v0);
    47875443  if(varavat->kveux == 1) {
    47885444    varavat->energyavat[iavat] = bl1->eps[bl9->l1] - fm;
     
    47965452    goto pnu601;
    47975453  }
    4798 
     5454  // Commande clusters ou non (1/0)!
     5455  if(kclst == 0) goto pnu1610;
     5456  // Cluster goes here!
     5457 pnu1610:
     5458  //  G4cout <<"(checkpoint 'pnu1610)" << G4endl;
    47995459  // ici la particule l1 s'échappe du noyau:
    48005460  bl5->nesc[bl9->l1] = 1;
     
    48115471  bl1->eps[bl9->l1] = bl1->eps[bl9->l1] - pot;
    48125472
     5473  // Test for a transparent nucleon for composit beams and stored for FermiBreakup
     5474  if(bl3->ia1 > 1 && nc[bl9->l1] == 0) {
     5475    //    G4cout <<"(checkpoint 'incripspnu1610)" << G4endl;
     5476    ips=ips+1;
     5477    isPartOfSpectatorNucleus[bl9->l1] = true;
     5478    ps->n_projspec[ips]=bl9->l1;
     5479    nb_transprojo = nb_transprojo + 1;
     5480  } // endif
     5481
     5482  // pnu610: goes here
     5483
    48135484  // comptage des particules hors du noyau (7/6/2002):
    48145485  // (remnant minimum=1 nucleon)
     
    48275498  // here no transmission possible
    48285499 pnu601:
     5500  //  G4cout <<"(checkpoint 'pnu601)" << G4endl;
    48295501  pspr=bl3->x1[bl9->l1]*(bl1->p1[bl9->l1])+bl3->x2[bl9->l1]*(bl1->p2[bl9->l1])+bl3->x3[bl9->l1]*(bl1->p3[bl9->l1]);
    48305502  if(varavat->kveux == 1) {
     
    48415513
    48425514 pnu602:
     5515  //  G4cout <<"(checkpoint 'pnu602)" << G4endl;
    48435516  if(verboseLevel > 3) {
    48445517    G4cout <<"G4Incl: Now at pnu602." << G4endl;
    48455518  }
    48465519 
    4847   if(bl2->k != 0) {
     5520  if(bl2->k != 0) { // GOTO elimination?
    48485521    kd = 0;
    48495522    ccr = tau;
     
    48625535    bl2->k = bl2->k - kd;
    48635536
    4864     if (bl5->nesc[bl9->l1] == 1) {
     5537    if (bl5->nesc[bl9->l1] != 0) { // modif 10/02 pour logique des clusters (nesc()=2!)
    48655538      goto pnu613;
    48665539    }
     
    48985571
    48995572 pnu615:
     5573  //  G4cout <<"(checkpoint 'pnu615)" << G4endl;
    49005574  if(verboseLevel > 3) {
    49015575    G4cout <<"G4Incl: Now at pnu615." << G4endl;
     
    49125586  }
    49135587 pnu613:
     5588  //  G4cout <<"(checkpoint 'pnu613)" << G4endl;
    49145589  if(verboseLevel > 3) {
    49155590    G4cout <<"G4Incl: Now at pnu613." << G4endl;
     
    49485623  // decay of the surviving deltas
    49495624 pnu230:
     5625  //  G4cout <<"(checkpoint 'pnu230)" << G4endl;
    49505626  if(verboseLevel > 3) {
    49515627    G4cout <<"G4Incl: Now at pnu230." << G4endl;
     
    49535629  // decay of the surviving deltas
    49545630pnu255:
     5631  //  G4cout <<"(checkpoint 'pnu255)" << G4endl;
    49555632  if(verboseLevel > 3) {
    49565633    G4cout <<"G4Incl: Now at pnu6255." << G4endl;
     
    49655642
    49665643  npidir = npion;
     5644
     5645  idq = 0;
     5646  destar = 0.;
     5647
    49675648  for(G4int i = 1; i <= ia; i++) {
     5649    G4int iblcdpp=0;
    49685650    if (bl1->ind1[i] == 0) {
    49695651      continue;
     
    49805662    xy3 = bl1->p3[i];
    49815663    xye = bl1->eps[i];
     5664    ichd=bl1->ind2[i];
    49825665    if(varavat->kveux == 1) {
    49835666      iavat = iavat + 1;
     
    50005683      G4cout <<"i = " << i << " bl1->p1[i] = " << bl1->p1[i] << " bl1->p2[i] = " << bl1->p2[i] << " bl1->p3[i] = " << bl1->p3[i] << " bl1->eps[i] = " << bl1->eps[i] << G4endl;
    50015684    }
    5002    
     5685
     5686// C 6/08/09; Don't have to check CDPP for the forced decay of a DELTA OUTSIDE!
     5687//       IF(NESC(I).EQ.1) GO TO 1850
     5688     
     5689// C------
     5690// C On teste CDPP apres la decroissance forcee June/2005 (AB-CV)
     5691// C    Si rejet de la decroissance -> delta devient nucleon sans pion
     5692// C       et toute l'energie en exces est mise en energie d'excitation du noyau
     5693// C       On respecte aussi la conservation de charge (Z du remnant!)
     5694 
     5695// C Le decay ne peut conduire a un noyau de A nucleons
     5696// C  sous l'energie de Fermi et dans une config. d'energie inferieure a
     5697// C  EFER-(IA2-NBALTTF)*TF).
     5698//        EGS=0.
     5699//        NBALTTF=0
     5700//        DO II=1,IA
     5701//          IF(NESC(II).EQ.0) THEN
     5702//          IF(SQRT(P1(II)**2+P2(II)**2+P3(II)**2).LT.PF) THEN
     5703//             NBALTTF=NBALTTF+1
     5704//             EGS=EGS+EPS(II)-FMP
     5705//          ENDIF
     5706//       ENDIF
     5707//        END DO
     5708//        IF(EGS.GE.(EFER-(IA2-NBALTTF)*TF)) GO TO 1850
     5709// C ATTENTION, logique negative!!! Liberer le goto si on veut supprimer la
     5710// C   sequence precedente (CDPP sur Delta-> pi N)
     5711// C        GO TO 1850
     5712
     5713// C Ici ce decay est interdit par CDPP.
     5714// C Restitution du Delta: un neutron au repos et correction conservee pour
     5715// C la charge IDQ et l'energie d'excitation DESTAR du remnant. On viole donc
     5716// C un peu la conservation d'impulsion, mais semble moins grave que de convertir
     5717// C la masse d'un pion en impulsion d'un nucleon unique....
     5718//       IBLCDPP=1              !flag de blocage par CDPP
     5719//       IND1(i) = 0    !identif delta (nucleon)
     5720//       IND2(i) = -1   !isospin du neutron
     5721//      IDQ = IDQ + (ICHD+1)/2
     5722//       p1(i)=0.               !impulsion energie
     5723//       p2(i)=0.
     5724//       p3(i)=0.
     5725//       eps(i)=FMP
     5726//      DESTAR = DESTAR + xye - FMP
     5727//       NPION=NPION-1  !pas le dernier pion
     5728
     5729// 1850  CONTINUE
     5730// C------   
    50035731    if(bl5->nesc[i] == 0) {
    50045732      idecf = 1;
     
    50225750      // fin surface
    50235751    }
     5752    if(iblcdpp == 1) continue; // goto pnu257;
    50245753
    50255754    if (bl1->ind2[i]*(bl1->ind2[i]) == 9) {
     
    50365765
    50375766  pnu283:
     5767    //    G4cout <<"(checkpoint 'pnu283)" << G4endl;
    50385768    if(verboseLevel > 3) {
    50395769      G4cout <<"G4Incl: Now at pnu283." << G4endl;
     
    50455775
    50465776  pnu280:
     5777    //    G4cout <<"(checkpoint 'pnu285)" << G4endl;
    50475778    if(verboseLevel > 3) {
    50485779      G4cout <<"G4Incl: Now at pnu280." << G4endl;
     
    50535784
    50545785  pnu285:
     5786    //    G4cout <<"(checkpoint 'pnu285)" << G4endl;
    50555787    if(verboseLevel > 3) {
    50565788      G4cout <<"G4Incl: Now at pnu285." << G4endl;
     
    50945826
    50955827 pnu256:
     5828  //  G4cout <<"(checkpoint 'pnu256)" << G4endl;
    50965829  if(verboseLevel > 3) {
    50975830    G4cout <<"G4Incl: Now at pnu256." << G4endl;
     
    51025835  npx = 0;
    51035836  erem = 0.;
     5837  // Excitation energy of the final delta of blocked decay: (AB CV 6/2005)
     5838  erem = erem + destar;
    51045839  izrem = 0;
     5840  // Correct the charge of the remnant if the final delta is blocked: (A.B., C.V. 6/2005)
     5841  izrem = izrem + idq;
    51055842  inrem = 0;
    51065843  iarem = 0;
     
    51155852  pout3 = 0.0;
    51165853  eout = 0.0;
     5854  p1spec=0.;
     5855  p2spec=0.;
     5856  p3spec=0.;
    51175857  cmultn = 0.0;
    51185858
    5119   if (kindstruct->kindf7 <= 2) {
     5859  if (kindstruct->kindf7 <= 2 && kindstruct->kindf7 > 0) {
    51205860    if (ncol == 0 || nc[1] == 0) { // then nc(1)->nc[0]
    51215861      if(verboseLevel > 3) {
     
    51265866  }
    51275867  else {
    5128     if (kindstruct->kindf7 <= 5) {
     5868    if (kindstruct->kindf7 <= 5 && kindstruct->kindf7 > 0) {
    51295869      if (ncol == 0) {
    51305870        if(verboseLevel > 3) {
     
    51495889  // pour eviter renvoi des resultats du run precedent cv 20/11/98
    51505890 pnu9100:
     5891  //  G4cout <<"(checkpoint 'pnu9100)" << G4endl;
    51515892  iarem = bl3->ia2;
    51525893  izrem = iz2;
     
    51615902
    51625903 pnu9101:
     5904  //  G4cout <<"(checkpoint 'pnu9101)" << G4endl;
    51635905  if(verboseLevel > 3) {
    51645906    G4cout <<"G4Incl: Now at pnu9101." << G4endl;
     
    51685910  ekout = 0.0;
    51695911
    5170   for(G4int i = 1; i <= ia; i++) {
    5171     if(bl5->nesc[i] != 0) {
    5172       xl1 = xl1-bl3->x2[i]*(bl1->p3[i]) + (bl3->x3[i])*(bl1->p2[i]);
    5173       xl2 = xl2-bl3->x3[i]*(bl1->p1[i]) + bl3->x1[i]*(bl1->p3[i]);
    5174       xl3 = xl3-bl3->x1[i]*(bl1->p2[i]) + bl3->x2[i]*(bl1->p1[i]);
    5175 
    5176       // ici ajout de pout cv le 5/7/95
    5177       pout1 = pout1 + bl1->p1[i];
    5178       pout2 = pout2 + bl1->p2[i];
    5179       pout3 = pout3 + bl1->p3[i];
    5180       eout = eout+bl1->eps[i] - fmp;
    5181       //      ic33 = int((std::floor(double(bl1->ind2[i]+3))/double(2)));
    5182       ic33 = (bl1->ind2[i]+3)/2;
    5183       //nopart = nopart + 1;
    5184       kind[nopart] = 3 - ic33;
    5185       if(verboseLevel > 3) {
    5186         G4cout <<"kind[" << nopart << "] = " << kind[nopart] << G4endl;
    5187       }
    5188       ep[nopart] = bl1->eps[i] - fmp;
    5189       if(verboseLevel > 2) {
    5190         if(ep[nopart] > calincl->f[2]) {
    5191           G4cout <<"ep[" << nopart << "] = " << ep[nopart] << " > " << calincl->f[2] << G4endl;
    5192           G4cout <<"E = " << bl1->eps[nopart] << G4endl;
    5193           G4cout <<"px = " << bl1->p1[nopart] << " py = " << bl1->p2[nopart] << " pz = " << bl1->p3[nopart] << G4endl;
    5194           G4cout <<"Particle mass = " << fmp << G4endl;
    5195         }
    5196       }
    5197       bmass[nopart] = fmp;
    5198       ekout = ekout + ep[nopart];
    5199       ptotl = std::sqrt(std::pow(bl1->p1[i],2) + std::pow(bl1->p2[i],2) + std::pow(bl1->p3[i],2));
    5200       alpha[nopart] = bl1->p1[i]/ptotl;
    5201       beta[nopart] = bl1->p2[i]/ptotl;
    5202       gam[nopart] = bl1->p3[i]/ptotl;
    5203       nopart = nopart + 1;
    5204       continue;
    5205     }
    5206    
    5207     t[3] = bl3->x1[i]*(bl3->x1[i]) + bl3->x2[i]*(bl3->x2[i]) + bl3->x3[i]*(bl3->x3[i]); //t(4)->t[3]
    5208     erem = erem + bl1->eps[i] - fmp;
    5209     rcm1 = rcm1 + bl3->x1[i];
    5210     rcm2 = rcm2 + bl3->x2[i];
    5211     rcm3 = rcm3 + bl3->x3[i];
    5212     prem1 = prem1 + bl1->p1[i];
    5213     prem2 = prem2 + bl1->p2[i];
    5214     prem3 = prem3 + bl1->p3[i];
    5215     izrem = izrem + (1 + bl1->ind2[i])/2;
    5216     iarem = iarem + 1;
    5217   }
    5218 
     5912  if(kclst != 0) { // Clusters go here!
     5913  }
     5914
     5915// Treat here the projectile spectators (including transparents):
     5916  projo_spec(bl3->ia1,ips,fmpinc,pinc,tlab);
     5917
     5918  for(G4int i = 1; i <= ia; i++) { // do 258 i=1,ia
     5919    //  pnu259:
     5920    if (bl5->nesc[i] == 0) goto pnu254;
     5921    if (bl5->nesc[i] > 1) continue; // on evite les nucleons des clusters
     5922
     5923    // here nesc=1 or negative value (emitted nucleons, spectators included)     
     5924    xl1_i=bl3->x2[i]*bl1->p3[i]-bl3->x3[i]*bl1->p2[i];  // moment angulaire emporte
     5925    xl2_i=bl3->x3[i]*bl1->p1[i]-bl3->x1[i]*bl1->p3[i];
     5926    xl3_i=bl3->x1[i]*bl1->p2[i]-bl3->x2[i]*bl1->p1[i];
     5927
     5928    xl1=xl1-xl1_i;                                                   
     5929    xl2=xl2-xl2_i;                                                     
     5930    xl3=xl3-xl3_i;                                                     
     5931
     5932    //   ici ajout de pout cv le 5/7/95
     5933    pout1=pout1+bl1->p1[i];
     5934    pout2=pout2+bl1->p2[i];
     5935    pout3=pout3+bl1->p3[i];
     5936    //      write(6,*)'eout nucleon',eout
     5937    eout = eout + bl1->eps[i]-fmp;
     5938
     5939    ic33=(bl1->ind2[i]+3)/2;
     5940
     5941    // here we don't copy the spectators of the projectile bound in a
     5942    //   spectator nucleus (treated by the deexcitation module):
     5943    if(kindstruct->kindf7 < 0 && i <= bl3->ia1 && ps->a_projspec != 0) {
     5944      for(G4int iloc =  1; iloc <= ps->a_projspec; iloc++) { //do iloc=1,a_projspec
     5945        if(i == ps->n_projspec[iloc]) {
     5946          p1spec=p1spec+bl1->p1[i];
     5947          p2spec=p2spec+bl1->p2[i];
     5948          p3spec=p3spec+bl1->p3[i];
     5949          // for balance, a transparent from projectile is out:
     5950          if(i > ips-nb_transprojo) ekout=ekout+bl1->eps[i]-fmp;
     5951          goto pnu258_end_of_outer_loop;
     5952          //      continue;
     5953        } // endif
     5954      } // enddo
     5955    } // endif
     5956    //    if (isPartOfSpectatorNucleus[i]) goto pnu258_end_of_outer_loop;
     5957
     5958    nopart=nopart+1;
     5959
     5960    ekout=ekout+bl1->eps[i]-fmp;
     5961
     5962    kind[nopart]=3-ic33;
     5963    // spectators of composite projectiles (7/2006, ab)
     5964    if(npproj[i] == 1) kind[nopart] = -kind[nopart];
     5965
     5966    ep[nopart]=bl1->eps[i]-fmp;
     5967    bmass[nopart]=fmp;
     5968    ptotl=std::sqrt(std::pow(bl1->p1[i],2) + std::pow(bl1->p2[i],2)+std::pow(bl1->p3[i],2));
     5969    alpha[nopart]=bl1->p1[i]/ptotl;
     5970    beta[nopart]=bl1->p2[i]/ptotl;
     5971    gam[nopart]=bl1->p3[i]/ptotl;
     5972 
     5973    continue;
     5974  pnu254:
     5975    t[4]=bl3->x1[i]*bl3->x1[i]+bl3->x2[i]*bl3->x2[i]+bl3->x3[i]*bl3->x3[i];
     5976    erem=erem+bl1->eps[i]-fmp;
     5977    rcm1=rcm1+bl3->x1[i];
     5978    rcm2=rcm2+bl3->x2[i];
     5979    rcm3=rcm3+bl3->x3[i];
     5980    prem1=prem1+bl1->p1[i];
     5981    prem2=prem2+bl1->p2[i];
     5982    prem3=prem3+bl1->p3[i];
     5983    izrem=izrem+(1+bl1->ind2[i])/2;
     5984    iarem=iarem+1;
     5985  pnu258_end_of_outer_loop:
     5986    continue;
     5987  }
     5988  //  258 continue 
     5989
     5990  //pnu258:
     5991  //  G4cout <<"(checkpoint 'pnu258)" << G4endl;
    52195992  //  correction pions 21/3/95 jc
    52205993  ichpion = 0;
     
    52296002      xl3 = xl3 - y1[ipion]*q2[ipion] + y2[ipion]*q1[ipion];
    52306003      ichpion = ichpion + ipi[ipion]/2;
    5231       //      nopart = nopart + 1;
     6004      nopart = nopart + 1;
    52326005      kind[nopart] = 4 - ipi[ipion]/2;
    52336006      ptotl = std::sqrt(std::pow(q1[ipion],2) + std::pow(q2[ipion],2) + std::pow(q3[ipion],2));
     
    52386011      beta[nopart] = q2[ipion]/ptotl;
    52396012      gam[nopart] = q3[ipion]/ptotl;
    5240       nopart++;
     6013      //      nopart++;
    52416014    }
    52426015  }
     
    53546127    }
    53556128
    5356     for(G4int ipart = 0; ipart < nopart; ipart++) {
     6129    for(G4int ipart = 0; ipart <= nopart; ipart++) {
    53576130      ep[ipart] = ep[ipart]*fffc;
    53586131    }
     
    53616134  // modif boudard juillet 99 (il faut tenir compte de la renormalisation
    53626135  // des energies pour les impulsions.)
    5363   pfrem1 = 0.0;
    5364   pfrem2 = 0.0;
    5365   pfrem3 = pinc;
    5366   for(G4int ipart = 0; ipart < nopart; ipart++) {
    5367     xmodp = std::sqrt(ep[ipart]*(2.0*bmass[ipart] + ep[ipart]));
     6136  pfrem1= -p1spec;
     6137  pfrem2= -p2spec;
     6138  pfrem3=pinc-p3spec;
     6139//   if(useProjSpect) {
     6140//     pfrem1 = -p1_spec;
     6141//     pfrem2 = -p2_spec;
     6142//     pfrem3 = pinc - p3_spec;
     6143//   } else {
     6144//     pfrem1 = 0.0;
     6145//     pfrem2 = 0.0;
     6146//     pfrem3 = pinc;
     6147//   }
     6148  for(G4int ipart = 0; ipart <= nopart; ipart++) {
     6149    G4double xmodp = 0.0;
     6150    if(ep[ipart] < 0.0) { // Safeguard against particles with negative energy
     6151      xmodp = 0.0;
     6152      G4cout <<"The energy of particle " << ipart << " is negative (" << ep[ipart] << "). Forcing xmodp = " << xmodp << "." << G4endl;
     6153    } else {
     6154      xmodp = std::sqrt(ep[ipart]*(2.0*bmass[ipart] + ep[ipart]));
     6155    }
    53686156    pfrem1 = pfrem1 - alpha[ipart]*xmodp;
    53696157    pfrem2 = pfrem2 - beta[ipart]*xmodp;
     
    53946182    esrem = 0.0;
    53956183  }
     6184  goto pnureturn;
    53966185
    53976186  if(verboseLevel > 3) {
     
    54046193  }
    54056194 pnureturn:
     6195  //  G4cout <<"(checkpoint 'pnureturn)" << G4endl;
     6196//   if(useProjSpect) {
     6197//     varntp->spectatorA = a_projspec;
     6198//     varntp->spectatorZ = z_projspec;
     6199//     varntp->spectatorEx = ex_projspec;
     6200//     varntp->spectatorT = t_projspec;
     6201//     varntp->spectatorM = m_projspec;
     6202//     varntp->spectatorP1 = p1_projspec;
     6203//     varntp->spectatorP2 = p1_projspec;
     6204//     varntp->spectatorP3 = p1_projspec;
     6205//   }
    54066206  (*ibert_p) = ibert;
    54076207  (*nopart_p) = nopart;
     
    54156215  (*bimpact_p) = bimpact;
    54166216  (*l_p) = l;
    5417 }
    5418 
     6217  (*xjrem) = 0;
     6218  (*yjrem) = 0;
     6219  (*zjrem) = 0;
     6220}
    54196221
    54206222void G4Incl::collis(G4double *p1_p, G4double *p2_p, G4double *p3_p, G4double *e1_p, G4double *pout11_p, G4double *pout12_p,
     
    65677369    // pauli strict
    65687370    pmod = std::sqrt(std::pow(bl1->p1[l],2) + std::pow(bl1->p2[l],2) + std::pow(bl1->p3[l],2));
    6569     if (pmod < 270.0) {
     7371    if (pmod < fermi->pf) {
    65707372      return 1.0;
    65717373    } else {
     
    66747476  G4double sine = 0.0;
    66757477
    6676   if((m-1) < 0) {
     7478  if((m-1) < 0) { // Nucleon - Nucleon
    66777479    sine = deltaProductionCrossSection(E,int(i));
    66787480  }
    66797481
    6680   if((m-1) == 0) {
     7482  if((m-1) == 0) { // Nucleon - Delta
    66817483    sine = srec(E,(bl6->xx10),i,int(bl6->isa));
    66827484  }
    66837485
    6684   if((m-1) > 0) {
     7486  if((m-1) > 0) { // Delta - Delta
    66857487    sine = 0.0;
    66867488  }
    66877489
    66887490  stotResult = sine + lowEnergy(E,m,i);
     7491#ifdef G4INCLDEBUG
     7492  theLogger->fillHistogram1D("totalCXResult", stotResult);
     7493  theLogger->fillHistogram1D("totalLowECX", lowEnergy(E, m, i));
     7494  if(m == 0) { // Nucleon - Nucleon
     7495    if(i == 2) { // pp
     7496      theLogger->fillHistogram2D("ppCX", E, stotResult);
     7497    } else if(i == 0) { // pn
     7498      theLogger->fillHistogram2D("pnCX", E, stotResult);
     7499    } else if(i == -2) { // nn
     7500      theLogger->fillHistogram2D("nnCX", E, stotResult);
     7501    }
     7502  } else if(m == 1) { // Nucleon - Delta
     7503    theLogger->fillHistogram2D("NDCX", E, stotResult);
     7504  } else if(m == 2) { // Delta - Delta
     7505    theLogger->fillHistogram2D("DDCX", E, stotResult);
     7506  }
     7507#endif
    66897508  return stotResult;
    66907509}
     
    68587677}
    68597678
    6860 G4double G4Incl::transmissionProb(G4double E, G4double iz, G4double izn, G4double r, G4double v0)
    6861 {
    6862   // transmission probability for a nucleon of kinetic energy
    6863   // E on the edge of the well of depth v0 (nr approximation)
    6864   // iz is the isospin of the nucleon,izn the instanteneous charge
    6865   // of the nucleus and r is the target radius
    6866 
    6867   G4double x = 0.0;
     7679//      FUNCTION BARR(E,IZ,IA,IZN,R,V0)
     7680//  tp =          transmissionProb(bl1->eps[bl9->l1]-fm,bl1->ind2[bl9->l1],1,itch,bl3->r2,v0);
     7681G4double G4Incl::transmissionProb(G4double E, G4int iz, G4int ia, G4int izn,G4double R, G4double v0)
     7682{
     7683// C
     7684// C
     7685// C       NOUVEAU BARR RELATIVISTE ATTENTION AUX ENTREES SORTIES!
     7686// C    (06/2005)
     7687// C                                                                       P-N24450
     7688// CCC   BARR=TRANSMISSION PROBABILITY FOR A PARTICLE (Nucleon, cluster or
     7689// CCC   pion) of kinetic energy E on the edge of the (attractive) well of
     7690// CCC   depth V0 felt by the particle.
     7691// CCC          IZ is the isospin of the particle,
     7692// CCC          IZN the instantaneous charge of the nucleus and R the radius of
     7693// CCC       the well.
     7694// CCC          IA is the mass number of the particle, and MRE its mass energy.             
     7695// C                                                                       P-N24500
     7696// C     Modified 9/10/2002 for clusters (d,t,3He,4He) (IZ=isospin,IA=A)
     7697// C     IZ must be correct so that charge Q=(IA+IZ)/2.
     7698// C     Modified 4/2004 for relativistic expressions and pions.
     7699
     7700  G4double mre;
    68687701  G4double barr = 0.0;
    6869 
    6870   // We need enough energy to escape from the potential well.
    6871   if (E > v0) {
    6872     x = std::sqrt(E*(E - v0));
    6873     barr = 4.0*x/(E + E - v0 + x + x);
    6874     if (iz > 0 && izn != 0) { // izn = 0 causes division by zero
    6875       G4double b = izn*1.44/r;
    6876       G4double px = std::sqrt((E - v0)/b);
    6877      
    6878       if (px < 1.0) {
    6879         G4double g = izn/137.03*std::sqrt(2.0*938.3/(E - v0))*(std::acos(px) - px*std::sqrt(1.0 - px*px));
    6880         if (g > 35.){
    6881           barr=0.0;
    6882         } else {
    6883           barr = barr*std::exp(-2.0*g);
    6884         }
    6885         return barr;
    6886       } else {
    6887         return barr;
    6888       }
    6889     } else {
    6890       return barr;
    6891     }
     7702  G4double v0ia = v0*ia;
     7703  mre = ia*938.3;
     7704
     7705  if (E > v0ia && izn > 0 && R != 0) goto tp1;
     7706  barr = 0.0;
     7707  return barr;
     7708
     7709 tp1:
     7710  G4double x=std::sqrt((2.*mre*E+E*E)*(2.*mre*(E-v0ia)+std::pow((E-v0ia),2)));                                         
     7711  barr=4.*x/(2.*mre*(2.*E-v0ia)+std::pow(E,2)+std::pow(E-v0ia,2)+2.*x);
     7712  G4double iq=(ia+iz)/2.;
     7713  if (iq > 0 && E > v0ia) goto tp2;
     7714  return barr;
     7715
     7716 tp2:
     7717  G4double b=iq*izn*1.44/R;                                             
     7718  G4double px=std::sqrt((E-v0ia)/b);                                             
     7719  if (px < 1.) goto tp3;
     7720  return barr;
     7721
     7722 tp3:
     7723  G4double g=iq*izn/137.03*std::sqrt(2.*mre/(E-v0ia)/(1.+(E-v0ia)/2./mre))
     7724    *(std::acos(px)-px*std::sqrt(1.-px*px));
     7725  if (g > 35.) {
     7726    barr=0.0;
    68927727  } else {
    6893     return barr;
    6894   }
     7728    barr=barr*std::exp(-2.*g);
     7729  } // endif
     7730  return barr;
    68957731}
    68967732
     
    69087744  G4double s_l = 0.0;
    69097745  G4double t1 = 0.0, t3 = 0.0, t4 = 0.0, t5 = 0.0;
    6910   if (ws->nosurf <= 0) { // modif pour w.s.:
    6911     xv = p/pf;
    6912     if(t2 <= pf2) {
    6913       r = interpolateFunction(xv);
    6914     } else {
    6915       r = ws->rmaxws;
    6916     }
    6917     r = r*r;
    6918   }
     7746   if (ws->nosurf <= 0) { // modif pour w.s.:
     7747     xv = p/pf;
     7748     if(t2 <= pf2) {
     7749       r = interpolateFunction(xv);
     7750#ifdef G4INCLDEBUG
     7751     theLogger->fillHistogram1D("refInterpolXV", xv);
     7752     theLogger->fillHistogram1D("refInterpolRes", r);
     7753     if(xv > 1.0) theLogger->fillHistogram1D("refInterpolResWhenXVgt1", r);
     7754#endif
     7755     } else {
     7756       r = ws->rmaxws;
     7757     }
     7758     r = r*r;
     7759   }
     7760/*
     7761  if (ws->nosurf <= 0) {
     7762    // modif pour w.s.:
     7763    xv=p/pf;
     7764    r=interpolateFunction(xv);
     7765    r=r*r;
     7766    if (t2 > pf2) r=std::pow(ws->rmaxws,2);
     7767  } //endif
     7768*/
    69197769 ref21:
    69207770  t4 = x1*x1 + x2*x2 + x3*x3;
     
    69697819  }
    69707820
    6971   bl3->ia2 = int(std::floor(calincl->f[0] + 0.1)); // f(1) -> f[0]
     7821  //  bl3->ia2 = int(std::floor(calincl->targetA() + 0.1)); // f(1) -> f[0]
     7822  bl3->ia2 = calincl->targetA();
    69727823  sep = 6.8309;
    69737824
     
    69767827      itg = 6 - 1;
    69777828    }
    6978     if(bl3->ia2 == 3 && calincl->f[1] == 1) {
     7829    if(bl3->ia2 == 3 && calincl->targetZ() == 1) {
    69797830      itg = 7 - 1;
    69807831    }
    6981     if(bl3->ia2 == 3 && calincl->f[1] == 2) {
     7832    if(bl3->ia2 == 3 && calincl->targetZ() == 2) {
    69827833      itg = 8 - 1;
    69837834    }
     
    69887839  }
    69897840
    6990   if((calincl->f[2] >= 10.0) && (calincl->f[2] <= 100.0)) {
    6991     if(calincl->f[6] == 1.0) {
     7841  if((calincl->bulletE() >= 10.0) && (calincl->bulletE() <= 100.0)) {
     7842    if(calincl->bulletType() == 1) {
    69927843      bl3->ia1 = int(1.0);
    69937844      iz1 = 1.0;
    69947845      G4double fmpinc = 938.2796;
    6995       G4double pbeam2 = calincl->f[2]*(calincl->f[2] + 2.0*fmpinc);
     7846      G4double pbeam2 = calincl->bulletE()*(calincl->bulletE() + 2.0*fmpinc);
    69967847      bmaxt = ws->bmax;
    6997       proba_trans = coulombTransm(calincl->f[2],bl3->ia1,iz1,calincl->f[0],calincl->f[1]);
    6998       proba = forceAbs(1,calincl->f[0],calincl->f[1],calincl->f[2],bmaxt,proba_trans);
     7848      proba_trans = coulombTransm(calincl->bulletE(),bl3->ia1,iz1,calincl->targetA(),calincl->targetZ());
     7849      proba = forceAbs(1,calincl->targetA(),calincl->targetZ(),calincl->bulletE(),bmaxt,proba_trans);
    69997850     
    70007851      standardRandom(&alea,&(hazard->igraine[4]));
     
    70037854      }
    70047855
    7005       (*iarem) = int(calincl->f[0]) + bl3->ia1;
    7006       (*izrem) = int(calincl->f[1]) + int(iz1);
     7856      (*iarem) = int(calincl->targetA()) + bl3->ia1;
     7857      (*izrem) = int(calincl->targetZ()) + int(iz1);
    70077858     
    7008       del = std::sqrt(std::pow(((calincl->f[0] + 1.0)*fmpinc + calincl->f[2]),2) - pbeam2);
     7859      del = std::sqrt(std::pow(((calincl->targetA() + 1.0)*fmpinc + calincl->bulletE()),2) - pbeam2);
    70097860     
    7010       (*erecrem) = pbeam2/((calincl->f[0] + 1.0)*fmpinc+calincl->f[2] + del);
    7011 
    7012       (*esrem) = calincl->f[2] + sep - (*erecrem);
     7861      (*erecrem) = pbeam2/((calincl->targetA() + 1.0)*fmpinc+calincl->bulletE() + del);
     7862
     7863      (*esrem) = calincl->bulletE() + sep - (*erecrem);
    70137864
    70147865      (*alrem) = 0.00001;
     
    70197870      return;
    70207871    }
    7021     else if((calincl->f[6] == 2) && (calincl->f[2] >= 20.0)) {
     7872    else if((calincl->bulletType() == 2) && (calincl->bulletE() >= 20.0)) {
    70227873      bl3->ia1 = int(1.0);
    70237874      iz1 = 0.0;
    70247875      G4double fmpinc = 938.2796;
    7025       G4double pbeam2 = calincl->f[2]*(calincl->f[2] + 2.0*fmpinc);
     7876      G4double pbeam2 = calincl->bulletE()*(calincl->bulletE() + 2.0*fmpinc);
    70267877      bmaxt = ws->bmax;
    7027       proba_trans = coulombTransm(calincl->f[2],bl3->ia1,iz1,calincl->f[0],calincl->f[1]);
    7028       proba = forceAbs(1,calincl->f[0],calincl->f[1],calincl->f[2],bmaxt,proba_trans);
     7878      proba_trans = coulombTransm(calincl->bulletE(),bl3->ia1,iz1,calincl->targetA(),calincl->targetZ());
     7879      proba = forceAbs(1,calincl->targetA(),calincl->targetZ(),calincl->bulletE(),bmaxt,proba_trans);
    70297880     
    70307881      standardRandom(&alea,&(hazard->igraine[4]));
     
    70337884      }
    70347885
    7035       (*iarem) = int(calincl->f[0]) + bl3->ia1;
    7036       (*izrem) = int(calincl->f[1]) + int(iz1);
     7886      (*iarem) = int(calincl->targetA()) + bl3->ia1;
     7887      (*izrem) = int(calincl->targetZ()) + int(iz1);
    70377888     
    7038       del = std::sqrt(std::pow(((calincl->f[0]+1.)*fmpinc+calincl->f[2]),2)-pbeam2);
     7889      del = std::sqrt(std::pow(((calincl->targetA()+1.)*fmpinc+calincl->bulletE()),2)-pbeam2);
    70397890     
    7040       (*erecrem) = pbeam2/((calincl->f[0] + 1.0)*fmpinc + calincl->f[2] + del);
    7041 
    7042       (*esrem) = calincl->f[2] + sep - (*erecrem);
     7891      (*erecrem) = pbeam2/((calincl->targetA() + 1.0)*fmpinc + calincl->bulletE() + del);
     7892
     7893      (*esrem) = calincl->bulletE() + sep - (*erecrem);
    70437894
    70447895      (*alrem) = 0.00001;
     
    71087959    return dp0;
    71097960  }
    7110   G4double rp = radius(ap);                                                     
    7111   G4double rt = radius(at);                                                     
     7961  G4double rp = radius(G4int(ap));                                                     
     7962  G4double rt = radius(G4int(at));                                                     
    71127963  G4double vp = (dp1 + dpth)*dppi*std::pow(rp,3);                                         
    71137964  G4double vt = (dp1 + dpth)*dppi*std::pow(rt,3);                                         
     
    73108161{
    73118162  // Gaussian random number generator
    7312  
     8163  G4double xg, xxg, xshuf;
     8164 gaussianRandom1:
     8165  xg=0.;
     8166  for(G4int i = 1; i <= 12; i++) { //do 6 j=1,12
     8167    standardRandom(&xxg,&(hazard->ial));
     8168    //  gaussianRandom6:
     8169    xg=xg+xxg;
     8170  }
     8171  xg=xg-6.;
     8172  if (xg*xg > 9.0) goto gaussianRandom1;
     8173  standardRandom(&xshuf,&(hazard->igraine[10]));
     8174  if (xshuf > 0.5) standardRandom(&xxg,&(hazard->ial));
     8175  // gaussianRandom2:
     8176  (*rndm) = xg;
     8177  return;
     8178    /* 
    73138179  G4double tempRandom = 0.0, random = 0.0, randomShuffle = 0.0;
    73148180 
     
    73328198
    73338199  (*rndm) = random;
     8200    */
    73348201}
    73358202
     
    73468213}
    73478214
    7348 G4double G4Incl::radius(G4double A)
     8215G4double G4Incl::radius(G4int A)
    73498216{                                               
    73508217  const G4double dp1 = 1.0, dp3 = 3.0;
     
    73608227             
    73618228  G4double fact = std::sqrt(dp5/dp3);                                               
    7362   G4int ia = int(std::floor(A+0.4));                                                       
     8229  //  G4int ia = int(std::floor(A+0.4));                                                       
     8230  G4int ia = A;
    73638231  G4double result = fact * (0.84 * std::pow(A,dpth) + 0.55);                               
    73648232  for(G4int i = 0; i < naSize; i++) {
     
    76098477}
    76108478
     8479// C****************************************************************************
     8480
     8481void G4Incl::projo_spec(G4int, G4int ips,
     8482                   G4double, G4double, G4double) // max_a_proj is a global #define'd as a global constant
     8483{
     8484  //      subroutine projo_spec(ia1,ips,max_a_proj,
     8485  //     sn_projspec,fmpinc,pinc,tlab)
     8486  //      common/bl1/p1(300),p2(300),p3(300),eps(300),ind1(300),ind2(300),ta
     8487  // spectators of the projectile treated here (nucleus for fermi-breakup):
     8488  // ips is the number of spect, their label is in n_projspec(ips).
     8489  // e,p are outside the target potential for these nucleons.
     8490  // la transmission de max_a_proj=60 ne marche pas....explicite ici!
     8491  //      integer a_projspec,z_projspec,n_projspec(60)
     8492  //      real*4 m_projspec
     8493  //      common/proj_spect/a_projspec,z_projspec,ex_projspec,t_projspec,
     8494  //     s p1_projspec,p2_projspec,p3_projspec,m_projspec
     8495  ///      common/quatvectprojo/eps_c(60),p3_c(60),
     8496  //     s  p1_s(60),p2_s(60),p3_s(60),
     8497  //     s  t_c(60)
     8498  // (eps_c,p1_s,p2_s,p3_s,eps_c used to store the kinematics of nucleons
     8499  // for composit projectiles before entering the potential)
     8500  //      common/fermi/tf,pf,pf2     
     8501
     8502  //  G4double ttrou[21];
     8503  G4double fja = 0.0;
     8504  G4double fjz = 0.0;
     8505  //  G4double ex2;
     8506  //  G4double rmmass;
     8507  //  const G4double um = 931.20793;
     8508
     8509// c verifs: ground state
     8510// c      es=0.
     8511// c      p1s=0.
     8512// c      p2s=0.
     8513// c      p3s=0.
     8514// c      gsmass=0.
     8515// c      do iloc=1,ia1
     8516// c      es=es+eps_c(iloc)
     8517// c      p1s=p1s+p1_s(iloc)
     8518// c      p2s=p2s+p2_s(iloc)
     8519// c      p3s=p3s+p3_s(iloc)
     8520// c      gsmass=gsmass+sqrt(eps_c(iloc)**2
     8521// c     s        -p1_s(iloc)**2-p2_s(iloc)**2-p3_s(iloc)**2)
     8522// c      enddo
     8523// c      sgs=sqrt(es**2-p1s**2-p2s**2-p3s**2)
     8524// c      write(6,*) 'sqs, gsmass :',sgs,gsmass
     8525// c      write(6,*) 'es,p1s,p2s,p3s:',es,p1s,p2s,p3s
     8526// c end verifs
     8527     
     8528//  G4cout <<"proj_spect called with: " << G4endl;
     8529//  G4cout <<"ips = " << ips << G4endl;
     8530  ps->a_projspec=0;
     8531  ps->z_projspec=0;
     8532  ps->t_projspec=0.0;
     8533  G4double e_spec=0.;
     8534    G4double p1_spec=0.;
     8535    G4double p2_spec=0.;
     8536    G4double p3_spec=0.;
     8537    G4double gs_mass=0.;
     8538
     8539  if(ips > 1) {
     8540    for(G4int i_spec=1; i_spec <= ips; i_spec++) {
     8541      G4int i_c = ps->n_projspec[i_spec];
     8542      e_spec = e_spec+bl1->eps[i_c];
     8543      p1_spec = p1_spec+bl1->p1[i_c];
     8544      p2_spec = p2_spec+bl1->p2[i_c];
     8545      p3_spec = p3_spec+bl1->p3[i_c];
     8546      G4double pi_spec2= std::pow(bl1->p1[i_c],2) + std::pow(bl1->p2[i_c],2) + std::pow(bl1->p3[i_c],2);
     8547      // current ground state mass:
     8548      gs_mass=gs_mass+std::sqrt(std::pow(bl1->eps[i_c],2)-pi_spec2);
     8549      if(bl1->ind2[i_c] == 1) ps->z_projspec=ps->z_projspec+1;
     8550    } // enddo
     8551    G4double p_spec2=std::pow(p1_spec,2)+std::pow(p2_spec,2)+std::pow(p3_spec,2);
     8552    G4double s_spec = sqrt(std::pow(e_spec,2)-p_spec2);
     8553
     8554    // no projectile spectator if a>=4 and a=z or a=n (no dresner breakup)
     8555    if(ips >= 4 && (ps->z_projspec == ips || ps->z_projspec == 0)) {
     8556      for(G4int i_spec = 1; i_spec <= ips; i_spec++) { //do i_spec=1,ips
     8557        G4int i_c = ps->n_projspec[i_spec];
     8558        // single nucleon forced on shell! momentum kept.
     8559        // single nucleon forced on shell! energy kept.
     8560        G4double arg=(std::pow(bl1->eps[i_c],2)-std::pow(938.2796,2))/
     8561          (std::pow(bl1->p1[i_c],2)+std::pow(bl1->p2[i_c], 2)+std::pow(bl1->p3[i_c],2));
     8562        G4double coef=0.0;
     8563        if(arg < 0.) { // Single nucleon is forced on shell. We have
     8564                       // to choose between energy and momentum
     8565                       // conservation... so we choose energy:
     8566          coef = 1.0;
     8567          bl1->eps[i_c]=std::sqrt(std::pow(bl1->p1[i_c],2) + std::pow(bl1->p2[i_c], 2) +
     8568                                  std::pow(bl1->p3[i_c], 2) + std::pow(938.2796,2));
     8569        } else {
     8570          coef=std::sqrt(arg);
     8571          bl1->p1[i_c]=bl1->p1[i_c]*coef;
     8572          bl1->p2[i_c]=bl1->p2[i_c]*coef;
     8573          bl1->p3[i_c]=bl1->p3[i_c]*coef;
     8574        }
     8575      } // enddo
     8576      return;
     8577    } // endif
     8578       
     8579    // excitation energy from particle-hole excitation:
     8580    //   seconde methode de calcul ex4:
     8581    for(G4int i = 1; i <= bl3->ia1; i++) { // do i=1,ia1
     8582      G4int nb_p=i;
     8583      //      call ordered(t_c(i),nb_p,tpart)
     8584      ordered(qvp->t_c[i], nb_p);
     8585    } // enddo
     8586    G4double ex4=0.;
     8587    for(G4int i = 1; i <= ips; i++) { //do i=1,ips
     8588      G4int j=ps->n_projspec[i];
     8589      ex4=ex4+qvp->t_c[j]-ps->tab[i]; //ex4=ex4+qvp->t_c[j]-ps->tpart[i];
     8590    } // enddo
     8591
     8592    ps->ex_projspec =ex4;
     8593
     8594    // coherent rest mass:
     8595    ps->m_projspec = s_spec - ps->ex_projspec;
     8596
     8597    ps->a_projspec=ips;
     8598
     8599    if((ps->ex_projspec < 0.) || (ps->m_projspec < 0.)) {
     8600      G4cout <<"ex_projspec is negative,a,z: " << ps->ex_projspec << " " << fja << " " << fjz << G4endl;
     8601      G4cout <<"...or m is negative,a,z:" << ps->m_projspec << " " << fja << " " << fjz << G4endl;
     8602    } // endif
     8603
     8604    ps->t_projspec = e_spec-s_spec;
     8605    ps->p1_projspec = p1_spec;                 
     8606    ps->p2_projspec = p2_spec;
     8607    ps->p3_projspec = p3_spec;
     8608     
     8609// c check module...     
     8610// c      write(6,*) 'projectile spectator a,z:',a_projspec,z_projspec
     8611// c      write(6,*) 'm,t,e*:',m_projspec,t_projspec,ex_projspec
     8612// c      write(6,*) 'p1,p2,p3:',p1_projspec,p2_projspec,p3_projspec
     8613// c      write(6,*) '   constituants:',ips
     8614// c      do i_spec=1,ips
     8615// c            i_c = n_projspec(i_spec)
     8616// c      write(6,*) i_c,eps(i_c),p1(i_c),p2(i_c),p3(i_c)       
     8617// c      enddo
     8618// c ...end check module
     8619
     8620    return;
     8621  } else if(ips == 1) { // then
     8622    ps->a_projspec = 0; // number of nucleons in the spectator nucleus
     8623    G4int i_c = ps->n_projspec[1];
     8624    //c single nucleon forced on shell! momentum kept.
     8625    //c      eps(i_c)=sqrt(p1(i_c)**2+p2(i_c)**2+p3(i_c)**2+938.2796**2)     
     8626    //c single nucleon forced on shell! energy kept.
     8627    G4double arg=(std::pow(bl1->eps[i_c],2)-std::pow(938.2796,2))/
     8628      (std::pow(bl1->p1[i_c],2)+std::pow(bl1->p2[i_c],2)+std::pow(bl1->p3[i_c],2));
     8629    G4double coef=0.0; // Initialize the coefficieant
     8630    if(arg < 0.) {
     8631      G4cout <<"off shell problems in projo_spec, forced coef = 1.0 to recover from the error" << G4endl;
     8632      coef = 1.0;
     8633    } else {
     8634      coef = std::sqrt(arg);
     8635    }
     8636
     8637    bl1->p1[i_c]=bl1->p1[i_c]*coef;
     8638    bl1->p2[i_c]=bl1->p2[i_c]*coef;
     8639    bl1->p3[i_c]=bl1->p3[i_c]*coef;
     8640  } //endif
     8641
     8642  ps->a_projspec = 0; // number of nucleons in the spectator nucleus
     8643  return;
     8644}
     8645     
     8646void G4Incl::ordered(G4double t, G4int nb)
     8647{
     8648  //      SUBROUTINE ORDERED(T,nb,TAB)
     8649  //C This subroutine will ordered in TAB() from min TAB(1) to max
     8650  //C TAB(nb), nb values of T sent successively.
     8651  //C CALL ORDERED (T1,1), CALL ORDERED (T2,2),..CALL ORDERED (Tnb,nb)
     8652  //      DIMENSION TAB(1)
     8653
     8654  //  G4cout <<"Ordered was called" << G4endl;
     8655  if(nb == 1) {
     8656    ps->tab[1]=t;
     8657    return;
     8658  } // endif
     8659
     8660  G4int i=0;
     8661
     8662 ordered100:
     8663  i=i+1;
     8664  if(t < ps->tab[i]) {
     8665    //    for(G4int l = nb-1; l != i; l--) { //do l=nb-1,i,-1
     8666    for(G4int l = nb-1; l >= i; l--) { //do l=nb-1,i,-1
     8667      //      G4cout <<"Ordered: L = " << l << " nb = " << nb <<  " i = " << i << G4endl;
     8668      ps->tab[l+1]=ps->tab[l];
     8669    } // enddo
     8670    ps->tab[i]=t;
     8671    return;
     8672  } else {
     8673    if(i <= nb-1) goto ordered100;
     8674    ps->tab[i]=t;
     8675    return;
     8676  } // endif
     8677  return;
     8678}
     8679
    76118680// Utilities
    76128681
     
    79038972  G4cout <<"(particle " << index << G4endl;
    79048973  if(bl1->ind1[index] == 0) { // Nucleon
    7905     if(bl1->ind1[index] == 1) G4cout << "(quote proton)" << G4endl;
    7906     else if(bl1->ind1[index] == -1) G4cout << "(quote neutron)" << G4endl;
    7907     else G4cout << "(quote unidentified-nucleon)" << G4endl;
     8974    if(bl1->ind2[index] == 1) {
     8975      G4cout << "(quote proton)" << G4endl;
     8976    } else if(bl1->ind2[index] == -1) {
     8977      G4cout << "(quote neutron)" << G4endl;
     8978    } else {
     8979      G4cout << "(quote unidentified-nucleon-ind1-" << bl1->ind1[index] <<"-ind2-" << bl1->ind2[index] << G4endl;
     8980    }
    79088981  } else if(bl1->ind1[index] == 1) { // Delta
    7909     if(bl1->ind2[index] >= -2 && bl1->ind2[index] <= 2) G4cout << "(quote delta-"
    7910                                                                << bl1->ind2[index]
    7911                                                                << ")" << G4endl;
    7912     else G4cout << "(quote unidentified-delta)" << G4endl;
     8982    if(bl1->ind2[index] >= -2 && bl1->ind2[index] <= 2) {
     8983      G4cout << "(quote delta-"
     8984             << bl1->ind2[index]
     8985             << ")" << G4endl;
     8986    } else {
     8987      G4cout << "(quote unidentified-delta)" << G4endl;
     8988    }
    79138989  } else {
    79148990    G4cout <<"(quote unidentified-particle)" << G4endl;
     
    79389014  G4cout <<"(list ;; Particles at the beginning of the avatar" << G4endl;
    79399015  G4int ia = bl3->ia1 + bl3->ia2;
    7940   for(G4int i = 1; i != ia; ++i) { // do i=1,IA
     9016  for(G4int i = 1; i <= ia; ++i) { // do i=1,IA
    79419017    print_one_particle(i);
    79429018  }
  • trunk/source/processes/hadronic/models/incl/src/G4InclAblaCascadeInterface.cc

    r1228 r1340  
    2424// ********************************************************************
    2525//
    26 // $Id: G4InclAblaCascadeInterface.cc,v 1.13 2009/12/04 13:16:57 kaitanie Exp $
     26// $Id: G4InclAblaCascadeInterface.cc,v 1.16 2010/10/29 06:48:43 gunter Exp $
    2727// Translation of INCL4.2/ABLA V3
    2828// Pekka Kaitaniemi, HIP (translation)
     
    3434
    3535#include "G4InclAblaCascadeInterface.hh"
     36#include "G4FermiBreakUp.hh"
    3637#include "math.h"
    3738#include "G4GenericIon.hh"
     
    4647
    4748  varntp = new G4VarNtp();
    48   calincl = new G4Calincl();
     49  calincl = 0;
    4950  ws = new G4Ws();
    5051  mat = new G4Mat();
    5152  incl = new G4Incl(hazard, calincl, ws, mat, varntp);
     53  if(!getenv("G4INCLABLANOFERMIBREAKUP")) { // Use Fermi Break-up by default if it is NOT explicitly disabled
     54    incl->setUseFermiBreakUp(true);
     55  }
    5256
    5357  verboseLevel = 0;
     
    5862  delete hazard;
    5963  delete varntp;
    60   delete calincl;
    6164  delete ws;
    6265  delete mat;
     
    6871  G4int maxTries = 200;
    6972
    70   G4int particleI, n = 0;
    71 
     73  G4int particleI;
    7274  G4int bulletType = 0;
    7375
     
    8688  }
    8789
    88   // INCL4 needs the energy in units MeV
    89   G4double bulletE = aTrack.GetKineticEnergy() * MeV;
    90 
    9190#ifdef DEBUGINCL
    9291  G4cout <<"Bullet energy = " << bulletE / MeV << G4endl;
    9392#endif
    94 
    95   G4double targetA = theNucleus.GetN();
    96   G4double targetZ = theNucleus.GetZ();
    9793
    9894  G4double eKin;
     
    10096  G4DynamicParticle *cascadeParticle = 0;
    10197  G4ParticleDefinition *aParticleDefinition = 0;
     98 
     99  G4FermiBreakUp *fermiBreakUp = new G4FermiBreakUp();
     100  G4FragmentVector *theFermiBreakupResult = 0;
     101  G4ParticleTable *theTableOfParticles = G4ParticleTable::GetParticleTable();
    102102
    103103  // INCL assumes the projectile particle is going in the direction of
     
    113113  theResult.Clear(); // Make sure the output data structure is clean.
    114114
    115   // Map Geant4 particle types to corresponding INCL4 types.
    116   enum bulletParticleType {nucleus = 0, proton = 1, neutron = 2, pionPlus = 3, pionZero = 4,
    117                            pionMinus = 5, deuteron = 6, triton = 7, he3 = 8, he4 = 9};
    118 
    119   // Coding particles for use with INCL4 and ABLA
    120   if (aTrack.GetDefinition() ==    G4Proton::Proton()    ) bulletType = proton;
    121   if (aTrack.GetDefinition() ==   G4Neutron::Neutron()   ) bulletType = neutron;
    122   if (aTrack.GetDefinition() ==  G4PionPlus::PionPlus()  ) bulletType = pionPlus;
    123   if (aTrack.GetDefinition() == G4PionMinus::PionMinus() ) bulletType = pionMinus;
    124   if (aTrack.GetDefinition() ==  G4PionZero::PionZero()  ) bulletType = pionZero;
     115  calincl = new G4InclInput(aTrack, theNucleus, false);
     116  incl->setInput(calincl);
     117
     118  G4InclInput::printProjectileTargetInfo(aTrack, theNucleus);
     119  calincl->printInfo();
    125120
    126121#ifdef DEBUGINCL
     
    139134#endif
    140135
    141  for(int i = 0; i < 15; i++) {
    142    calincl->f[i] = 0.0; // Initialize INCL input data
    143  }
    144 
    145136  // Check wheter the input is acceptable.
    146   if((bulletType != 0) && ((targetA != 1) && (targetZ != 1))) {
    147     calincl->f[0] = targetA;    // Target mass number
    148     calincl->f[1] = targetZ;    // Charge number
    149     calincl->f[6] = bulletType; // Type
    150     calincl->f[2] = bulletE;    // Energy [MeV]
    151     calincl->f[5] = 1.0;        // Time scaling
    152     calincl->f[4] = 45.0;       // Nuclear potential
    153 
     137  if((calincl->bulletType() != 0) && ((calincl->targetA() != 1) && (calincl->targetZ() != 1))) {
    154138    ws->nosurf = -2;  // Nucleus surface, -2 = Woods-Saxon
    155139    ws->xfoisa = 8;
     
    160144
    161145    mat->nbmat = 1;
    162     mat->amat[0] = int(calincl->f[0]);
    163     mat->zmat[0] = int(calincl->f[1]);
     146    mat->amat[0] = int(calincl->targetA());
     147    mat->zmat[0] = int(calincl->targetZ());
    164148
    165149    incl->initIncl(true);
     
    170154        G4cout <<"G4InclAblaCascadeInterface: Try number = " << nTries << G4endl;
    171155      }
    172       incl->processEventInclAbla(eventNumber);
     156      incl->processEventInclAbla(calincl, eventNumber);
    173157
    174158      if(verboseLevel > 1) {
     
    181165       * Diagnostic output
    182166       */
    183       G4cout <<"G4InclAblaCascadeInterface: Bullet type: " << bulletType << G4endl;
    184       G4cout <<"G4Incl4AblaCascadeInterface: Bullet energy: " << bulletE << " MeV" << G4endl;
    185 
    186       G4cout <<"G4InclAblaCascadeInterface: Target A:  " << targetA << G4endl;
    187       G4cout <<"G4InclAblaCascadeInterface: Target Z:  " << targetZ << G4endl;
     167      G4cout <<"G4InclAblaCascadeInterface: Bullet type: " << calincl->bulletType() << G4endl;
     168      G4cout <<"G4Incl4AblaCascadeInterface: Bullet energy: " << calincl->bulletE() << " MeV" << G4endl;
     169
     170      G4cout <<"G4InclAblaCascadeInterface: Target A:  " << calincl->targetA() << G4endl;
     171      G4cout <<"G4InclAblaCascadeInterface: Target Z:  " << calincl->targetZ() << G4endl;
    188172
    189173      if(verboseLevel > 3) {
    190         diagdata <<"G4InclAblaCascadeInterface: Bullet type: " << bulletType << G4endl;
    191         diagdata <<"G4InclAblaCascadeInterface: Bullet energy: " << bulletE << " MeV" << G4endl;
     174        diagdata <<"G4InclAblaCascadeInterface: Bullet type: " << calincl->bulletType() << G4endl;
     175        diagdata <<"G4InclAblaCascadeInterface: Bullet energy: " << calincl->bulletE() << " MeV" << G4endl;
    192176       
    193         diagdata <<"G4InclAblaCascadeInterface: Target A:  " << targetA << G4endl;
    194         diagdata <<"G4InclAblaCascadeInterface: Target Z:  " << targetZ << G4endl;
    195       }
    196 
    197       for(particleI = 0; particleI < varntp->ntrack; particleI++) {
    198         G4cout << n                       << " " << calincl->f[6]             << " " << calincl->f[2] << " ";
    199         G4cout << varntp->massini         << " " << varntp->mzini             << " ";
    200         G4cout << varntp->exini           << " " << varntp->mulncasc          << " " << varntp->mulnevap          << " " << varntp->mulntot << " ";
    201         G4cout << varntp->bimpact         << " " << varntp->jremn             << " " << varntp->kfis              << " " << varntp->estfis << " ";
    202         G4cout << varntp->izfis           << " " << varntp->iafis             << " " << varntp->ntrack            << " " << varntp->itypcasc[particleI] << " ";
    203         G4cout << varntp->avv[particleI]  << " " << varntp->zvv[particleI]    << " " << varntp->enerj[particleI]  << " ";
    204         G4cout << varntp->plab[particleI] << " " << varntp->tetlab[particleI] << " " << varntp->philab[particleI] << G4endl;
    205         // For diagnostic output
    206         if(verboseLevel > 3) {
    207           diagdata << n                       << " " << calincl->f[6]             << " " << calincl->f[2] << " ";
    208           diagdata << varntp->massini         << " " << varntp->mzini             << " ";
    209           diagdata << varntp->exini           << " " << varntp->mulncasc          << " " << varntp->mulnevap          << " " << varntp->mulntot << " ";
    210           diagdata << varntp->bimpact         << " " << varntp->jremn             << " " << varntp->kfis              << " " << varntp->estfis << " ";
    211           diagdata << varntp->izfis           << " " << varntp->iafis             << " " << varntp->ntrack            << " ";
    212           diagdata                                                                       << varntp->itypcasc[particleI] << " ";
    213           diagdata << varntp->avv[particleI]  << " " << varntp->zvv[particleI]    << " " << varntp->enerj[particleI]  << " ";
    214           diagdata << varntp->plab[particleI] << " " << varntp->tetlab[particleI] << " " << varntp->philab[particleI] << G4endl;
    215         }
    216       }
     177        diagdata <<"G4InclAblaCascadeInterface: Target A:  " << calincl->targetA() << G4endl;
     178        diagdata <<"G4InclAblaCascadeInterface: Target Z:  " << calincl->targetZ() << G4endl;
     179      }
     180
    217181    }
    218182
     
    227191      theResult.SetStatusChange(stopAndKill);
    228192     
    229       if(bulletType == proton) {
    230         aParticleDefinition = G4Proton::ProtonDefinition();
    231       } else if(bulletType == neutron) {
    232         aParticleDefinition = G4Neutron::NeutronDefinition();
    233       } else if(bulletType == pionPlus) {
    234         aParticleDefinition = G4PionPlus::PionPlusDefinition();
    235       } else if(bulletType == pionZero) {
    236         aParticleDefinition = G4PionZero::PionZeroDefinition();
    237       } else if(bulletType == pionMinus) {
    238         aParticleDefinition = G4PionMinus::PionMinusDefinition();
    239       } else { // Projectile was not regognized
    240         aParticleDefinition = 0;
    241       }
     193      G4int bulletType = calincl->bulletType();
     194      aParticleDefinition = G4InclInput::getParticleDefinition(bulletType);
    242195
    243196      if(aParticleDefinition != 0) {
     
    328281      if((varntp->avv[particleI] > 1) && (varntp->zvv[particleI] >= 1)) { // Nucleus fragment
    329282        G4ParticleDefinition * aIonDef = 0;
    330         G4ParticleTable *theTableOfParticles = G4ParticleTable::GetParticleTable();
    331283
    332284        G4int A = G4int(varntp->avv[particleI]);
     
    404356        }
    405357      }
     358    }
     359
     360    // Finally do Fermi break-up if needed
     361    if(varntp->needsFermiBreakup) {
     362      //      baryonNumberBalanceInINCL -= varntp->massini;
     363      //      chargeNumberBalanceInINCL -= varntp->mzini;
     364      // Call Fermi Break-up
     365      G4double nuclearMass = G4NucleiProperties::GetNuclearMass(G4int(varntp->massini), G4int(varntp->mzini)) + varntp->exini * MeV;
     366      G4LorentzVector fragmentMomentum(varntp->pxrem * MeV, varntp->pyrem * MeV, varntp->pzrem * MeV,
     367                                       varntp->erecrem * MeV + nuclearMass);
     368      G4double momentumScaling = G4InclUtils::calculate4MomentumScaling(G4int(varntp->massini), G4int(varntp->mzini),
     369                                                                        varntp->exini,
     370                                                                        varntp->erecrem,
     371                                                                        varntp->pxrem,
     372                                                                        varntp->pyrem,
     373                                                                        varntp->pzrem);
     374      G4LorentzVector p4(momentumScaling * varntp->pxrem * MeV, momentumScaling * varntp->pyrem * MeV,
     375                         momentumScaling * varntp->pzrem * MeV,
     376                         varntp->erecrem + nuclearMass);
     377
     378      // For four-momentum, baryon number and charge conservation check:
     379      G4LorentzVector fourMomentumBalance = p4;
     380      G4int baryonNumberBalance = G4int(varntp->massini);
     381      G4int chargeBalance = G4int(varntp->mzini);
     382
     383      G4LorentzRotation toFragmentZ;
     384      toFragmentZ.rotateZ(-p4.theta());
     385      toFragmentZ.rotateY(-p4.phi());
     386      G4LorentzRotation toFragmentLab = toFragmentZ.inverse();
     387      //      p4 *= toFragmentZ;
     388
     389      G4LorentzVector p4rest = p4;
     390      //      p4rest.boost(-p4.boostVector());
     391      if(verboseLevel > 0) {
     392        G4cout <<"Cascade remnant nucleus:" << G4endl;
     393        G4cout <<"p4: " << G4endl;
     394        G4cout <<" px: " << p4.px() <<" py: " << p4.py() <<" pz: " << p4.pz() << G4endl;
     395        G4cout <<" E = " << p4.e() << G4endl;
     396
     397        G4cout <<"p4rest: " << G4endl;
     398        G4cout <<" px: " << p4rest.px() <<" py: " << p4rest.py() <<" pz: " << p4rest.pz() << G4endl;
     399        G4cout <<" E = " << p4rest.e() << G4endl;
     400      }
     401
     402      G4Fragment theCascadeRemnant(G4int(varntp->massini), G4int(varntp->mzini), p4rest);
     403      theFermiBreakupResult = fermiBreakUp->BreakItUp(theCascadeRemnant);
     404      if(theFermiBreakupResult != 0) {
     405      G4FragmentVector::iterator fragment;
     406      for(fragment = theFermiBreakupResult->begin(); fragment != theFermiBreakupResult->end(); fragment++) {
     407        G4ParticleDefinition *theFragmentDefinition = 0;
     408        if((*fragment)->GetA_asInt() == 1 && (*fragment)->GetZ_asInt() == 0) { // Neutron
     409          theFragmentDefinition = G4Neutron::NeutronDefinition();
     410        } else if ((*fragment)->GetA_asInt() == 1 && (*fragment)->GetZ_asInt() == 1) {
     411          theFragmentDefinition = G4Proton::ProtonDefinition();
     412        } else {
     413          theFragmentDefinition = theTableOfParticles->GetIon((*fragment)->GetZ_asInt(), (*fragment)->GetA_asInt(), (*fragment)->GetExcitationEnergy());
     414        }
     415
     416        if(theFragmentDefinition != 0) {
     417          G4DynamicParticle *theFragment = new G4DynamicParticle(theFragmentDefinition, (*fragment)->GetMomentum());
     418          G4LorentzVector labMomentum = theFragment->Get4Momentum();
     419          //      labMomentum.boost(p4.boostVector());
     420          //      labMomentum *= toFragmentLab;
     421          //      labMomentum *= toLabFrame;
     422          theFragment->Set4Momentum(labMomentum);
     423          fourMomentumBalance -= theFragment->Get4Momentum();
     424          baryonNumberBalance -= theFragmentDefinition->GetAtomicMass();
     425          chargeBalance -= theFragmentDefinition->GetAtomicNumber();
     426          if(verboseLevel > 0) {
     427            G4cout <<"Resulting fragment: " << G4endl;
     428            G4cout <<" kinetic energy = " << theFragment->GetKineticEnergy() / MeV << " MeV" << G4endl;
     429            G4cout <<" momentum = " << theFragment->GetMomentum().mag() / MeV << " MeV" << G4endl;
     430          }
     431          theResult.AddSecondary(theFragment);
     432        } else {
     433          G4cout <<"G4InclAblaCascadeInterface: Error. Fragment produced by Fermi break-up does not exist." << G4endl;
     434          G4cout <<"Resulting fragment: " << G4endl;
     435          G4cout <<" Z = " << (*fragment)->GetZ_asInt() << G4endl;
     436          G4cout <<" A = " << (*fragment)->GetA_asInt() << G4endl;
     437          G4cout <<" Excitation : " << (*fragment)->GetExcitationEnergy() / MeV << " MeV" << G4endl;
     438          G4cout <<" momentum = " << (*fragment)->GetMomentum().mag() / MeV << " MeV" << G4endl;
     439        }
     440      }
     441      if(std::abs(fourMomentumBalance.mag() / MeV) > 0.1 * MeV) {
     442        G4cout <<"Four-momentum balance after remnant nucleus Fermi break-up:" << G4endl;
     443        G4cout <<"Magnitude: " << fourMomentumBalance.mag() / MeV << " MeV" << G4endl;
     444        G4cout <<"Vector components (px, py, pz, E) = ("
     445               << fourMomentumBalance.px() << ", "
     446               << fourMomentumBalance.py() << ", "
     447               << fourMomentumBalance.pz() << ", "
     448               << fourMomentumBalance.e() << ")" << G4endl;
     449      }
     450      if(baryonNumberBalance != 0) {
     451        G4cout <<"Baryon number balance after remnant nucleus Fermi break-up: " << baryonNumberBalance << G4endl;
     452      }
     453      if(chargeBalance != 0) {
     454        G4cout <<"Charge balance after remnant nucleus Fermi break-up: " << chargeBalance << G4endl;
     455      }
     456    }
    406457    }
    407458
     
    449500    theResult.SetStatusChange(stopAndKill);
    450501
    451     G4ParticleTable *theTableOfParticles = G4ParticleTable::GetParticleTable();
    452502    cascadeParticle = new G4DynamicParticle(theTableOfParticles->FindParticle(aTrack.GetDefinition()), aTrack.Get4Momentum());
    453503
     
    472522    }
    473523
    474     if((targetA == 1) && (targetZ == 1)) { // Unsupported target
     524    if((calincl->targetA() == 1) && (calincl->targetZ() == 1)) { // Unsupported target
    475525      if(verboseLevel > 1) {
    476526        G4cout <<"Unsupported target: " << G4endl;
    477         G4cout <<"Target A: " << targetA << G4endl;
    478         G4cout <<"TargetZ: " << targetZ << G4endl;
     527        G4cout <<"Target A: " << calincl->targetA() << G4endl;
     528        G4cout <<"TargetZ: " << calincl->targetZ() << G4endl;
    479529      }
    480530      if(verboseLevel > 3) {
    481531        diagdata <<"Unsupported target: " << G4endl;
    482         diagdata <<"Target A: " << targetA << G4endl;
    483        diagdata <<"TargetZ: " << targetZ << G4endl;
    484       }
    485     }
    486 
    487     if(bulletE < 100) { // INCL does not support E < 100 MeV.
     532        diagdata <<"Target A: " << calincl->targetA() << G4endl;
     533        diagdata <<"TargetZ: " << calincl->targetZ() << G4endl;
     534      }
     535    }
     536
     537    if(calincl->bulletE() < 100) { // INCL does not support E < 100 MeV.
    488538      if(verboseLevel > 1) {
    489         G4cout <<"Unsupported bullet energy: " << bulletE << " MeV. (Lower limit is 100 MeV)." << G4endl;
     539        G4cout <<"Unsupported bullet energy: " << calincl->bulletE() << " MeV. (Lower limit is 100 MeV)." << G4endl;
    490540        G4cout <<"WARNING: Returning the original bullet with original energy back to Geant4." << G4endl;
    491541      }
    492542      if(verboseLevel > 3) {
    493         diagdata <<"Unsupported bullet energy: " << bulletE << " MeV. (Lower limit is 100 MeV)." << G4endl;
     543        diagdata <<"Unsupported bullet energy: " << calincl->bulletE() << " MeV. (Lower limit is 100 MeV)." << G4endl;
    494544      }
    495545    }
     
    500550  }
    501551
     552  delete fermiBreakUp;
     553  delete calincl;
     554  calincl = 0;
    502555  return &theResult;
    503556}
  • trunk/source/processes/hadronic/models/incl/src/G4InclAblaLightIonInterface.cc

    r1228 r1340  
    2424// ********************************************************************
    2525//
    26 // $Id: G4InclAblaLightIonInterface.cc,v 1.11 2009/12/04 13:16:57 kaitanie Exp $
     26// $Id: G4InclAblaLightIonInterface.cc,v 1.14 2010/10/29 06:48:43 gunter Exp $
    2727// Translation of INCL4.2/ABLA V3
    2828// Pekka Kaitaniemi, HIP (translation)
     
    3131// Aatos Heikkinen, HIP (project coordination)
    3232
     33#include <vector>
     34
    3335#include "G4InclAblaLightIonInterface.hh"
     36#include "G4FermiBreakUp.hh"
    3437#include "math.h"
    3538#include "G4GenericIon.hh"
     
    4447
    4548  varntp = new G4VarNtp();
    46   calincl = new G4Calincl();
     49  calincl = 0;
    4750  ws = new G4Ws();
    4851  mat = new G4Mat();
    4952  incl = new G4Incl(hazard, calincl, ws, mat, varntp);
    50 
     53  useProjectileSpectator = true;
     54  useFermiBreakup = true;
     55  incl->setUseProjectileSpectators(useProjectileSpectator);
     56  if(!getenv("G4INCLABLANOFERMIBREAKUP")) { // Use Fermi Break-up by default if it is NOT explicitly disabled
     57    incl->setUseFermiBreakUp(true);
     58    useFermiBreakup = true;
     59  }
    5160  verboseLevel = 0;
     61  if(getenv("G4INCLVERBOSE")) {
     62    verboseLevel = 1;
     63  }
    5264}
    5365
     
    6476G4HadFinalState* G4InclAblaLightIonInterface::ApplyYourself(const G4HadProjectile& aTrack, G4Nucleus& theNucleus)
    6577{
     78  //  const G4bool useFermiBreakup = false;
    6679  G4int maxTries = 200;
    6780
    68   G4int particleI, n = 0;
    69 
    70   G4int bulletType = 0;
    71 
    72   // Print diagnostic messages: 0 = silent, 1 and 2 = verbose
    73   verboseLevel = 0;
     81  G4int particleI;
     82
     83  G4int baryonNumberBalanceInINCL = 0;
     84  G4int chargeNumberBalanceInINCL = 0;
     85
     86  G4ParticleTable *theTableOfParticles = G4ParticleTable::GetParticleTable();
    7487
    7588  // Increase the event number:
    7689  eventNumber++;
    7790
     91  // Clean up the INCL input
     92  if(calincl != 0) {
     93    delete calincl;
     94    calincl = 0;
     95  }
     96
    7897  if (verboseLevel > 1) {
    7998    G4cout << " >>> G4InclAblaLightIonInterface::ApplyYourself called" << G4endl;
     
    84103  }
    85104
    86   // INCL4 needs the energy in units MeV
    87   G4double bulletE = aTrack.GetKineticEnergy() / MeV;
    88 
    89   G4double targetA = theNucleus.GetN();
    90   G4double targetZ = theNucleus.GetZ();
     105  if(verboseLevel > 1) {
     106    G4Calincl::printProjectileTargetInfo(aTrack, theNucleus);
     107  }
     108
     109  // Inverse kinematics for targets with Z = 1 and A = 1
     110  //  if(false) {
     111  G4LorentzRotation toBreit = aTrack.Get4Momentum().boostVector();
     112
     113  if(theNucleus.GetZ_asInt() == 1 && theNucleus.GetA_asInt() == 1 && G4Calincl::canUseInverseKinematics(aTrack, theNucleus)) {
     114    G4ParticleDefinition *oldTargetDef = theTableOfParticles->GetIon(theNucleus.GetA_asInt(), theNucleus.GetZ_asInt(), 0.0);
     115    const G4ParticleDefinition *oldProjectileDef = aTrack.GetDefinition();
     116
     117    G4int oldTargetA = oldTargetDef->GetAtomicMass();
     118    G4int newTargetA = oldProjectileDef->GetAtomicMass();
     119    G4int newTargetZ = oldProjectileDef->GetAtomicNumber();
     120
     121    if(newTargetA > 0 && newTargetZ > 0 && oldTargetDef != 0 && oldProjectileDef != 0) {
     122      G4Nucleus swappedTarget(oldProjectileDef->GetAtomicMass(), oldProjectileDef->GetAtomicNumber());
     123
     124      //      G4cout <<"Original projectile kinE = " << aTrack.GetKineticEnergy() / MeV << G4endl;
     125
     126      // We need the same energy/nucleon.
     127      G4double projectileE = ((aTrack.GetKineticEnergy() / MeV) / newTargetA) * oldTargetA * MeV;
     128
     129      //    G4cout <<"projectileE = " << projectileE << G4endl;
     130      G4DynamicParticle swappedProjectileParticle(oldTargetDef, G4ThreeVector(0.0, 0.0, 1.0), projectileE);
     131      const G4LorentzVector swapped4Momentum = (swappedProjectileParticle.Get4Momentum()*=toBreit);
     132      swappedProjectileParticle.Set4Momentum(swapped4Momentum);
     133      const G4HadProjectile swappedProjectile(swappedProjectileParticle);
     134      //  G4cout <<"New projectile kinE = " << swappedProjectile.GetKineticEnergy() / MeV << G4endl;
     135      calincl = new G4InclInput(swappedProjectile, swappedTarget, true);
     136    } else {
     137      G4cout <<"Badly defined target after swapping. Falling back to normal (non-swapped) mode." << G4endl;
     138      calincl = new G4InclInput(aTrack, theNucleus, false);
     139    }
     140  } else {
     141    calincl = new G4InclInput(aTrack, theNucleus, false);
     142  }
    91143
    92144  G4double eKin;
     
    105157  G4LorentzRotation toLabFrame = toZ.inverse();
    106158
     159  /*
     160  G4cout <<"Projectile theta = " << projectileMomentum.theta() << " phi = " << projectileMomentum.phi() << G4endl;
     161  G4cout <<"Projectile momentum "
     162         << "(px = " << projectileMomentum.px()
     163         << ", py = " << projectileMomentum.py()
     164         << ", pz = " << projectileMomentum.pz() << ")" << G4endl;
     165  G4cout << "Projectile energy = " << bulletE << " MeV" << G4endl;
     166  */
     167
     168  G4FermiBreakUp *fermiBreakUp = new G4FermiBreakUp();
     169  G4FragmentVector *theSpectatorFermiBreakupResult = 0;
     170  G4FragmentVector *theFermiBreakupResult = 0;
     171
    107172  theResult.Clear(); // Make sure the output data structure is clean.
     173
     174  std::vector<G4DynamicParticle*> result; // Temporary list for the results
    108175
    109176  // Map Geant4 particle types to corresponding INCL4 types.
    110177  enum bulletParticleType {nucleus = 0, proton = 1, neutron = 2, pionPlus = 3, pionZero = 4,
    111                            pionMinus = 5, deuteron = 6, triton = 7, he3 = 8, he4 = 9};
    112 
    113   // Coding particles for use with INCL4 and ABLA
    114   if (aTrack.GetDefinition() == G4Deuteron::Deuteron()   ) bulletType = deuteron;
    115   if (aTrack.GetDefinition() == G4Triton::Triton()       ) bulletType = triton;
    116   if (aTrack.GetDefinition() == G4He3::He3()             ) bulletType = he3;
    117   if (aTrack.GetDefinition() == G4Alpha::Alpha()         ) bulletType = he4;
    118 
    119   for(int i = 0; i < 15; i++) {
    120     calincl->f[i] = 0.0; // Initialize INCL input data
     178                           pionMinus = 5, deuteron = 6, triton = 7, he3 = 8, he4 = 9,
     179                           c12 = -12}; // Carbon beam support.
     180
     181  G4int bulletType = calincl->bulletType();
     182  chargeNumberBalanceInINCL = calincl->targetZ();
     183  baryonNumberBalanceInINCL = calincl->targetA();
     184
     185  //  G4cout <<"Type of the projectile (INCL projectile code): " << bulletType << G4endl;
     186
     187  if(bulletType == proton) {
     188    chargeNumberBalanceInINCL += 1;
     189    baryonNumberBalanceInINCL += 1;
     190  } else if(bulletType == neutron) {
     191    baryonNumberBalanceInINCL += 1;
     192  } else if(bulletType == pionPlus) { //Note: positive pion doesn't contribute to the baryon and charge number counters
     193    chargeNumberBalanceInINCL += 1;
     194  } else if(bulletType == pionMinus) {
     195    chargeNumberBalanceInINCL -= 1;
     196  } else if(bulletType == deuteron) {
     197    chargeNumberBalanceInINCL += 1;
     198    baryonNumberBalanceInINCL += 2;
     199  } else if(bulletType == triton) {
     200    chargeNumberBalanceInINCL += 1;
     201    baryonNumberBalanceInINCL += 3;
     202  } else if(bulletType == he3) {
     203    chargeNumberBalanceInINCL += 2;
     204    baryonNumberBalanceInINCL += 3;
     205  } else if(bulletType == he4) {
     206    chargeNumberBalanceInINCL += 2;
     207    baryonNumberBalanceInINCL += 4;
     208  } if(bulletType == c12) {
     209    chargeNumberBalanceInINCL += 6;
     210    baryonNumberBalanceInINCL += 12;
     211  } if(bulletType == -666) {
     212    chargeNumberBalanceInINCL += calincl->extendedProjectileZ();
     213    baryonNumberBalanceInINCL += calincl->extendedProjectileA();
    121214  }
    122215
    123216  // Check wheter the input is acceptable.
    124   if((bulletType != 0) && ((targetA != 1) && (targetZ != 1))) {
    125     calincl->f[0] = targetA;    // Target mass number
    126     calincl->f[1] = targetZ;    // Charge number
    127     calincl->f[6] = bulletType; // Type
    128     calincl->f[2] = bulletE;    // Energy [MeV]
    129     calincl->f[5] = 1.0;        // Time scaling
    130     calincl->f[4] = 45.0;       // Nuclear potential
    131 
     217  if((bulletType != 0) && ((calincl->targetA() != 1) && (calincl->targetZ() != 1))) {
    132218    ws->nosurf = -2;  // Nucleus surface, -2 = Woods-Saxon
    133219    ws->xfoisa = 8;
     
    138224
    139225    mat->nbmat = 1;
    140     mat->amat[0] = int(calincl->f[0]);
    141     mat->zmat[0] = int(calincl->f[1]);
    142 
     226    mat->amat[0] = int(calincl->targetA());
     227    mat->zmat[0] = int(calincl->targetA());
     228
     229    incl->setInput(calincl);
    143230    incl->initIncl(true);
    144231
     
    148235        G4cout <<"G4InclAblaLightIonInterface: Try number = " << nTries << G4endl;
    149236      }
    150       incl->processEventInclAbla(eventNumber);
     237      incl->processEventInclAbla(calincl, eventNumber);
    151238
    152239      if(verboseLevel > 1) {
     
    159246       * Diagnostic output
    160247       */
    161       G4cout <<"G4InclAblaLightIonInterface: Bullet type: " << bulletType << G4endl;
    162       G4cout <<"G4Incl4AblaCascadeInterface: Bullet energy: " << bulletE << " MeV" << G4endl;
    163 
    164       G4cout <<"G4InclAblaLightIonInterface: Target A:  " << targetA << G4endl;
    165       G4cout <<"G4InclAblaLightIonInterface: Target Z:  " << targetZ << G4endl;
     248      G4cout <<"G4InclAblaLightIonInterface: Bullet type: " << calincl->bulletType() << G4endl;
     249      G4cout <<"G4Incl4AblaCascadeInterface: Bullet energy: " << calincl->bulletE() << " MeV" << G4endl;
     250      if(bulletType == -666) {
     251        G4cout <<"   Extended projectile: A = " << calincl->extendedProjectileA()
     252               <<" Z = " << calincl->extendedProjectileZ() << G4endl;
     253      }
     254
     255      G4cout <<"G4InclAblaLightIonInterface: Target A:  " << calincl->targetA() << G4endl;
     256      G4cout <<"G4InclAblaLightIonInterface: Target Z:  " << calincl->targetZ() << G4endl;
    166257
    167258      if(verboseLevel > 3) {
    168         diagdata <<"G4InclAblaLightIonInterface: Bullet type: " << bulletType << G4endl;
    169         diagdata <<"G4InclAblaLightIonInterface: Bullet energy: " << bulletE << " MeV" << G4endl;
     259        diagdata <<"G4InclAblaLightIonInterface: Bullet type: " << calincl->bulletType() << G4endl;
     260        diagdata <<"G4InclAblaLightIonInterface: Bullet energy: " << calincl->bulletE() << " MeV" << G4endl;
    170261       
    171         diagdata <<"G4InclAblaLightIonInterface: Target A:  " << targetA << G4endl;
    172         diagdata <<"G4InclAblaLightIonInterface: Target Z:  " << targetZ << G4endl;
    173       }
    174 
    175       for(particleI = 0; particleI < varntp->ntrack; particleI++) {
    176         G4cout << n                       << " " << calincl->f[6]             << " " << calincl->f[2] << " ";
    177         G4cout << varntp->massini         << " " << varntp->mzini             << " ";
    178         G4cout << varntp->exini           << " " << varntp->mulncasc          << " " << varntp->mulnevap          << " " << varntp->mulntot << " ";
    179         G4cout << varntp->bimpact         << " " << varntp->jremn             << " " << varntp->kfis              << " " << varntp->estfis << " ";
    180         G4cout << varntp->izfis           << " " << varntp->iafis             << " " << varntp->ntrack            << " " << varntp->itypcasc[particleI] << " ";
    181         G4cout << varntp->avv[particleI]  << " " << varntp->zvv[particleI]    << " " << varntp->enerj[particleI]  << " ";
    182         G4cout << varntp->plab[particleI] << " " << varntp->tetlab[particleI] << " " << varntp->philab[particleI] << G4endl;
    183         // For diagnostic output
    184         if(verboseLevel > 3) {
    185           diagdata << n                       << " " << calincl->f[6]             << " " << calincl->f[2] << " ";
    186           diagdata << varntp->massini         << " " << varntp->mzini             << " ";
    187           diagdata << varntp->exini           << " " << varntp->mulncasc          << " " << varntp->mulnevap          << " " << varntp->mulntot << " ";
    188           diagdata << varntp->bimpact         << " " << varntp->jremn             << " " << varntp->kfis              << " " << varntp->estfis << " ";
    189           diagdata << varntp->izfis           << " " << varntp->iafis             << " " << varntp->ntrack            << " ";
    190           diagdata                                                                       << varntp->itypcasc[particleI] << " ";
    191           diagdata << varntp->avv[particleI]  << " " << varntp->zvv[particleI]    << " " << varntp->enerj[particleI]  << " ";
    192           diagdata << varntp->plab[particleI] << " " << varntp->tetlab[particleI] << " " << varntp->philab[particleI] << G4endl;
    193         }
     262        diagdata <<"G4InclAblaLightIonInterface: Target A:  " << calincl->targetA() << G4endl;
     263        diagdata <<"G4InclAblaLightIonInterface: Target Z:  " << calincl->targetZ() << G4endl;
    194264      }
    195265    }
     
    231301        cascadeParticle->SetDefinition(aParticleDefinition);
    232302        cascadeParticle->Set4Momentum(aTrack.Get4Momentum());
    233         theResult.AddSecondary(cascadeParticle);
     303        result.push_back(cascadeParticle);
    234304      }
    235305    }
     
    239309    theResult.SetStatusChange(stopAndKill);
    240310   
    241     for(particleI = 0; particleI < varntp->ntrack; particleI++) { // Loop through the INCL4+ABLA output.
     311    for(particleI = 0; particleI <= varntp->ntrack; particleI++) { // Loop through the INCL4+ABLA output.
    242312      // Get energy/momentum and construct momentum vector in INCL4 coordinates.
     313      //      if(varntp->itypcasc[particleI] == -1) continue; // Avoid nucleons that are part of the spectator
     314      if(varntp->avv[particleI] == 0 && varntp->zvv[particleI] == 0) continue;
    243315      momx = varntp->plab[particleI]*std::sin(varntp->tetlab[particleI]*CLHEP::pi/180.0)*std::cos(varntp->philab[particleI]*CLHEP::pi/180.0)*MeV;
    244316      momy = varntp->plab[particleI]*std::sin(varntp->tetlab[particleI]*CLHEP::pi/180.0)*std::sin(varntp->philab[particleI]*CLHEP::pi/180.0)*MeV;
     
    262334          new G4DynamicParticle(G4Proton::ProtonDefinition(), momDirection, eKin);
    263335        particleIdentified++;
     336        baryonNumberBalanceInINCL -= 1;
     337        chargeNumberBalanceInINCL -= 1;
    264338      }
    265339
     
    268342          new G4DynamicParticle(G4Neutron::NeutronDefinition(), momDirection, eKin);
    269343        particleIdentified++;
     344        baryonNumberBalanceInINCL -= 1;
    270345      }
    271346
     
    274349          new G4DynamicParticle(G4PionPlus::PionPlusDefinition(), momDirection, eKin);
    275350        particleIdentified++;
     351        chargeNumberBalanceInINCL -= 1;
    276352      }
    277353
     
    280356          new G4DynamicParticle(G4PionZero::PionZeroDefinition(), momDirection, eKin);
    281357        particleIdentified++;
     358        chargeNumberBalanceInINCL -= 0;
    282359      }
    283360
     
    286363          new G4DynamicParticle(G4PionMinus::PionMinusDefinition(), momDirection, eKin);
    287364        particleIdentified++;
     365        chargeNumberBalanceInINCL -= -1;
    288366      }
    289367
    290368      if((varntp->avv[particleI] > 1) && (varntp->zvv[particleI] >= 1)) { // Nucleus fragment
    291         G4ParticleDefinition * aIonDef = 0;
    292         G4ParticleTable *theTableOfParticles = G4ParticleTable::GetParticleTable();
     369        G4ParticleDefinition * aIonDef = 0;
    293370
    294371        G4int A = G4int(varntp->avv[particleI]);
     
    313390            new G4DynamicParticle(aIonDef, momDirection, eKin);
    314391          particleIdentified++;
     392          baryonNumberBalanceInINCL -= A;
     393          chargeNumberBalanceInINCL -= Z;
    315394        }
    316395      }
    317396       
    318397      if(particleIdentified == 1) { // Particle identified properly.
    319         cascadeParticle->Set4Momentum(cascadeParticle->Get4Momentum()*=toLabFrame);
    320         theResult.AddSecondary(cascadeParticle); // Put data into G4HadFinalState.
     398        cascadeParticle->Set4Momentum(cascadeParticle->Get4Momentum()*=toLabFrame);
     399        result.push_back(cascadeParticle);
    321400      }
    322401      else { // Particle identification failed.
     
    332411    }
    333412
     413    // Spectator nucleus Fermi break-up
     414    if(useFermiBreakup && useProjectileSpectator && varntp->masp > 1) {
     415      baryonNumberBalanceInINCL -= G4int(varntp->masp);
     416      G4double nuclearMass = G4NucleiProperties::GetNuclearMass(G4int(varntp->masp), G4int(varntp->mzsp)) + varntp->exsp * MeV;
     417      // Use momentum scaling to compensate for different masses in G4 and INCL:
     418      G4double momentumScaling = G4InclUtils::calculate4MomentumScaling(G4int(varntp->masp),
     419                                                                        G4int(varntp->mzsp),
     420                                                                        varntp->exsp,
     421                                                                        varntp->spectatorT,
     422                                                                        varntp->spectatorP1,
     423                                                                        varntp->spectatorP2,
     424                                                                        varntp->spectatorP3);
     425      G4LorentzVector p4(momentumScaling * varntp->spectatorP1 * MeV, momentumScaling * varntp->spectatorP2 * MeV,
     426                         momentumScaling * varntp->spectatorP3 * MeV,
     427                         varntp->spectatorT * MeV + nuclearMass);
     428      // Four-momentum, baryon number and charge balance:
     429      G4LorentzVector fourMomentumBalance = p4;
     430      G4int baryonNumberBalance = G4int(varntp->masp);
     431      chargeNumberBalanceInINCL -= G4int(varntp->mzsp);
     432      G4int chargeBalance = G4int(varntp->mzsp);
     433
     434      G4LorentzRotation toFragmentZ;
     435      // Assume that Fermi breakup uses Z as the direction of the projectile
     436      toFragmentZ.rotateZ(-p4.theta());
     437      toFragmentZ.rotateY(-p4.phi());
     438      G4LorentzRotation toFragmentLab = toFragmentZ.inverse();
     439      //      p4 *= toFragmentZ;
     440     
     441      G4LorentzVector p4rest = p4;
     442      //      p4rest.boost(-p4.boostVector());
     443      if(verboseLevel > 0) {
     444        G4cout <<"Spectator nucleus:" << G4endl;
     445        G4cout <<"p4: " << G4endl;
     446        G4cout <<" px: " << p4.px() <<" py: " << p4.py() <<" pz: " << p4.pz() << G4endl;
     447        G4cout <<" E = " << p4.e() << G4endl;
     448        G4cout <<"p4rest: " << G4endl;
     449        G4cout <<" px: " << p4rest.px() <<" py: " << p4rest.py() <<" pz: " << p4rest.pz() << G4endl;
     450        G4cout <<" E = " << p4rest.e() << G4endl;
     451      }
     452      G4Fragment theSpectatorNucleus(G4int(varntp->masp), G4int(varntp->mzsp), p4rest);
     453      theSpectatorFermiBreakupResult = fermiBreakUp->BreakItUp(theSpectatorNucleus);
     454      if(theSpectatorFermiBreakupResult != 0) {
     455      G4FragmentVector::iterator fragment;
     456      for(fragment = theSpectatorFermiBreakupResult->begin(); fragment != theSpectatorFermiBreakupResult->end(); fragment++) {
     457        G4ParticleDefinition *theFragmentDefinition = 0;
     458        if((*fragment)->GetA_asInt() == 1 && (*fragment)->GetZ_asInt() == 0) { // Neutron
     459          theFragmentDefinition = G4Neutron::NeutronDefinition();
     460        } else if ((*fragment)->GetA_asInt() == 1 && (*fragment)->GetZ_asInt() == 1) {
     461          theFragmentDefinition = G4Proton::ProtonDefinition();
     462        } else {
     463          theFragmentDefinition = theTableOfParticles->GetIon((*fragment)->GetZ_asInt(), (*fragment)->GetA_asInt(), (*fragment)->GetExcitationEnergy());
     464        }
     465        if(theFragmentDefinition != 0) {
     466          G4DynamicParticle *theFragment = new G4DynamicParticle(theFragmentDefinition, (*fragment)->GetMomentum());
     467          G4LorentzVector labMomentum = theFragment->Get4Momentum();
     468          //      labMomentum.boost(p4.boostVector());
     469          //      labMomentum *= toFragmentLab;
     470          //      labMomentum *= toLabFrame;
     471          theFragment->Set4Momentum(labMomentum);
     472          fourMomentumBalance -= theFragment->Get4Momentum();
     473          baryonNumberBalance -= theFragmentDefinition->GetAtomicMass();
     474          chargeBalance -= theFragmentDefinition->GetAtomicNumber();
     475          if(verboseLevel > 0) {
     476            G4cout <<"Resulting fragment: " << G4endl;
     477            G4cout <<" kinetic energy = " << theFragment->GetKineticEnergy() / MeV << " MeV" << G4endl;
     478            G4cout <<" momentum = " << theFragment->GetMomentum().mag() / MeV << " MeV" << G4endl;
     479          }
     480          result.push_back(theFragment);
     481        } else {
     482          G4cout <<"G4InclAblaCascadeInterface: Error. Fragment produced by Fermi break-up does not exist."
     483                 << G4endl;
     484          G4cout <<"Resulting fragment: " << G4endl;
     485          G4cout <<" Z = " << (*fragment)->GetZ_asInt() << G4endl;
     486          G4cout <<" A = " << (*fragment)->GetA_asInt() << G4endl;
     487          G4cout <<" Excitation : " << (*fragment)->GetExcitationEnergy() / MeV << " MeV" << G4endl;
     488          G4cout <<" momentum = " << (*fragment)->GetMomentum().mag() / MeV << " MeV" << G4endl;
     489        }
     490      }
     491      if(std::abs(fourMomentumBalance.mag() / MeV) > 0.1 * MeV) {
     492        G4cout <<"Four-momentum balance after spectator nucleus Fermi break-up:" << G4endl;
     493        G4cout <<"Magnitude: " << fourMomentumBalance.mag() / MeV << " MeV" << G4endl;
     494        G4cout <<"Vector components (px, py, pz, E) = ("
     495               << fourMomentumBalance.px() << ", "
     496               << fourMomentumBalance.py() << ", "
     497               << fourMomentumBalance.pz() << ", "
     498               << fourMomentumBalance.e() << ")" << G4endl;
     499      }
     500      if(baryonNumberBalance != 0) {
     501        G4cout <<"Event " << eventNumber << ": Baryon number balance after spectator nucleus Fermi break-up: " << baryonNumberBalance << G4endl;
     502      }
     503      if(chargeBalance != 0) {
     504        G4cout <<"Event " << eventNumber <<": Charge balance after spectator nucleus Fermi break-up: " << chargeBalance << G4endl;
     505      }
     506    }
     507  }
     508
     509    // Finally do Fermi break-up if needed
     510    if(varntp->needsFermiBreakup && varntp->massini > 0) {
     511      baryonNumberBalanceInINCL -= G4int(varntp->massini);
     512      chargeNumberBalanceInINCL -= G4int(varntp->mzini);
     513      // Call Fermi Break-up
     514      G4double nuclearMass = G4NucleiProperties::GetNuclearMass(G4int(varntp->massini), G4int(varntp->mzini)) + varntp->exini * MeV;
     515      G4LorentzVector fragmentMomentum(varntp->pxrem * MeV, varntp->pyrem * MeV, varntp->pzrem * MeV,
     516                                       varntp->erecrem * MeV + nuclearMass);
     517      G4double momentumScaling = G4InclUtils::calculate4MomentumScaling(G4int(varntp->massini), G4int(varntp->mzini),
     518                                                                        varntp->exini,
     519                                                                        varntp->erecrem,
     520                                                                        varntp->pxrem,
     521                                                                        varntp->pyrem,
     522                                                                        varntp->pzrem);
     523      G4LorentzVector p4(momentumScaling * varntp->pxrem * MeV, momentumScaling * varntp->pyrem * MeV,
     524                         momentumScaling * varntp->pzrem * MeV,
     525                         varntp->erecrem + nuclearMass);
     526
     527      // For four-momentum, baryon number and charge conservation check:
     528      G4LorentzVector fourMomentumBalance = p4;
     529      G4int baryonNumberBalance = G4int(varntp->massini);
     530      G4int chargeBalance = G4int(varntp->mzini);
     531
     532      G4LorentzRotation toFragmentZ;
     533      toFragmentZ.rotateZ(-p4.theta());
     534      toFragmentZ.rotateY(-p4.phi());
     535      G4LorentzRotation toFragmentLab = toFragmentZ.inverse();
     536      //      p4 *= toFragmentZ;
     537
     538      G4LorentzVector p4rest = p4;
     539      //      p4rest.boost(-p4.boostVector());
     540      if(verboseLevel > 0) {
     541        G4cout <<"Cascade remnant nucleus:" << G4endl;
     542        G4cout <<"p4: " << G4endl;
     543        G4cout <<" px: " << p4.px() <<" py: " << p4.py() <<" pz: " << p4.pz() << G4endl;
     544        G4cout <<" E = " << p4.e() << G4endl;
     545
     546        G4cout <<"p4rest: " << G4endl;
     547        G4cout <<" px: " << p4rest.px() <<" py: " << p4rest.py() <<" pz: " << p4rest.pz() << G4endl;
     548        G4cout <<" E = " << p4rest.e() << G4endl;
     549      }
     550
     551      G4Fragment theCascadeRemnant(G4int(varntp->massini), G4int(varntp->mzini), p4rest);
     552      theFermiBreakupResult = fermiBreakUp->BreakItUp(theCascadeRemnant);
     553      if(theFermiBreakupResult != 0) {
     554      G4FragmentVector::iterator fragment;
     555      for(fragment = theFermiBreakupResult->begin(); fragment != theFermiBreakupResult->end(); fragment++) {
     556        G4ParticleDefinition *theFragmentDefinition = 0;
     557        if((*fragment)->GetA_asInt() == 1 && (*fragment)->GetZ_asInt() == 0) { // Neutron
     558          theFragmentDefinition = G4Neutron::NeutronDefinition();
     559        } else if ((*fragment)->GetA_asInt() == 1 && (*fragment)->GetZ_asInt() == 1) {
     560          theFragmentDefinition = G4Proton::ProtonDefinition();
     561        } else {
     562          theFragmentDefinition = theTableOfParticles->GetIon((*fragment)->GetZ_asInt(), (*fragment)->GetA_asInt(), (*fragment)->GetExcitationEnergy());
     563        }
     564
     565        if(theFragmentDefinition != 0) {
     566          G4DynamicParticle *theFragment = new G4DynamicParticle(theFragmentDefinition, (*fragment)->GetMomentum());
     567          G4LorentzVector labMomentum = theFragment->Get4Momentum();
     568          //      labMomentum.boost(p4.boostVector());
     569          //      labMomentum *= toFragmentLab;
     570          //      labMomentum *= toLabFrame;
     571          theFragment->Set4Momentum(labMomentum);
     572          fourMomentumBalance -= theFragment->Get4Momentum();
     573          baryonNumberBalance -= theFragmentDefinition->GetAtomicMass();
     574          chargeBalance -= theFragmentDefinition->GetAtomicNumber();
     575          if(verboseLevel > 0) {
     576            G4cout <<"Resulting fragment: " << G4endl;
     577            G4cout <<" kinetic energy = " << theFragment->GetKineticEnergy() / MeV << " MeV" << G4endl;
     578            G4cout <<" momentum = " << theFragment->GetMomentum().mag() / MeV << " MeV" << G4endl;
     579          }
     580          result.push_back(theFragment);
     581        } else {
     582          G4cout <<"G4InclAblaCascadeInterface: Error. Fragment produced by Fermi break-up does not exist." << G4endl;
     583          G4cout <<"Resulting fragment: " << G4endl;
     584          G4cout <<" Z = " << (*fragment)->GetZ_asInt() << G4endl;
     585          G4cout <<" A = " << (*fragment)->GetA_asInt() << G4endl;
     586          G4cout <<" Excitation : " << (*fragment)->GetExcitationEnergy() / MeV << " MeV" << G4endl;
     587          G4cout <<" momentum = " << (*fragment)->GetMomentum().mag() / MeV << " MeV" << G4endl;
     588        }
     589      }
     590      if(std::abs(fourMomentumBalance.mag() / MeV) > 0.1 * MeV) {
     591        G4cout <<"Four-momentum balance after remnant nucleus Fermi break-up:" << G4endl;
     592        G4cout <<"Magnitude: " << fourMomentumBalance.mag() / MeV << " MeV" << G4endl;
     593        G4cout <<"Vector components (px, py, pz, E) = ("
     594               << fourMomentumBalance.px() << ", "
     595               << fourMomentumBalance.py() << ", "
     596               << fourMomentumBalance.pz() << ", "
     597               << fourMomentumBalance.e() << ")" << G4endl;
     598      }
     599      if(baryonNumberBalance != 0) {
     600        G4cout <<"Baryon number balance after remnant nucleus Fermi break-up: " << baryonNumberBalance << G4endl;
     601      }
     602      if(chargeBalance != 0) {
     603        G4cout <<"Charge balance after remnant nucleus Fermi break-up: " << chargeBalance << G4endl;
     604      }
     605    }
     606    }
     607
    334608    varntp->ntrack = 0; // Clean up the number of generated particles in the event.
     609
     610    if(baryonNumberBalanceInINCL != 0 && verboseLevel > 1) {
     611      G4cout <<"Event " << eventNumber <<": G4InclAblaLightIonInterface: Baryon number conservation problem in INCL detected!" << G4endl;
     612      G4cout <<"Baryon number balance: " << baryonNumberBalanceInINCL << G4endl;
     613      if(baryonNumberBalanceInINCL < 0) {
     614        G4cout <<"Event " << eventNumber <<": Too many outcoming baryons!" << G4endl;
     615      } else if(baryonNumberBalanceInINCL > 0) {
     616        G4cout <<"Event " << eventNumber <<": Too few outcoming baryons!" << G4endl;
     617      }
     618    }
     619
     620    if(chargeNumberBalanceInINCL != 0 && verboseLevel > 1) {
     621      G4cout <<"Event " << eventNumber <<": G4InclAblaLightIonInterface: Charge number conservation problem in INCL detected!" << G4endl;
     622      G4cout <<"Event " << eventNumber <<": Charge number balance: " << chargeNumberBalanceInINCL << G4endl;
     623    }
    335624  }
    336625  /**
     
    344633    cascadeParticle = new G4DynamicParticle(theTableOfParticles->FindParticle(aTrack.GetDefinition()), aTrack.Get4Momentum());
    345634
    346     theResult.AddSecondary(cascadeParticle);
     635    result.push_back(cascadeParticle);
    347636
    348637    if(verboseLevel > 1) {
     
    364653    }
    365654
    366     if((targetA == 1) && (targetZ == 1)) { // Unsupported target
     655    if((calincl->targetA() == 1) && (calincl->targetZ() == 1)) { // Unsupported target
    367656      if(verboseLevel > 1) {
    368657        G4cout <<"Unsupported target: " << G4endl;
    369         G4cout <<"Target A: " << targetA << G4endl;
    370         G4cout <<"TargetZ: " << targetZ << G4endl;
     658        G4cout <<"Target A: " << calincl->targetA() << G4endl;
     659        G4cout <<"TargetZ: " << calincl->targetZ() << G4endl;
    371660      }
    372661      if(verboseLevel > 3) {
    373662        diagdata <<"Unsupported target: " << G4endl;
    374         diagdata <<"Target A: " << targetA << G4endl;
    375        diagdata <<"TargetZ: " << targetZ << G4endl;
    376       }
    377     }
    378 
    379     if(bulletE < 100) { // INCL does not support E < 100 MeV.
     663        diagdata <<"Target A: " << calincl->targetA() << G4endl;
     664        diagdata <<"TargetZ: " << calincl->targetZ() << G4endl;
     665      }
     666    }
     667
     668    if(calincl->bulletE() < 100) { // INCL does not support E < 100 MeV.
    380669      if(verboseLevel > 1) {
    381         G4cout <<"Unsupported bullet energy: " << bulletE << " MeV. (Lower limit is 100 MeV)." << G4endl;
     670        G4cout <<"Unsupported bullet energy: " << calincl->bulletE() << " MeV. (Lower limit is 100 MeV)." << G4endl;
    382671        G4cout <<"WARNING: Returning the original bullet with original energy back to Geant4." << G4endl;
    383672      }
    384673      if(verboseLevel > 3) {
    385         diagdata <<"Unsupported bullet energy: " << bulletE << " MeV. (Lower limit is 100 MeV)." << G4endl;
     674        diagdata <<"Unsupported bullet energy: " << calincl->bulletE() << " MeV. (Lower limit is 100 MeV)." << G4endl;
    386675      }
    387676    }
     
    392681  }
    393682
     683  // Finally copy the accumulated secondaries into the result collection:
     684  G4ThreeVector boostVector = aTrack.Get4Momentum().boostVector();
     685  G4LorentzRotation boostBack = toBreit.inverse();
     686
     687  for(std::vector<G4DynamicParticle*>::iterator i = result.begin(); i != result.end(); ++i) {
     688    // If the calculation was performed in inverse kinematics we have to
     689    // convert the result back...
     690    if(calincl->isInverseKinematics()) {
     691      G4LorentzVector mom = (*i)->Get4Momentum();
     692      mom.setPz(-1.0 * mom.pz()); // Reverse the z-component of the momentum vector
     693      mom *= boostBack;
     694      (*i)->Set4Momentum(mom);
     695    }
     696    theResult.AddSecondary((*i));
     697  }
     698
     699  delete calincl;
     700  calincl = 0;
    394701  return &theResult;
    395702}
  • trunk/source/processes/hadronic/models/incl/src/G4InclCascadeInterface.cc

    r819 r1340  
    2424// ********************************************************************
    2525//
    26 // $Id: G4InclCascadeInterface.cc,v 1.10 2007/12/10 16:32:02 gunter Exp $
     26// $Id: G4InclCascadeInterface.cc,v 1.12 2010/10/26 02:47:59 kaitanie Exp $
    2727// Translation of INCL4.2/ABLA V3
    2828// Pekka Kaitaniemi, HIP (translation)
     
    4545
    4646  varntp = new G4VarNtp();
    47   calincl = new G4Calincl();
     47  inclInput = 0;
    4848  ws = new G4Ws();
    4949  mat = new G4Mat();
    50   incl = new G4Incl(hazard, calincl, ws, mat, varntp);
     50  incl = new G4Incl(hazard, inclInput, ws, mat, varntp);
    5151
    5252  verboseLevel = 0;
     
    5757  delete hazard;
    5858  delete varntp;
    59   delete calincl;
     59  delete inclInput;
    6060  delete ws;
    6161  delete mat;
     
    6767  G4int maxTries = 200;
    6868
    69   G4int particleI, n = 0;
    70 
    71   G4int bulletType = 0;
     69  G4int particleI;
    7270
    7371  // Print diagnostic messages: 0 = silent, 1 and 2 = verbose
     
    8583  }
    8684
    87   // INCL4 needs the energy in units MeV
    88   G4double bulletE = aTrack.GetKineticEnergy() * MeV;
    89 
    9085#ifdef DEBUGINCL
    9186  G4cout <<"Bullet energy = " << bulletE / MeV << G4endl;
    9287#endif
    93 
    94   G4double targetA = theNucleus.GetN();
    95   G4double targetZ = theNucleus.GetZ();
    9688
    9789  G4double eKin;
     
    110102  G4LorentzRotation toLabFrame = toZ.inverse();
    111103
     104  inclInput = new G4InclInput(aTrack, theNucleus, false);
     105
    112106  theResult.Clear(); // Make sure the output data structure is clean.
    113 
    114   // Map Geant4 particle types to corresponding INCL4 types.
    115   enum bulletParticleType {nucleus = 0, proton = 1, neutron = 2, pionPlus = 3, pionZero = 4,
    116                            pionMinus = 5, deuteron = 6, triton = 7, he3 = 8, he4 = 9};
    117 
    118   // Coding particles for use with INCL4 and ABLA
    119   if (aTrack.GetDefinition() ==    G4Proton::Proton()    ) bulletType = proton;
    120   if (aTrack.GetDefinition() ==   G4Neutron::Neutron()   ) bulletType = neutron;
    121   if (aTrack.GetDefinition() ==  G4PionPlus::PionPlus()  ) bulletType = pionPlus;
    122   if (aTrack.GetDefinition() == G4PionMinus::PionMinus() ) bulletType = pionMinus;
    123   if (aTrack.GetDefinition() ==  G4PionZero::PionZero()  ) bulletType = pionZero;
    124107
    125108#ifdef DEBUGINCL
     
    137120#endif
    138121
    139   for(int i = 0; i < 15; i++) {
    140     calincl->f[i] = 0.0; // Initialize INCL input data
    141   }
    142 
    143122  // Check wheter the input is acceptable.
    144   if((bulletType != 0) && ((targetA != 1) && (targetZ != 1))) {
    145     calincl->f[0] = targetA;    // Target mass number
    146     calincl->f[1] = targetZ;    // Charge number
    147     calincl->f[6] = bulletType; // Type
    148     calincl->f[2] = bulletE;    // Energy [MeV]
    149     calincl->f[5] = 1.0;        // Time scaling
    150     calincl->f[4] = 45.0;       // Nuclear potential
    151 
     123  if((inclInput->bulletType() != 0) && ((inclInput->targetA() != 1) && (inclInput->targetZ() != 1))) {
    152124    ws->nosurf = -2;  // Nucleus surface, -2 = Woods-Saxon
    153125    ws->xfoisa = 8;
     
    158130
    159131    mat->nbmat = 1;
    160     mat->amat[0] = int(calincl->f[0]);
    161     mat->zmat[0] = int(calincl->f[1]);
     132    mat->amat[0] = int(inclInput->targetA());
     133    mat->zmat[0] = int(inclInput->targetZ());
    162134
    163135    incl->initIncl(true);
     
    168140        G4cout <<"G4InclCascadeInterface: Try number = " << nTries << G4endl;
    169141      }
    170       incl->processEventIncl();
     142      incl->processEventIncl(inclInput);
    171143
    172144      if(verboseLevel > 1) {
     
    179151       * Diagnostic output
    180152       */
    181       G4cout <<"G4InclCascadeInterface: Bullet type: " << bulletType << G4endl;
    182       G4cout <<"G4Incl4AblaCascadeInterface: Bullet energy: " << bulletE << " MeV" << G4endl;
    183 
    184       G4cout <<"G4InclCascadeInterface: Target A:  " << targetA << G4endl;
    185       G4cout <<"G4InclCascadeInterface: Target Z:  " << targetZ << G4endl;
     153      G4cout <<"G4InclCascadeInterface: Bullet type: " << inclInput->bulletType() << G4endl;
     154      G4cout <<"G4Incl4AblaCascadeInterface: Bullet energy: " << inclInput->bulletE() << " MeV" << G4endl;
     155
     156      G4cout <<"G4InclCascadeInterface: Target A:  " << inclInput->targetA() << G4endl;
     157      G4cout <<"G4InclCascadeInterface: Target Z:  " << inclInput->targetZ() << G4endl;
    186158
    187159      if(verboseLevel > 3) {
    188         diagdata <<"G4InclCascadeInterface: Bullet type: " << bulletType << G4endl;
    189         diagdata <<"G4InclCascadeInterface: Bullet energy: " << bulletE << " MeV" << G4endl;
     160        diagdata <<"G4InclCascadeInterface: Bullet type: " << inclInput->bulletType() << G4endl;
     161        diagdata <<"G4InclCascadeInterface: Bullet energy: " << inclInput->bulletE() << " MeV" << G4endl;
    190162       
    191         diagdata <<"G4InclCascadeInterface: Target A:  " << targetA << G4endl;
    192         diagdata <<"G4InclCascadeInterface: Target Z:  " << targetZ << G4endl;
    193       }
    194 
    195       for(particleI = 0; particleI < varntp->ntrack; particleI++) {
    196         G4cout << n                       << " " << calincl->f[6]             << " " << calincl->f[2] << " ";
    197         G4cout << varntp->massini         << " " << varntp->mzini             << " ";
    198         G4cout << varntp->exini           << " " << varntp->mulncasc          << " " << varntp->mulnevap          << " " << varntp->mulntot << " ";
    199         G4cout << varntp->bimpact         << " " << varntp->jremn             << " " << varntp->kfis              << " " << varntp->estfis << " ";
    200         G4cout << varntp->izfis           << " " << varntp->iafis             << " " << varntp->ntrack            << " " << varntp->itypcasc[particleI] << " ";
    201         G4cout << varntp->avv[particleI]  << " " << varntp->zvv[particleI]    << " " << varntp->enerj[particleI]  << " ";
    202         G4cout << varntp->plab[particleI] << " " << varntp->tetlab[particleI] << " " << varntp->philab[particleI] << G4endl;
    203         // For diagnostic output
    204         if(verboseLevel > 3) {
    205           diagdata << n                       << " " << calincl->f[6]             << " " << calincl->f[2] << " ";
    206           diagdata << varntp->massini         << " " << varntp->mzini             << " ";
    207           diagdata << varntp->exini           << " " << varntp->mulncasc          << " " << varntp->mulnevap          << " " << varntp->mulntot << " ";
    208           diagdata << varntp->bimpact         << " " << varntp->jremn             << " " << varntp->kfis              << " " << varntp->estfis << " ";
    209           diagdata << varntp->izfis           << " " << varntp->iafis             << " " << varntp->ntrack            << " ";
    210           diagdata                                                                       << varntp->itypcasc[particleI] << " ";
    211           diagdata << varntp->avv[particleI]  << " " << varntp->zvv[particleI]    << " " << varntp->enerj[particleI]  << " ";
    212           diagdata << varntp->plab[particleI] << " " << varntp->tetlab[particleI] << " " << varntp->philab[particleI] << G4endl;
    213         }
    214       }
     163        diagdata <<"G4InclCascadeInterface: Target A:  " << inclInput->targetA() << G4endl;
     164        diagdata <<"G4InclCascadeInterface: Target Z:  " << inclInput->targetZ() << G4endl;
     165      }
     166
     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      // }
    215187    }
    216188
     
    224196
    225197      theResult.SetStatusChange(stopAndKill);
    226      
    227       if(bulletType == proton) {
    228         aParticleDefinition = G4Proton::ProtonDefinition();
    229       }
    230       if(bulletType == neutron) {
    231         aParticleDefinition = G4Neutron::NeutronDefinition();
    232       }
    233       if(bulletType == pionPlus) {
    234         aParticleDefinition = G4PionPlus::PionPlusDefinition();
    235       }
    236       if(bulletType == pionZero) {
    237         aParticleDefinition = G4PionZero::PionZeroDefinition();
    238       }
    239       if(bulletType == pionMinus) {
    240         aParticleDefinition = G4PionMinus::PionMinusDefinition();
    241       }
     198      aParticleDefinition = G4InclInput::getParticleDefinition(inclInput->bulletType());
    242199
    243200      cascadeParticle = new G4DynamicParticle();
     
    434391    }
    435392
    436     if(bulletType == 0) {
     393    if(inclInput->bulletType() == 0) {
    437394      if(verboseLevel > 1) {
    438395        G4cout <<"G4InclCascadeInterface: Unknown bullet type" << G4endl;     
     
    445402    }
    446403
    447     if((targetA == 1) && (targetZ == 1)) { // Unsupported target
     404    if((inclInput->targetA() == 1) && (inclInput->targetZ() == 1)) { // Unsupported target
    448405      if(verboseLevel > 1) {
    449406        G4cout <<"Unsupported target: " << G4endl;
    450         G4cout <<"Target A: " << targetA << G4endl;
    451         G4cout <<"TargetZ: " << targetZ << G4endl;
     407        G4cout <<"Target A: " << inclInput->targetA() << G4endl;
     408        G4cout <<"TargetZ: " << inclInput->targetZ() << G4endl;
    452409      }
    453410      if(verboseLevel > 3) {
    454411        diagdata <<"Unsupported target: " << G4endl;
    455         diagdata <<"Target A: " << targetA << G4endl;
    456        diagdata <<"TargetZ: " << targetZ << G4endl;
    457       }
    458     }
    459 
    460     if(bulletE < 100) { // INCL does not support E < 100 MeV.
    461       if(verboseLevel > 1) {
    462         G4cout <<"Unsupported bullet energy: " << bulletE << " MeV. (Lower limit is 100 MeV)." << G4endl;
     412        diagdata <<"Target A: " << inclInput->targetA() << G4endl;
     413        diagdata <<"TargetZ: " << inclInput->targetZ() << G4endl;
     414      }
     415    }
     416
     417    if(inclInput->bulletE() < 100) { // INCL does not support E < 100 MeV.
     418      if(verboseLevel > 1) {
     419        G4cout <<"Unsupported bullet energy: " << inclInput->bulletE() << " MeV. (Lower limit is 100 MeV)." << G4endl;
    463420        G4cout <<"WARNING: Returning the original bullet with original energy back to Geant4." << G4endl;
    464421      }
    465422      if(verboseLevel > 3) {
    466         diagdata <<"Unsupported bullet energy: " << bulletE << " MeV. (Lower limit is 100 MeV)." << G4endl;
     423        diagdata <<"Unsupported bullet energy: " << inclInput->bulletE() << " MeV. (Lower limit is 100 MeV)." << G4endl;
    467424      }
    468425    }
  • trunk/source/processes/hadronic/models/incl/src/G4InclLightIonInterface.cc

    r819 r1340  
    2424// ********************************************************************
    2525//
    26 // $Id: G4InclLightIonInterface.cc,v 1.10 2007/12/10 16:32:07 gunter Exp $
     26// $Id: G4InclLightIonInterface.cc,v 1.12 2010/10/26 02:47:59 kaitanie Exp $
    2727// Translation of INCL4.2/ABLA V3
    2828// Pekka Kaitaniemi, HIP (translation)
     
    4343
    4444  varntp = new G4VarNtp();
    45   calincl = new G4Calincl();
     45  calincl = 0;
    4646  ws = new G4Ws();
    4747  mat = new G4Mat();
     
    6565  G4int maxTries = 200;
    6666
    67   G4int particleI, n = 0;
    68 
    6967  G4int bulletType = 0;
     68  G4int particleI;
    7069
    7170  // Print diagnostic messages: 0 = silent, 1 and 2 = verbose
     
    8685  G4double bulletE = aTrack.GetKineticEnergy() / MeV;
    8786
    88   G4double targetA = theNucleus.GetN();
    89   G4double targetZ = theNucleus.GetZ();
     87  G4int targetA = theNucleus.GetA_asInt();
     88  G4int targetZ = theNucleus.GetZ_asInt();
    9089
    9190  G4double eKin;
     
    116115  if (aTrack.GetDefinition() == G4Alpha::Alpha()         ) bulletType = he4;
    117116
    118   for(int i = 0; i < 15; i++) {
    119     calincl->f[i] = 0.0; // Initialize INCL input data
    120   }
     117  calincl = new G4InclInput();
    121118
    122119  // Check wheter the input is acceptable.
    123120  if((bulletType != 0) && ((targetA != 1) && (targetZ != 1))) {
    124     calincl->f[0] = targetA;    // Target mass number
    125     calincl->f[1] = targetZ;    // Charge number
    126     calincl->f[6] = bulletType; // Type
    127     calincl->f[2] = bulletE;    // Energy [MeV]
    128     calincl->f[5] = 1.0;        // Time scaling
    129     calincl->f[4] = 45.0;       // Nuclear potential
    130 
    131121    ws->nosurf = -2;  // Nucleus surface, -2 = Woods-Saxon
    132122    ws->xfoisa = 8;
     
    137127
    138128    mat->nbmat = 1;
    139     mat->amat[0] = int(calincl->f[0]);
    140     mat->zmat[0] = int(calincl->f[1]);
     129    mat->amat[0] = int(calincl->targetA());
     130    mat->zmat[0] = int(calincl->targetZ());
    141131
    142132    incl->initIncl(true);
     
    147137        G4cout <<"G4InclLightIonInterface: Try number = " << nTries << G4endl;
    148138      }
    149       incl->processEventIncl();
     139      incl->processEventIncl(calincl);
    150140
    151141      if(verboseLevel > 1) {
     
    170160        diagdata <<"G4InclLightIonInterface: Target A:  " << targetA << G4endl;
    171161        diagdata <<"G4InclLightIonInterface: Target Z:  " << targetZ << G4endl;
    172       }
    173 
    174       for(particleI = 0; particleI < varntp->ntrack; particleI++) {
    175         G4cout << n                       << " " << calincl->f[6]             << " " << calincl->f[2] << " ";
    176         G4cout << varntp->massini         << " " << varntp->mzini             << " ";
    177         G4cout << varntp->exini           << " " << varntp->mulncasc          << " " << varntp->mulnevap          << " " << varntp->mulntot << " ";
    178         G4cout << varntp->bimpact         << " " << varntp->jremn             << " " << varntp->kfis              << " " << varntp->estfis << " ";
    179         G4cout << varntp->izfis           << " " << varntp->iafis             << " " << varntp->ntrack            << " " << varntp->itypcasc[particleI] << " ";
    180         G4cout << varntp->avv[particleI]  << " " << varntp->zvv[particleI]    << " " << varntp->enerj[particleI]  << " ";
    181         G4cout << varntp->plab[particleI] << " " << varntp->tetlab[particleI] << " " << varntp->philab[particleI] << G4endl;
    182         // For diagnostic output
    183         if(verboseLevel > 3) {
    184           diagdata << n                       << " " << calincl->f[6]             << " " << calincl->f[2] << " ";
    185           diagdata << varntp->massini         << " " << varntp->mzini             << " ";
    186           diagdata << varntp->exini           << " " << varntp->mulncasc          << " " << varntp->mulnevap          << " " << varntp->mulntot << " ";
    187           diagdata << varntp->bimpact         << " " << varntp->jremn             << " " << varntp->kfis              << " " << varntp->estfis << " ";
    188           diagdata << varntp->izfis           << " " << varntp->iafis             << " " << varntp->ntrack            << " ";
    189           diagdata                                                                       << varntp->itypcasc[particleI] << " ";
    190           diagdata << varntp->avv[particleI]  << " " << varntp->zvv[particleI]    << " " << varntp->enerj[particleI]  << " ";
    191           diagdata << varntp->plab[particleI] << " " << varntp->tetlab[particleI] << " " << varntp->philab[particleI] << G4endl;
    192         }
    193162      }
    194163    }
Note: See TracChangeset for help on using the changeset viewer.