Ignore:
Timestamp:
Dec 22, 2010, 3:52:27 PM (14 years ago)
Author:
garnier
Message:

geant4 tag 9.4

Location:
trunk/source/processes/hadronic/models/incl
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/processes/hadronic/models/incl/GNUmakefile

    r1340 r1347  
    1 # $Id: GNUmakefile,v 1.11 2010/10/26 02:47:58 kaitanie Exp $
     1# $Id: GNUmakefile,v 1.13 2010/11/13 00:08:36 kaitanie Exp $
    22# -----------------------------------------------------------
    33# GNUmakefile for hadronic library.  Gabriele Cosmo, 18/9/96.
     
    3636            -I$(G4BASE)/processes/hadronic/models/management/include \
    3737            -I$(G4BASE)/processes/hadronic/models/util/include \
     38            -I$(G4BASE)/processes/hadronic/models/de_excitation/util/include \
    3839            -I$(G4BASE)/processes/hadronic/models/de_excitation/evaporation/include \
    3940            -I$(G4BASE)/processes/hadronic/models/de_excitation/fermi_breakup/include \
     41            -I$(G4BASE)/processes/hadronic/models/de_excitation/photon_evaporation/include \
     42            -I$(G4BASE)/processes/hadronic/models/de_excitation/multifragmentation/include \
     43            -I$(G4BASE)/processes/hadronic/models/de_excitation/handler/include \
     44            -I$(G4BASE)/processes/hadronic/models/de_excitation/management/include \
     45            -I$(G4BASE)/processes/hadronic/models/pre_equilibrium/exciton_model/include/ \
    4046            -I$(G4BASE)/particles/management/include \
    4147            -I$(G4BASE)/particles/leptons/include \
  • trunk/source/processes/hadronic/models/incl/History

    r1340 r1347  
    44     Geant4 - an Object-Oriented Toolkit for Physics Simulation
    55     ==========================================================
    6 $Id: History,v 1.32 2010/10/29 06:54:23 gunter Exp $
     6$Id: History,v 1.37 2010/11/17 20:19:09 kaitanie Exp $
    77---------------------------------------------------------------------
    88
     
    1717   ---------------------------------------------------------------
    1818
     1917 November 2010 - Pekka Kaitaniemi (hadr-incl-V09-03-10)
     20---------------------------------------------------------
     21- Fixed several issues reported by Coverity:
     22  o Fix: Fragment vector and Fermi break-up related emory leaks in
     23  INCL/ABLA interfaces
     24  o Initialize INCL internal variables properly
     25  o Check array boundaries in datafile reader
     26
     2716 November 2010 - Gabriele Cosmo (hadr-incl-V09-03-09)
     28-------------------------------------------------------
     29- More minor fixes from Coverity reports...
     30
     3112 November 2010 - Pekka Kaitaniemi (hadr-incl-V09-03-08)
     32---------------------------------------------------------
     33- Fixed several minor variable initialization issues reported by Coverity
     34
     3511 November 2010 - Pekka Kaitaniemi (hadr-incl-V09-03-07)
     36---------------------------------------------------------
     37- Fixed some minor variable initialization issues reported by Coverity
     38- Updated interfaces:
     39  o INCL + built-in ABLA de-excitation: G4InclAblaCascadeInterface and
     40  G4InclAblaLightIonInterface
     41  o INCL + PreCompound model: G4InclCascadeInterface and
     42  G4InclLightIonInterface
     43
     4403 November 2010 - Pekka Kaitaniemi (hadr-incl-V09-03-06)
     45---------------------------------------------------------
     46- Fixed insufficient array index safeguard in ABLA
     47- Silenced debugging output printed by G4InclAblaCascadeInterface
     48
    194929 October 2010 - Gunter Folger (hadr-incl-V09-03-05)
     50-----------------------------------------------------
    2051- Fixed several more compilation warnings for conversion of double to int
    2152   in  G4Incl.cc, G4InclAblaCascadeInterface.cc, and G4InclAblaLightIonInterface.cc.
  • trunk/source/processes/hadronic/models/incl/include/G4Abla.hh

    r1340 r1347  
    2424// ********************************************************************
    2525//
    26 // $Id: G4Abla.hh,v 1.13 2010/10/26 02:47:59 kaitanie Exp $
     26// $Id: G4Abla.hh,v 1.14 2010/11/17 20:19:09 kaitanie Exp $
    2727// Translation of INCL4.2/ABLA V3
    2828// Pekka Kaitaniemi, HIP (translation)
     
    5050public:
    5151  /**
    52    * Basic constructor.
    53    */
    54   G4Abla();
    55 
    56   /**
    5752   * This constructor is used by standalone test driver and the Geant4 interface.
    5853   *
     
    6257   */
    6358  G4Abla(G4Hazard *aHazard, G4Volant *aVolant, G4VarNtp *aVarntp);
    64 
    65   /**
    66    * Constructor that is to be used only for testing purposes.
    67    * @param aHazard random seeds
    68    * @param aVolant data structure for ABLA output   
    69    */
    70   G4Abla(G4Hazard *hazard, G4Volant *volant);
    7159
    7260  /**
     
    167155              G4double *probp_par, G4double *probn_par, G4double *proba_par,
    168156              G4double *probf_par, G4double *ptotl_par, G4double *sn_par, G4double *sbp_par, G4double *sba_par, G4double *ecn_par,
    169               G4double *ecp_par,G4double *eca_par, G4double *bp_par, G4double *ba_par, G4int inttype, G4int inum, G4int itest);
     157              G4double *ecp_par,G4double *eca_par, G4double *bp_par, G4double *ba_par, G4int, G4int inum, G4int itest);
    170158
    171159  /**
  • trunk/source/processes/hadronic/models/incl/include/G4AblaDataDefs.hh

    r1340 r1347  
    2424// ********************************************************************
    2525//
    26 // $Id: G4AblaDataDefs.hh,v 1.11 2010/10/26 02:47:59 kaitanie Exp $
     26// $Id: G4AblaDataDefs.hh,v 1.13 2010/11/13 00:08:36 kaitanie Exp $
    2727// Translation of INCL4.2/ABLA V3
    2828// Pekka Kaitaniemi, HIP (translation)
     
    9595   *
    9696   */
    97   G4Ald() {};
     97  G4Ald()
     98    :av(0.0), as(0.0), ak(0.0), optafan(0.0)
     99  {};
    98100  ~G4Ald() {};
    99101 
     
    141143
    142144public:
    143   G4Fiss() {};
     145  G4Fiss()
     146    :akap(0.0), bet(0.0), homega(0.0), koeff(0.0), ifis(0.0),
     147     optshp(0), optxfis(0), optles(0), optcol(0)
     148  {};
    144149  ~G4Fiss() {};
    145150 
     
    171176
    172177public:
    173   G4Opt() {};
     178  G4Opt()
     179    :optemd(0), optcha(0), eefac(0.0)
     180  {};
    174181  ~G4Opt() {};
    175182 
     
    182189class G4Eenuc {
    183190public:
    184   G4Eenuc() {};
     191  G4Eenuc() {
     192    for(G4int i = 0; i < EENUCSIZE; ++i) {
     193      she[i] = 0.0;
     194    }
     195    for(G4int i = 0; i < XHESIZE; ++i) {
     196      for(G4int j = 0; j < EENUCSIZE; ++j) {
     197        xhe[i][j] = 0.0;
     198      }
     199    }
     200  };
    185201  ~G4Eenuc() {};
    186202 
  • trunk/source/processes/hadronic/models/incl/include/G4Incl.hh

    r1340 r1347  
    2424// ********************************************************************
    2525//
    26 // $Id: G4Incl.hh,v 1.18 2010/10/26 02:47:59 kaitanie Exp $
     26// $Id: G4Incl.hh,v 1.19 2010/11/13 00:08:36 kaitanie Exp $
    2727// Translation of INCL4.2/ABLA V3
    2828// Pekka Kaitaniemi, HIP (translation)
     
    688688   private:
    689689
     690  /*
     691   * (Re)Initialize INCL internal variables
     692   */
     693  void clearState();
     694
    690695  /**
    691696   * Random seeds for INCL4 internal random number generators.
  • trunk/source/processes/hadronic/models/incl/include/G4InclAblaCascadeInterface.hh

    r1340 r1347  
    2424// ********************************************************************
    2525//
    26 // $Id: G4InclAblaCascadeInterface.hh,v 1.9 2010/10/26 02:47:59 kaitanie Exp $
     26// $Id: G4InclAblaCascadeInterface.hh,v 1.11 2010/11/13 00:08:36 kaitanie Exp $
    2727// Translation of INCL4.2/ABLA V3
    2828// Pekka Kaitaniemi, HIP (translation)
     
    9191 *
    9292 * @see G4InclAblaLightIonInterface
     93 * @see G4InclCascadeInterface
    9394 */
    9495
  • trunk/source/processes/hadronic/models/incl/include/G4InclAblaDataFile.hh

    r1337 r1347  
    2424// ********************************************************************
    2525//
    26 // $Id: G4InclAblaDataFile.hh,v 1.3 2010/06/14 16:10:01 gcosmo Exp $
     26// $Id: G4InclAblaDataFile.hh,v 1.4 2010/11/17 20:19:09 kaitanie Exp $
    2727// Translation of INCL4.2/ABLA V3
    2828// Pekka Kaitaniemi, HIP (translation)
     
    5252private:
    5353  G4int verboseLevel;
    54  
    55   G4String *dataPath;
    5654};
    5755
  • trunk/source/processes/hadronic/models/incl/include/G4InclCascadeInterface.hh

    r1340 r1347  
    2424// ********************************************************************
    2525//
    26 // $Id: G4InclCascadeInterface.hh,v 1.6 2010/10/26 02:47:59 kaitanie Exp $
     26// $Id: G4InclCascadeInterface.hh,v 1.8 2010/11/13 00:08:36 kaitanie Exp $
    2727// Translation of INCL4.2/ABLA V3
    2828// Pekka Kaitaniemi, HIP (translation)
     
    5959#include "G4AblaDataDefs.hh"
    6060#include "G4Incl.hh"
    61 #include "G4InclInput.hh"
     61
     62// Geant4 de-excitation
     63#include "G4ExcitationHandler.hh"
     64#include "G4PreCompoundModel.hh"
    6265
    6366#include <fstream>
     
    6770
    6871/**
     72 * <h1>INCL intra-nuclear cascade with Geant4 PreCompound for de-excitation</h1>
     73 *
    6974 * Interface for INCL. This interface handles basic hadron
    7075 * bullet particles (protons, neutrons, pions).
    71  * @see G4InclAblaLightIonInterface
     76 *
     77 * Example usage in case of protons:
     78 * @code
     79 * G4InclCascadeInterface* inclModel = new G4InclCascadeInterface;
     80 * inclModel -> SetMinEnergy(0.0 * MeV); // Set the energy limits
     81 * inclModel -> SetMaxEnergy(3.0 * GeV);
     82 *
     83 * G4ProtonInelasticProcess* protonInelasticProcess = new G4ProtonInelasticProcess();
     84 * G4ProtonInelasticCrossSection* protonInelasticCrossSection =  new G4ProtonInelasticCrossSection();
     85 *
     86 * protonInelasticProcess -> RegisterMe(inclModel);
     87 * protonInelasticProcess -> AddDataSet(protonInelasticCrossSection);
     88 *
     89 * particle = G4Proton::Proton();
     90 * processManager = particle -> GetProcessManager();
     91 * processManager -> AddDiscreteProcess(protonInelasticProcess);
     92 * @endcode
     93 * The same setup procedure is needed for neutron and pion inelastic processes
     94 * as well.
     95 *
     96 * @see G4InclLightIonInterface
    7297 */
    7398
     
    78103   * Basic constructor.
    79104   */
    80   G4InclCascadeInterface();
     105  G4InclCascadeInterface(const G4String& name = "INCL Cascade with Geant4 PreCompound");
    81106
    82107 
     
    94119
    95120  /**
    96    * Main method to apply the INCL/ABLA physics model.
     121   * Main method to apply the INCL physics model.
    97122   * @param aTrack the projectile particle
    98123   * @param theNucleus target nucleus
    99    * @return the output of the INCL/ABLA physics model
     124   * @return the output of the INCL physics model
    100125   */
    101126  G4HadFinalState* ApplyYourself(const G4HadProjectile& aTrack,  G4Nucleus& theNucleus);
     
    108133  G4Hazard *hazard; // The random seeds used by INCL.
    109134  G4VarNtp *varntp;
    110   G4InclInput *inclInput;
     135  G4InclInput *calincl;
    111136  G4Ws *ws;
    112137  G4Mat *mat;
    113138  G4Incl *incl;
    114  
     139
    115140  G4HadFinalState theResult; 
    116141  ofstream diagdata;
     
    119144  G4double previousTargetA;
    120145  G4double previousTargetZ;
     146
     147  G4ExcitationHandler *theExcitationHandler;
     148  G4PreCompoundModel *thePrecoModel;
    121149};
    122150
    123 #endif // G4INCLCASCADEINTERFACE_H
     151#endif // G4INCLABLACASCADEINTERFACE_H
  • trunk/source/processes/hadronic/models/incl/include/G4InclDataDefs.hh

    r1340 r1347  
    2424// ********************************************************************
    2525//
    26 // $Id: G4InclDataDefs.hh,v 1.10 2010/10/28 15:35:50 gcosmo Exp $
     26// $Id: G4InclDataDefs.hh,v 1.12 2010/11/17 20:19:09 kaitanie Exp $
    2727// Translation of INCL4.2/ABLA V3
    2828// Pekka Kaitaniemi, HIP (translation)
     
    6363class G4QuadvectProjo {
    6464public:
    65   G4QuadvectProjo() {};
     65  G4QuadvectProjo() {
     66    for(G4int i = 0; i < max_a_proj; ++i) {
     67      eps_c[i] = 0.0;
     68      t_c[i] = 0.0;
     69      p3_c[i] = 0.0;
     70      p1_s[i] = 0.0;
     71      p2_s[i] = 0.0;
     72      p3_s[i] = 0.0;
     73    }
     74  };
     75
    6676  ~G4QuadvectProjo() {};
    6777
     
    7383class G4VBe {
    7484public:
    75   G4VBe() {};
     85  G4VBe()
     86    :ia_be(0), iz_be(0),
     87     rms_be(0.0), pms_be(0.0), bind_be(0.0)
     88  { };
     89
    7690  ~G4VBe() {};
    7791
     
    87101  G4InclProjSpect() {
    88102    //    G4cout <<"Projectile spectator data structure created!" << G4endl;
     103    clear();
    89104  };
    90105  ~G4InclProjSpect() {};
     
    95110    a_projspec = 0;
    96111    z_projspec = 0;
    97     m_projspec = 0.0;
     112    t_projspec = 0.0;
    98113    ex_projspec = 0.0;
    99114    p1_projspec = 0.0;
    100115    p2_projspec = 0.0;
    101116    p3_projspec = 0.0;
     117    m_projspec = 0.0;
    102118  };
    103119
     
    108124};
    109125
    110 #define FSIZE 15
    111 /**
    112  * Initial values of a hadronic cascade problem.
    113  */
    114 class G4Calincl {
    115 public:
    116   G4Calincl() {
    117     isExtendedProjectile = false;
    118   };
    119 
    120   G4Calincl(const G4HadProjectile &aTrack, const G4Nucleus &theNucleus, G4bool inverseKinematics = false) {
    121     for(int i = 0; i < 15; i++) {
    122       f[i] = 0.0; // Initialize INCL input data
    123     }
    124 
    125     usingInverseKinematics = inverseKinematics;
    126 
    127     f[0] = theNucleus.GetA_asInt(); // Target mass number
    128     f[1] = theNucleus.GetZ_asInt(); // Target charge number
    129     f[6] = getBulletType(aTrack.GetDefinition()); // Projectile type (INCL particle code)
    130     f[2] = aTrack.GetKineticEnergy() / MeV; // Projectile energy (total, in MeV)
    131     f[5] = 1.0; // Time scaling
    132     f[4] = 45.0; // Nuclear potential
    133     setExtendedProjectileInfo(aTrack.GetDefinition());
    134     //    G4cout <<"Projectile type = " << f[6] << G4endl;
    135     //    G4cout <<"Energy = " << f[2] << G4endl;
    136     //    G4cout <<"Target A = " << f[0] << " Z = " << f[1] << G4endl;
    137   };
    138 
    139   ~G4Calincl() {};
    140  
    141   static void printProjectileTargetInfo(const G4HadProjectile &aTrack, const G4Nucleus &theNucleus) {
    142     G4cout <<"Projectile = " << aTrack.GetDefinition()->GetParticleName() << G4endl;
    143     G4cout <<"    four-momentum: " << aTrack.Get4Momentum() << G4endl;
    144     G4cout <<"Energy = " << aTrack.GetKineticEnergy() / MeV << G4endl;
    145     G4cout <<"Target A = " << theNucleus.GetA_asInt() << " Z = " << theNucleus.GetZ_asInt() << G4endl;
    146   }
    147 
    148   static G4bool canUseInverseKinematics(const G4HadProjectile &aTrack, const G4Nucleus &theNucleus) {
    149     G4int targetA = theNucleus.GetA_asInt();
    150     const G4ParticleDefinition *projectileDef = aTrack.GetDefinition();
    151     G4int projectileA = projectileDef->GetAtomicMass();
    152     //    G4int projectileZ = projectileDef->GetAtomicNumber();
    153     if(targetA > 0 && targetA < 18 && (projectileDef != G4Proton::Proton() &&
    154                                        projectileDef != G4Neutron::Neutron() &&
    155                                        projectileDef != G4PionPlus::PionPlus() &&
    156                                        projectileDef != G4PionZero::PionZero() &&
    157                                        projectileDef != G4PionMinus::PionMinus()) &&
    158        projectileA > 1) {
    159       return true;
    160     } else {
    161       return false;
    162     }
    163   }
    164 
    165   G4double bulletE() {
    166     return f[2];
    167   }
    168 
    169   G4int getBulletType() {
    170     return G4int(f[6]);
    171   };
    172 
    173   void setExtendedProjectileInfo(const G4ParticleDefinition *pd) {
    174     if(getBulletType(pd) == -666) {
    175       extendedProjectileA = pd->GetAtomicMass();
    176       extendedProjectileZ = pd->GetAtomicNumber();
    177       isExtendedProjectile = true;
    178     } else {
    179       isExtendedProjectile = false;
    180     }
    181   };
    182 
    183   G4int getBulletType(const G4ParticleDefinition *pd) {
    184     G4ParticleTable *pt = G4ParticleTable::GetParticleTable();
    185 
    186     if(pd == G4Proton::Proton()) {
    187       return 1;
    188     } else if(pd == G4Neutron::Neutron()) {
    189       return 2;
    190     } else if(pd == G4PionPlus::PionPlus()) {
    191       return 3;
    192     } else if(pd == G4PionMinus::PionMinus()) {
    193       return 5;
    194     } else if(pd == G4PionZero::PionZero()) {
    195       return 4;
    196     } else if(pd == G4Deuteron::Deuteron()) {
    197       return 6;
    198     } else if(pd == G4Triton::Triton()) {
    199       return 7;
    200     } else if(pd == G4He3::He3()) {
    201       return 8;
    202     } else if(pd == G4Alpha::Alpha()) {
    203       return 9;
    204     } else if(pd == pt->GetIon(6, 12, 0.0)) { // C12 special case. This should be phased-out in favor of "extended projectile"
    205       return -12;
    206     } else { // Is this extended projectile?
    207       G4int A = pd->GetAtomicMass();
    208       G4int Z = pd->GetAtomicNumber();
    209       if(A > 4 && A <= 16 && Z > 2 && Z <= 8) { // Ions from Lithium to Oxygen
    210         return -666; // Code of an extended projectile
    211       }
    212     }
    213     G4cout <<"Error! Projectile " << pd->GetParticleName() << " not defined!" << G4endl;
    214     return 0;
    215   };
    216 
    217   G4bool isInverseKinematics() {
    218     return usingInverseKinematics;
    219   };
    220 
    221   G4double targetA() { return f[0]; };
    222   G4double targetZ() { return f[1]; };
    223 
    224   G4int extendedProjectileA;
    225   G4int extendedProjectileZ;
    226   G4bool isExtendedProjectile;
    227 
    228   /**
    229    * Here f is an array containing the following initial values:
    230    * - f[0] : target mass number
    231    * - f[1] : target charge number
    232    * - f[2] : bullet energy
    233    * - f[3] : minimum proton energy to leave the target (default: 0.0)
    234    * - f[4] : nuclear potential (default: 45.0 MeV)
    235    * - f[5] : time scale (default: 1.0)
    236    * - f[6] : bullet type (1: proton, 2: neutron, 3: pi+, 4: pi0 5: pi-, 6:H2, 7: H3, 8: He3, 9: He4
    237    * - f[7] : minimum neutron energy to leave the target (default: 0.0)
    238    * - f[8] : target material identifier (G4Mat)
    239    * - f[9] : not used
    240    * - f[10] : not used
    241    * - f[11] : not used
    242    * - f[12] : not used
    243    * - f[13] : not used
    244    * - f[14] : not used
    245    */
    246   G4double f[FSIZE];
    247 
    248   /**
    249    * Number of events to be processed.
    250    */
    251   G4int icoup;
    252 
    253   G4bool usingInverseKinematics;
    254 };
    255 
    256126#define IGRAINESIZE 19
    257127/**
     
    262132class G4Hazard{
    263133public:
    264   G4Hazard() {};
     134  G4Hazard() {
     135    ial = 0;
     136    for(G4int i = 0; i < IGRAINESIZE; ++i) {
     137      igraine[i] = 0;
     138    }
     139  };
     140
    265141  ~G4Hazard() {};
    266142
     
    283159class G4Mat {
    284160public:
    285   G4Mat() { };
     161  G4Mat() {
     162    nbmat = 0;
     163
     164    for(G4int i = 0; i < MATSIZE; ++i) {
     165      zmat[i] = 0;
     166      amat[i] = 0;
     167    }
     168
     169    for(G4int i = 0; i < MATGEOSIZE; ++i) {
     170      for(G4int j = 0; j < MATSIZE; ++j) {
     171        bmax_geo[i][j] = 0;
     172      }
     173    }
     174};
     175
    286176  ~G4Mat() { };
    287177
     
    313203class G4LightGausNuc {
    314204public:
    315   G4LightGausNuc() {};
     205  G4LightGausNuc() {
     206    for(G4int i = 0; i < LGNSIZE; ++i) {
     207      rms1t[i] = 0.0;
     208      pf1t[i] = 0.0;
     209      pfln[i] = 0.0;
     210      tfln[i] = 0.0;
     211      vnuc[i] = 0.0;
     212    }
     213  };
     214
    316215  ~G4LightGausNuc() {};
    317216 
     
    329228class G4LightNuc {
    330229public:
    331   G4LightNuc() {};
     230  G4LightNuc() {
     231    for(G4int i = 0; i < LNSIZE; ++i) {
     232      r[i] = 0.0;
     233      a[i] = 0.0;
     234    }
     235  };
     236
    332237  ~G4LightNuc() {};
    333238
     
    350255class G4Saxw {
    351256public:
    352   G4Saxw() {};
     257  G4Saxw() {
     258    for(G4int i = 0; i < SAXWROWS; ++i) {
     259      for(G4int j = 0; j < SAXWCOLS; ++j) {
     260        x[i][j] = 0.0;
     261        y[i][j] = 0.0;
     262        s[i][j] = 0.0;
     263      }
     264    }
     265    imat = 0; n = 0; k = 0;
     266  };
     267
    353268  ~G4Saxw() {};
    354269 
     
    391306  G4Ws() {
    392307    fneck = 0.0;
    393   };
     308    r0 = 0.0;
     309    adif = 0.0;
     310    rmaxws = 0.0;
     311    drws = 0.0;
     312    nosurf = 0.0;
     313    xfoisa = 0.0;
     314    bmax = 0.0;
     315    npaulstr = 0.0;
     316  };
     317
    394318  ~G4Ws() {};
    395319 
     
    453377class G4Dton {
    454378public:
    455   G4Dton() {};
     379  G4Dton() {
     380    fn = 0.0;
     381    for(G4int i = 0; i < DTONSIZE; ++i) {
     382      c[i] = 0.0;
     383      d[i] = 0.0;
     384    }
     385  };
     386
    456387  ~G4Dton() {};
    457388 
     
    469400class G4Spl2 {
    470401public:
    471   G4Spl2() {};
     402  G4Spl2() {
     403    for(G4int i = 0; i < SPL2SIZE; ++i) {
     404      x[i] = 0.0; y[i] = 0.0;
     405      a[i] = 0.0; b[i] = 0.0; c[i] = 0.0;
     406    }
     407    n = 0;
     408  };
     409
    472410  ~G4Spl2() {};
    473411 
     
    491429class G4Bl1 {
    492430public:
    493   G4Bl1() {};
     431  G4Bl1() {
     432    ta = 0.0;
     433    for(G4int i = 0; i < BL1SIZE; ++i) {
     434      p1[i] = 0.0; p2[i] = 0.0; p3[i] = 0.0; eps[i] = 0.0;
     435      ind1[i] = 0; ind2[i] = 0;
     436    }
     437  };
     438
    494439  ~G4Bl1() {};
    495440 
     
    510455};
    511456
    512 #define BL2CROISSIZE 19900
    513 #define BL2INDSIZE 19900
     457#define BL2SIZE 19900
    514458/**
    515459 *
     
    517461class G4Bl2 {
    518462public:
    519   G4Bl2() {};
     463  G4Bl2() {
     464    k = 0;
     465    for(G4int i = 0; i < BL2SIZE; ++i) {
     466      crois[i] = 0.0;
     467      ind[i] = 0;
     468      jnd[i] = 0;
     469    }   
     470  };
     471
    520472  ~G4Bl2() {};
    521473 
     
    533485   *
    534486   */
    535   G4double crois[BL2CROISSIZE];
     487  G4double crois[BL2SIZE];
    536488
    537489  /**
     
    543495   *
    544496   */
    545   G4int ind[BL2INDSIZE];
    546 
    547   /**
    548    *
    549    */
    550   G4int jnd[BL2INDSIZE];
     497  G4int ind[BL2SIZE];
     498
     499  /**
     500   *
     501   */
     502  G4int jnd[BL2SIZE];
    551503};
    552504
     
    558510class G4Bl3 {
    559511public:
    560   G4Bl3() {};
     512  G4Bl3() {
     513    r1 = 0.0; r2 = 0.0;
     514    ia1 = 0; ia2 = 0;
     515    rab2 = 0.0;
     516
     517    for(G4int i = 0; i < BL3SIZE; ++i) {
     518      x1[i] = 0.0; x2[i] = 0.0; x3[i] = 0.0;
     519    }
     520  };
     521
    561522  ~G4Bl3() {};
    562523 
     
    599560class G4Bl4 {
    600561public:
    601   G4Bl4() {};
     562  G4Bl4()
     563    :tmax5(0.0)
     564  {};
     565
    602566  ~G4Bl4() {};
    603567
     
    615579class G4Bl5 {
    616580public:
    617   G4Bl5() {};
     581  G4Bl5() {
     582    for(G4int i = 0; i < BL5SIZE; ++i) {
     583      tlg[i] = 0.0;
     584      nesc[i] = 0;
     585    }
     586  };
     587
    618588  ~G4Bl5() {};
    619589 
     
    634604class G4Bl6 {
    635605public:
    636   G4Bl6() {};
     606  G4Bl6()
     607    :xx10(0.0), isa(0.0)
     608  {};
     609
    637610  ~G4Bl6() {};
    638611 
     
    653626class G4Bl8 {
    654627public:
    655   G4Bl8() {};
     628  G4Bl8()
     629    :rathr(0.0), ramass(0.0)
     630  {};
     631
    656632  ~G4Bl8() {};
    657633
     
    677653    l1 = 0;
    678654    l2 = 0;
     655    for(G4int i = 0; i < BL9SIZE; ++i) {
     656      hel[i] = 0.0;
     657    }
    679658  };
    680659  ~G4Bl9() {};
     
    696675class G4Bl10 {
    697676public:
    698   G4Bl10() {};
     677  G4Bl10()
     678    :ri4(0.0), rs4(0.0), r2i(0.0), r2s(0.0), pdummy(0.0), pf(0.0)
     679  {};
    699680  ~G4Bl10() {};
    700681
     
    710691class G4Kind {
    711692public:
    712   G4Kind() {};
     693  G4Kind()
     694    :kindf7(0)
     695  {};
    713696  ~G4Kind() {};
    714697
     
    770753class G4VarAvat {
    771754public:
    772   G4VarAvat() {};
     755  G4VarAvat() {
     756    kveux = 0;
     757    bavat = 0.0;
     758    nopartavat = 0; ncolavat = 0;
     759    nb_avat = 0;
     760
     761    for(G4int i = 0; i < VARSIZE; ++i) {
     762      r1_in[i] = 0.0;
     763      r1_first_avat[i] = 0.0;
     764    }
     765
     766    for(G4int i = 0; i < VAEPSSIZE; ++i) {
     767      epsd[i] = 0.0;
     768      eps2[i] = 0.0;
     769      eps4[i] = 0.0;
     770      eps6[i] = 0.0;
     771      epsf[i] = 0.0;
     772    }
     773
     774    for(G4int i = 0; i < VAAVM; ++i) {
     775      timeavat[i] = 0.0;
     776      l1avat[i] = 0.0;
     777      l2avat[i] = 0.0;
     778      jpartl1[i] = 0.0;
     779      jpartl2[i] = 0.0;
     780      del1avat[i] = 0.0;
     781      del2avat[i] = 0.0;
     782      energyavat[i] = 0.0;
     783      bloc_paul[i] = 0.0;
     784      bloc_cdpp[i] = 0.0;
     785      go_out[i] = 0.0;
     786    }
     787  };
     788
    773789  ~G4VarAvat() {};
    774790
     
    822838class G4VarNtp {
    823839public:
    824   G4VarNtp() {};
     840  G4VarNtp() {
     841    clear();
     842  };
     843
    825844  ~G4VarNtp() {};
    826845
     
    834853    targetA = 0;
    835854    targetZ = 0;
    836     masp = 0.0; mzsp = 0.0; exsp = 0.0;
     855    masp = 0.0; mzsp = 0.0; exsp = 0.0; mrem = 0.0;
    837856    // To be deleted?
    838857    spectatorA = 0;
     
    11901209class G4Paul {
    11911210public:
    1192   G4Paul() {};
     1211  G4Paul()
     1212    :ct0(0.0), ct1(0.0), ct2(0.0), ct3(0.0), ct4(0.0), ct5(0.0), ct6(0.0),
     1213     pr(0.0), pr2(0.0), xrr(0.0), xrr2(0.0),
     1214     cp0(0.0), cp1(0.0), cp2(0.0), cp3(0.0), cp4(0.0), cp5(0.0), cp6(0.0)
     1215  {};
     1216
    11931217  ~G4Paul() {};
    11941218 
  • trunk/source/processes/hadronic/models/incl/include/G4InclLightIonInterface.hh

    r1340 r1347  
    2424// ********************************************************************
    2525//
    26 // $Id: G4InclLightIonInterface.hh,v 1.6 2010/10/26 02:47:59 kaitanie Exp $
     26// $Id: G4InclLightIonInterface.hh,v 1.8 2010/11/13 00:08:36 kaitanie Exp $
    2727// Translation of INCL4.2/ABLA V3
    2828// Pekka Kaitaniemi, HIP (translation)
     
    4646#define G4INCLLIGHTIONINTERFACE_H 1
    4747
    48 #include "G4Nucleon.hh"
    49 #include "G4Nucleus.hh"
    50 #include "G4HadronicInteraction.hh"
    5148#include "G4VIntraNuclearTransportModel.hh"
    5249#include "G4KineticTrackVector.hh"
     
    6158#include "G4Incl.hh"
    6259
     60// Geant4 de-excitation
     61#include "G4ExcitationHandler.hh"
     62#include "G4PreCompoundModel.hh"
     63
    6364#include <fstream>
    6465#include <iostream>
     
    6768
    6869/**
    69  * Interface for INCL. This interface handles basic light ion
    70  * bullet particles (deuterons, tritons, he3 and alphas).
    71  * @see G4InclAblaLightIonInterface
     70 * Interface for INCL with Geant4 PreCompound de-excitation. This
     71 * interface handles basic light ion bullet particles from deuterons
     72 * up to carbon-12. @see G4InclAblaLightIonInterface
    7273 */
    7374
     
    9495
    9596  /**
    96    * Main method to apply the INCL/ABLA physics model.
     97   * Main method to apply the INCL physics model.
    9798   * @param aTrack the projectile particle
    9899   * @param theNucleus target nucleus
    99    * @return the output of the INCL/ABLA physics model
     100   * @return the output of the INCL physics model
    100101   */
    101102  G4HadFinalState* ApplyYourself(const G4HadProjectile& aTrack,  G4Nucleus& theNucleus);
     
    119120  G4double previousTargetA;
    120121  G4double previousTargetZ;
     122  G4bool useProjectileSpectator;
     123  G4bool useFermiBreakup;
     124
     125  G4ExcitationHandler *theExcitationHandler;
     126  G4PreCompoundModel *thePrecoModel;
    121127};
    122128
    123 #endif // G4INCLLIGHTIONINTERFACE_H
     129#endif // G4INCLABLALIGHTIONINTERFACE_H
  • trunk/source/processes/hadronic/models/incl/include/G4InclRandomNumbers.hh

    r1340 r1347  
    2424// ********************************************************************
    2525//
    26 // $Id: G4InclRandomNumbers.hh,v 1.6 2010/10/26 02:47:59 kaitanie Exp $
     26// $Id: G4InclRandomNumbers.hh,v 1.8 2010/11/13 00:08:36 kaitanie Exp $
    2727// Translation of INCL4.2/ABLA V3
    2828// Pekka Kaitaniemi, HIP (translation)
     
    4343
    4444public:
    45   G4InclRandomInterface() { }
     45  G4InclRandomInterface() {
     46    this->seed = 1337; // Default seed, this is never actually used.
     47  }
    4648  G4InclRandomInterface(G4long seed) {
    4749    this->seed = seed;
  • trunk/source/processes/hadronic/models/incl/src/G4Abla.cc

    r1340 r1347  
    2424// ********************************************************************
    2525//
    26 // $Id: G4Abla.cc,v 1.22 2010/10/26 02:47:59 kaitanie Exp $
     26// $Id: G4Abla.cc,v 1.27 2010/11/17 20:19:09 kaitanie Exp $
    2727// Translation of INCL4.2/ABLA V3
    2828// Pekka Kaitaniemi, HIP (translation)
     
    4040#include "G4AblaFissionSimfis18.hh"
    4141#include "G4AblaFission.hh"
    42 
    43 G4Abla::G4Abla()
    44 {
    45   verboseLevel = 0;
    46   ilast = 0;
    47 }
    48 
    49 G4Abla::G4Abla(G4Hazard *hazard, G4Volant *volant)
    50 {
    51   verboseLevel = 0;
    52   ilast = 0;
    53   volant = volant; // ABLA internal particle data
    54   volant->iv = 0;
    55   hazard = hazard; // Random seeds
    56 
    57   randomGenerator = new G4InclGeant4Random();
    58   //randomGenerator = new G4Ranecu();
    59   varntp = new G4VarNtp();
    60   pace = new G4Pace();
    61   ald = new G4Ald();
    62   eenuc = new G4Eenuc();
    63   ec2sub = new G4Ec2sub();
    64   ecld = new G4Ecld();
    65   fb = new G4Fb();
    66   fiss = new G4Fiss();
    67   opt = new G4Opt();
    68 }
    6942
    7043G4Abla::G4Abla(G4Hazard *aHazard, G4Volant *aVolant, G4VarNtp *aVarntp)
     
    10982G4Abla::~G4Abla()
    11083{
     84  delete fissionModel;
    11185  delete randomGenerator;
    11286  delete pace;
     
    483457      //               G4double *pleva_par, G4double *pxeva_par, G4double *pyeva_par,
    484458      //               G4double *ff_par, G4int *inttype_par, G4int *inum_par);
    485       G4double zf1, af1, malpha1, ffpleva1, ffpxeva1, ffpyeva1;
    486       G4int ff1, ftype1;
     459      G4double zf1 = 0.0, af1 = 0.0, malpha1 = 0.0, ffpleva1 = 0.0, ffpxeva1 = 0.0, ffpyeva1 = 0.0;
     460      G4int ff1 = 0, ftype1 = 0;
    487461      evapora(zff1, aff1, epf1_out, 0.0, &zf1, &af1, &malpha1, &ffpleva1,
    488462              &ffpxeva1, &ffpyeva1, &ff1, &ftype1, &inum);
     
    560534      //               G4double *pleva_par, G4double *pxeva_par, G4double *pyeva_par,
    561535      //               G4double *ff_par, G4int *inttype_par, G4int *inum_par);
    562       G4double zf2, af2, malpha2, ffpleva2, ffpxeva2, ffpyeva2;
    563       G4int ff2, ftype2;
     536      G4double zf2 = 0.0, af2 = 0.0, malpha2 = 0.0, ffpleva2 = 0.0, ffpxeva2 = 0.0, ffpyeva2 = 0.0;
     537      G4int ff2 = 0, ftype2 = 0;
    564538      evapora(zff2,aff2,epf2_out,0.0,&zf2,&af2,&malpha2,&ffpleva2,
    565539              &ffpxeva2,&ffpyeva2,&ff2,&ftype2,&inum);
     
    16081582                    G4double *sbp_par, G4double *sba_par, G4double *ecn_par,
    16091583                    G4double *ecp_par,G4double *eca_par, G4double *bp_par,
    1610                     G4double *ba_par, G4int inttype, G4int inum, G4int itest)
     1584                    G4double *ba_par, G4int, G4int inum, G4int itest)
    16111585{
    16121586  G4int dummy0 = 0;
     
    17581732
    17591733  imaxwell = 1;
    1760   inttype = 0;
    17611734 
    17621735  // limiting of excitation energy where fission occurs                   
     
    28422815  i = idint(y/(2.0e-02)) + 1;
    28432816   
    2844   if(i >= bsbkSize) {
     2817  if((i + 1) >= bsbkSize) {
    28452818    if(verboseLevel > 2) {
    2846       G4cout <<"G4Abla error: index i = " << i << " is greater than array size permits." << G4endl;
     2819      G4cout <<"G4Abla error: index " << i + 1 << " is greater than array size permits." << G4endl;
    28472820    }
    28482821    bipolResult = 0.0;
     
    37043677// own class
    37053678
    3706 void G4Abla::standardRandom(G4double *rndm, G4long *seed)
    3707 {
    3708   (*seed) = (*seed); // Avoid warning during compilation.
     3679void G4Abla::standardRandom(G4double *rndm, G4long*)
     3680{
    37093681  // Use Geant4 G4UniformRand
    37103682  (*rndm) = randomGenerator->getRandom();
  • trunk/source/processes/hadronic/models/incl/src/G4AblaFission.cc

    r968 r1347  
    2424// ********************************************************************
    2525//
    26 // $Id: G4AblaFission.cc,v 1.3 2008/11/06 08:42:00 gcosmo Exp $
     26// $Id: G4AblaFission.cc,v 1.5 2010/11/17 20:19:09 kaitanie Exp $
    2727// Translation of INCL4.2/ABLA V3
    2828// Pekka Kaitaniemi, HIP (translation)
     
    3636G4AblaFission::G4AblaFission()
    3737{
     38  hazard = 0;
     39  randomGenerator = 0;
    3840}
    3941
     
    10861088}
    10871089
    1088 void G4AblaFission::standardRandom(G4double *rndm, G4long *seed)
    1089 {
    1090   (*seed) = (*seed); // Avoid warning during compilation.
     1090void G4AblaFission::standardRandom(G4double *rndm, G4long*)
     1091{
    10911092  // Use Geant4 G4UniformRand
    10921093  (*rndm) = randomGenerator->getRandom();
  • trunk/source/processes/hadronic/models/incl/src/G4AblaFissionSimfis18.cc

    r968 r1347  
    2424// ********************************************************************
    2525//
    26 // $Id: G4AblaFissionSimfis18.cc,v 1.3 2008/11/06 08:42:00 gcosmo Exp $
     26// $Id: G4AblaFissionSimfis18.cc,v 1.5 2010/11/17 20:19:09 kaitanie Exp $
    2727// Translation of INCL4.2/ABLA V3
    2828// Pekka Kaitaniemi, HIP (translation)
     
    3636G4AblaFissionSimfis18::G4AblaFissionSimfis18()
    3737{
     38  hazard = 0;
     39  randomGenerator = 0;
    3840}
    3941
     
    14121414}
    14131415
    1414 void G4AblaFissionSimfis18::standardRandom(G4double *rndm, G4long *seed)
    1415 {
    1416   (*seed) = (*seed); // Avoid warning during compilation.
     1416void G4AblaFissionSimfis18::standardRandom(G4double *rndm, G4long*)
     1417{
    14171418  // Use Geant4 G4UniformRand
    14181419  (*rndm) = randomGenerator->getRandom();
  • trunk/source/processes/hadronic/models/incl/src/G4Incl.cc

    r1340 r1347  
    2424// ********************************************************************
    2525//
    26 // $Id: G4Incl.cc,v 1.33 2010/10/29 06:48:43 gunter Exp $
     26// $Id: G4Incl.cc,v 1.37 2010/12/15 07:41:31 gunter Exp $
    2727// Translation of INCL4.2/ABLA V3
    2828// Pekka Kaitaniemi, HIP (translation)
     
    5757  randomGenerator = new G4InclGeant4Random();
    5858  //  randomGenerator = new G4Ranecu();
     59  clearState();
    5960}
    6061
     
    8586  //  randomGenerator = new G4Ranecu();
    8687  randomGenerator = new G4InclGeant4Random();
     88  clearState();
    8789}
    8890
     
    149151
    150152  theLogger = 0;
     153  clearState();
    151154}
    152155
    153156G4Incl::~G4Incl()
    154157{
     158  delete be;
     159  delete ps;
     160  delete fermi;
     161  delete qvp;
     162
    155163  delete randomGenerator;
    156164  delete light_gaus_nuc;
     
    385393void G4Incl::processEventIncl(G4InclInput *input)
    386394{
     395  //G4cout <<"Starting event " << eventnumber << G4endl;
    387396  if(input == 0) {
    388397    G4cerr <<"G4Incl fatal error: NULL pointer passed as input!" << G4endl;
     
    393402  const G4double uma = 931.4942;
    394403  const G4double melec = 0.511;
    395 
    396   G4double   pcorem = 0.0;
    397   G4double   pxrem = 0.0;
    398   G4double   pyrem = 0.0;
    399   G4double   pzrem = 0.0;
     404  const G4double fmp = 938.2796;
     405
     406  G4double pcorem = 0.0;
     407  G4double pxrem = 0.0;
     408  G4double pyrem = 0.0;
     409  G4double pzrem = 0.0;
    400410
    401411  G4double ap = 0.0, zp = 0.0, mprojo = 0.0, pbeam = 0.0;
    402412
    403413  varntp->clear();
    404   if(calincl->bulletType() == 3) { // pi+
     414
     415  if(calincl->bulletType() == -12) {
     416    be->ia_be = std::abs(calincl->bulletType());
     417    be->iz_be = 6;
     418  } else if(calincl->bulletType() == -666) {
     419    be->iz_be = calincl->extendedProjectileZ();
     420    be->ia_be = calincl->extendedProjectileA();
     421  }
     422
     423  if(calincl->isExtendedProjectile() == false && calincl->bulletType() < -max_a_proj) {
     424  //  if(calincl->bulletType() < -max_a_proj) {
     425    G4cout <<"max a of composite projectile is: " << max_a_proj << G4endl;
     426    exit(0);
     427  }
     428  if(calincl->bulletType() < 0) {
     429    //    calincl->bulletType() = std::floor(calincl->bulletType() + 0.1); WTF???
     430    be->pms_be=100.;
     431    G4int i_tabled=0;
     432    if(be->iz_be == 3 && be->ia_be == 6) {
     433      be->rms_be=2.56;
     434      be->bind_be=32.0;
     435      i_tabled=1;
     436    } else if(be->iz_be == 3 && be->ia_be == 7) { // TODO: Check the values!
     437      be->rms_be=2.56;
     438      be->bind_be=32.0;
     439      i_tabled=1;
     440    } else if(be->iz_be == 3 && be->ia_be == 8) {
     441      be->rms_be=2.40;
     442      be->bind_be=39.25;
     443      i_tabled=1;
     444    } else if(be->iz_be == 4 && be->ia_be == 7) {
     445      be->rms_be=2.51;
     446      be->bind_be=58.17;
     447      i_tabled=1;
     448    } else if(be->iz_be == 4 && be->ia_be == 9) {
     449      be->rms_be=2.51;
     450      be->bind_be=58.17;
     451      i_tabled=1;
     452    } else if(be->iz_be == 4 && be->ia_be == 10) {
     453      be->rms_be=2.45;
     454      be->bind_be=64.75;
     455      i_tabled=1;
     456    } else if(be->iz_be == 5 && be->ia_be == 10) {
     457      be->rms_be=2.45;
     458      be->bind_be=64.75;
     459      i_tabled=1;
     460    } else if(be->iz_be == 5 && be->ia_be == 11) {
     461      be->rms_be=2.40;
     462      be->bind_be=76.21;
     463      i_tabled=1;
     464    } else if(be->iz_be == 6 && be->ia_be == 9) { // TODO: Check the values!
     465      be->rms_be=2.44;
     466      be->bind_be=92.17;
     467      i_tabled=1;
     468    } else if(be->iz_be == 6 && be->ia_be == 10) { // TODO: Check the values!
     469      be->rms_be=2.44;
     470      be->bind_be=92.17;
     471      i_tabled=1;
     472    } else if(be->iz_be == 6 && be->ia_be == 11) { // TODO: Check the values!
     473      be->rms_be=2.44;
     474      be->bind_be=92.17;
     475      i_tabled=1;
     476    } else if(be->iz_be == 6 && calincl->bulletType() == -12) { // Special Carbon case
     477      G4cout <<"Carbon 12 (special) selected." << G4endl;
     478      be->rms_be=2.44;
     479      be->bind_be=92.17;
     480      i_tabled=1;
     481    } else if(be->iz_be == 6 && be->ia_be == 12) {
     482      be->rms_be=2.44;
     483      be->bind_be=92.17;
     484      i_tabled=1;
     485    } else if(be->iz_be == 7 && be->ia_be == 16) {
     486      be->rms_be=2.73;
     487      be->bind_be=127.62;
     488      i_tabled=1;
     489    } else {
     490      G4cout <<"Warning: No rms and binding for projectile ion A = " << be->ia_be << " Z = " << be->iz_be << G4endl;
     491      be->rms_be=2.44;
     492      be->bind_be=92.17;
     493      G4cout <<"Warning: Using probably bad values rms = " << be->rms_be << " binding = " << be->bind_be << G4endl;
     494      i_tabled=1;     
     495    }
     496     
     497    if(i_tabled == 0) {
     498      G4cout <<"This heavy ion (a,z)= " << be->ia_be << " " << be->iz_be << " is not defined as beam in INCL" << G4endl;
     499      exit(0);
     500    }
     501     
     502    //    G4cout <<"z projectile, rms_r, rms_p (gaussian model)" << be->iz_be << " " << be->rms_be << " " << be->pms_be << G4endl;
     503    //    G4cout <<"binding energy (mev):" << be->bind_be << G4endl;
     504    //    G4cout <<"fermi-breakup dresner below a=" << calincl->f[11] << G4endl;
     505  }     
     506  //  G4cout <<"Target Mass and Charge: " << calincl->targetA() << " " << calincl->targetZ() << G4endl;
     507  //  calincl->f[10] = 0; // No clusters
     508
     509  if(calincl->bulletType() == -12) {  // C12 special case
     510    mprojo=fmp*std::abs(calincl->bulletType()) - be->bind_be;
     511    pbeam=std::sqrt(calincl->bulletE()*(calincl->bulletE()+2.*mprojo));
     512    ap=std::abs(calincl->bulletType());
     513    zp=be->iz_be;
     514  } else if(calincl->bulletType() == -666) { // Generic extended projectile
     515    mprojo=fmp*be->ia_be - be->bind_be;
     516    pbeam=std::sqrt(calincl->bulletE()*(calincl->bulletE()+2.*mprojo));
     517    ap=be->ia_be;
     518    zp=be->iz_be;
     519  }
     520  // pi+
     521  if(calincl->bulletType() == 3) {
    405522    mprojo = 139.56995;
    406523    ap = 0.0;
     
    408525  }
    409526
    410   if(calincl->bulletType() == 4) { // pi0
     527  // pi0
     528  if(calincl->bulletType() == 4) {
    411529    mprojo = 134.9764;
    412530    ap = 0.0;
     
    414532  }
    415533
    416   if(calincl->bulletType() == 5) { // pi-
     534  // pi-
     535  if(calincl->bulletType() == 5) {
    417536    mprojo = 139.56995;
    418537    ap = 0.0;
     
    420539  }
    421540
    422   // Coulomb en entree seulement pour les particules ci-dessous.
    423   if(calincl->bulletType() == 1) { // proton
     541  // coulomb en entree seulement pour les particules ci-dessous
     542
     543  // proton
     544  if(calincl->bulletType() == 1) {
    424545    mprojo = 938.27231;
    425546    ap = 1.0;
    426547    zp = 1.0;
    427548  }
    428  
    429   if(calincl->bulletType() == 2) { // neutron 
     549
     550  // neutron 
     551  if(calincl->bulletType() == 2) {
    430552    mprojo = 939.56563;
    431553    ap = 1.0;
    432554    zp = 0.0;
    433555  }
    434  
    435   if(calincl->bulletType() == 6) { // deuteron
     556
     557  // deuteron
     558  if(calincl->bulletType() == 6) {
    436559    mprojo = 1875.61276;
    437560    ap = 2.0;
    438561    zp = 1.0;
    439562  }
    440  
    441   if(calincl->bulletType() == 7) { // triton
     563
     564  // triton
     565  if(calincl->bulletType() == 7) {
    442566    mprojo = 2808.95;
    443567    ap = 3.0;
    444568    zp = 1.0;
    445569  }
    446  
    447   if(calincl->bulletType() == 8) { // He3
     570
     571  // He3
     572  if(calincl->bulletType() == 8) {
    448573    mprojo = 2808.42;
    449574    ap = 3.0;
     
    451576  }
    452577
    453   if(calincl->bulletType() == 9) { // Alpha
     578  // Alpha
     579  if(calincl->bulletType() == 9) {
    454580    mprojo = 3727.42;
    455581    ap = 4.0;
     
    457583  }
    458584
    459   if(calincl->bulletType() == -12) { // Carbon
    460     mprojo = 12.0 * 938.27231;
     585  // Carbon
     586  if(calincl->bulletType() == -12) {
     587    mprojo = 6.0*938.27231 + 6.0*939.56563;
    461588    ap = 12.0;
    462589    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();
    467590  }
    468591
     
    482605  G4double bimpac = 0.0;
    483606  G4int jrem = 0;
     607  G4double xjrem = 0.0, yjrem = 0.0, zjrem = 0.0;
    484608  G4double alrem = 0.0;
    485609
    486   /**
    487    * Coulomb barrier treatment.
    488    */
     610  // Coulomb barrier
     611 
    489612  G4double probaTrans = 0.0;
    490613  G4double rndm = 0.0;
    491614
    492615  if((calincl->bulletType() == 1) || (calincl->bulletType() >= 6)) {
     616    //    probaTrans = coulombTransm(calincl->bulletE(),apro,zpro,calincl->targetA(),calincl->targetZ());
    493617    probaTrans = coulombTransm(calincl->bulletE(),ap,zp,calincl->targetA(),calincl->targetZ());
    494618    standardRandom(&rndm, &(hazard->ial));
     
    499623  }
    500624
    501   /**
    502    * Call the actual INCL routine.
    503    */
    504 
     625  //  G4cout <<"Before PNU:" << G4endl;
    505626  //  randomGenerator->printSeeds();
    506   G4double jremx, jremy, jremz;
    507   pnu(&ibert, &nopart,&izrem,&iarem,&esrem,&erecrem,&alrem,&berem,&garem,&bimpac,&jrem,
    508       &jremx, &jremy, &jremz);
     627  // Call the actual INCL routine:
     628  pnu(&ibert, &nopart,&izrem,&iarem,&esrem,&erecrem,&alrem,&berem,&garem,&bimpac,
     629      &jrem, &xjrem, &yjrem, &zjrem);
     630  //  G4cout <<"After PNU:" << G4endl;
     631  //  randomGenerator->printSeeds();
     632  G4double mrem = int(zjrem/197.328); // CHECK
     633  if (mrem > jrem) mrem=jrem;
     634  if (mrem < -jrem) mrem=-jrem;
     635
     636//   nopart=1;
     637//   kind[0]=1;
     638//   ep[0]=799.835;
     639//   alpha[0]=0.08716;
     640//   beta[0]=0.;
     641//   gam[0]=0.99619;
     642//   izrem=82;
     643//   iarem=208;
     644//   esrem=200.;
     645//   erecrem=0.18870;
     646//   alrem=-0.47101;
     647//   berem=0.;
     648//   garem=0.88213;
     649//   bimpac=2.;
    509650  forceAbsor(&nopart, &iarem, &izrem, &esrem, &erecrem, &alrem, &berem, &garem, &jrem);
    510   G4double aprf = double(iarem); // mass number of the prefragment
    511   G4double jprf = 0.0;           // angular momentum of the prefragment
    512 
    513   // Mean angular momentum of prefragment.                                 
    514   jprf = 0.165 * std::pow(at,(2.0/3.0)) * aprf * (at - aprf) / (at - 1.0);                               
     651  G4double aprf = double(iarem);    // mass number of the prefragment
     652  G4double jprf = 0.0;                // angular momentum of the prefragment
     653
     654  // Mean angular momentum of prefragment                                 
     655  jprf = 0.165 * std::pow(at,(2.0/3.0)) * aprf*(at - aprf)/(at - 1.0);                               
    515656  if (jprf < 0) {
    516657    jprf = 0.0;
    517658  }
    518659
    519   // Reference M. de Jong, Ignatyuk, Schmidt Nuc. Phys A 613, p442, 7th line
     660  // check m.de jong, ignatyuk, schmidt nuc.phys a 613, pg442, 7th line
    520661  jprf = std::sqrt(2*jprf);
     662
    521663  jprf = jrem;
    522   varntp->jremn = jrem; // Copy jrem to output tuple.
    523 
    524   G4double numpi = 0;  // Number  of pions.
    525   G4double multn = 0;  // Number (multiplicity) of neutrons.
    526   G4double multp = 0;  // Number (multiplicity) of protons.
    527 
    528   // Ecriture dans le ntuple des particules de cascade (sauf remnant).     
    529   varntp->ntrack = nopart; // Nombre de particules pour ce tir.
     664  varntp->jremn = jrem;      // jrem copie dans le ntuple
     665
     666  G4double numpi = 0;  // compteurs de pions, neutrons protons
     667  G4double multn = 0;
     668  G4double multp = 0;
     669
     670  // ecriture dans le ntuple des particules de cascade (sauf remnant)     
     671  varntp->ntrack = nopart;          // nombre de particules pour ce tir
     672  if(varntp->ntrack >= VARNTPSIZE) {
     673    if(verboseLevel > 2) {
     674      G4cout <<"G4Incl error: Output data structure not big enough." << G4endl;
     675    }
     676  }
    530677  varntp->massini = iarem;
    531678  varntp->mzini = izrem;
     
    533680  varntp->bimpact = bimpac;
    534681 
    535   /**
    536    * Three ways to compute the mass of the remnant:
    537    * -from the output of the cascade and the canonic mass
    538    * -from energy balance (input - all emitted energies)
    539    * -following the approximations of the cugnon code (esrem...)
    540    */
    541   G4double f0 = calincl->targetA();
    542   G4double f1 = calincl->targetZ();
    543   G4double f2 = calincl->bulletE();
    544   G4double mcorem = mprojo + f2 + abla->pace2(f0, f1) + f0 * uma - f1 * melec;
     682  //  three ways to compute the mass of the remnant:
     683  //                -from the output of the cascade and the canonic mass
     684  //                -from energy balance (input - all emitted energies)
     685  //                -following the approximations of the cugnon code (esrem...)
     686  G4double mcorem = mprojo + calincl->bulletE() + abla->pace2(double(calincl->targetA()),double(calincl->targetZ()))
     687    + calincl->targetA()*uma - calincl->targetZ()*melec;
    545688
    546689  G4double pxbil = 0.0;
     
    549692
    550693  if(nopart > -1) {
    551     for(G4int j = 0; j < nopart; j++) {
    552       varntp->itypcasc[j] = 1;
     694    // Fill the projectile spectator variables
     695    varntp->masp = ps->a_projspec;
     696    varntp->mzsp = ps->z_projspec;
     697    varntp->exsp = ps->ex_projspec;
     698    varntp->spectatorP1 = ps->p1_projspec;
     699    varntp->spectatorP2 = ps->p2_projspec;
     700    varntp->spectatorP3 = ps->p3_projspec;
     701    varntp->spectatorT = ps->t_projspec;
     702    for(G4int j = 0; j <= nopart; j++) {
     703      if(ep[j] < 0.0) { // Workaround to avoid negative energies (and taking std::sqrt of a negative number).
     704        G4cout <<"G4Incl: Not registering particle with energy: " << ep[j] << G4endl;
     705        continue;
     706      }
     707      if(kind[j] == 0) continue; // Empty particle rows are sometimes produced by lurking indexing problems. We can simply skip those "bad" entries...
     708      if(gam[j] > CLHEP::pi) {
     709        if(verboseLevel > 2) {
     710          G4cout <<"G4Incl: Just avoided floating point exception by using an ugly hack..." << G4endl;
     711        }
     712        continue; // Avoid floating point exception
     713      }
     714
     715      varntp->itypcasc[j] = 1; // Particle was produced by the cascade
     716      // Spectators of composite projectiles (7/2006, AB)
     717      // (kind is negative in that case)
     718      if(kind[j] <= 0) { // Particle is a projectile spectator that comes directly from the cascade
     719        kind[j] *= -1;
     720        varntp->itypcasc[j]=-1;
     721        //      G4cout <<"Spectator registered!" << G4endl;
     722        //      continue;
     723      }
     724       
    553725      // kind(): 1=proton, 2=neutron, 3=pi+, 4=pi0, 5=pi -     
    554726      if(kind[j] == 1) {
    555727        varntp->avv[j] = 1;
    556728        varntp->zvv[j] = 1;
    557         varntp->plab[j] = std::sqrt(ep[j] * (ep[j] + 1876.5592)); // cugnon
     729        varntp->plab[j] = std::sqrt(ep[j]*(ep[j]+1876.5592)); // cugnon
    558730        multp = multp + 1;
    559731        mcorem = mcorem - ep[j] - 938.27231;
     
    568740        varntp->zvv[j] = 0;
    569741        varntp->plab[j] = std::sqrt(ep[j]*(ep[j]+1876.5592)); // cugnon
    570         //varntp->plab[j] = std::sqrt(ep[j] * (ep[j] + 1879.13126)); // PK mass check
    571742        multn = multn + 1;
    572743        mcorem = mcorem - ep[j] - 939.56563;
     
    576747        }
    577748      }
    578 
     749     
    579750      if(kind[j] == 3) {
    580751        varntp->avv[j] = -1;
     
    656827        mcorem = mcorem - ep[j] - 3724.818;
    657828        if(verboseLevel > 3) {
    658           G4cout <<"G4Incl: He4 produced! " << G4endl;
     829          G4cout <<"G4Incl: He3 produced! " << G4endl;
    659830          G4cout <<"G4Incl: Momentum: "<< varntp->plab[j] << G4endl;
    660831        }
     
    669840
    670841      if(verboseLevel > 3) {
    671         G4cout <<"Momentum: " << varntp->plab[j] << G4endl;
    672         G4cout <<"Theta: " << varntp->tetlab[j] << G4endl;
    673         G4cout <<"Phi: " << varntp->philab[j] << G4endl;
     842        G4cout <<"Momentum: " << varntp->plab[j]   << G4endl;
     843        G4cout <<"Theta: "    << varntp->tetlab[j] << G4endl;
     844        G4cout <<"Phi: "      << varntp->philab[j] << G4endl;
    674845      }
    675846    }
    676847
    677848    // calcul de la masse (impulsion) du remnant coherente avec la conservation d'energie:
    678     pcorem=std::sqrt(erecrem*(erecrem +2.*938.2796*iarem));   // cugnon
    679     mcorem = 938.2796*iarem;                               // cugnon
    680                
     849    pcorem = std::sqrt(erecrem*(erecrem + 2.0 * 938.2796 * iarem));   // cugnon
     850    mcorem = 938.2796 * iarem;                               // cugnon
     851    varntp->pcorem = pcorem;
     852    varntp->mcorem = mcorem;
    681853    // Note: Il faut negliger l'energie d'excitation (ESREM) pour que le bilan
    682854    // d'impulsion soit correct a la sortie de la cascade.....et prendre la
    683855    // masse MCOREM comme ci-dessus (fausse de ~1GeV par rapport aux tables...)       
    684     pxrem=pcorem*alrem;
    685     pyrem=pcorem*berem;
    686     pzrem=pcorem*garem;
    687        
    688     pxbil=pxbil+pxrem;
    689     pybil=pybil+pyrem;
    690     pzbil=pzbil+pzrem;
    691 
    692     if((std::fabs(pzbil-pbeam) > 5.0) || (std::sqrt(std::pow(pxbil,2)+std::pow(pybil,2)) >= 3.0)) {
     856    pxrem = pcorem * alrem;
     857    pyrem = pcorem * berem;
     858    pzrem = pcorem * garem;
     859    varntp->pxrem = pxrem;
     860    varntp->pyrem = pyrem;
     861    varntp->pzrem = pzrem;
     862    pxbil = pxbil + pxrem;
     863    pybil = pybil + pyrem;
     864    pzbil = pzbil + pzrem;
     865
     866    // If on purpose, add here the spectator nuclei:   
     867    if(calincl->bulletType() < 0 && ps->a_projspec != 0) {
     868      pxbil=pxbil+ps->p1_projspec;
     869      pybil=pybil+ps->p2_projspec;
     870      pzbil=pzbil+ps->p3_projspec;
     871    }
     872
     873    if((std::fabs(pzbil - pbeam) > 5.0) || (std::sqrt(std::pow(pxbil,2) + std::pow(pybil,2)) >= 3.0)) {
    693874      if(verboseLevel > 3) {
    694875        G4cout <<"Bad momentum conservation after INCL:" << G4endl;
     
    704885    varntp->iafis = 0;
    705886
    706     //  varntp->ntrack = varntp->ntrack + 1;  // on recopie le remnant dans le ntuple
     887    // on recopie le remnant dans le ntuple
     888    varntp->ntrack = varntp->ntrack + 1;
    707889    varntp->massini = iarem;
    708890    varntp->mzini = izrem;
    709891    varntp->exini = esrem;
    710     varntp->itypcasc[varntp->ntrack] = 1;
    711     varntp->avv[varntp->ntrack] = iarem;
    712     varntp->zvv[varntp->ntrack]= izrem;
    713     varntp->plab[varntp->ntrack] = pcorem;
    714     varntp->enerj[varntp->ntrack] = std::sqrt(std::pow(pcorem,2) + std::pow(mcorem,2)) - mcorem;
    715     varntp->tetlab[varntp->ntrack] = 180.0*std::acos(garem)/3.141592654;
    716     varntp->philab[varntp->ntrack] = 180.0*std::atan2(berem,alrem)/3.141592654;
    717     varntp->ntrack++;
    718     varntp->mulncasc = varntp->ntrack;
    719     varntp->mulnevap = 0;
    720     varntp->mulntot = varntp->mulncasc + varntp->mulnevap;
    721     if(verboseLevel > 3) {
    722       G4cout <<"G4Incl: Returning nucleus fragment. " << G4endl;
    723       G4cout <<"G4Incl: Fragment A = " << varntp->avv[varntp->ntrack] << " Z = " << varntp->zvv[varntp->ntrack] << G4endl;
    724       G4cout <<"Energy: " << varntp->enerj[varntp->ntrack] << G4endl;
    725       G4cout <<"Momentum: " << varntp->plab[varntp->ntrack] << G4endl;
    726       G4cout <<"Theta: " << varntp->tetlab[varntp->ntrack] << G4endl;
    727       G4cout <<"Phi: " << varntp->philab[varntp->ntrack] << G4endl;
    728     }
    729   }
    730   else {
    731     if(nopart == -2) {
    732       varntp->ntrack = -2; //FIX: Error flag to remove events containing unphysical events (Ekin > Ebullet).
    733     }
    734     else {
    735       varntp->ntrack = -1;
    736     }
     892    varntp->pxrem = pxrem;
     893    varntp->pyrem = pyrem;
     894    varntp->pzrem = pzrem;
     895    varntp->mcorem = mcorem;
     896    varntp->erecrem = pcorem;
     897    varntp->erecrem = erecrem;
     898
     899#ifdef G4INCLDEBUG
     900    theLogger->fillHistogram1D("bimpact", varntp->bimpact);
     901#endif
     902
     903#ifdef G4INCLDEBUG
     904    theLogger->fillHistogram1D("mzini", varntp->mzini);
     905#endif
     906  }
     907  if(nopart == -2) {
     908    varntp->ntrack = -2; //FIX: Error flag to remove events containing unphysical events (Ekin > Ebullet).
     909    evaporationResult->ntrack = -2; //FIX: Error flag to remove events containing unphysical events (Ekin > Ebullet).
     910  }
     911  else if(nopart == -1) {
     912    varntp->ntrack = -1;
     913    evaporationResult->ntrack = -1;
     914  }
     915  if(verboseLevel > 2) {
     916    G4cout << __FILE__ << ":" << __LINE__ << "Dump varntp after combining: " << G4endl;
     917    varntp->dump();
    737918  }
    738919}
     
    81508331}
    81518332
    8152 void G4Incl::standardRandom(G4double *rndm, G4long *seed)
    8153 {
    8154   (*seed) = (*seed); // Avoid warning during compilation.
     8333void G4Incl::standardRandom(G4double *rndm, G4long*)
     8334{
    81558335  // Use Geant4 G4UniformRand
    81568336  //  (*rndm) = G4UniformRand();
     
    85508730    } // enddo
    85518731    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);
     8732    G4double s_spec = std::sqrt(std::pow(e_spec,2)-p_spec2);
    85538733
    85548734    // no projectile spectator if a>=4 and a=z or a=n (no dresner breakup)
     
    88449024}
    88459025
     9026// Initialization helper
     9027void G4Incl::clearState() {
     9028  G4int epSize = 300;
     9029  for(G4int i = 0; i < epSize; ++i) {
     9030    kind[i] = 0;
     9031    ep[i] = 0.0;
     9032    alpha[i] = 0.0;
     9033    beta[i] = 0.0;
     9034    gam[i] = 0.0;
     9035  }
     9036  inside_step = 0;
     9037}
     9038
    88469039// C------------------------------------------------------------------------
    88479040// C Logging
     
    89239116//       COMMON/BL2/CROIS(19900),K,IND(20000),JND(20000)
    89249117//       COMMON/BL3/R1,R2,X1(300),X2(300),X3(300),IA1,IA2,RAB2             P-N22270
     9118
     9119  if(index < 0) {
     9120    G4cout <<";; Error! index < 0! index = " << index << G4endl;
     9121    return;
     9122  }
    89259123
    89269124  G4int i_ind1 = bl1->ind1[bl2->ind[index]];
  • trunk/source/processes/hadronic/models/incl/src/G4InclAblaCascadeInterface.cc

    r1340 r1347  
    2424// ********************************************************************
    2525//
    26 // $Id: G4InclAblaCascadeInterface.cc,v 1.16 2010/10/29 06:48:43 gunter Exp $
     26// $Id: G4InclAblaCascadeInterface.cc,v 1.20 2010/11/17 20:19:09 kaitanie Exp $
    2727// Translation of INCL4.2/ABLA V3
    2828// Pekka Kaitaniemi, HIP (translation)
     
    116116  incl->setInput(calincl);
    117117
    118   G4InclInput::printProjectileTargetInfo(aTrack, theNucleus);
    119   calincl->printInfo();
     118  //  G4InclInput::printProjectileTargetInfo(aTrack, theNucleus);
     119  //  calincl->printInfo();
    120120
    121121#ifdef DEBUGINCL
     
    439439        }
    440440      }
     441      delete theFermiBreakupResult;
     442      theFermiBreakupResult = 0;
     443
    441444      if(std::abs(fourMomentumBalance.mag() / MeV) > 0.1 * MeV) {
    442445        G4cout <<"Four-momentum balance after remnant nucleus Fermi break-up:" << G4endl;
  • trunk/source/processes/hadronic/models/incl/src/G4InclAblaDataFile.cc

    r1337 r1347  
    2424// ********************************************************************
    2525//
    26 // $Id: G4InclAblaDataFile.cc,v 1.9 2010/06/14 16:10:01 gcosmo Exp $
     26// $Id: G4InclAblaDataFile.cc,v 1.10 2010/11/17 20:19:09 kaitanie Exp $
    2727// Translation of INCL4.2/ABLA V3
    2828// Pekka Kaitaniemi, HIP (translation)
     
    116116  vgsldin.close();
    117117
    118   int A = 0, Zbegin = 0, Zend = 0;
    119118  G4String str1, str2, str3;
    120119  for(int i = 0; i < 500; i++) {
     
    124123  }
    125124 
     125  int A = 0, Zbegin = 0, Zend = 0;
    126126  for(int i = 0; i < massnumbers; i++) {
    127127    pace2in >> str1 >> A >> str2 >> Zbegin >> str3 >> Zend;
    128     for(int j = Zbegin; j <= Zend; j++) {
    129       pace2in >> pace2;
    130       setPace2(A, j, pace2);
     128    if(Zbegin >= 0 && Zbegin < getPaceCols() &&
     129       A >= 0 && A < getPaceRows()) {
     130      for(int j = Zbegin; j <= Zend; j++) {
     131        pace2in >> pace2;
     132        setPace2(A, j, pace2);
     133      }
    131134    }
    132135  }
  • trunk/source/processes/hadronic/models/incl/src/G4InclAblaLightIonInterface.cc

    r1340 r1347  
    2424// ********************************************************************
    2525//
    26 // $Id: G4InclAblaLightIonInterface.cc,v 1.14 2010/10/29 06:48:43 gunter Exp $
     26// $Id: G4InclAblaLightIonInterface.cc,v 1.16 2010/11/17 20:19:09 kaitanie Exp $
    2727// Translation of INCL4.2/ABLA V3
    2828// Pekka Kaitaniemi, HIP (translation)
     
    103103  }
    104104
    105   if(verboseLevel > 1) {
    106     G4Calincl::printProjectileTargetInfo(aTrack, theNucleus);
    107   }
    108 
    109105  // Inverse kinematics for targets with Z = 1 and A = 1
    110106  //  if(false) {
    111107  G4LorentzRotation toBreit = aTrack.Get4Momentum().boostVector();
    112108
    113   if(theNucleus.GetZ_asInt() == 1 && theNucleus.GetA_asInt() == 1 && G4Calincl::canUseInverseKinematics(aTrack, theNucleus)) {
     109  if(theNucleus.GetZ_asInt() == 1 && theNucleus.GetA_asInt() == 1 && G4InclInput::canUseInverseKinematics(aTrack, theNucleus)) {
    114110    G4ParticleDefinition *oldTargetDef = theTableOfParticles->GetIon(theNucleus.GetA_asInt(), theNucleus.GetZ_asInt(), 0.0);
    115111    const G4ParticleDefinition *oldProjectileDef = aTrack.GetDefinition();
    116112
     113    if(oldProjectileDef != 0 && oldTargetDef != 0) {
    117114    G4int oldTargetA = oldTargetDef->GetAtomicMass();
    118115    G4int newTargetA = oldProjectileDef->GetAtomicMass();
    119116    G4int newTargetZ = oldProjectileDef->GetAtomicNumber();
    120117
    121     if(newTargetA > 0 && newTargetZ > 0 && oldTargetDef != 0 && oldProjectileDef != 0) {
     118    if(newTargetA > 0 && newTargetZ > 0) {
    122119      G4Nucleus swappedTarget(oldProjectileDef->GetAtomicMass(), oldProjectileDef->GetAtomicNumber());
    123120
     
    137134      G4cout <<"Badly defined target after swapping. Falling back to normal (non-swapped) mode." << G4endl;
    138135      calincl = new G4InclInput(aTrack, theNucleus, false);
     136    }
    139137    }
    140138  } else {
     
    489487        }
    490488      }
     489      delete theSpectatorFermiBreakupResult;
     490      theSpectatorFermiBreakupResult = 0;
     491
    491492      if(std::abs(fourMomentumBalance.mag() / MeV) > 0.1 * MeV) {
    492493        G4cout <<"Four-momentum balance after spectator nucleus Fermi break-up:" << G4endl;
     
    588589        }
    589590      }
     591      delete theFermiBreakupResult;
     592      theFermiBreakupResult = 0;
     593
    590594      if(std::abs(fourMomentumBalance.mag() / MeV) > 0.1 * MeV) {
    591595        G4cout <<"Four-momentum balance after remnant nucleus Fermi break-up:" << G4endl;
     
    697701  }
    698702
     703  delete fermiBreakUp;
    699704  delete calincl;
    700705  calincl = 0;
  • trunk/source/processes/hadronic/models/incl/src/G4InclCascadeInterface.cc

    r1340 r1347  
    2424// ********************************************************************
    2525//
    26 // $Id: G4InclCascadeInterface.cc,v 1.12 2010/10/26 02:47:59 kaitanie Exp $
     26// $Id: G4InclCascadeInterface.cc,v 1.15 2010/11/17 20:19:09 kaitanie Exp $
    2727// Translation of INCL4.2/ABLA V3
    2828// Pekka Kaitaniemi, HIP (translation)
     
    3434
    3535#include "G4InclCascadeInterface.hh"
     36#include "G4FermiBreakUp.hh"
    3637#include "math.h"
    3738#include "G4GenericIon.hh"
    3839#include "CLHEP/Random/Random.h"
    3940
    40 G4InclCascadeInterface::G4InclCascadeInterface()
     41G4InclCascadeInterface::G4InclCascadeInterface(const G4String& nam)
     42  :G4VIntraNuclearTransportModel(nam)
    4143{
    4244  hazard = new G4Hazard();
     
    4547
    4648  varntp = new G4VarNtp();
    47   inclInput = 0;
     49  calincl = 0;
    4850  ws = new G4Ws();
    4951  mat = new G4Mat();
    50   incl = new G4Incl(hazard, inclInput, ws, mat, varntp);
     52  incl = new G4Incl(hazard, calincl, ws, mat, varntp);
     53
     54  theExcitationHandler = new G4ExcitationHandler;
     55  thePrecoModel = new G4PreCompoundModel(theExcitationHandler);
     56
     57  if(!getenv("G4INCLABLANOFERMIBREAKUP")) { // Use Fermi Break-up by default if it is NOT explicitly disabled
     58    incl->setUseFermiBreakUp(true);
     59  }
    5160
    5261  verboseLevel = 0;
     
    5564G4InclCascadeInterface::~G4InclCascadeInterface()
    5665{
     66  delete thePrecoModel;
     67  delete theExcitationHandler;
     68
    5769  delete hazard;
    5870  delete varntp;
    59   delete inclInput;
    6071  delete ws;
    6172  delete mat;
     
    6879
    6980  G4int particleI;
     81  G4int bulletType = 0;
    7082
    7183  // Print diagnostic messages: 0 = silent, 1 and 2 = verbose
     
    91103  G4DynamicParticle *cascadeParticle = 0;
    92104  G4ParticleDefinition *aParticleDefinition = 0;
     105 
     106  G4ReactionProductVector *thePrecoResult = 0;
     107  G4ParticleTable *theTableOfParticles = G4ParticleTable::GetParticleTable();
    93108
    94109  // INCL assumes the projectile particle is going in the direction of
     
    102117  G4LorentzRotation toLabFrame = toZ.inverse();
    103118
    104   inclInput = new G4InclInput(aTrack, theNucleus, false);
    105 
    106119  theResult.Clear(); // Make sure the output data structure is clean.
     120
     121  calincl = new G4InclInput(aTrack, theNucleus, false);
     122  incl->setInput(calincl);
     123
     124  //  G4InclInput::printProjectileTargetInfo(aTrack, theNucleus);
     125  //  calincl->printInfo();
    107126
    108127#ifdef DEBUGINCL
     
    117136  G4double eKinSum = bulletE;
    118137  G4LorentzVector labv = G4LorentzVector(0.0, 0.0, std::sqrt(bulletE*(bulletE + 2.*mass)), bulletE + mass + amass);
     138  G4LorentzVector labvA = G4LorentzVector(0.0, 0.0, 0.0, 0.0);
    119139  G4cout <<"Energy in the beginning = " << labv.e() / MeV << G4endl;
    120140#endif
    121141
    122142  // Check wheter the input is acceptable.
    123   if((inclInput->bulletType() != 0) && ((inclInput->targetA() != 1) && (inclInput->targetZ() != 1))) {
     143  if((calincl->bulletType() != 0) && ((calincl->targetA() != 1) && (calincl->targetZ() != 1))) {
    124144    ws->nosurf = -2;  // Nucleus surface, -2 = Woods-Saxon
    125145    ws->xfoisa = 8;
     
    130150
    131151    mat->nbmat = 1;
    132     mat->amat[0] = int(inclInput->targetA());
    133     mat->zmat[0] = int(inclInput->targetZ());
     152    mat->amat[0] = int(calincl->targetA());
     153    mat->zmat[0] = int(calincl->targetZ());
    134154
    135155    incl->initIncl(true);
     
    140160        G4cout <<"G4InclCascadeInterface: Try number = " << nTries << G4endl;
    141161      }
    142       incl->processEventIncl(inclInput);
     162      incl->processEventIncl(calincl);
    143163
    144164      if(verboseLevel > 1) {
     
    151171       * Diagnostic output
    152172       */
    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;
     173      G4cout <<"G4InclCascadeInterface: Bullet type: " << calincl->bulletType() << G4endl;
     174      G4cout <<"G4Incl4AblaCascadeInterface: Bullet energy: " << calincl->bulletE() << " MeV" << G4endl;
     175
     176      G4cout <<"G4InclCascadeInterface: Target A:  " << calincl->targetA() << G4endl;
     177      G4cout <<"G4InclCascadeInterface: Target Z:  " << calincl->targetZ() << G4endl;
    158178
    159179      if(verboseLevel > 3) {
    160         diagdata <<"G4InclCascadeInterface: Bullet type: " << inclInput->bulletType() << G4endl;
    161         diagdata <<"G4InclCascadeInterface: Bullet energy: " << inclInput->bulletE() << " MeV" << G4endl;
     180        diagdata <<"G4InclCascadeInterface: Bullet type: " << calincl->bulletType() << G4endl;
     181        diagdata <<"G4InclCascadeInterface: Bullet energy: " << calincl->bulletE() << " MeV" << G4endl;
    162182       
    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       // }
     183        diagdata <<"G4InclCascadeInterface: Target A:  " << calincl->targetA() << G4endl;
     184        diagdata <<"G4InclCascadeInterface: Target Z:  " << calincl->targetZ() << G4endl;
     185      }
     186
    187187    }
    188188
     
    196196
    197197      theResult.SetStatusChange(stopAndKill);
    198       aParticleDefinition = G4InclInput::getParticleDefinition(inclInput->bulletType());
    199 
    200       cascadeParticle = new G4DynamicParticle();
    201       cascadeParticle->SetDefinition(aParticleDefinition);
    202       cascadeParticle->Set4Momentum(aTrack.Get4Momentum());
    203       theResult.AddSecondary(cascadeParticle);
     198     
     199      G4int bulletType = calincl->bulletType();
     200      aParticleDefinition = G4InclInput::getParticleDefinition(bulletType);
     201
     202      if(aParticleDefinition != 0) {
     203        cascadeParticle = new G4DynamicParticle();
     204        cascadeParticle->SetDefinition(aParticleDefinition);
     205        cascadeParticle->Set4Momentum(aTrack.Get4Momentum());
     206        theResult.AddSecondary(cascadeParticle);
     207      }
    204208    }
    205209
     
    209213
    210214#ifdef DEBUGINCL
    211     G4cout << "E [MeV]" << std::setw(12) << " Ekin [MeV]" << std::setw(12) << " E* [MeV]" << std::setw(12) << "Px [MeV]" << std::setw(12) << " Py [MeV]" << std::setw(12) << "Pz [MeV]" << std::setw(12) << "Pt [MeV]" << std::setw(12) << "A" << std::setw(12) << "Z" << G4endl; 
     215    G4cout << "E [MeV]" << std::setw(12)
     216           << " Ekin [MeV]" << std::setw(12)
     217           << "Px [MeV]" << std::setw(12)
     218           << " Py [MeV]" << std::setw(12)
     219           << "Pz [MeV]" << std::setw(12)
     220           << "Pt [MeV]" << std::setw(12)
     221           << "A" << std::setw(12)
     222           << "Z" << G4endl;
    212223#endif
    213224
     
    276287      if((varntp->avv[particleI] > 1) && (varntp->zvv[particleI] >= 1)) { // Nucleus fragment
    277288        G4ParticleDefinition * aIonDef = 0;
    278         G4ParticleTable *theTableOfParticles = G4ParticleTable::GetParticleTable();
    279289
    280290        G4int A = G4int(varntp->avv[particleI]);
     
    315325        G4double p = mom.mag();
    316326        labv -= fm;
    317         G4double px = mom.x() * MeV;
    318         G4double py = mom.y() * MeV;
    319         G4double pz = mom.z() * MeV;
     327        if(varntp->avv[particleI] > 1) {
     328          labvA += fm;
     329        }
     330        G4double px = mom.x() * MeV;
     331        G4double py = mom.y() * MeV;
     332        G4double pz = mom.z() * MeV;
    320333        G4double pt = std::sqrt(px*px+py*py);
    321334        G4double e  = fm.e();
     
    330343        G4cout << fm.e() / MeV
    331344               << std::setw(12) << cascadeParticle->GetKineticEnergy() / MeV
    332                << std::setw(12) << exE / MeV
    333345               << std::setw(12) << mom.x() / MeV
    334346               << std::setw(12) << mom.y() / MeV
     
    351363      }
    352364    }
     365
     366      G4double nuclearMass = G4NucleiProperties::GetNuclearMass(G4int(varntp->massini), G4int(varntp->mzini)) + varntp->exini * MeV;
     367      G4LorentzVector fragmentMomentum(varntp->pxrem * MeV, varntp->pyrem * MeV, varntp->pzrem * MeV,
     368                                       varntp->erecrem * MeV + nuclearMass);
     369      G4double momentumScaling = G4InclUtils::calculate4MomentumScaling(G4int(varntp->massini), G4int(varntp->mzini),
     370                                                                        varntp->exini,
     371                                                                        varntp->erecrem,
     372                                                                        varntp->pxrem,
     373                                                                        varntp->pyrem,
     374                                                                        varntp->pzrem);
     375      G4LorentzVector p4(momentumScaling * varntp->pxrem * MeV, momentumScaling * varntp->pyrem * MeV,
     376                         momentumScaling * varntp->pzrem * MeV,
     377                         varntp->erecrem + nuclearMass);
     378
     379      // For four-momentum, baryon number and charge conservation check:
     380      G4LorentzVector fourMomentumBalance = p4;
     381      G4int baryonNumberBalance = G4int(varntp->massini);
     382      G4int chargeBalance = G4int(varntp->mzini);
     383
     384      G4LorentzRotation toFragmentZ;
     385      toFragmentZ.rotateZ(-p4.theta());
     386      toFragmentZ.rotateY(-p4.phi());
     387      G4LorentzRotation toFragmentLab = toFragmentZ.inverse();
     388      p4 *= toFragmentZ;
     389
     390      G4LorentzVector p4rest = p4;
     391      p4rest.boost(-p4.boostVector());
     392      if(verboseLevel > 0) {
     393        G4cout <<"Cascade remnant nucleus:" << G4endl;
     394        G4cout <<"p4: " << G4endl;
     395        G4cout <<" px: " << p4.px() <<" py: " << p4.py() <<" pz: " << p4.pz() << G4endl;
     396        G4cout <<" E = " << p4.e() << G4endl;
     397
     398        G4cout <<"p4rest: " << G4endl;
     399        G4cout <<" px: " << p4rest.px() <<" py: " << p4rest.py() <<" pz: " << p4rest.pz() << G4endl;
     400        G4cout <<" E = " << p4rest.e() << G4endl;
     401      }
     402
     403      G4Fragment theCascadeRemnant(G4int(varntp->massini), G4int(varntp->mzini), p4rest);
     404      thePrecoResult = thePrecoModel->DeExcite(theCascadeRemnant);
     405      if(thePrecoResult != 0) {
     406      G4ReactionProductVector::iterator fragment;
     407      for(fragment = thePrecoResult->begin(); fragment != thePrecoResult->end(); fragment++) {
     408        G4ParticleDefinition *theFragmentDefinition = (*fragment)->GetDefinition();
     409
     410        if(theFragmentDefinition != 0) {
     411          G4DynamicParticle *theFragment = new G4DynamicParticle(theFragmentDefinition, (*fragment)->GetMomentum());
     412          G4LorentzVector labMomentum = theFragment->Get4Momentum();
     413          labMomentum.boost(p4.boostVector());
     414          labMomentum *= toFragmentLab;
     415          labMomentum *= toLabFrame;
     416          theFragment->Set4Momentum(labMomentum);
     417          fourMomentumBalance -= theFragment->Get4Momentum();
     418          baryonNumberBalance -= theFragmentDefinition->GetAtomicMass();
     419          chargeBalance -= theFragmentDefinition->GetAtomicNumber();
     420          if(verboseLevel > 0) {
     421            G4cout <<"Resulting fragment: " << G4endl;
     422            G4cout <<" kinetic energy = " << theFragment->GetKineticEnergy() / MeV << " MeV" << G4endl;
     423            G4cout <<" momentum = " << theFragment->GetMomentum().mag() / MeV << " MeV" << G4endl;
     424          }
     425          theResult.AddSecondary(theFragment);
     426        } else {
     427          G4cout <<"G4InclCascadeInterface: Error. Fragment produced by Fermi break-up does not exist." << G4endl;
     428          G4cout <<"Resulting fragment: " << G4endl;
     429          G4cout <<" momentum = " << (*fragment)->GetMomentum().mag() / MeV << " MeV" << G4endl;
     430        }
     431      }
     432      delete thePrecoResult;
     433      thePrecoResult = 0;
     434
     435      if(verboseLevel > 1 && std::abs(fourMomentumBalance.mag() / MeV) > 0.1 * MeV) {
     436        G4cout <<"Four-momentum balance after remnant nucleus Fermi break-up:" << G4endl;
     437        G4cout <<"Magnitude: " << fourMomentumBalance.mag() / MeV << " MeV" << G4endl;
     438        G4cout <<"Vector components (px, py, pz, E) = ("
     439               << fourMomentumBalance.px() << ", "
     440               << fourMomentumBalance.py() << ", "
     441               << fourMomentumBalance.pz() << ", "
     442               << fourMomentumBalance.e() << ")" << G4endl;
     443      }
     444      if(baryonNumberBalance != 0 && verboseLevel > 1) {
     445        G4cout <<"Baryon number balance after remnant nucleus Fermi break-up: " << baryonNumberBalance << G4endl;
     446      }
     447      if(chargeBalance != 0 && verboseLevel > 1) {
     448        G4cout <<"Charge balance after remnant nucleus Fermi break-up: " << chargeBalance << G4endl;
     449      }
     450      }
     451      //    } // if(needsFermiBreakUp)
     452
    353453#ifdef DEBUGINCL
    354454    G4cout <<"--------------------------------------------------------------------------------" << G4endl;
    355455    G4double pt = std::sqrt(std::pow(labv.x(), 2) + std::pow(labv.y(), 2));
    356     G4cout << labv.e() / MeV << std::setw(12) << eKinSum / MeV << std::setw(12) << labv.x() << std::setw(12) << labv.y() << std::setw(12) << labv.z() << std::setw(12) <<  pt / MeV << std::setw(12) << baryonNumber << std::setw(12) << chargeNumber << " totals" << G4endl;
     456    G4double ptA = std::sqrt(std::pow(labvA.x(), 2) + std::pow(labvA.y(), 2));
     457    G4cout << labv.e() / MeV << std::setw(12)
     458           << eKinSum  / MeV << std::setw(12)
     459           << labv.x() / MeV << std::setw(12)
     460           << labv.y() / MeV << std::setw(12)
     461           << labv.z() / MeV << std::setw(12)
     462           << pt       / MeV << std::setw(12)
     463           << baryonNumber << std::setw(12)
     464           << chargeNumber << " totals" << G4endl;
     465    G4cout << " - " << std::setw(12)
     466           << " - " << std::setw(12)
     467           << labvA.x() / MeV << std::setw(12)
     468           << labvA.y() / MeV << std::setw(12)
     469           << labvA.z() / MeV << std::setw(12)
     470           << ptA       / MeV << std::setw(12)
     471           << " - " << std::setw(12) << " - " << " totals ABLA" << G4endl;
    357472    G4cout << G4endl;
    358 
     473 
    359474    if(verboseLevel > 3) {
    360475      if(baryonNumber != 0) {
     
    369484    }
    370485#endif
    371     
     486   
    372487    varntp->ntrack = 0; // Clean up the number of generated particles in the event.
    373488  }
     
    379494    theResult.SetStatusChange(stopAndKill);
    380495
    381     G4ParticleTable *theTableOfParticles = G4ParticleTable::GetParticleTable();
    382496    cascadeParticle = new G4DynamicParticle(theTableOfParticles->FindParticle(aTrack.GetDefinition()), aTrack.Get4Momentum());
    383497
     
    388502    }
    389503    if(verboseLevel > 3) {
    390       diagdata <<"ERROR G4InclCascadeInterface: Processing event number (internal) failed " << eventNumber << G4endl;
    391     }
    392 
    393     if(inclInput->bulletType() == 0) {
     504      diagdata <<"ERROR G4InclCascadeInterface: Error processing event number (internal) failed " << eventNumber << G4endl;
     505    }
     506
     507    if(bulletType == 0) {
    394508      if(verboseLevel > 1) {
    395509        G4cout <<"G4InclCascadeInterface: Unknown bullet type" << G4endl;     
     
    402516    }
    403517
    404     if((inclInput->targetA() == 1) && (inclInput->targetZ() == 1)) { // Unsupported target
     518    if((calincl->targetA() == 1) && (calincl->targetZ() == 1)) { // Unsupported target
    405519      if(verboseLevel > 1) {
    406520        G4cout <<"Unsupported target: " << G4endl;
    407         G4cout <<"Target A: " << inclInput->targetA() << G4endl;
    408         G4cout <<"TargetZ: " << inclInput->targetZ() << G4endl;
     521        G4cout <<"Target A: " << calincl->targetA() << G4endl;
     522        G4cout <<"TargetZ: " << calincl->targetZ() << G4endl;
    409523      }
    410524      if(verboseLevel > 3) {
    411525        diagdata <<"Unsupported target: " << 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.
     526        diagdata <<"Target A: " << calincl->targetA() << G4endl;
     527        diagdata <<"TargetZ: " << calincl->targetZ() << G4endl;
     528      }
     529    }
     530
     531    if(calincl->bulletE() < 100) { // INCL does not support E < 100 MeV.
    418532      if(verboseLevel > 1) {
    419         G4cout <<"Unsupported bullet energy: " << inclInput->bulletE() << " MeV. (Lower limit is 100 MeV)." << G4endl;
     533        G4cout <<"Unsupported bullet energy: " << calincl->bulletE() << " MeV. (Lower limit is 100 MeV)." << G4endl;
    420534        G4cout <<"WARNING: Returning the original bullet with original energy back to Geant4." << G4endl;
    421535      }
    422536      if(verboseLevel > 3) {
    423         diagdata <<"Unsupported bullet energy: " << inclInput->bulletE() << " MeV. (Lower limit is 100 MeV)." << G4endl;
     537        diagdata <<"Unsupported bullet energy: " << calincl->bulletE() << " MeV. (Lower limit is 100 MeV)." << G4endl;
    424538      }
    425539    }
     
    430544  }
    431545
     546  delete calincl;
     547  calincl = 0;
    432548  return &theResult;
    433549}
  • trunk/source/processes/hadronic/models/incl/src/G4InclLightIonInterface.cc

    r1340 r1347  
    2424// ********************************************************************
    2525//
    26 // $Id: G4InclLightIonInterface.cc,v 1.12 2010/10/26 02:47:59 kaitanie Exp $
     26// $Id: G4InclLightIonInterface.cc,v 1.15 2010/11/17 20:19:09 kaitanie 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 "G4InclLightIonInterface.hh"
     36#include "G4FermiBreakUp.hh"
    3437#include "math.h"
    3538#include "G4GenericIon.hh"
     
    3942{
    4043  hazard = new G4Hazard();
     44
    4145  const G4long* table_entry = CLHEP::HepRandom::getTheSeeds(); // Get random seed from CLHEP.
    4246  hazard->ial = (*table_entry);
     47
     48  theExcitationHandler = new G4ExcitationHandler;
     49  thePrecoModel = new G4PreCompoundModel(theExcitationHandler);
    4350
    4451  varntp = new G4VarNtp();
     
    4754  mat = new G4Mat();
    4855  incl = new G4Incl(hazard, calincl, ws, mat, varntp);
    49 
     56  useProjectileSpectator = true;
     57  useFermiBreakup = true;
     58  incl->setUseProjectileSpectators(useProjectileSpectator);
     59  if(!getenv("G4INCLABLANOFERMIBREAKUP")) { // Use Fermi Break-up by default if it is NOT explicitly disabled
     60    incl->setUseFermiBreakUp(true);
     61    useFermiBreakup = true;
     62  }
    5063  verboseLevel = 0;
     64  if(getenv("G4INCLVERBOSE")) {
     65    verboseLevel = 1;
     66  }
    5167}
    5268
    5369G4InclLightIonInterface::~G4InclLightIonInterface()
    5470{
     71  delete thePrecoModel;
     72  delete theExcitationHandler;
     73
    5574  delete hazard;
    5675  delete varntp;
     
    6382G4HadFinalState* G4InclLightIonInterface::ApplyYourself(const G4HadProjectile& aTrack, G4Nucleus& theNucleus)
    6483{
     84  //  const G4bool useFermiBreakup = false;
    6585  G4int maxTries = 200;
    6686
    67   G4int bulletType = 0;
    6887  G4int particleI;
    6988
    70   // Print diagnostic messages: 0 = silent, 1 and 2 = verbose
    71   verboseLevel = 0;
     89  G4int baryonNumberBalanceInINCL = 0;
     90  G4int chargeNumberBalanceInINCL = 0;
     91
     92  G4ParticleTable *theTableOfParticles = G4ParticleTable::GetParticleTable();
    7293
    7394  // Increase the event number:
    7495  eventNumber++;
    7596
     97  // Clean up the INCL input
     98  if(calincl != 0) {
     99    delete calincl;
     100    calincl = 0;
     101  }
     102
    76103  if (verboseLevel > 1) {
    77104    G4cout << " >>> G4InclLightIonInterface::ApplyYourself called" << G4endl;
     
    82109  }
    83110
    84   // INCL4 needs the energy in units MeV
    85   G4double bulletE = aTrack.GetKineticEnergy() / MeV;
    86 
    87   G4int targetA = theNucleus.GetA_asInt();
    88   G4int targetZ = theNucleus.GetZ_asInt();
     111  // Inverse kinematics for targets with Z = 1 and A = 1
     112  //  if(false) {
     113  G4LorentzRotation toBreit = aTrack.Get4Momentum().boostVector();
     114
     115  if(theNucleus.GetZ_asInt() == 1 && theNucleus.GetA_asInt() == 1 && G4InclInput::canUseInverseKinematics(aTrack, theNucleus)) {
     116    G4ParticleDefinition *oldTargetDef = theTableOfParticles->GetIon(theNucleus.GetA_asInt(), theNucleus.GetZ_asInt(), 0.0);
     117    const G4ParticleDefinition *oldProjectileDef = aTrack.GetDefinition();
     118
     119    if(oldTargetDef != 0 && oldProjectileDef != 0) {
     120    G4int oldTargetA = oldTargetDef->GetAtomicMass();
     121    G4int newTargetA = oldProjectileDef->GetAtomicMass();
     122    G4int newTargetZ = oldProjectileDef->GetAtomicNumber();
     123
     124    if(newTargetA > 0 && newTargetZ > 0) {
     125      G4Nucleus swappedTarget(oldProjectileDef->GetAtomicMass(), oldProjectileDef->GetAtomicNumber());
     126
     127      //      G4cout <<"Original projectile kinE = " << aTrack.GetKineticEnergy() / MeV << G4endl;
     128
     129      // We need the same energy/nucleon.
     130      G4double projectileE = ((aTrack.GetKineticEnergy() / MeV) / newTargetA) * oldTargetA * MeV;
     131
     132      //    G4cout <<"projectileE = " << projectileE << G4endl;
     133      G4DynamicParticle swappedProjectileParticle(oldTargetDef, G4ThreeVector(0.0, 0.0, 1.0), projectileE);
     134      const G4LorentzVector swapped4Momentum = (swappedProjectileParticle.Get4Momentum()*=toBreit);
     135      swappedProjectileParticle.Set4Momentum(swapped4Momentum);
     136      const G4HadProjectile swappedProjectile(swappedProjectileParticle);
     137      //  G4cout <<"New projectile kinE = " << swappedProjectile.GetKineticEnergy() / MeV << G4endl;
     138      calincl = new G4InclInput(swappedProjectile, swappedTarget, true);
     139    } else {
     140      G4cout <<"Badly defined target after swapping. Falling back to normal (non-swapped) mode." << G4endl;
     141      calincl = new G4InclInput(aTrack, theNucleus, false);
     142    }
     143    }
     144  } else {
     145    calincl = new G4InclInput(aTrack, theNucleus, false);
     146  }
    89147
    90148  G4double eKin;
     
    103161  G4LorentzRotation toLabFrame = toZ.inverse();
    104162
     163  /*
     164  G4cout <<"Projectile theta = " << projectileMomentum.theta() << " phi = " << projectileMomentum.phi() << G4endl;
     165  G4cout <<"Projectile momentum "
     166         << "(px = " << projectileMomentum.px()
     167         << ", py = " << projectileMomentum.py()
     168         << ", pz = " << projectileMomentum.pz() << ")" << G4endl;
     169  G4cout << "Projectile energy = " << bulletE << " MeV" << G4endl;
     170  */
     171
     172  G4ReactionProductVector *thePrecoResult = 0;
     173  G4ReactionProductVector *theSpectatorPrecoResult = 0;
     174
    105175  theResult.Clear(); // Make sure the output data structure is clean.
     176
     177  std::vector<G4DynamicParticle*> result; // Temporary list for the results
    106178
    107179  // Map Geant4 particle types to corresponding INCL4 types.
    108180  enum bulletParticleType {nucleus = 0, proton = 1, neutron = 2, pionPlus = 3, pionZero = 4,
    109                            pionMinus = 5, deuteron = 6, triton = 7, he3 = 8, he4 = 9};
    110 
    111   // Coding particles for use with INCL4 and ABLA
    112   if (aTrack.GetDefinition() == G4Deuteron::Deuteron()   ) bulletType = deuteron;
    113   if (aTrack.GetDefinition() == G4Triton::Triton()       ) bulletType = triton;
    114   if (aTrack.GetDefinition() == G4He3::He3()             ) bulletType = he3;
    115   if (aTrack.GetDefinition() == G4Alpha::Alpha()         ) bulletType = he4;
    116 
    117   calincl = new G4InclInput();
     181                           pionMinus = 5, deuteron = 6, triton = 7, he3 = 8, he4 = 9,
     182                           c12 = -12}; // Carbon beam support.
     183
     184  G4int bulletType = calincl->bulletType();
     185  chargeNumberBalanceInINCL = calincl->targetZ();
     186  baryonNumberBalanceInINCL = calincl->targetA();
     187
     188  //  G4cout <<"Type of the projectile (INCL projectile code): " << bulletType << G4endl;
     189
     190  if(bulletType == proton) {
     191    chargeNumberBalanceInINCL += 1;
     192    baryonNumberBalanceInINCL += 1;
     193  } else if(bulletType == neutron) {
     194    baryonNumberBalanceInINCL += 1;
     195  } else if(bulletType == pionPlus) { //Note: positive pion doesn't contribute to the baryon and charge number counters
     196    chargeNumberBalanceInINCL += 1;
     197  } else if(bulletType == pionMinus) {
     198    chargeNumberBalanceInINCL -= 1;
     199  } else if(bulletType == deuteron) {
     200    chargeNumberBalanceInINCL += 1;
     201    baryonNumberBalanceInINCL += 2;
     202  } else if(bulletType == triton) {
     203    chargeNumberBalanceInINCL += 1;
     204    baryonNumberBalanceInINCL += 3;
     205  } else if(bulletType == he3) {
     206    chargeNumberBalanceInINCL += 2;
     207    baryonNumberBalanceInINCL += 3;
     208  } else if(bulletType == he4) {
     209    chargeNumberBalanceInINCL += 2;
     210    baryonNumberBalanceInINCL += 4;
     211  } if(bulletType == c12) {
     212    chargeNumberBalanceInINCL += 6;
     213    baryonNumberBalanceInINCL += 12;
     214  } if(bulletType == -666) {
     215    chargeNumberBalanceInINCL += calincl->extendedProjectileZ();
     216    baryonNumberBalanceInINCL += calincl->extendedProjectileA();
     217  }
    118218
    119219  // Check wheter the input is acceptable.
    120   if((bulletType != 0) && ((targetA != 1) && (targetZ != 1))) {
     220  if((bulletType != 0) && ((calincl->targetA() != 1) && (calincl->targetZ() != 1))) {
    121221    ws->nosurf = -2;  // Nucleus surface, -2 = Woods-Saxon
    122222    ws->xfoisa = 8;
     
    128228    mat->nbmat = 1;
    129229    mat->amat[0] = int(calincl->targetA());
    130     mat->zmat[0] = int(calincl->targetZ());
    131 
     230    mat->zmat[0] = int(calincl->targetA());
     231
     232    incl->setInput(calincl);
    132233    incl->initIncl(true);
    133234
     
    148249       * Diagnostic output
    149250       */
    150       G4cout <<"G4InclLightIonInterface: Bullet type: " << bulletType << G4endl;
    151       G4cout <<"G4Incl4AblaCascadeInterface: Bullet energy: " << bulletE << " MeV" << G4endl;
    152 
    153       G4cout <<"G4InclLightIonInterface: Target A:  " << targetA << G4endl;
    154       G4cout <<"G4InclLightIonInterface: Target Z:  " << targetZ << G4endl;
     251      G4cout <<"G4InclLightIonInterface: Bullet type: " << calincl->bulletType() << G4endl;
     252      G4cout <<"G4Incl4AblaCascadeInterface: Bullet energy: " << calincl->bulletE() << " MeV" << G4endl;
     253      if(bulletType == -666) {
     254        G4cout <<"   Extended projectile: A = " << calincl->extendedProjectileA()
     255               <<" Z = " << calincl->extendedProjectileZ() << G4endl;
     256      }
     257
     258      G4cout <<"G4InclLightIonInterface: Target A:  " << calincl->targetA() << G4endl;
     259      G4cout <<"G4InclLightIonInterface: Target Z:  " << calincl->targetZ() << G4endl;
    155260
    156261      if(verboseLevel > 3) {
    157         diagdata <<"G4InclLightIonInterface: Bullet type: " << bulletType << G4endl;
    158         diagdata <<"G4InclLightIonInterface: Bullet energy: " << bulletE << " MeV" << G4endl;
     262        diagdata <<"G4InclLightIonInterface: Bullet type: " << calincl->bulletType() << G4endl;
     263        diagdata <<"G4InclLightIonInterface: Bullet energy: " << calincl->bulletE() << " MeV" << G4endl;
    159264       
    160         diagdata <<"G4InclLightIonInterface: Target A:  " << targetA << G4endl;
    161         diagdata <<"G4InclLightIonInterface: Target Z:  " << targetZ << G4endl;
     265        diagdata <<"G4InclLightIonInterface: Target A:  " << calincl->targetA() << G4endl;
     266        diagdata <<"G4InclLightIonInterface: Target Z:  " << calincl->targetZ() << G4endl;
    162267      }
    163268    }
     
    175280      if(bulletType == proton) {
    176281        aParticleDefinition = G4Proton::ProtonDefinition();
    177       }
    178       if(bulletType == neutron) {
     282      } else if(bulletType == neutron) {
    179283        aParticleDefinition = G4Neutron::NeutronDefinition();
    180       }
    181       if(bulletType == pionPlus) {
     284      } else if(bulletType == pionPlus) {
    182285        aParticleDefinition = G4PionPlus::PionPlusDefinition();
    183       }
    184       if(bulletType == pionZero) {
     286      } else if(bulletType == pionZero) {
    185287        aParticleDefinition = G4PionZero::PionZeroDefinition();
    186       }
    187       if(bulletType == pionMinus) {
     288      } else if(bulletType == pionMinus) {
    188289        aParticleDefinition = G4PionMinus::PionMinusDefinition();
    189       }
    190 
    191       cascadeParticle = new G4DynamicParticle();
    192       cascadeParticle->SetDefinition(aParticleDefinition);
    193       cascadeParticle->Set4Momentum(aTrack.Get4Momentum());
    194       theResult.AddSecondary(cascadeParticle);
     290      } else if(bulletType == deuteron) {
     291        aParticleDefinition = G4Deuteron::DeuteronDefinition();
     292      } else if(bulletType == triton) {
     293        aParticleDefinition = G4Triton::TritonDefinition();
     294      } else if(bulletType == he3) {
     295        aParticleDefinition = G4He3::He3Definition();
     296      } else if(bulletType == he4) {
     297        aParticleDefinition = G4Alpha::AlphaDefinition();
     298      } else { // Particle was not recognized. Probably an unsupported particle was given as input
     299        aParticleDefinition = 0;
     300      }
     301
     302      if(aParticleDefinition != 0) {
     303        cascadeParticle = new G4DynamicParticle();
     304        cascadeParticle->SetDefinition(aParticleDefinition);
     305        cascadeParticle->Set4Momentum(aTrack.Get4Momentum());
     306        result.push_back(cascadeParticle);
     307      }
    195308    }
    196309
     
    199312    theResult.SetStatusChange(stopAndKill);
    200313   
    201     for(particleI = 0; particleI < varntp->ntrack; particleI++) { // Loop through the INCL4+ABLA output.
     314    for(particleI = 0; particleI <= varntp->ntrack; particleI++) { // Loop through the INCL4+ABLA output.
    202315      // Get energy/momentum and construct momentum vector in INCL4 coordinates.
     316      //      if(varntp->itypcasc[particleI] == -1) continue; // Avoid nucleons that are part of the spectator
     317      if(varntp->avv[particleI] == 0 && varntp->zvv[particleI] == 0) continue;
    203318      momx = varntp->plab[particleI]*std::sin(varntp->tetlab[particleI]*CLHEP::pi/180.0)*std::cos(varntp->philab[particleI]*CLHEP::pi/180.0)*MeV;
    204319      momy = varntp->plab[particleI]*std::sin(varntp->tetlab[particleI]*CLHEP::pi/180.0)*std::sin(varntp->philab[particleI]*CLHEP::pi/180.0)*MeV;
     
    222337          new G4DynamicParticle(G4Proton::ProtonDefinition(), momDirection, eKin);
    223338        particleIdentified++;
     339        baryonNumberBalanceInINCL -= 1;
     340        chargeNumberBalanceInINCL -= 1;
    224341      }
    225342
     
    228345          new G4DynamicParticle(G4Neutron::NeutronDefinition(), momDirection, eKin);
    229346        particleIdentified++;
     347        baryonNumberBalanceInINCL -= 1;
    230348      }
    231349
     
    234352          new G4DynamicParticle(G4PionPlus::PionPlusDefinition(), momDirection, eKin);
    235353        particleIdentified++;
     354        chargeNumberBalanceInINCL -= 1;
    236355      }
    237356
     
    240359          new G4DynamicParticle(G4PionZero::PionZeroDefinition(), momDirection, eKin);
    241360        particleIdentified++;
     361        chargeNumberBalanceInINCL -= 0;
    242362      }
    243363
     
    246366          new G4DynamicParticle(G4PionMinus::PionMinusDefinition(), momDirection, eKin);
    247367        particleIdentified++;
     368        chargeNumberBalanceInINCL -= -1;
    248369      }
    249370
    250371      if((varntp->avv[particleI] > 1) && (varntp->zvv[particleI] >= 1)) { // Nucleus fragment
    251         G4ParticleDefinition * aIonDef = 0;
    252         G4ParticleTable *theTableOfParticles = G4ParticleTable::GetParticleTable();
     372        G4ParticleDefinition * aIonDef = 0;
    253373
    254374        G4int A = G4int(varntp->avv[particleI]);
     
    273393            new G4DynamicParticle(aIonDef, momDirection, eKin);
    274394          particleIdentified++;
     395          baryonNumberBalanceInINCL -= A;
     396          chargeNumberBalanceInINCL -= Z;
    275397        }
    276398      }
    277399       
    278400      if(particleIdentified == 1) { // Particle identified properly.
    279         cascadeParticle->Set4Momentum(cascadeParticle->Get4Momentum()*=toLabFrame);
    280         theResult.AddSecondary(cascadeParticle); // Put data into G4HadFinalState.
     401        cascadeParticle->Set4Momentum(cascadeParticle->Get4Momentum()*=toLabFrame);
     402        result.push_back(cascadeParticle);
    281403      }
    282404      else { // Particle identification failed.
     
    292414    }
    293415
     416    // Spectator nucleus Fermi break-up
     417    if(useFermiBreakup && useProjectileSpectator && varntp->masp > 1) {
     418      baryonNumberBalanceInINCL -= G4int(varntp->masp);
     419      G4double nuclearMass = G4NucleiProperties::GetNuclearMass(G4int(varntp->masp), G4int(varntp->mzsp)) + varntp->exsp * MeV;
     420      // Use momentum scaling to compensate for different masses in G4 and INCL:
     421      G4double momentumScaling = G4InclUtils::calculate4MomentumScaling(G4int(varntp->masp),
     422                                                                        G4int(varntp->mzsp),
     423                                                                        varntp->exsp,
     424                                                                        varntp->spectatorT,
     425                                                                        varntp->spectatorP1,
     426                                                                        varntp->spectatorP2,
     427                                                                        varntp->spectatorP3);
     428      G4LorentzVector p4(momentumScaling * varntp->spectatorP1 * MeV, momentumScaling * varntp->spectatorP2 * MeV,
     429                         momentumScaling * varntp->spectatorP3 * MeV,
     430                         varntp->spectatorT * MeV + nuclearMass);
     431      // Four-momentum, baryon number and charge balance:
     432      G4LorentzVector fourMomentumBalance = p4;
     433      G4int baryonNumberBalance = G4int(varntp->masp);
     434      chargeNumberBalanceInINCL -= G4int(varntp->mzsp);
     435      G4int chargeBalance = G4int(varntp->mzsp);
     436
     437      G4LorentzRotation toFragmentZ;
     438      // Assume that Fermi breakup uses Z as the direction of the projectile
     439      toFragmentZ.rotateZ(-p4.theta());
     440      toFragmentZ.rotateY(-p4.phi());
     441      G4LorentzRotation toFragmentLab = toFragmentZ.inverse();
     442      p4 *= toFragmentZ;
     443     
     444      G4LorentzVector p4rest = p4;
     445      p4rest.boost(-p4.boostVector());
     446      if(verboseLevel > 0) {
     447        G4cout <<"Spectator nucleus:" << G4endl;
     448        G4cout <<"p4: " << G4endl;
     449        G4cout <<" px: " << p4.px() <<" py: " << p4.py() <<" pz: " << p4.pz() << G4endl;
     450        G4cout <<" E = " << p4.e() << G4endl;
     451        G4cout <<"p4rest: " << G4endl;
     452        G4cout <<" px: " << p4rest.px() <<" py: " << p4rest.py() <<" pz: " << p4rest.pz() << G4endl;
     453        G4cout <<" E = " << p4rest.e() << G4endl;
     454      }
     455      G4Fragment theSpectatorNucleus(G4int(varntp->masp), G4int(varntp->mzsp), p4rest);
     456      theSpectatorPrecoResult = thePrecoModel->DeExcite(theSpectatorNucleus);
     457      if(theSpectatorPrecoResult != 0) {
     458      G4ReactionProductVector::iterator fragment;
     459      for(fragment = theSpectatorPrecoResult->begin(); fragment != theSpectatorPrecoResult->end(); fragment++) {
     460        G4ParticleDefinition *theFragmentDefinition = (*fragment)->GetDefinition();
     461
     462        if(theFragmentDefinition != 0) {
     463          G4DynamicParticle *theFragment = new G4DynamicParticle(theFragmentDefinition, (*fragment)->GetMomentum());
     464          G4LorentzVector labMomentum = theFragment->Get4Momentum();
     465          labMomentum.boost(p4.boostVector());
     466          labMomentum *= toFragmentLab;
     467          labMomentum *= toLabFrame;
     468          theFragment->Set4Momentum(labMomentum);
     469          fourMomentumBalance -= theFragment->Get4Momentum();
     470          baryonNumberBalance -= theFragmentDefinition->GetAtomicMass();
     471          chargeBalance -= theFragmentDefinition->GetAtomicNumber();
     472          if(verboseLevel > 0) {
     473            G4cout <<"Resulting fragment: " << G4endl;
     474            G4cout <<" kinetic energy = " << theFragment->GetKineticEnergy() / MeV << " MeV" << G4endl;
     475            G4cout <<" momentum = " << theFragment->GetMomentum().mag() / MeV << " MeV" << G4endl;
     476          }
     477          theResult.AddSecondary(theFragment);
     478        } else {
     479          G4cout <<"G4InclCascadeInterface: Error. Fragment produced by Fermi break-up does not exist." << G4endl;
     480          G4cout <<"Resulting fragment: " << G4endl;
     481          G4cout <<" momentum = " << (*fragment)->GetMomentum().mag() / MeV << " MeV" << G4endl;
     482        }
     483      }
     484      delete theSpectatorPrecoResult;
     485      theSpectatorPrecoResult = 0;
     486
     487      if(verboseLevel > 1 && std::abs(fourMomentumBalance.mag() / MeV) > 0.1 * MeV) {
     488        G4cout <<"Four-momentum balance after remnant nucleus Fermi break-up:" << G4endl;
     489        G4cout <<"Magnitude: " << fourMomentumBalance.mag() / MeV << " MeV" << G4endl;
     490        G4cout <<"Vector components (px, py, pz, E) = ("
     491               << fourMomentumBalance.px() << ", "
     492               << fourMomentumBalance.py() << ", "
     493               << fourMomentumBalance.pz() << ", "
     494               << fourMomentumBalance.e() << ")" << G4endl;
     495      }
     496      if(baryonNumberBalance != 0 && verboseLevel > 1) {
     497        G4cout <<"Baryon number balance after remnant nucleus Fermi break-up: " << baryonNumberBalance << G4endl;
     498      }
     499      if(chargeBalance != 0 && verboseLevel > 1) {
     500        G4cout <<"Charge balance after remnant nucleus Fermi break-up: " << chargeBalance << G4endl;
     501      }
     502      }
     503    }
     504
     505    // Finally do Fermi break-up if needed
     506    if(varntp->massini > 0) {
     507      baryonNumberBalanceInINCL -= G4int(varntp->massini);
     508      chargeNumberBalanceInINCL -= G4int(varntp->mzini);
     509      // Call Fermi Break-up
     510      G4double nuclearMass = G4NucleiProperties::GetNuclearMass(G4int(varntp->massini), G4int(varntp->mzini)) + varntp->exini * MeV;
     511      G4LorentzVector fragmentMomentum(varntp->pxrem * MeV, varntp->pyrem * MeV, varntp->pzrem * MeV,
     512                                       varntp->erecrem * MeV + nuclearMass);
     513      G4double momentumScaling = G4InclUtils::calculate4MomentumScaling(G4int(varntp->massini), G4int(varntp->mzini),
     514                                                                        varntp->exini,
     515                                                                        varntp->erecrem,
     516                                                                        varntp->pxrem,
     517                                                                        varntp->pyrem,
     518                                                                        varntp->pzrem);
     519      G4LorentzVector p4(momentumScaling * varntp->pxrem * MeV, momentumScaling * varntp->pyrem * MeV,
     520                         momentumScaling * varntp->pzrem * MeV,
     521                         varntp->erecrem + nuclearMass);
     522
     523      // For four-momentum, baryon number and charge conservation check:
     524      G4LorentzVector fourMomentumBalance = p4;
     525      G4int baryonNumberBalance = G4int(varntp->massini);
     526      G4int chargeBalance = G4int(varntp->mzini);
     527
     528      G4LorentzRotation toFragmentZ;
     529      toFragmentZ.rotateZ(-p4.theta());
     530      toFragmentZ.rotateY(-p4.phi());
     531      G4LorentzRotation toFragmentLab = toFragmentZ.inverse();
     532      p4 *= toFragmentZ;
     533
     534      G4LorentzVector p4rest = p4;
     535      p4rest.boost(-p4.boostVector());
     536      if(verboseLevel > 0) {
     537        G4cout <<"Cascade remnant nucleus:" << G4endl;
     538        G4cout <<"p4: " << G4endl;
     539        G4cout <<" px: " << p4.px() <<" py: " << p4.py() <<" pz: " << p4.pz() << G4endl;
     540        G4cout <<" E = " << p4.e() << G4endl;
     541
     542        G4cout <<"p4rest: " << G4endl;
     543        G4cout <<" px: " << p4rest.px() <<" py: " << p4rest.py() <<" pz: " << p4rest.pz() << G4endl;
     544        G4cout <<" E = " << p4rest.e() << G4endl;
     545      }
     546
     547      G4Fragment theCascadeRemnant(G4int(varntp->massini), G4int(varntp->mzini), p4rest);
     548      thePrecoResult = thePrecoModel->DeExcite(theCascadeRemnant);
     549      if(thePrecoResult != 0) {
     550      G4ReactionProductVector::iterator fragment;
     551      for(fragment = thePrecoResult->begin(); fragment != thePrecoResult->end(); fragment++) {
     552        G4ParticleDefinition *theFragmentDefinition = (*fragment)->GetDefinition();
     553
     554        if(theFragmentDefinition != 0) {
     555          G4DynamicParticle *theFragment = new G4DynamicParticle(theFragmentDefinition, (*fragment)->GetMomentum());
     556          G4LorentzVector labMomentum = theFragment->Get4Momentum();
     557          labMomentum.boost(p4.boostVector());
     558          labMomentum *= toFragmentLab;
     559          labMomentum *= toLabFrame;
     560          theFragment->Set4Momentum(labMomentum);
     561          fourMomentumBalance -= theFragment->Get4Momentum();
     562          baryonNumberBalance -= theFragmentDefinition->GetAtomicMass();
     563          chargeBalance -= theFragmentDefinition->GetAtomicNumber();
     564          if(verboseLevel > 0) {
     565            G4cout <<"Resulting fragment: " << G4endl;
     566            G4cout <<" kinetic energy = " << theFragment->GetKineticEnergy() / MeV << " MeV" << G4endl;
     567            G4cout <<" momentum = " << theFragment->GetMomentum().mag() / MeV << " MeV" << G4endl;
     568          }
     569          theResult.AddSecondary(theFragment);
     570        } else {
     571          G4cout <<"G4InclCascadeInterface: Error. Fragment produced by Fermi break-up does not exist." << G4endl;
     572          G4cout <<"Resulting fragment: " << G4endl;
     573          G4cout <<" momentum = " << (*fragment)->GetMomentum().mag() / MeV << " MeV" << G4endl;
     574        }
     575      }
     576      delete thePrecoResult;
     577      thePrecoResult = 0;
     578
     579      if(verboseLevel > 1 && std::abs(fourMomentumBalance.mag() / MeV) > 0.1 * MeV) {
     580        G4cout <<"Four-momentum balance after remnant nucleus Fermi break-up:" << G4endl;
     581        G4cout <<"Magnitude: " << fourMomentumBalance.mag() / MeV << " MeV" << G4endl;
     582        G4cout <<"Vector components (px, py, pz, E) = ("
     583               << fourMomentumBalance.px() << ", "
     584               << fourMomentumBalance.py() << ", "
     585               << fourMomentumBalance.pz() << ", "
     586               << fourMomentumBalance.e() << ")" << G4endl;
     587      }
     588      if(baryonNumberBalance != 0 && verboseLevel > 1) {
     589        G4cout <<"Baryon number balance after remnant nucleus Fermi break-up: " << baryonNumberBalance << G4endl;
     590      }
     591      if(chargeBalance != 0 && verboseLevel > 1) {
     592        G4cout <<"Charge balance after remnant nucleus Fermi break-up: " << chargeBalance << G4endl;
     593      }
     594      }
     595    }
     596
    294597    varntp->ntrack = 0; // Clean up the number of generated particles in the event.
     598
     599    if(baryonNumberBalanceInINCL != 0 && verboseLevel > 1) {
     600      G4cout <<"Event " << eventNumber <<": G4InclLightIonInterface: Baryon number conservation problem in INCL detected!" << G4endl;
     601      G4cout <<"Baryon number balance: " << baryonNumberBalanceInINCL << G4endl;
     602      if(baryonNumberBalanceInINCL < 0) {
     603        G4cout <<"Event " << eventNumber <<": Too many outcoming baryons!" << G4endl;
     604      } else if(baryonNumberBalanceInINCL > 0) {
     605        G4cout <<"Event " << eventNumber <<": Too few outcoming baryons!" << G4endl;
     606      }
     607    }
     608
     609    if(chargeNumberBalanceInINCL != 0 && verboseLevel > 1) {
     610      G4cout <<"Event " << eventNumber <<": G4InclLightIonInterface: Charge number conservation problem in INCL detected!" << G4endl;
     611      G4cout <<"Event " << eventNumber <<": Charge number balance: " << chargeNumberBalanceInINCL << G4endl;
     612    }
    295613  }
    296614  /**
     
    304622    cascadeParticle = new G4DynamicParticle(theTableOfParticles->FindParticle(aTrack.GetDefinition()), aTrack.Get4Momentum());
    305623
    306     theResult.AddSecondary(cascadeParticle);
     624    result.push_back(cascadeParticle);
    307625
    308626    if(verboseLevel > 1) {
     
    317635        G4cout <<"G4InclLightIonInterface: Unknown bullet type" << G4endl;     
    318636        G4cout <<"Bullet particle name: " << cascadeParticle->GetDefinition()->GetParticleName() << G4endl;
    319       }     
     637      }
    320638      if(verboseLevel > 3) {
    321639        diagdata <<"G4InclLightIonInterface: Unknown bullet type" << G4endl;     
     
    324642    }
    325643
    326     if((targetA == 1) && (targetZ == 1)) { // Unsupported target
     644    if((calincl->targetA() == 1) && (calincl->targetZ() == 1)) { // Unsupported target
    327645      if(verboseLevel > 1) {
    328646        G4cout <<"Unsupported target: " << G4endl;
    329         G4cout <<"Target A: " << targetA << G4endl;
    330         G4cout <<"TargetZ: " << targetZ << G4endl;
     647        G4cout <<"Target A: " << calincl->targetA() << G4endl;
     648        G4cout <<"TargetZ: " << calincl->targetZ() << G4endl;
    331649      }
    332650      if(verboseLevel > 3) {
    333651        diagdata <<"Unsupported target: " << G4endl;
    334         diagdata <<"Target A: " << targetA << G4endl;
    335        diagdata <<"TargetZ: " << targetZ << G4endl;
    336       }
    337     }
    338 
    339     if(bulletE < 100) { // INCL does not support E < 100 MeV.
     652        diagdata <<"Target A: " << calincl->targetA() << G4endl;
     653        diagdata <<"TargetZ: " << calincl->targetZ() << G4endl;
     654      }
     655    }
     656
     657    if(calincl->bulletE() < 100) { // INCL does not support E < 100 MeV.
    340658      if(verboseLevel > 1) {
    341         G4cout <<"Unsupported bullet energy: " << bulletE << " MeV. (Lower limit is 100 MeV)." << G4endl;
     659        G4cout <<"Unsupported bullet energy: " << calincl->bulletE() << " MeV. (Lower limit is 100 MeV)." << G4endl;
    342660        G4cout <<"WARNING: Returning the original bullet with original energy back to Geant4." << G4endl;
    343661      }
    344662      if(verboseLevel > 3) {
    345         diagdata <<"Unsupported bullet energy: " << bulletE << " MeV. (Lower limit is 100 MeV)." << G4endl;
    346       }
    347     }
     663        diagdata <<"Unsupported bullet energy: " << calincl->bulletE() << " MeV. (Lower limit is 100 MeV)." << G4endl;
     664      }
     665    }
     666
    348667    if(verboseLevel > 3) {
    349668      diagdata <<"WARNING: returning the original bullet with original energy back to Geant4." << G4endl;
     
    351670  }
    352671
     672  // Finally copy the accumulated secondaries into the result collection:
     673  G4ThreeVector boostVector = aTrack.Get4Momentum().boostVector();
     674  G4LorentzRotation boostBack = toBreit.inverse();
     675
     676  for(std::vector<G4DynamicParticle*>::iterator i = result.begin(); i != result.end(); ++i) {
     677    // If the calculation was performed in inverse kinematics we have to
     678    // convert the result back...
     679    if(calincl->isInverseKinematics()) {
     680      G4LorentzVector mom = (*i)->Get4Momentum();
     681      mom.setPz(-1.0 * mom.pz()); // Reverse the z-component of the momentum vector
     682      mom *= boostBack;
     683      (*i)->Set4Momentum(mom);
     684    }
     685    theResult.AddSecondary((*i));
     686  }
     687
     688  delete calincl;
     689  calincl = 0;
    353690  return &theResult;
    354691}
Note: See TracChangeset for help on using the changeset viewer.