Ignore:
Timestamp:
Apr 6, 2009, 12:30:29 PM (16 years ago)
Author:
garnier
Message:

update processes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/processes/hadronic/models/coherent_elastic/src/G4ChargeExchangeProcess.cc

    r819 r962  
    2525//
    2626//
    27 // $Id: G4ChargeExchangeProcess.cc,v 1.9 2007/01/30 10:23:26 vnivanch Exp $
    28 // GEANT4 tag $Name: $
     27// $Id: G4ChargeExchangeProcess.cc,v 1.15 2008/11/27 16:43:00 vnivanch Exp $
     28// GEANT4 tag $Name: geant4-09-02-ref-02 $
    2929//
    3030//
    31 // Geant4 Hadron Elastic Scattering Process -- header file
     31// Geant4 Hadron Charge Exchange Process -- source file
    3232//
    3333// Created 21 April 2006 V.Ivanchenko
     
    4545#include "G4CrossSectionDataStore.hh"
    4646#include "G4HadronElasticDataSet.hh"
    47 #include "G4VQCrossSection.hh"
    48 #include "G4QElasticCrossSection.hh"
    49 #include "G4QCHIPSWorld.hh"
    5047#include "G4Element.hh"
    5148#include "G4ElementVector.hh"
     
    5350#include "G4Neutron.hh"
    5451#include "G4Proton.hh"
    55 #include "G4HadronElastic.hh"
    5652#include "G4PhysicsLinearVector.hh"
    5753
     
    5955  : G4HadronicProcess(procName), first(true)
    6056{
    61   thEnergy = 19.*MeV;
     57  SetProcessSubType(fChargeExchange);
     58  thEnergy = 20.*MeV;
    6259  verboseLevel= 1;
    63   qCManager = 0;
    6460  AddDataSet(new G4HadronElasticDataSet);
    6561  theProton   = G4Proton::Proton();
     
    9995}
    10096
    101 void G4ChargeExchangeProcess::SetQElasticCrossSection(G4VQCrossSection* p)
    102 {
    103   qCManager = p;
    104 }
    105 
    10697void G4ChargeExchangeProcess::
    10798BuildPhysicsTable(const G4ParticleDefinition& aParticleType)
     
    120111
    121112      G4double F[n] = {0.33,0.27,0.29,0.31,0.27,0.18,0.13,0.1,0.09,0.07};
    122       factors = new G4PhysicsLinearVector(0.0,1.8*GeV,n);
     113      factors = new G4PhysicsLinearVector(0.0,2.0*GeV,n);
    123114      for(size_t i=0; i<n; i++) {factors->PutValue(i,F[i]);}
    124115
     
    126117
    127118      G4double F[n] = {0.50,0.45,0.40,0.35,0.30,0.25,0.06,0.04,0.005,0.0};
    128       factors = new G4PhysicsLinearVector(0.0,3.6*GeV,n);
     119      factors = new G4PhysicsLinearVector(0.0,4.0*GeV,n);
    129120      for(size_t i=0; i<n; i++) {factors->PutValue(i,F[i]);}
    130121    }
     122    //factors->SetSpline(true);
    131123
    132124    if(verboseLevel>1)
     
    135127             << G4endl;
    136128  }
    137   store->BuildPhysicsTable(aParticleType);
    138 }
    139 
    140 G4double G4ChargeExchangeProcess::GetMeanFreePath(const G4Track& track,
    141                                                   G4double,
    142                                                   G4ForceCondition* cond)
    143 {
    144   *cond = NotForced;
    145   const G4DynamicParticle* dp = track.GetDynamicParticle();
    146   const G4Material* material = track.GetMaterial();
    147   cross = 0.0;
    148   G4double x = DBL_MAX;
    149 
    150   // The process is effective only above the threshold
    151   if(dp->GetKineticEnergy() < thEnergy) return x;
    152 
    153   // Compute cross sesctions
    154   const G4ElementVector* theElementVector = material->GetElementVector();
    155   const G4double* theAtomNumDensityVector = material->GetVecNbOfAtomsPerVolume();
    156   G4double temp = material->GetTemperature();
    157   G4int nelm   = material->GetNumberOfElements();
    158   if(verboseLevel>1)
    159     G4cout << "G4ChargeExchangeProcess get mfp for "
    160            << theParticle->GetParticleName()
    161            << "  p(GeV)= " << dp->GetTotalMomentum()/GeV
    162            << " in " << material->GetName()
    163            << G4endl;
    164   for (G4int i=0; i<nelm; i++) {
    165     const G4Element* elm = (*theElementVector)[i];
    166     G4double x = GetMicroscopicCrossSection(dp, elm, temp);
    167     cross += theAtomNumDensityVector[i]*x;
    168     xsec[i] = cross;
    169   }
    170   if(verboseLevel>1)
    171     G4cout << "G4ChargeExchangeProcess cross(1/mm)= " << cross
    172            << "  E(MeV)= " << dp->GetKineticEnergy()
    173            << "  " << theParticle->GetParticleName()
    174            << "  in " << material->GetName()
    175            << G4endl;
    176   if(cross > DBL_MIN) x = 1./cross;
    177 
    178   return x;
     129  G4HadronicProcess::BuildPhysicsTable(aParticleType);
    179130}
    180131
     
    188139  G4int iz = G4int(Z);
    189140  G4double x = 0.0;
    190   if(iz == 1) return x;
     141
     142  // The process is effective only above the threshold
     143  if(iz == 1 || dp->GetKineticEnergy() < thEnergy) return x;
    191144
    192145  if(verboseLevel>1)
     
    195148           << G4endl;
    196149  x = store->GetCrossSection(dp, elm, temp);
    197 
    198   // NaN finder
    199   if(!(x < 0.0 || x >= 0.0)) {
    200     if (verboseLevel > -1) {
    201       G4cout << "G4ChargeExchangeProcess WARNING: Z= " << iz 
    202              << " pdg= " <<  pPDG
    203              << " mom(GeV)= " << dp->GetTotalMomentum()/GeV
    204              << " cross= " << x
    205              << " set to zero"
    206              << G4endl;
    207     }
    208     x = 0.0;
    209   }
    210150
    211151  if(verboseLevel>1)
     
    217157  G4bool b;
    218158  G4double A = elm->GetN();
    219   x *= factors->GetValue(dp->GetTotalMomentum(), b)/std::pow(A, 0.42);
     159  G4double ptot = dp->GetTotalMomentum();
     160  x *= factors->GetValue(ptot, b)/std::pow(A, 0.42);
    220161  if(theParticle == thePiPlus || theParticle == theProton ||
    221162     theParticle == theKPlus  || theParticle == theANeutron)
    222     x *= (1.0 - Z/A);
     163    { x *= (1.0 - Z/A); }
    223164
    224165  else if(theParticle == thePiMinus || theParticle == theNeutron ||
    225166          theParticle == theKMinus  || theParticle == theAProton)
    226     x *= Z/A;
     167    { x *= Z/A; }
     168
     169  if(theParticle->GetPDGMass() < GeV) {
     170    if(ptot > 2.*GeV) x *= 4.0*GeV*GeV/(ptot*ptot);
     171  }
     172
     173  if(verboseLevel>1)
     174    G4cout << "Corrected cross(mb)= " << x/millibarn << G4endl;
    227175
    228176  return x;
    229 }
    230 
    231 G4VParticleChange* G4ChargeExchangeProcess::PostStepDoIt(
    232                                   const G4Track& track,
    233                                   const G4Step& step)
    234 {
    235   G4ForceCondition* cn = 0;
    236   aParticleChange.Initialize(track);
    237   G4double mfp = GetMeanFreePath(track, 0.0, cn);
    238   if(mfp == DBL_MAX) return G4VDiscreteProcess::PostStepDoIt(track,step);
    239 
    240   G4double kineticEnergy = track.GetKineticEnergy();
    241   G4Material* material = track.GetMaterial();
    242 
    243   // Select element
    244   const G4ElementVector* theElementVector = material->GetElementVector();
    245   G4Element* elm = (*theElementVector)[0];
    246   G4int nelm = material->GetNumberOfElements() - 1;
    247   if (nelm > 0) {
    248     G4double x = G4UniformRand()*cross;
    249     G4int i = -1;
    250     do {i++;} while (x > xsec[i] && i < nelm);
    251     elm = (*theElementVector)[i];
    252   }
    253   G4double Z = elm->GetZ();
    254   G4double A = G4double(G4int(elm->GetN()+0.5));
    255 
    256   // Select isotope
    257   G4IsotopeVector* isv = elm->GetIsotopeVector();
    258   G4int ni = 0;
    259   if(isv) ni = isv->size();
    260 
    261   if(ni == 1) {
    262     A = G4double((*isv)[0]->GetN());
    263   } else if(ni > 1) {
    264 
    265     G4double* ab = elm->GetRelativeAbundanceVector();
    266     G4int j = -1;
    267     ni--;
    268     G4double y = G4UniformRand();
    269     do {
    270       j++;
    271       y -= ab[j];
    272     } while (y > 0.0 && j < ni);
    273     A = G4double((*isv)[j]->GetN());
    274   }
    275   G4HadronicInteraction* hadi =
    276     ChooseHadronicInteraction( kineticEnergy, material, elm);
    277 
    278   // Initialize the hadronic projectile from the track
    279   G4HadProjectile thePro(track);
    280   if(verboseLevel>1)
    281     G4cout << "G4ChargeExchangeProcess::PostStepDoIt for "
    282            << theParticle->GetParticleName()
    283            << " Target Z= " << Z
    284            << " A= " << A << G4endl;
    285   targetNucleus.SetParameters(A, Z);
    286 
    287   aParticleChange.Initialize(track);
    288   G4HadFinalState* result = hadi->ApplyYourself(thePro, targetNucleus);
    289   G4ThreeVector indir = track.GetMomentumDirection();
    290   G4int nsec = result->GetNumberOfSecondaries();
    291 
    292   if(verboseLevel>1)
    293     G4cout << "Efin= " << result->GetEnergyChange()
    294            << " de= " << result->GetLocalEnergyDeposit()
    295            << " nsec= " << nsec
    296            << G4endl;
    297 
    298 
    299   if(nsec > 0) {
    300     aParticleChange.ProposeEnergy(0.0);
    301     aParticleChange.ProposeTrackStatus(fStopAndKill);
    302     aParticleChange.ProposeLocalEnergyDeposit(result->GetLocalEnergyDeposit());
    303     aParticleChange.SetNumberOfSecondaries(nsec);
    304     for(G4int j=0; j<nsec; j++) {
    305       G4DynamicParticle* p = result->GetSecondary(j)->GetParticle();
    306       G4ThreeVector pdir = p->GetMomentumDirection();
    307       // G4cout << "recoil " << pdir << G4endl;
    308       pdir = pdir.rotateUz(indir);
    309       // G4cout << "recoil rotated " << pdir << G4endl;
    310       p->SetMomentumDirection(pdir);
    311       aParticleChange.AddSecondary(p);
    312     }
    313   }
    314   result->Clear();
    315 
    316   return G4VDiscreteProcess::PostStepDoIt(track,step);
    317177}
    318178
Note: See TracChangeset for help on using the changeset viewer.