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

update processes

Location:
trunk/source/processes/hadronic/models/coherent_elastic/src
Files:
6 edited

Legend:

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

    r819 r962  
    2525//
    2626//
    27 // $Id: G4ChargeExchange.cc,v 1.11 2007/05/25 17:46:52 dennis Exp $
    28 // GEANT4 tag $Name: $
     27// $Id: G4ChargeExchange.cc,v 1.14 2008/12/18 13:01:48 gunter Exp $
     28// GEANT4 tag $Name: geant4-09-02-ref-02 $
    2929//
    3030//
     
    4141#include "G4ParticleDefinition.hh"
    4242#include "G4IonTable.hh"
    43 #include "G4QElasticCrossSection.hh"
    44 #include "G4VQCrossSection.hh"
    45 #include "G4ElasticHadrNucleusHE.hh"
    4643#include "Randomize.hh"
    47 #include "G4HadronElastic.hh"
    48 
    49 
    50 G4ChargeExchange::G4ChargeExchange(G4HadronElastic* hel, G4double elim,
    51                                    G4double ehigh)
    52 : G4HadronicInteraction("G4ChargeExchange"),
    53   fElastic(hel),
    54   native(false),
    55   ekinlim(elim),
    56   ekinhigh(ehigh)
     44#include "G4NucleiProperties.hh"
     45
     46G4ChargeExchange::G4ChargeExchange() : G4HadronicInteraction("Charge Exchange")
    5747{
    5848  SetMinEnergy( 0.0*GeV );
    5949  SetMaxEnergy( 100.*TeV );
    60   ekinlow = 19.0*MeV;
    61 
    62   verboseLevel= 0;
    63   if(!fElastic) {
    64     native = true;
    65     fElastic = new G4HadronElastic();
    66   }
    67   qCManager   = fElastic->GetCS();
    68   hElastic    = fElastic->GetHElastic();
     50
     51  lowEnergyRecoilLimit = 100.*keV; 
     52  lowestEnergyLimit    = 1.*MeV; 
    6953
    7054  theProton   = G4Proton::Proton();
     
    10084
    10185G4ChargeExchange::~G4ChargeExchange()
    102 {
    103   if(native) delete fElastic;
    104 }
     86{}
    10587
    10688G4HadFinalState* G4ChargeExchange::ApplyYourself(
     
    11799  G4int A = static_cast<G4int>(aTarget+0.5);
    118100
    119   if(ekin == 0.0 || A < 3) {
     101  if(ekin <= lowestEnergyLimit || A < 3) {
    120102    theParticleChange.SetEnergyChange(ekin);
    121103    theParticleChange.SetMomentumChange(aTrack.Get4Momentum().vect().unit());
     
    133115  // Scattered particle referred to axis of incident particle
    134116  const G4ParticleDefinition* theParticle = aParticle->GetDefinition();
    135   G4double m1 = theParticle->GetPDGMass();
    136117
    137118  G4int N = A - Z;
     
    145126  G4ParticleDefinition * theDef = 0;
    146127
    147   if (Z == 1 && A == 3) theDef = theT;
    148   else if (Z == 2 && A == 3) theDef = theHe3;
    149   else if (Z == 2 && A == 4) theDef = theA;
    150   else theDef = G4ParticleTable::GetParticleTable()->FindIon(Z,A,0,Z);
    151 
    152   G4double m2 = theDef->GetPDGMass();
     128  G4double m2 = G4NucleiProperties::GetNuclearMass((G4double)A, (G4double)Z);
    153129  G4LorentzVector lv1 = aParticle->Get4Momentum();
    154130  G4LorentzVector lv0(0.0,0.0,0.0,m2);
     
    259235
    260236  G4double etot = lv0.e() + lv1.e();
    261   if(etot < m11 + m21) return &theParticleChange;
     237
     238  // kinematiacally impossible
     239  if(etot < m11 + m21) {
     240    theParticleChange.SetEnergyChange(ekin);
     241    theParticleChange.SetMomentumChange(aTrack.Get4Momentum().vect().unit());
     242    return &theParticleChange;
     243  }
    262244
    263245  G4ThreeVector p1 = lv1.vect();
    264   G4double e1 = 0.5*etot*(1.0 + (m21*m21 - m11*m11)/(etot*etot));
     246  G4double e1 = 0.5*etot*(1.0 - (m21*m21 - m11*m11)/(etot*etot));
    265247  //  G4double e2 = etot - e1;
    266248  G4double ptot = std::sqrt(e1*e1 - m11*m11);
    267249
    268250  G4double tmax = 4.0*ptot*ptot;
    269   G4double t = 0.0;
    270 
    271   // Choose generator
    272   G4ElasticGenerator gtype = fLElastic;
    273   if ((theParticle == theProton || theParticle == theNeutron) &&
    274       Z <= 2 && ekin >= ekinlow) {
    275     gtype = fQElastic;
    276   } else {
    277     if(ekin >= ekinlow)       gtype = fSWave;
    278     else if(ekin >= ekinhigh) gtype = fHElastic;
    279   }
    280 
    281   // Sample t
    282   if(gtype == fQElastic) {
    283     if (verboseLevel > 1)
    284       G4cout << "G4ChargeExchange: Z= " << Z << " N= "
    285              << N << " pdg= " <<  projPDG
    286              << " mom(GeV)= " << plab/GeV << "  " << qCManager << G4endl;
    287     if(Z == 1 && N == 2) N = 1;
    288     else if (Z == 2 && N == 1) N = 2;
    289     G4double cs = qCManager->GetCrossSection(false,plab,Z,N,projPDG);
    290     if(cs > 0.0) t = qCManager->GetExchangeT(Z,N,projPDG);
    291     else gtype = fSWave;
    292   }
    293 
    294   if(gtype == fHElastic) {
    295     t = hElastic->SampleT(theParticle,plab,Z,A);
    296     if(t > tmax) gtype = fSWave;
    297   }
    298 
    299   if(gtype == fLElastic) {
    300     t = GeV*GeV*fElastic->SampleT(ptot,m1,m2,aTarget);
    301     if(t > tmax) gtype = fSWave;
    302   }
    303 
    304   // NaN finder
    305   if(!(t < 0.0 || t >= 0.0)) {
    306     if (verboseLevel > -1) {
    307       G4cout << "G4ChargeExchange:WARNING: Z= " << Z << " N= "
    308              << N << " pdg= " <<  projPDG
    309              << " mom(GeV)= " << plab/GeV
    310              << " the model type " << gtype;
    311       if(gtype ==  fQElastic) G4cout << " CHIPS ";
    312       else if(gtype ==  fLElastic) G4cout << " LElastic ";
    313       else if(gtype ==  fHElastic) G4cout << " HElastic ";
    314       G4cout << " t= " << t
    315              << " S-wave will be sampled"
    316              << G4endl;
    317     }
    318     gtype = fSWave;
    319   }
    320 
    321   if(gtype == fSWave) t = G4UniformRand()*tmax;
     251  G4double g2 = GeV*GeV;
     252
     253  G4double t = g2*SampleT(tmax/g2,aTarget);
    322254
    323255  if(verboseLevel>1)
    324     G4cout <<"type= " << gtype <<" t= " << t << " tmax= " << tmax
     256    G4cout <<"## G4ChargeExchange t= " << t << " tmax= " << tmax
    325257           << " ptot= " << ptot << G4endl;
    326258
     
    328260  G4double phi  = G4UniformRand()*twopi;
    329261  G4double cost = 1. - 2.0*t/tmax;
    330   if(std::abs(cost) > 1.0) cost = -1.0 + 2.0*G4UniformRand();
     262  if(std::abs(cost) > 1.0) cost = 1.0;
    331263  G4double sint = std::sqrt((1.0-cost)*(1.0+cost));
    332264
    333   if (verboseLevel > 1)
    334     G4cout << "cos(t)=" << cost << " std::sin(t)=" << sint << G4endl;
     265  //if (verboseLevel > 1)
     266  //  G4cout << "cos(t)=" << cost << " std::sin(t)=" << sint << G4endl;
    335267
    336268  G4ThreeVector v1(sint*std::cos(phi),sint*std::sin(phi),cost);
     
    343275
    344276  theParticleChange.SetStatusChange(stopAndKill);
     277  theParticleChange.SetEnergyChange(0.0);
    345278  G4DynamicParticle * aSec = new G4DynamicParticle(theSecondary, nlv1);
    346279  theParticleChange.AddSecondary(aSec);
    347280
    348281  G4double erec =  nlv0.e() - m21;
     282
     283  //G4cout << "erec= " <<erec << " Esec= " << aSec->GetKineticEnergy() << G4endl; 
     284
    349285  if(theHyperon) {
    350286    theParticleChange.SetLocalEnergyDeposit(erec);
     
    352288    aSec->SetDefinition(theRecoil);
    353289    aSec->SetKineticEnergy(0.0);
    354   } else if(erec > ekinlim) {
     290  } else if(erec > lowEnergyRecoilLimit) {
    355291    aSec = new G4DynamicParticle(theRecoil, nlv0);
    356292    theParticleChange.AddSecondary(aSec);
    357293  } else {
     294    if(erec < 0.0) erec = 0.0;
    358295    theParticleChange.SetLocalEnergyDeposit(erec);
    359296  }
    360297  return &theParticleChange;
    361298}
     299
     300G4double G4ChargeExchange::SampleT(G4double tmax, G4double A)
     301{
     302  G4double aa, bb, cc, dd;
     303  if (A <= 62.) {
     304    aa = std::pow(A, 1.63);
     305    bb = 14.5*std::pow(A, 0.66);
     306    cc = 1.4*std::pow(A, 0.33);
     307    dd = 10.;
     308  } else {
     309    aa = std::pow(A, 1.33);
     310    bb = 60.*std::pow(A, 0.33);
     311    cc = 0.4*std::pow(A, 0.40);
     312    dd = 10.;
     313  }
     314  G4double x1 = (1.0 - std::exp(-tmax*bb))*aa/bb;
     315  G4double x2 = (1.0 - std::exp(-tmax*dd))*cc/dd;
     316 
     317  G4double t;
     318  G4double y = bb;
     319  if(G4UniformRand()*(x1 + x2) < x2) y = dd;
     320
     321  do {t = -std::log(G4UniformRand())/y;} while (t > tmax);
     322
     323  return t;
     324}
     325
  • 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
  • trunk/source/processes/hadronic/models/coherent_elastic/src/G4DiffuseElastic.cc

    r819 r962  
    2525//
    2626// $Id: G4DiffuseElastic.cc,v 1.20 2008/01/14 10:39:13 vnivanch Exp $
    27 // GEANT4 tag $Name: $
     27// GEANT4 tag $Name: geant4-09-02-ref-02 $
    2828//
    2929//
  • trunk/source/processes/hadronic/models/coherent_elastic/src/G4ElasticHadrNucleusHE.cc

    r819 r962  
    2626//
    2727// $Id: G4ElasticHadrNucleusHE.cc,v 1.79 2008/01/14 10:39:13 vnivanch Exp $
    28 // GEANT4 tag $Name: $
     28// GEANT4 tag $Name: geant4-09-02-ref-02 $
    2929//
    3030//
  • trunk/source/processes/hadronic/models/coherent_elastic/src/G4HadronElastic.cc

    r819 r962  
    2424// ********************************************************************
    2525//
    26 // $Id: G4HadronElastic.cc,v 1.56.2.1 2008/04/23 14:14:55 gcosmo Exp $
    27 // GEANT4 tag $Name: geant4-09-01-patch-02 $
     26// $Id: G4HadronElastic.cc,v 1.61 2008/08/05 07:37:39 vnivanch Exp $
     27// GEANT4 tag $Name: geant4-09-02-ref-02 $
    2828//
    2929//
     
    100100  thePionPlus = G4PionPlus::PionPlus();
    101101  thePionMinus= G4PionMinus::PionMinus();
     102
     103  nnans = 0;
     104  npos  = 0;
     105  nneg  = 0;
     106  neneg = 0;
    102107}
    103108
     
    105110{
    106111  delete hElastic;
     112  if( (nnans + npos + nneg + neneg) > 0 ) {
     113    G4cout << "### G4HadronElastic destructor Warnings: ";
     114    if(nnans > 0) G4cout << "###          N(nans)    = " << nnans;
     115    if(npos > 0)  G4cout << "###          N(cost > 1)= " << npos;
     116    if(nneg > 0)  G4cout << "###          N(cost <-1)= " << nneg;
     117    if(neneg > 0) G4cout << "###          N(E < 0)=    " << neneg;
     118    G4cout << "###" << G4endl;
     119  }
    107120}
    108121
     
    148161  G4int N = A - Z;
    149162  G4int projPDG = theParticle->GetPDGEncoding();
    150   if (verboseLevel>1)
     163  if (verboseLevel>1) {
    151164    G4cout << "G4HadronElastic for " << theParticle->GetParticleName()
    152165           << " PDGcode= " << projPDG << " on nucleus Z= " << Z
    153166           << " A= " << A << " N= " << N
    154167           << G4endl;
    155 
     168  }
    156169  G4ParticleDefinition * theDef = 0;
    157170
     
    180193
    181194  // Q-elastic for p,n scattering on H and He
    182   if (theParticle == theProton || theParticle == theNeutron)
     195  if (theParticle == theProton || theParticle == theNeutron) {
    183196    //     && Z <= 2 && ekin >= lowEnergyLimitQ) 
    184197    gtype = fQElastic;
    185198
    186   else {
     199  } else {
    187200    // S-wave for very low energy
    188201    if(plab < plabLowLimit) gtype = fSWave;
    189202    // HE-elastic for energetic projectile mesons
    190203    else if(ekin >= lowEnergyLimitHE && theParticle->GetBaryonNumber() == 0)
    191       gtype = fHElastic;
     204      { gtype = fHElastic; }
    192205  }
    193206
     
    212225
    213226  if(gtype == fLElastic) {
    214     t = GeV*GeV*SampleT(ptot,m1,m2,aTarget);
     227    G4double g2 = GeV*GeV;
     228    t = g2*SampleT(tmax/g2,m1,m2,aTarget);
    215229  }
    216230
     
    234248    }
    235249    t = 0.0;
     250    nnans++;
    236251  }
    237252
    238253  if(gtype == fSWave) t = G4UniformRand()*tmax;
    239254
    240   if(verboseLevel>1)
     255  if(verboseLevel>1) {
    241256    G4cout <<"type= " << gtype <<" t= " << t << " tmax= " << tmax
    242257           << " ptot= " << ptot << G4endl;
    243 
     258  }
    244259  // Sampling in CM system
    245260  G4double phi  = G4UniformRand()*twopi;
     
    247262  G4double sint;
    248263
    249   if( cost >= 1.0 || cost < -1 )
    250   {
     264  // problem in sampling
     265  if(cost >= 1.0) {
    251266    cost = 1.0;
    252267    sint = 0.0;
    253   }
    254   else 
    255   {
     268    npos++;
     269  } else if(cost < -1 ) {
     270    /*
     271    G4cout << "G4HadronElastic:WARNING: Z= " << Z << " N= "
     272           << N << " " << aParticle->GetDefinition()->GetParticleName()
     273           << " mom(GeV)= " << plab/GeV
     274           << " the model type " << gtype;
     275    if(gtype ==  fQElastic) G4cout << " CHIPS ";
     276    else if(gtype ==  fLElastic) G4cout << " LElastic ";
     277    else if(gtype ==  fHElastic) G4cout << " HElastic ";
     278    G4cout << " cost= " << cost
     279           << G4endl;
     280    */
     281    cost = 1.0;
     282    sint = 0.0;
     283    nneg++;
     284
     285    // normal situation
     286  } else  {
    256287    sint = std::sqrt((1.0-cost)*(1.0+cost));
    257288  }   
    258   if (verboseLevel>1)
     289  if (verboseLevel>1) {
    259290    G4cout << "cos(t)=" << cost << " std::sin(t)=" << sint << G4endl;
    260 
     291  }
    261292  G4ThreeVector v1(sint*std::cos(phi),sint*std::sin(phi),cost);
    262293  v1 *= ptot;
     
    273304  }
    274305  if(eFinal <= lowestEnergyLimit) {
    275     if(eFinal < 0.0) {
     306    if(eFinal < 0.0 && verboseLevel > 0) {
     307      neneg++;
    276308      G4cout << "G4HadronElastic WARNING ekin= " << eFinal
    277309             << " after scattering of "
     
    308340
    309341G4double
    310 G4HadronElastic::SampleT(G4double, G4double, G4double, G4double atno2)
     342G4HadronElastic::SampleT(G4double tmax, G4double, G4double, G4double atno2)
    311343{
    312344  // G4cout << "Entering elastic scattering 2"<<G4endl;
     
    315347  // parameterized functions and a Monte Carlo method to invert the CDF.
    316348
    317   G4double ran = G4UniformRand();
     349  //  G4double ran = G4UniformRand();
    318350  G4double aa, bb, cc, dd, rr;
    319351  if (atno2 <= 62.) {
     
    330362  aa = aa/bb;
    331363  cc = cc/dd;
     364  G4double ran, t1, t2;
     365  do {
     366    ran = G4UniformRand();
     367    t1 = -std::log(ran)/bb;
     368    t2 = -std::log(ran)/dd;
     369  } while(t1 > tmax || t2 > tmax);
     370
    332371  rr = (aa + cc)*ran;
     372
    333373  if (verboseLevel > 1) {
    334374    G4cout << "DoIt: aa,bb,cc,dd,rr" << G4endl;
    335375    G4cout << aa << " " << bb << " " << cc << " " << dd << " " << rr << G4endl;
    336   }
    337   G4double t1 = -std::log(ran)/bb;
    338   G4double t2 = -std::log(ran)/dd;
    339   if (verboseLevel > 1) {
    340376    G4cout << "t1,Fctcos " << t1 << " " << Fctcos(t1, aa, bb, cc, dd, rr) << G4endl;
    341377    G4cout << "t2,Fctcos " << t2 << " " << Fctcos(t2, aa, bb, cc, dd, rr) << G4endl;
     
    348384              aa, bb, cc, dd, rr);
    349385  if (verboseLevel > 1) {
    350     G4cout << "From Rtmi, ier1=" << ier1 << G4endl;
     386    G4cout << "From Rtmi, ier1=" << ier1 << " t= " << t << G4endl;
    351387    G4cout << "t, Fctcos " << t << " " << Fctcos(t, aa, bb, cc, dd, rr) << G4endl;
    352388  }
  • trunk/source/processes/hadronic/models/coherent_elastic/src/G4UHadronElasticProcess.cc

    r819 r962  
    2424// ********************************************************************
    2525//
    26 // $Id: G4UHadronElasticProcess.cc,v 1.35.2.1 2008/04/23 14:14:55 gcosmo Exp $
    27 // GEANT4 tag $Name: geant4-09-01-patch-02 $
     26// $Id: G4UHadronElasticProcess.cc,v 1.39 2008/10/22 08:16:40 vnivanch Exp $
     27// GEANT4 tag $Name: geant4-09-02-ref-02 $
    2828//
    2929// Geant4 Hadron Elastic Scattering Process -- header file
     
    5858  : G4HadronicProcess(pName), lowestEnergy(0.0), first(true)
    5959{
     60  SetProcessSubType(fHadronElastic);
    6061  AddDataSet(new G4HadronElasticDataSet);
    6162  theProton   = G4Proton::Proton();
     
    8990    if(theParticle->GetPDGCharge() != 0.0) lowestEnergy = eV;
    9091     
    91     if(verboseLevel>1 ||
    92        (verboseLevel==1 && theParticle == theNeutron)) {
    93       G4cout << G4endl;
     92    //    if(verboseLevel>1 ||
     93    //   (verboseLevel==1 && theParticle == theNeutron)) {
     94    if(verboseLevel>1 && theParticle == theNeutron) {
     95    //      G4cout << G4endl;
    9496      G4cout << "G4UHadronElasticProcess for "
    9597             << theParticle->GetParticleName()
     
    100102    }
    101103  }
    102   store->BuildPhysicsTable(aParticleType);
     104  G4HadronicProcess::BuildPhysicsTable(aParticleType);
     105  //store->BuildPhysicsTable(aParticleType);
    103106}
    104107
Note: See TracChangeset for help on using the changeset viewer.