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

update processes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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  }
Note: See TracChangeset for help on using the changeset viewer.