Ignore:
Timestamp:
Jun 18, 2010, 11:42:07 AM (14 years ago)
Author:
garnier
Message:

update geant4-09-04-beta-cand-01 interfaces-V09-03-09 vis-V09-03-08

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/processes/hadronic/models/cascade/cascade/src/G4PreCompoundCascadeInterface.cc

    r962 r1315  
    2323// * acceptance of all terms of the Geant4 Software license.          *
    2424// ********************************************************************
     25// $Id: G4PreCompoundCascadeInterface.cc,v 1.13 2010/05/21 18:07:30 mkelsey Exp $
     26// Geant4 tag: $Name: geant4-09-04-beta-cand-01 $
    2527//
     28// 20100114  M. Kelsey -- Remove G4CascadeMomentum, use G4LorentzVector directly
     29// 20100413  M. Kelsey -- Pass G4CollisionOutput by ref to ::collide()
     30// 20100414  M. Kelsey -- Check for K0L/K0S before using G4InuclElemPart::type
     31// 20100419  M. Kelsey -- Access G4CollisionOutput lists by const-ref, and
     32//              const_iterator
     33// 20100428  M. Kelsey -- Use G4InuclParticleNames enum
     34// 20100429  M. Kelsey -- Change "case gamma:" to "case photon:"
     35// 20100517  M. Kelsey -- Follow new ctors for G4*Collider family.
     36// 20100520  M. Kelsey -- Add missing name string to ctor, follow code changes
     37//              from G4CascadeInterface.
    2638
    2739#include "G4PreCompoundCascadeInterface.hh"
    2840#include "globals.hh"
    29 #include "G4DynamicParticleVector.hh"
    30 #include "G4IonTable.hh"
    31 #include "G4PreCompoundInuclCollider.hh"
    32 #include "G4IntraNucleiCascader.hh"
    33 #include "G4ElementaryParticleCollider.hh"
    34 #include "G4NonEquilibriumEvaporator.hh"
    35 #include "G4BigBanger.hh"
     41#include "G4CollisionOutput.hh"
     42#include "G4DynamicParticle.hh"
    3643#include "G4InuclElementaryParticle.hh"
    3744#include "G4InuclNuclei.hh"
    3845#include "G4InuclParticle.hh"
    39 #include "G4CollisionOutput.hh"
     46#include "G4InuclParticleNames.hh"
     47#include "G4KaonZeroShort.hh"
     48#include "G4KaonZeroLong.hh"
     49#include "G4LorentzRotation.hh"
     50#include "G4Nucleus.hh"
     51#include "G4ParticleDefinition.hh"
     52#include "G4PreCompoundInuclCollider.hh"
     53#include "G4Track.hh"
    4054#include "G4V3DNucleus.hh"
    41 #include "G4Track.hh"
    42 #include "G4Nucleus.hh"
    43 #include "G4NucleiModel.hh"
    44 #include "G4LorentzRotation.hh"
    45 
    46 
    47 typedef std::vector<G4InuclElementaryParticle>::iterator particleIterator;
    48 typedef std::vector<G4InuclNuclei>::iterator nucleiIterator;
    49 
    50 G4PreCompoundCascadeInterface::G4PreCompoundCascadeInterface()
    51   :verboseLevel(0)  {
     55
     56using namespace G4InuclParticleNames;
     57
     58
     59typedef std::vector<G4InuclElementaryParticle>::const_iterator particleIterator;
     60typedef std::vector<G4InuclNuclei>::const_iterator nucleiIterator;
     61
     62G4PreCompoundCascadeInterface::G4PreCompoundCascadeInterface(const G4String& nam)
     63  :G4VIntraNuclearTransportModel(nam), verboseLevel(0)  {
    5264
    5365  if (verboseLevel > 3) {
     
    8597  // NOTE: Geant4 units are MeV = 1 and GeV = 1000. Cascade code by default use GeV = 1.
    8698
    87   enum particleType { nuclei      = 0,  proton     = 1,  neutron   = 2,  pionPlus = 3,
    88                       pionMinus   = 5,  pionZero   = 7,  photon    = 10,
    89                       kaonPlus    = 11, kaonMinus  = 13, kaonZero  = 15,
    90                       kaonZeroBar = 17, lambda     = 21, sigmaPlus = 23,
    91                       sigmaZero   = 25, sigmaMinus = 27, xiZero    = 29, xiMinus  = 31 };
    92 
    93   G4int bulletType = 0;
    94 
    95   // Coding particles
    96   if (aTrack.GetDefinition() == G4Proton::Proton()         ) bulletType = proton;
    97   if (aTrack.GetDefinition() == G4Neutron::Neutron()       ) bulletType = neutron;
    98   if (aTrack.GetDefinition() == G4PionPlus::PionPlus()     ) bulletType = pionPlus;
    99   if (aTrack.GetDefinition() == G4PionMinus::PionMinus()   ) bulletType = pionMinus;
    100   if (aTrack.GetDefinition() == G4PionZero::PionZero()     ) bulletType = pionZero;
    101   if (aTrack.GetDefinition() == G4Gamma::Gamma()           ) bulletType = photon;
    102   if (aTrack.GetDefinition() == G4KaonPlus::KaonPlus()     ) bulletType = kaonPlus;
    103   if (aTrack.GetDefinition() == G4KaonMinus::KaonMinus()   ) bulletType = kaonMinus;
    104   if (aTrack.GetDefinition() == G4Lambda::Lambda()         ) bulletType = lambda;
    105   if (aTrack.GetDefinition() == G4SigmaPlus::SigmaPlus()   ) bulletType = sigmaPlus;
    106   if (aTrack.GetDefinition() == G4SigmaZero::SigmaZero()   ) bulletType = sigmaZero;
    107   if (aTrack.GetDefinition() == G4SigmaMinus::SigmaMinus() ) bulletType = sigmaMinus;
    108   if (aTrack.GetDefinition() == G4XiZero::XiZero()         ) bulletType = xiZero;
    109   if (aTrack.GetDefinition() == G4XiMinus::XiMinus()       ) bulletType = xiMinus; 
    110 
     99  G4int bulletType;
    111100  if (aTrack.GetDefinition() == G4KaonZeroLong::KaonZeroLong() ||
    112       aTrack.GetDefinition() == G4KaonZeroShort::KaonZeroShort() ) {
    113     if (G4UniformRand() > 0.5) {
    114       bulletType = kaonZero;
    115     } else {
    116       bulletType = kaonZeroBar;
    117     }
    118   }
     101      aTrack.GetDefinition() == G4KaonZeroShort::KaonZeroShort() )
     102    bulletType = (G4UniformRand() > 0.5) ? kaonZero : kaonZeroBar;
     103  else
     104    bulletType = G4InuclElementaryParticle::type(aTrack.GetDefinition());
    119105
    120106  // Code momentum and energy.
    121   G4double px,py,pz;
    122   px=aTrack.Get4Momentum().px() / GeV;
    123   py=aTrack.Get4Momentum().py() / GeV;
    124   pz=aTrack.Get4Momentum().pz() / GeV;
    125 
    126107  G4LorentzVector projectileMomentum = aTrack.Get4Momentum();
    127108  G4LorentzRotation toZ;
     
    130111  G4LorentzRotation toLabFrame = toZ.inverse();
    131112
    132   G4CascadeMomentum momentumBullet;
    133   momentumBullet[0] =0.;
    134   momentumBullet[1] =0;
    135   momentumBullet[2] =0;
    136   momentumBullet[3] =std::sqrt(px*px+py*py+pz*pz);
    137 
    138   G4InuclElementaryParticle *  bullet = new G4InuclElementaryParticle(momentumBullet, bulletType);
     113  G4LorentzVector momentumBullet(0., 0., aTrack.GetTotalMomentum()/GeV,
     114                                 aTrack.GetTotalEnergy()/GeV);
     115
     116  G4InuclElementaryParticle *  bullet =
     117    new G4InuclElementaryParticle(momentumBullet, bulletType);
    139118
    140119  sumEnergy = bullet->getKineticEnergy(); // In GeV
    141 
    142   if (bulletType == proton || bulletType == neutron || bulletType == lambda ||
    143       bulletType == sigmaPlus || bulletType == sigmaZero || bulletType == sigmaMinus ||
    144       bulletType == xiZero || bulletType == xiMinus) {
    145 
    146     sumBaryon += 1;
    147   }
     120  sumBaryon += bullet->baryon();
    148121
    149122  // Set target
    150123  G4InuclNuclei*   target  = 0;
    151124  G4InuclParticle* targetH = 0;
    152   // and outcoming particles
    153   G4DynamicParticle* cascadeParticle = 0;
    154 
    155   G4CascadeMomentum targetMomentum;
    156125
    157126  G4double theNucleusA = theNucleus.GetN();
    158127
    159128  if ( !(G4int(theNucleusA) == 1) ) {
    160     target  = new G4InuclNuclei(targetMomentum,
    161                                 theNucleusA,
    162                                 theNucleus.GetZ());
    163     target->setEnergy();
    164 
    165     const G4CascadeMomentum& bmom = bullet->getMomentum();
    166     eInit = std::sqrt(bmom[0] * bmom[0]);
    167     const G4CascadeMomentum& tmom = target->getMomentum();
    168     eInit += std::sqrt(tmom[0] * tmom[0]);
     129    target  = new G4InuclNuclei(theNucleusA, theNucleus.GetZ());
     130    eInit = bullet->getEnergy() + target->getEnergy();
    169131
    170132    sumBaryon += theNucleusA;
     
    183145
    184146  // Colliders initialisation
    185   G4ElementaryParticleCollider*   colep = new G4ElementaryParticleCollider;
    186 
    187   G4IntraNucleiCascader*            inc = new G4IntraNucleiCascader; // the actual cascade
    188   inc->setInteractionCase(1); // Interaction type is particle with nuclei.
    189 
    190   G4NonEquilibriumEvaporator*     noneq = new G4NonEquilibriumEvaporator;
    191   G4BigBanger*                     bigb = new G4BigBanger;
    192   G4PreCompoundInuclCollider*  collider = new G4PreCompoundInuclCollider(colep, inc, noneq, bigb);
     147  G4PreCompoundInuclCollider*  collider = new G4PreCompoundInuclCollider;
    193148
    194149  G4int  maxTries = 10; // maximum tries for inelastic collision to avoid infinite loop
     
    197152  if (G4int(theNucleusA) == 1) { // special treatment for target H(1,1) (proton)
    198153
    199     targetH = new G4InuclElementaryParticle(targetMomentum, 1);
     154    targetH = new G4InuclElementaryParticle(1);
    200155
    201156    G4float cutElastic[32];
     
    214169    cutElastic[kaonPlus ]   = 0.5; // 0.5 GeV
    215170    cutElastic[kaonMinus]   = 0.5;
    216     cutElastic[kaonMinus]   = 0.5;
    217171    cutElastic[kaonZero]    = 0.5;
    218172    cutElastic[kaonZeroBar] = 0.5;
     
    222176
    223177
    224     if (momentumBullet[3] > cutElastic[bulletType]) { // inelastic collision possible
     178    if (momentumBullet.z() > cutElastic[bulletType]) { // inelastic collision possible
    225179
    226180      do {   // we try to create inelastic interaction
    227         output = collider->collide(bullet, targetH);
     181        output.reset();
     182        collider->collide(bullet, targetH, output);
    228183        nTries++;
    229184      } while(
     
    235190
    236191    } else { // only elastic collision is energetically possible
    237       output = collider->collide(bullet, targetH);
     192      collider->collide(bullet, targetH, output);
    238193    }
    239194
    240195    sumBaryon += 1;
    241196
    242     const G4CascadeMomentum& bmom = bullet->getMomentum();
    243     eInit = std::sqrt(bmom[0] * bmom[0]);
    244     const G4CascadeMomentum& tmom = targetH->getMomentum();
    245     eInit += std::sqrt(tmom[0] * tmom[0]);
     197    eInit = bullet->getEnergy() + target->getEnergy();
    246198
    247199    if (verboseLevel > 2) {
     
    254206    do  // we try to create inelastic interaction
    255207      {
    256         output = collider->collide(bullet, target );
     208        output.reset();
     209        collider->collide(bullet, target, output);
    257210        nTries++;
    258211      } while (
    259                //             (nTries < maxTries)                                                               &&
    260                //(output.getOutgoingParticles().size() + output.getNucleiFragments().size() < 2.5) &&
    261                //(output.getOutgoingParticles().size()!=0)                                         &&
    262                //(output.getOutgoingParticles().begin()->type()==bullet->type())
    263                //);
    264 
    265212               (nTries < maxTries) &&
    266213               output.getOutgoingParticles().size() == 1 &&     // we retry when elastic collision happened
     
    272219  }
    273220 
    274   if (verboseLevel > 1)
    275     {
     221  if (verboseLevel > 1) {
    276222      G4cout << " Cascade output: " << G4endl;
    277223      output.printCollisionOutput();
    278     }
     224  }
    279225 
     226  // Rotate event to put Z axis along original projectile direction
     227  output.rotateEvent(toLabFrame);
     228
    280229  // Convert cascade data to use hadronics interface
    281   std::vector<G4InuclNuclei>            nucleiFragments = output.getNucleiFragments();
    282   std::vector<G4InuclElementaryParticle> particles =      output.getOutgoingParticles();
     230  const std::vector<G4InuclNuclei>& nucleiFragments = output.getNucleiFragments();
     231  const std::vector<G4InuclElementaryParticle>& particles = output.getOutgoingParticles();
    283232
    284233  theResult.SetStatusChange(stopAndKill);
    285234
     235  // Get outcoming particles
     236  G4DynamicParticle* cascadeParticle = 0;
    286237  if (!particles.empty()) {
    287     particleIterator ipart;
    288     G4int outgoingParticle;
    289 
    290     for (ipart = particles.begin(); ipart != particles.end(); ipart++) {
    291       outgoingParticle = ipart->type();
    292       const G4CascadeMomentum& mom = ipart->getMomentum();
    293       eTot   += std::sqrt(mom[0] * mom[0]);
    294 
    295       G4double ekin = ipart->getKineticEnergy() * GeV;
    296       G4ThreeVector aMom(mom[1], mom[2], mom[3]);
    297       aMom = aMom.unit();
    298 
    299       if (ipart->baryon() ) {
    300         sumBaryon -= 1;
     238    particleIterator ipart = particles.begin();
     239    for (; ipart != particles.end(); ipart++) {
     240      G4int outgoingType = ipart->type();
     241
     242      eTot += ipart->getEnergy();
     243      sumBaryon -= ipart->baryon();
     244      sumEnergy -= ipart->getKineticEnergy();
     245
     246      if (!ipart->valid() || ipart->quasi_deutron()) {
     247        G4cerr << " ERROR: G4PreCompoundCascadeInterface::Propagate incompatible"
     248               << " particle type " << ipart->type() << G4endl;
     249        continue;
    301250      }
    302251
    303       sumEnergy -= ekin / GeV;
    304 
    305       switch(outgoingParticle) {
    306 
    307       case proton:
    308 #ifdef debug_G4PreCompoundCascadeInterface
    309         G4cerr << "proton " << counter << " " << aMom << " " << ekin << G4endl;
    310 #endif
    311         cascadeParticle = new G4DynamicParticle(G4Proton::ProtonDefinition(), aMom, ekin);
    312         break;
    313 
    314       case neutron:
    315 
    316 #ifdef debug_G4PreCompoundCascadeInterface
    317         G4cerr << "neutron "<< counter<<" "<<aMom<<" "<<  ekin<<G4endl;
    318 #endif
    319         cascadeParticle = new G4DynamicParticle(G4Neutron::NeutronDefinition(), aMom, ekin);
    320         break;
    321 
    322       case pionPlus:
    323         cascadeParticle = new G4DynamicParticle(G4PionPlus::PionPlusDefinition(), aMom, ekin);
    324 
    325 #ifdef debug_G4PreCompoundCascadeInterface
    326         G4cerr << "pionPlus "<< counter<<" "<<aMom<<" "<<  ekin<<G4endl;
    327 #endif
    328         break;
    329 
    330       case pionMinus:
    331         cascadeParticle = new G4DynamicParticle(G4PionMinus::PionMinusDefinition(), aMom, ekin);
    332 
    333 #ifdef debug_G4PreCompoundCascadeInterface
    334         G4cerr << "pionMinus "<< counter<<" "<<aMom<<" "<<  ekin<<G4endl;
    335 #endif
    336         break;
    337 
    338       case pionZero:
    339         cascadeParticle = new G4DynamicParticle(G4PionZero::PionZeroDefinition(), aMom, ekin);
    340 
    341 #ifdef debug_G4PreCompoundCascadeInterface
    342         G4cerr << "pionZero "<< counter<<" "<<aMom<<" "<<  ekin<<G4endl;
    343 #endif
    344         break;
    345 
    346       case photon:
    347         cascadeParticle = new G4DynamicParticle(G4Gamma::Gamma(), aMom, ekin);
    348 
    349 #ifdef debug_G4PreCompoundCascadeInterface
    350         G4cerr << "photon "<< counter<<" "<<aMom<<" "<<  ekin<<G4endl;
    351 #endif
    352         break;
    353 
    354 
    355       case kaonPlus:
    356         cascadeParticle = new G4DynamicParticle(G4KaonPlus::KaonPlusDefinition(), aMom, ekin);
    357         break;
    358 
    359       case kaonMinus:
    360         cascadeParticle = new G4DynamicParticle(G4KaonMinus::KaonMinusDefinition(), aMom, ekin);
    361         break;
    362 
    363       case kaonZero:
    364         if (G4UniformRand() > 0.5) {
    365           cascadeParticle = new G4DynamicParticle(G4KaonZeroLong::KaonZeroLongDefinition(), aMom, ekin);
    366         } else {
    367           cascadeParticle = new G4DynamicParticle(G4KaonZeroShort::KaonZeroShortDefinition(), aMom, ekin);
    368         }
    369         break;
    370 
    371       case kaonZeroBar:
    372         if (G4UniformRand() > 0.5) {
    373           cascadeParticle = new G4DynamicParticle(G4KaonZeroLong::KaonZeroLongDefinition(), aMom, ekin);
    374         } else {
    375           cascadeParticle = new G4DynamicParticle(G4KaonZeroShort::KaonZeroShortDefinition(), aMom, ekin);
    376         }
    377         break;
    378 
    379       case lambda:
    380         cascadeParticle = new G4DynamicParticle(G4Lambda::LambdaDefinition(), aMom, ekin);
    381         break;
    382 
    383       case sigmaPlus:
    384         cascadeParticle = new G4DynamicParticle(G4SigmaPlus::SigmaPlusDefinition(), aMom, ekin);
    385         break;
    386 
    387       case sigmaZero:
    388         cascadeParticle = new G4DynamicParticle(G4SigmaZero::SigmaZeroDefinition(), aMom, ekin);
    389         break;
    390 
    391       case sigmaMinus:
    392         cascadeParticle = new G4DynamicParticle(G4SigmaMinus::SigmaMinusDefinition(), aMom, ekin);
    393         break;
    394 
    395       case xiZero:
    396         cascadeParticle = new G4DynamicParticle(G4XiZero::XiZeroDefinition(), aMom, ekin);
    397         break;
    398 
    399       case xiMinus:
    400         cascadeParticle = new G4DynamicParticle(G4XiMinus::XiMinusDefinition(), aMom, ekin);
    401         break;
    402 
    403       default:
    404         G4cout << " ERROR: G4PreCompoundCascadeInterface::Propagate undefined particle type" << G4endl;
     252      // Copy local G4DynPart to public output (handle kaon mixing specially)
     253      if (outgoingType == kaonZero || outgoingType == kaonZeroBar) {
     254        G4ThreeVector momDir = ipart->getMomentum().vect().unit();
     255        G4double ekin = ipart->getKineticEnergy();
     256
     257        G4ParticleDefinition* pd = G4KaonZeroShort::Definition();
     258        if (G4UniformRand() > 0.5) pd = G4KaonZeroLong::Definition();
     259
     260        cascadeParticle = new G4DynamicParticle(pd, momDir, ekin);
     261      } else {
     262        cascadeParticle = new G4DynamicParticle(ipart->getDynamicParticle());
    405263      }
    406 
    407       cascadeParticle->Set4Momentum(cascadeParticle->Get4Momentum()*=toLabFrame);
     264 
    408265      theResult.AddSecondary(cascadeParticle);
    409266    }
     
    412269  // get nuclei fragments
    413270  G4DynamicParticle * aFragment = 0;
    414   G4ParticleDefinition * aIonDef = 0;
    415   G4ParticleTable *theTableOfParticles = G4ParticleTable::GetParticleTable();
    416 
    417271  if (!nucleiFragments.empty()) {
    418     nucleiIterator ifrag;
    419 
    420     for (ifrag = nucleiFragments.begin(); ifrag != nucleiFragments.end(); ifrag++)
    421       {
    422         G4double eKin = ifrag->getKineticEnergy() * GeV;
    423         const G4CascadeMomentum& mom = ifrag->getMomentum();
    424         eTot   += std::sqrt(mom[0] * mom[0]);
    425 
    426         G4ThreeVector aMom(mom[1], mom[2], mom[3]);
    427         aMom = aMom.unit();
    428 
    429         // hpw @@@ ==> Should be zero: G4double fragmentExitation = ifrag->getExitationEnergyInGeV();
    430 
    431         if (verboseLevel > 2) {
    432           G4cout << " Nuclei fragment: " << G4endl;
    433           ifrag->printParticle();
    434         }
    435 
    436         G4int A = G4int(ifrag->getA());
    437         G4int Z = G4int(ifrag->getZ());
    438         aIonDef = theTableOfParticles->FindIon(Z, A, 0, Z);
    439      
    440         aFragment =  new G4DynamicParticle(aIonDef, aMom, eKin);
    441 
    442         sumBaryon -= A;
    443         sumEnergy -= eKin / GeV;
    444 
    445         aFragment->Set4Momentum(aFragment->Get4Momentum()*=toLabFrame);
    446         theResult.AddSecondary(aFragment);
     272    nucleiIterator ifrag = nucleiFragments.begin();
     273    for (; ifrag != nucleiFragments.end(); ifrag++) {
     274      eTot += ifrag->getEnergy();
     275      sumBaryon -= ifrag->getA();
     276      sumEnergy -= ifrag->getKineticEnergy();
     277
     278      if (verboseLevel > 2) {
     279        G4cout << " Nuclei fragment: " << G4endl;
     280        ifrag->printParticle();
    447281      }
    448   }
    449 
     282
     283      // Copy local G4DynPart to public output
     284      aFragment =  new G4DynamicParticle(ifrag->getDynamicParticle());
     285      theResult.AddSecondary(aFragment);
     286    }
     287  }
     288
     289  // Report violations of energy, baryon conservation
    450290  if (verboseLevel > 2) {
    451291    if (sumBaryon != 0) {
    452       G4cout << "ERROR: no baryon number conservation, sum of baryons = " << sumBaryon << G4endl;
     292      G4cout << "ERROR: no baryon number conservation, sum of baryons = "
     293             << sumBaryon << G4endl;
    453294    }
    454295
    455296    if (sumEnergy > 0.01 ) {
    456       G4cout << "Kinetic energy conservation violated by " << sumEnergy << " GeV" << G4endl;
     297      G4cout << "Kinetic energy conservation violated by "
     298             << sumEnergy << " GeV" << G4endl;
    457299    }
    458300     
    459     G4cout << "Total energy conservation at level ~" << (eInit - eTot) * GeV << " MeV" << G4endl;
     301    G4cout << "Total energy conservation at level ~"
     302           << (eInit - eTot) * GeV << " MeV" << G4endl;
    460303   
    461304    if (sumEnergy < -5.0e-5 ) { // 0.05 MeV
    462       G4cout << "FATAL ERROR: energy created  " << sumEnergy * GeV << " MeV" << G4endl;
     305      G4cout << "FATAL ERROR: energy created  "
     306             << sumEnergy * GeV << " MeV" << G4endl;
    463307    }
    464308  }
    465309
    466310  delete bullet;
    467   delete colep;
    468   delete inc;
    469   delete noneq;
    470   delete bigb;
    471311  delete collider;
    472312
    473313  if(target != 0) delete target;
    474314  if(targetH != 0) delete targetH;
    475   // if(cascadeParticle != 0) delete cascadeParticle;
    476   // if(aFragment != 0) delete aFragment;
    477315
    478316  return &theResult;
Note: See TracChangeset for help on using the changeset viewer.