Ignore:
Timestamp:
Nov 25, 2009, 5:13:58 PM (15 years ago)
Author:
garnier
Message:

update CVS release candidate geant4.9.3.01

Location:
trunk/source/processes/electromagnetic/utils/src
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/processes/electromagnetic/utils/src/G4DummyModel.cc

    r1055 r1196  
    2525//
    2626// $Id: G4DummyModel.cc,v 1.4 2009/04/07 18:39:47 vnivanch Exp $
    27 // GEANT4 tag $Name: geant4-09-03-beta-cand-01 $
     27// GEANT4 tag $Name: geant4-09-03-cand-01 $
    2828//
    2929// -------------------------------------------------------------------
  • trunk/source/processes/electromagnetic/utils/src/G4ElectronIonPair.cc

    r1007 r1196  
    2525//
    2626// $Id: G4ElectronIonPair.cc,v 1.2 2008/10/17 14:46:16 vnivanch Exp $
    27 // GEANT4 tag $Name: geant4-09-02 $
     27// GEANT4 tag $Name: geant4-09-03-cand-01 $
    2828//
    2929// -------------------------------------------------------------------
  • trunk/source/processes/electromagnetic/utils/src/G4EmCalculator.cc

    r1055 r1196  
    2424// ********************************************************************
    2525//
    26 // $Id: G4EmCalculator.cc,v 1.46 2009/02/24 09:56:03 vnivanch Exp $
    27 // GEANT4 tag $Name: geant4-09-03-beta-cand-01 $
     26// $Id: G4EmCalculator.cc,v 1.48 2009/11/11 23:59:48 vnivanch Exp $
     27// GEANT4 tag $Name: geant4-09-03-cand-01 $
    2828//
    2929// -------------------------------------------------------------------
     
    127127  if(couple && UpdateParticle(p, kinEnergy) ) {
    128128    res = manager->GetDEDX(p, kinEnergy, couple);
     129    /*
    129130    if(isIon) {
    130       G4double eth = 2.0*MeV/massRatio;
    131       if(kinEnergy > eth) {
    132         G4double x1 = corr->ComputeIonCorrections(p,mat,kinEnergy);
    133         G4double x2 = corr->ComputeIonCorrections(p,mat,eth);
    134         res += x1 - x2*eth/kinEnergy;
    135         /*     
    136         G4cout << "### GetDEDX: E= " << kinEnergy << " res= " << res
    137                << " x1= " << x1 << " x2= " << x2
    138                << " del= " << x1 - x2*eth/kinEnergy << G4endl;;
    139         */
    140       } 
    141     }
    142 
     131      if(FindEmModel(p, currentProcessName, kinEnergy)) {
     132        G4double length = 1.*um;
     133        G4cout << "### GetDEDX: E= " << kinEnergy << " res= " << res;
     134        G4double eloss = res*length;
     135        G4double niel  = 0.0;
     136        currentModel->CorrectionsAlongStep(couple,&dynParticle,eloss,niel,length);
     137        res = eloss/length;
     138   
     139        //G4cout << "### GetDEDX: E= " << kinEnergy << " res= " << res; 
     140        G4cout << " res1= " << res << G4endl;;
     141      }
     142    } 
     143    */
    143144    if(verbose>0) {
    144145      G4cout << "G4EmCalculator::GetDEDX: E(MeV)= " << kinEnergy/MeV
     
    147148             << "  " <<  p->GetParticleName()
    148149             << " in " <<  mat->GetName()
     150             << " isIon= " << isIon
    149151             << G4endl;
    150152    }
     
    307309    FindLambdaTable(p, processName);
    308310    if(currentLambda) {
    309       G4bool b;
    310311      G4double e = kinEnergy*massRatio;
    311       res = (((*currentLambda)[idx])->GetValue(e,b))*chargeSquare;
     312      res = (((*currentLambda)[idx])->Value(e))*chargeSquare;
    312313      if(verbose>0) {
    313314        G4cout << "E(MeV)= " << kinEnergy/MeV
     
    436437      }
    437438
    438       // emulate boundary region for different parameterisations
     439      // emulate smoothing procedure
    439440      G4double eth = currentModel->LowEnergyLimit();
    440441      //      G4cout << "massRatio= " << massRatio << " eth= " << eth << G4endl;
    441       if(eth > 0.05*MeV && eth < 10.*MeV && escaled > eth &&
    442          loweModel != currentModel && loweModel) {
     442      if(loweModel) {
    443443        G4double res0 = 0.0;
    444444        G4double res1 = 0.0;
     
    462462               << res1 <<  "  q2= " << chargeSquare << G4endl;
    463463        */
    464         res *= (1.0 + (res0/res1 - 1.0)*eth/escaled);
    465 
    466         if(isIon) {
    467           G4double ethscaled = eth/massRatio;
    468           if(kinEnergy > ethscaled) {
    469             G4double x1 = corr->ComputeIonCorrections(p,mat,kinEnergy);
    470             G4double x2 = corr->ComputeIonCorrections(p,mat,ethscaled);
    471             res += x1 - x2*ethscaled/kinEnergy;
    472           }
     464        res += (res0 - res1)*eth/escaled;
     465      }
     466
     467      // low energy correction for ions
     468      /*
     469      if(isIon) {
     470        G4double length = 1.*nm;
     471        const G4Region* r = 0;
     472        const G4MaterialCutsCouple* couple = FindCouple(mat, r);
     473        G4double eloss = res*length;
     474        G4double niel  = 0.0;
     475        currentModel->CorrectionsAlongStep(couple,&dynParticle,eloss,niel,length);
     476        res = eloss/length;
    473477       
    474           if(verbose > 1) {
    475             G4cout << "After Corrections: DEDX(MeV/mm)= " << res*mm/MeV
    476                    << " DEDX(MeV*cm^2/g)= " << res*gram/(MeV*cm2*mat->GetDensity())
    477                    << G4endl;
    478           }
     478        if(verbose > 1) {
     479          G4cout << "After Corrections: DEDX(MeV/mm)= " << res*mm/MeV
     480                 << " DEDX(MeV*cm^2/g)= " << res*gram/(MeV*cm2*mat->GetDensity())
     481                 << G4endl;
    479482        }
    480483      }
     484      */
     485    }
    481486     
    482       if(verbose > 0) {
    483         G4cout << "E(MeV)= " << kinEnergy/MeV
    484                << " DEDX(MeV/mm)= " << res*mm/MeV
    485                << " DEDX(MeV*cm^2/g)= " << res*gram/(MeV*cm2*mat->GetDensity())
    486                << " cut(MeV)= " << cut/MeV
    487                << "  " <<  p->GetParticleName()
    488                << " in " <<  currentMaterialName
    489                << " Zi^2= " << chargeSquare
    490                << G4endl;
    491       }
     487    if(verbose > 0) {
     488      G4cout << "E(MeV)= " << kinEnergy/MeV
     489             << " DEDX(MeV/mm)= " << res*mm/MeV
     490             << " DEDX(MeV*cm^2/g)= " << res*gram/(MeV*cm2*mat->GetDensity())
     491             << " cut(MeV)= " << cut/MeV
     492             << "  " <<  p->GetParticleName()
     493             << " in " <<  currentMaterialName
     494             << " Zi^2= " << chargeSquare
     495             << G4endl;
    492496    }
    493497  }
     
    745749{
    746750  if(p != currentParticle) {
     751
     752    // new particle
    747753    currentParticle = p;
     754    dynParticle.SetDefinition(const_cast<G4ParticleDefinition*>(p));
     755    dynParticle.SetKineticEnergy(kinEnergy);
    748756    baseParticle    = 0;
    749757    currentParticleName = p->GetParticleName();
     
    753761    currentProcess  = FindEnergyLossProcess(p);
    754762    currentProcessName = "";
    755     if(currentProcess) currentProcessName = currentProcess->GetProcessName();
    756 
    757     if(p->GetParticleType() == "nucleus"
    758        && currentParticleName != "deuteron" 
    759        && currentParticleName != "triton"
    760        && currentParticleName != "alpha+"
    761        && currentParticleName != "helium"
    762        && currentParticleName != "hydrogen"
    763       ) {
    764       baseParticle = theGenericIon;
    765       massRatio = baseParticle->GetPDGMass()/p->GetPDGMass();
    766       isIon = true;
    767       //      G4cout << p->GetParticleName()
    768       // << " in " << currentMaterial->GetName()
    769       //       << "  e= " << kinEnergy << G4endl;
    770       chargeSquare =
    771         ionEffCharge->EffectiveChargeSquareRatio(p, currentMaterial, kinEnergy);
    772       //G4cout << "q2= " << chargeSquare << G4endl;
    773     } else {
    774       isIon = false;
    775       if(currentProcess) {
    776         baseParticle    = currentProcess->BaseParticle();
    777 
    778         if(baseParticle) {
    779           massRatio = baseParticle->GetPDGMass()/p->GetPDGMass();
    780           G4double q = baseParticle->GetPDGCharge()/eplus;
    781           chargeSquare /= (q*q);
    782         }
    783       }
    784     }
    785   }
     763    isIon = false;
     764
     765    // ionisation process exist
     766    if(currentProcess) {
     767      currentProcessName = currentProcess->GetProcessName();
     768      baseParticle = currentProcess->BaseParticle();
     769
     770      // base particle is used
     771      if(baseParticle) {
     772        massRatio = baseParticle->GetPDGMass()/p->GetPDGMass();
     773        G4double q = p->GetPDGCharge()/baseParticle->GetPDGCharge();
     774        chargeSquare = q*q;
     775      }
     776
     777      if(p->GetParticleType()   == "nucleus"
     778         && currentParticleName != "deuteron" 
     779         && currentParticleName != "triton"
     780         && currentParticleName != "alpha+"
     781         && currentParticleName != "helium"
     782         && currentParticleName != "hydrogen"
     783         ) {
     784        isIon = true;
     785        massRatio = theGenericIon->GetPDGMass()/p->GetPDGMass();
     786        baseParticle = theGenericIon;
     787        //      G4cout << p->GetParticleName()
     788        // << " in " << currentMaterial->GetName()
     789        //       << "  e= " << kinEnergy << G4endl;
     790      }
     791    }
     792  }
     793
     794  // Effective charge for ions
    786795  if(isIon) {
    787796    chargeSquare =
    788      ionEffCharge->EffectiveChargeSquareRatio(p, currentMaterial, kinEnergy)
     797      corr->EffectiveChargeSquareRatio(p, currentMaterial, kinEnergy)
    789798      * corr->EffectiveChargeCorrection(p,currentMaterial,kinEnergy);
    790799    if(currentProcess) {
     
    810819    p = currentParticle;
    811820  }
     821  return p;
     822}
     823
     824//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
     825
     826const G4ParticleDefinition* G4EmCalculator::FindIon(G4int Z, G4int A)
     827{
     828  const G4ParticleDefinition* p =
     829    G4ParticleTable::GetParticleTable()->FindIon(Z,A,0,Z);
    812830  return p;
    813831}
     
    897915    G4String partname =  p->GetParticleName();
    898916    const G4ParticleDefinition* part = p;
    899     if(isIon) part = theGenericIon;
    900 
     917    if(isIon) { part = theGenericIon; }
     918
     919    // energy loss process
    901920    G4LossTableManager* lManager = G4LossTableManager::Instance();
    902921    const std::vector<G4VEnergyLossProcess*> vel =
    903       lManager->GetEnergyLossProcessVector();
     922    lManager->GetEnergyLossProcessVector();
    904923    G4int n = vel.size();
    905924    for(G4int i=0; i<n; i++) {
    906925      if((vel[i])->GetProcessName() == currentName &&
    907926         (vel[i])->Particle() == part)
    908       {
    909         currentLambda = (vel[i])->LambdaTable();
    910         isApplicable    = true;
    911         break;
    912       }
    913     }
     927        {
     928          currentLambda = (vel[i])->LambdaTable();
     929          isApplicable    = true;
     930          break;
     931        }
     932    }
     933 
     934    // discrete process
    914935    if(!currentLambda) {
    915936      const std::vector<G4VEmProcess*> vem = lManager->GetEmProcessVector();
     
    925946      }
    926947    }
     948
     949    // msc process
    927950    if(!currentLambda) {
    928951      const std::vector<G4VMultipleScattering*> vmsc =
     
    957980  const G4ParticleDefinition* part = p;
    958981  G4double scaledEnergy = kinEnergy*massRatio;
    959   if(isIon) part = theGenericIon;
     982  if(isIon) { part = theGenericIon; }
    960983
    961984  if(verbose > 1) {
     
    967990  }
    968991
    969   // Search for the process
     992  // Search for energy loss process
    970993  currentName = processName;
    971994  currentModel = 0;
     
    976999    lManager->GetEnergyLossProcessVector();
    9771000  G4int n = vel.size();
     1001  G4VEnergyLossProcess* elproc = 0;
    9781002  for(G4int i=0; i<n; i++) {
    9791003    //    G4cout << "i= " << i << " part= "
    9801004    //  << (vel[i])->Particle()->GetParticleName()
    9811005    //     << "   proc= " << (vel[i])->GetProcessName()  << G4endl;
    982     if((vel[i])->GetProcessName() == currentName &&
    983        (vel[i])->Particle() == part)
    984     {
    985       const G4ParticleDefinition* bp = (vel[i])->BaseParticle();
    986       //      G4cout << "i= " << i << " bp= " << bp << G4endl;
    987       if(!bp) {
    988         currentModel = (vel[i])->SelectModelForMaterial(scaledEnergy, idx);
    989         loweModel = (vel[i])->SelectModelForMaterial(keV, idx);
    990         isApplicable    = true;
    991         break;
     1006    if((vel[i])->GetProcessName() == currentName) {
     1007      if(baseParticle) {
     1008        if((vel[i])->Particle() == baseParticle) {
     1009          elproc = vel[i];
     1010          break;
     1011        }
    9921012      } else {
    993         for(G4int j=0; j<n; j++) {
    994           if((vel[j])->Particle() == bp) {
    995             currentModel = (vel[j])->SelectModelForMaterial(scaledEnergy, idx);
    996             loweModel = (vel[j])->SelectModelForMaterial(keV, idx);
    997             isApplicable    = true;
    998             break;
    999           }
     1013        if((vel[i])->Particle() == part) {
     1014          elproc = vel[i];
     1015          break;
    10001016        }
    10011017      }
    10021018    }
    10031019  }
     1020  if(elproc) {
     1021    isApplicable = true;
     1022    currentModel = elproc->SelectModelForMaterial(scaledEnergy, idx);
     1023    G4double eth = currentModel->LowEnergyLimit();
     1024    if(eth > 0.0) { loweModel = elproc->SelectModelForMaterial(eth-keV, idx); }       
     1025  }
     1026
     1027  // Search for discrete process
    10041028  if(!currentModel) {
    10051029    const std::vector<G4VEmProcess*> vem = lManager->GetEmProcessVector();
     
    10101034      {
    10111035        currentModel = (vem[i])->SelectModelForMaterial(kinEnergy, idx);
    1012         loweModel = (vem[i])->SelectModelForMaterial(keV, idx);
     1036        G4double eth = currentModel->LowEnergyLimit();
     1037        if(eth > 0.0) { loweModel = (vem[i])->SelectModelForMaterial(eth-keV, idx); }       
    10131038        isApplicable    = true;
    10141039        break;
     
    10161041    }
    10171042  }
     1043
     1044  // Search for msc process
    10181045  if(!currentModel) {
    10191046    const std::vector<G4VMultipleScattering*> vmsc =
     
    10251052      {
    10261053        currentModel = (vmsc[i])->SelectModelForMaterial(kinEnergy, idx);
    1027         loweModel = (vmsc[i])->SelectModelForMaterial(keV, idx);
     1054        G4double eth = currentModel->LowEnergyLimit();
     1055        if(eth > 0.0) { loweModel = (vmsc[i])->SelectModelForMaterial(eth-keV, idx); }       
    10281056        isApplicable    = true;
    10291057        break;
     
    10431071  G4String partname =  p->GetParticleName();
    10441072  const G4ParticleDefinition* part = p;
     1073 
    10451074  if(p->GetParticleType() == "nucleus" &&
    10461075     partname != "deuteron" &&
    1047      partname != "triton") part = G4GenericIon::GenericIon();
     1076     partname != "triton") { part = theGenericIon; }
    10481077 
    10491078  G4LossTableManager* lManager = G4LossTableManager::Instance();
     
    10521081  G4int n = vel.size();
    10531082  for(G4int i=0; i<n; i++) {
    1054     if((vel[i])->Particle() == part) {
     1083    if( (vel[i])->Particle() == part ) {
    10551084      elp = vel[i];
    10561085      break;
  • trunk/source/processes/electromagnetic/utils/src/G4EmConfigurator.cc

    r1055 r1196  
    2424// ********************************************************************
    2525//
    26 // $Id: G4EmConfigurator.cc,v 1.4 2009/02/26 11:33:33 vnivanch Exp $
    27 // GEANT4 tag $Name: geant4-09-03-beta-cand-01 $
     26// $Id: G4EmConfigurator.cc,v 1.5 2009/07/20 17:06:48 vnivanch Exp $
     27// GEANT4 tag $Name: geant4-09-03-cand-01 $
    2828//
    2929// -------------------------------------------------------------------
     
    223223          // set fluctuation model for ionisation processes
    224224          if(fluc && ptype == eloss) {
    225             G4VEnergyLossProcess* p = reinterpret_cast<G4VEnergyLossProcess*>(proc);
     225            G4VEnergyLossProcess* p = static_cast<G4VEnergyLossProcess*>(proc);
    226226            p->SetFluctModel(fluc);
    227227         
     
    262262          // added model
    263263          if(ptype == eloss) {
    264             G4VEnergyLossProcess* p = reinterpret_cast<G4VEnergyLossProcess*>(proc);
     264            G4VEnergyLossProcess* p = static_cast<G4VEnergyLossProcess*>(proc);
    265265            p->AddEmModel(index,mod,fluc,reg);
    266266            //G4cout << "### Added eloss model order= " << index << " for "
    267267            //     << particleName << " and " << processName << "  " << mod << G4endl;
    268268          } else if(ptype == discrete) {
    269             G4VEmProcess* p = reinterpret_cast<G4VEmProcess*>(proc);
     269            G4VEmProcess* p = static_cast<G4VEmProcess*>(proc);
    270270            p->AddEmModel(index,mod,reg);
    271271          } else if(ptype == msc) {
    272             G4VMultipleScattering* p = reinterpret_cast<G4VMultipleScattering*>(proc);
     272            G4VMultipleScattering* p = static_cast<G4VMultipleScattering*>(proc);
    273273            p->AddEmModel(index,mod,reg);
    274274          }
  • trunk/source/processes/electromagnetic/utils/src/G4EmCorrections.cc

    r1007 r1196  
    2424// ********************************************************************
    2525//
    26 // $Id: G4EmCorrections.cc,v 1.51 2008/12/18 13:01:44 gunter Exp $
    27 // GEANT4 tag $Name: geant4-09-02 $
     26// $Id: G4EmCorrections.cc,v 1.54 2009/10/29 17:56:36 vnivanch Exp $
     27// GEANT4 tag $Name: geant4-09-03-cand-01 $
    2828//
    2929// -------------------------------------------------------------------
     
    687687    massFactor = proton_mass_c2/p->GetPDGMass();
    688688    idx = -1;
    689     G4int dz = 1000;
    690689
    691690    for(G4int i=0; i<nIons; i++) {
    692       if(materialList[i] == mat) {
    693         G4int delz = currentZ - Zion[i];
    694         if(delz < 0) delz = -delz;
    695         if(delz < dz) {
    696           idx = i;
    697           dz = delz;
    698           if(0 == delz) break;
    699         }
     691      if(materialList[i] == mat && currentZ == Zion[i]) {
     692        idx = i;
     693        break;
    700694      }
    701695    }
    702     //    G4cout << " idx= " << idx << " dz= " << dz << G4endl;
    703     if(idx > 0) {
     696    //    G4cout << " idx= " << idx << " dz= " << G4endl;
     697    if(idx >= 0) {
    704698      if(!ionList[idx]) BuildCorrectionVector();
    705699      if(ionList[idx])  curVector = stopData[idx];
    706     }
     700    } else { return factor; }
    707701  }
    708702  if(curVector) {
    709     G4bool b;
    710     factor = curVector->GetValue(ekin*massFactor,b);
     703    factor = curVector->Value(ekin*massFactor);
    711704    if(verbose > 1) {
    712705      G4cout << "E= " << ekin << " factor= " << factor << " massfactor= "
     
    771764           << " massRatio= " << massRatio << G4endl;
    772765  }
    773   G4bool b;
    774766
    775767  G4PhysicsLogVector* vv =
     
    777769  vv->SetSpline(true);
    778770  G4double e, eion, dedx, dedx1;
    779   G4double eth0 = v->GetLowEdgeEnergy(0);
     771  G4double eth0 = v->Energy(0);
    780772  G4double escal = eth/massRatio;
    781773  G4double qe =
     
    790782  //     << " dedxt1= " << dedx1t << G4endl;   
    791783
    792   for(G4int i=0; i<nbinCorr; i++) {
    793     e = vv->GetLowEdgeEnergy(i);
     784  for(G4int i=0; i<=nbinCorr; i++) {
     785    e = vv->Energy(i);
    794786    escal = e/massRatio;
    795787    eion  = escal/A;
    796788    if(eion <= eth0) {
    797       dedx = v->GetValue(eth0, b)*std::sqrt(eion/eth0);
     789      dedx = v->Value(eth0)*std::sqrt(eion/eth0);
    798790    } else {
    799       dedx = v->GetValue(eion, b);
     791      dedx = v->Value(eion);
    800792    }
    801793    qe = effCharge.EffectiveChargeSquareRatio(curParticle,curMaterial,escal);
  • trunk/source/processes/electromagnetic/utils/src/G4EmElementSelector.cc

    r1055 r1196  
    2424// ********************************************************************
    2525//
    26 // $Id: G4EmElementSelector.cc,v 1.10 2009/05/26 16:59:35 vnivanch Exp $
    27 // GEANT4 tag $Name: geant4-09-03-beta-cand-01 $
     26// $Id: G4EmElementSelector.cc,v 1.11 2009/09/29 11:31:37 vnivanch Exp $
     27// GEANT4 tag $Name: geant4-09-03-cand-01 $
    2828//
    2929// -------------------------------------------------------------------
     
    6868  if(nElmMinusOne > 0) {
    6969    xSections.reserve(n);
    70     for(G4int i=0; i<n; i++) {
     70    for(G4int i=0; i<n; ++i) {
    7171      G4PhysicsLogVector* v = new G4PhysicsLogVector(lowEnergy,highEnergy,nbins);
    7272      //v->SetSpline(spline);
     
    8282{
    8383  if(nElmMinusOne > 0) {
    84     for(G4int i=0; i<=nElmMinusOne; i++) {
     84    for(G4int i=0; i<=nElmMinusOne; ++i) {
    8585      delete xSections[i];
    8686    }
     
    105105
    106106  // loop over bins
    107   for(G4int j=0; j<nbins; j++) {
    108     G4double e = (xSections[0])->GetLowEdgeEnergy(j);
     107  for(G4int j=0; j<=nbins; ++j) {
     108    G4double e = (xSections[0])->Energy(j);
    109109    model->SetupForMaterial(part, material, e);
    110110    cross = 0.0;
    111111    //G4cout << "j= " << j << " e(MeV)= " << e/MeV << G4endl;
    112     for (i=0; i<=nElmMinusOne; i++) {
     112    for (i=0; i<=nElmMinusOne; ++i) {
    113113      cross += theAtomNumDensityVector[i]*     
    114114        model->ComputeCrossSectionPerAtom(part, (*theElementVector)[i], e,
     
    120120  // xSections start from null, so use probabilities from the next bin
    121121  if(DBL_MIN >= (*xSections[nElmMinusOne])[0]) {
    122     for (i=0; i<=nElmMinusOne; i++) {
     122    for (i=0; i<=nElmMinusOne; ++i) {
    123123      xSections[i]->PutValue(0, (*xSections[i])[1]);
    124124    }
    125125  }
    126126  // xSections ends with null, so use probabilities from the previous bin
    127   if(DBL_MIN >= (*xSections[nElmMinusOne])[nbins-1]) {
    128     for (i=0; i<=nElmMinusOne; i++) {
    129       xSections[i]->PutValue(nbins-1, (*xSections[i])[nbins-2]);
     127  if(DBL_MIN >= (*xSections[nElmMinusOne])[nbins]) {
     128    for (i=0; i<=nElmMinusOne; ++i) {
     129      xSections[i]->PutValue(nbins, (*xSections[i])[nbins-1]);
    130130    }
    131131  }
    132132  // perform normalization
    133   for(G4int j=0; j<nbins; j++) {
     133  for(G4int j=0; j<=nbins; ++j) {
    134134    cross = (*xSections[nElmMinusOne])[j];
    135135    // only for positive X-section
    136136    if(cross > DBL_MIN) {
    137       for (i=0; i<nElmMinusOne; i++) {
    138         xSections[i]->PutValue(j, (*xSections[i])[j]/cross);
     137      for (i=0; i<nElmMinusOne; ++i) {
     138        G4double x = (*xSections[i])[j]/cross;
     139        xSections[i]->PutValue(j, x);
    139140      }
    140141    }
     
    158159         << (*theElementVector)[nElmMinusOne]->GetName()
    159160         << G4endl;
     161  G4cout << G4endl;
    160162}
    161163
  • trunk/source/processes/electromagnetic/utils/src/G4EmModelManager.cc

    r1055 r1196  
    2424// ********************************************************************
    2525//
    26 // $Id: G4EmModelManager.cc,v 1.49 2009/04/17 10:35:32 vnivanch Exp $
    27 // GEANT4 tag $Name: geant4-09-03-beta-cand-01 $
     26// $Id: G4EmModelManager.cc,v 1.58 2009/10/29 18:07:08 vnivanch Exp $
     27// GEANT4 tag $Name: geant4-09-03-cand-01 $
    2828//
    2929// -------------------------------------------------------------------
     
    6262// 12-04-07 Add verbosity at destruction (V.Ivanchenko)
    6363// 08-04-08 Fixed and simplified initialisation of G4RegionModel (VI)
     64// 03-08-09 Create internal vectors only it is needed (VI)
    6465//
    6566// Class Description:
     
    8586  theListOfModelIndexes = new G4int [nModelsForRegion];
    8687  lowKineticEnergy      = new G4double [nModelsForRegion+1];
    87   for (G4int i=0; i<nModelsForRegion; i++) {
     88  for (G4int i=0; i<nModelsForRegion; ++i) {
    8889    theListOfModelIndexes[i] = indx[i];
    8990    lowKineticEnergy[i] = lowE[i];
     
    114115#include "G4Positron.hh"
    115116#include "G4UnitsTable.hh"
     117#include "G4DataVector.hh"
    116118
    117119//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
     
    120122  nEmModels(0),
    121123  nRegions(0),
    122   nCouples(0),
    123   idxOfRegionModels(0),
    124   setOfRegionModels(0),
    125   minSubRange(0.1),
    126124  particle(0),
    127125  verboseLevel(0)
    128126{
    129   models.clear();
    130   flucModels.clear();
    131   regions.clear();
    132   orderOfModels.clear();
    133   maxCutInRange    = 12.*cm;
    134127  maxSubCutInRange = 0.7*mm;
    135   theGamma = G4Gamma::Gamma();
    136   thePositron = G4Positron::Positron();
    137128  models.reserve(4);
    138129  flucModels.reserve(4);
     
    140131  orderOfModels.reserve(4);
    141132  isUsed.reserve(4);
     133  severalModels = true;
     134  currRegionModel = 0;
     135  currModel = 0;
    142136}
    143137
     
    146140G4EmModelManager::~G4EmModelManager()
    147141{
     142  verboseLevel = 0; // no verbosity at destruction
    148143  Clear();
    149144}
     
    156151    G4cout << "G4EmModelManager::Clear()" << G4endl;
    157152  }
    158 
    159   theCuts.clear();
    160   theSubCuts.clear();
    161   if(idxOfRegionModels) delete [] idxOfRegionModels;
    162   if(setOfRegionModels && nRegions) {
    163     for(G4int i=0; i<nRegions; i++) {
    164       delete (setOfRegionModels[i]);
    165     }
    166     delete [] setOfRegionModels;
    167   }
    168   idxOfRegionModels = 0;
    169   setOfRegionModels = 0;
     153  size_t n = setOfRegionModels.size();
     154  if(n > 0) {
     155    for(size_t i=0; i<n; ++i) {
     156      delete setOfRegionModels[i];
     157      setOfRegionModels[i] = 0;
     158    }
     159  }
    170160}
    171161
     
    195185{
    196186  if (nEmModels > 0) {
    197     for(G4int i=0; i<nEmModels; i++) {
     187    for(G4int i=0; i<nEmModels; ++i) {
    198188      if(nam == models[i]->GetName()) {
    199189        models[i]->SetLowEnergyLimit(emin);
     
    226216//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
    227217
    228 const G4DataVector* G4EmModelManager::Initialise(const G4ParticleDefinition* p,
    229                                                  const G4ParticleDefinition* sp,
    230                                                  G4double theMinSubRange,
    231                                                  G4int val)
     218const G4DataVector*
     219G4EmModelManager::Initialise(const G4ParticleDefinition* p,
     220                             const G4ParticleDefinition* secondaryParticle,
     221                             G4double minSubRange,
     222                             G4int val)
    232223{
    233224  verboseLevel = val;
     
    238229  }
    239230  // Are models defined?
    240   if(!nEmModels) {
    241     G4Exception("G4EmModelManager::Initialise without any model defined for "+partname);
    242   }
     231  if(nEmModels < 1) {
     232    G4Exception("G4EmModelManager::Initialise: no model defined for " + partname);
     233  }
     234
    243235  particle = p;
    244   secondaryParticle = sp;
    245   minSubRange = theMinSubRange;
    246 
    247   Clear();
     236  Clear(); // needed if run is not first
     237
    248238  G4RegionStore* regionStore = G4RegionStore::GetInstance();
    249239  const G4Region* world =
     
    256246  G4bool isWorld = false;
    257247
    258   for (G4int ii=0; ii<nEmModels; ii++) {
     248  for (G4int ii=0; ii<nEmModels; ++ii) {
    259249    const G4Region* r = regions[ii];
    260250    if ( r == 0 || r == world) {
     
    264254      G4bool newRegion = true;
    265255      if (nRegions>1) {
    266         for (G4int j=1; j<nRegions; j++) {
     256        for (G4int j=1; j<nRegions; ++j) {
    267257          if ( r == setr[j] ) newRegion = false;
    268258        }
     
    274264    }
    275265  }
     266  // Are models defined?
     267  if(!isWorld) {
     268    G4Exception("G4EmModelManager::Initialise: no models defined for " +
     269                partname + " in the World volume");
     270  }
    276271
    277272  G4ProductionCutsTable* theCoupleTable=
    278273    G4ProductionCutsTable::GetProductionCutsTable();
    279   G4int numOfCouples = theCoupleTable->GetTableSize();
    280   if(nRegions > 1) idxOfRegionModels = new G4int[numOfCouples];
    281   setOfRegionModels = new G4RegionModels*[nRegions];
     274  size_t numOfCouples = theCoupleTable->GetTableSize();
     275
     276  // prepare vectors, shortcut for the case of only 1 model
     277  if(nRegions > 1 && nEmModels > 1) {
     278    if(numOfCouples > idxOfRegionModels.size()) idxOfRegionModels.resize(numOfCouples);
     279  }
     280  size_t nr = 1;
     281  if(nEmModels > 1) nr = nRegions;
     282  if(nr > setOfRegionModels.size()) setOfRegionModels.resize(nr);
    282283
    283284  std::vector<G4int>    modelAtRegion(nEmModels);
     
    287288
    288289  // Order models for regions
    289   for (G4int reg=0; reg<nRegions; reg++) {
     290  for (G4int reg=0; reg<nRegions; ++reg) {
    290291    const G4Region* region = setr[reg];
    291292    G4int n = 0;
    292293
    293     if(isWorld || 0 < reg) {
    294 
    295       for (G4int ii=0; ii<nEmModels; ii++) {
    296 
    297         G4VEmModel* model = models[ii];
    298         if ( region == regions[ii] ) {
    299 
    300           G4double tmin = model->LowEnergyLimit();
    301           G4double tmax = model->HighEnergyLimit();
    302           G4int  ord    = orderOfModels[ii];
    303           G4bool push   = true;
    304           G4bool insert = false;
    305           G4int  idx    = n;
    306 
    307           if(1 < verboseLevel) {
    308             G4cout << "Model #" << ii
    309                    << " <" << model->GetName() << "> for region <";
    310             if (region) G4cout << region->GetName();
    311             G4cout << ">  "
    312                    << " tmin(MeV)= " << tmin/MeV
    313                    << "; tmax(MeV)= " << tmax/MeV
    314                    << "; order= " << ord
    315                    << G4endl;
    316           }
     294    for (G4int ii=0; ii<nEmModels; ++ii) {
     295
     296      G4VEmModel* model = models[ii];
     297      if ( region == regions[ii] ) {
     298
     299        G4double tmin = model->LowEnergyLimit();
     300        G4double tmax = model->HighEnergyLimit();
     301        G4int  ord    = orderOfModels[ii];
     302        G4bool push   = true;
     303        G4bool insert = false;
     304        G4int  idx    = n;
     305
     306        if(1 < verboseLevel) {
     307          G4cout << "Model #" << ii
     308                 << " <" << model->GetName() << "> for region <";
     309          if (region) G4cout << region->GetName();
     310          G4cout << ">  "
     311                 << " tmin(MeV)= " << tmin/MeV
     312                 << "; tmax(MeV)= " << tmax/MeV
     313                 << "; order= " << ord
     314                 << G4endl;
     315        }
    317316       
    318           if(n > 0) {
    319 
    320             // extend energy range to previous models
    321             tmin = std::min(tmin, eHigh[n-1]);
    322             tmax = std::max(tmax, eLow[0]);
    323             //G4cout << "tmin= " << tmin << "  tmax= "
    324             //     << tmax << "  ord= " << ord <<G4endl;
    325             // empty energy range
    326             if( tmax - tmin <= eV) push = false;
    327             // low-energy model
    328             else if (tmax == eLow[0]) {
    329               push = false;
    330               insert = true;
    331               idx = 0;
    332               // resolve intersections
    333             } else if(tmin < eHigh[n-1]) {
    334               // compare order
    335               for(G4int k=0; k<n; k++) {
    336                 // new model has lower application
    337                 if(ord >= modelOrd[k]) {
    338                   if(tmin < eHigh[k]  && tmin >= eLow[k]) tmin = eHigh[k];
    339                   if(tmax <= eHigh[k] && tmax >  eLow[k]) tmax = eLow[k];
    340                   if(tmax > eHigh[k] && tmin < eLow[k]) {
    341                     if(tmax - eHigh[k] > eLow[k] - tmin) tmin = eHigh[k];
    342                     else tmax = eLow[k];
    343                   }
    344                   if( tmax - tmin <= eV) {
    345                     push = false;
    346                     break;
    347                   }
     317        if(n > 0) {
     318
     319          // extend energy range to previous models
     320          tmin = std::min(tmin, eHigh[n-1]);
     321          tmax = std::max(tmax, eLow[0]);
     322          //G4cout << "tmin= " << tmin << "  tmax= "
     323          //       << tmax << "  ord= " << ord <<G4endl;
     324          // empty energy range
     325          if( tmax - tmin <= eV) push = false;
     326          // low-energy model
     327          else if (tmax == eLow[0]) {
     328            push = false;
     329            insert = true;
     330            idx = 0;
     331            // resolve intersections
     332          } else if(tmin < eHigh[n-1]) {
     333            // compare order
     334            for(G4int k=0; k<n; ++k) {
     335              // new model has lower application
     336              if(ord >= modelOrd[k]) {
     337                if(tmin < eHigh[k]  && tmin >= eLow[k]) tmin = eHigh[k];
     338                if(tmax <= eHigh[k] && tmax >  eLow[k]) tmax = eLow[k];
     339                if(tmax > eHigh[k] && tmin < eLow[k]) {
     340                  if(tmax - eHigh[k] > eLow[k] - tmin) tmin = eHigh[k];
     341                  else tmax = eLow[k];
     342                }
     343                if( tmax - tmin <= eV) {
     344                  push = false;
     345                  break;
    348346                }
    349347              }
    350               //G4cout << "tmin= " << tmin << "  tmax= "
    351               //     << tmax << "  push= " << push << " idx= " << idx <<G4endl;
    352               if(push) {
    353                 if (tmax == eLow[0]) {
     348            }
     349            //G4cout << "tmin= " << tmin << "  tmax= "
     350            //     << tmax << "  push= " << push << " idx= " << idx <<G4endl;
     351            if(push) {
     352              if (tmax == eLow[0]) {
     353                push = false;
     354                insert = true;
     355                idx = 0;
     356                // continue resolve intersections
     357              } else if(tmin < eHigh[n-1]) {
     358                // last energy interval
     359                if(tmin > eLow[n-1] && tmax >= eHigh[n-1]) {
     360                  eHigh[n-1] = tmin;
     361                  // first energy interval
     362                } else if(tmin <= eLow[0] && tmax < eHigh[0]) {
     363                  eLow[0] = tmax;
    354364                  push = false;
    355365                  insert = true;
    356366                  idx = 0;
    357                   // continue resolve intersections
    358                 } else if(tmin < eHigh[n-1]) {
    359                   // last energy interval
    360                   if(tmin > eLow[n-1] && tmax >= eHigh[n-1]) {
    361                     eHigh[n-1] = tmin;
    362                     // first energy interval
    363                   } else if(tmin <= eLow[0] && tmax < eHigh[0]) {
    364                     eLow[0] = tmax;
    365                     push = false;
    366                     insert = true;
    367                     idx = 0;
    368                   } else {
    369                     // find energy interval to replace
    370                     for(G4int k=0; k<n; k++) {
    371                       if(tmin <= eLow[k] && tmax >= eHigh[k]) {
    372                         push = false;
    373                         modelAtRegion[k] = ii;
    374                         modelOrd[k] = ord;
    375                         isUsed[ii] = 1;
    376                       }
    377                     }
     367                } else {
     368                  // find energy interval to replace
     369                  for(G4int k=0; k<n; ++k) {
     370                    if(tmin <= eLow[k] && tmax >= eHigh[k]) {
     371                      push = false;
     372                      modelAtRegion[k] = ii;
     373                      modelOrd[k] = ord;
     374                      isUsed[ii] = 1;
     375                    }
    378376                  }
    379377                }
     
    381379            }
    382380          }
    383           if(insert) {
    384             for(G4int k=n-1; k>=idx; k--) {           
    385               modelAtRegion[k+1] = modelAtRegion[k];
    386               modelOrd[k+1] = modelOrd[k];
    387               eLow[k+1]  = eLow[k];
    388               eHigh[k+1] = eHigh[k];
    389             }
    390           }
    391           //G4cout << "push= " << push << " insert= " << insert
    392           //<< " idx= " << idx <<G4endl;
    393           if (push || insert) {
    394             n++;
    395             modelAtRegion[idx] = ii;
    396             modelOrd[idx] = ord;
    397             eLow[idx]  = tmin;
    398             eHigh[idx] = tmax;
    399             isUsed[ii] = 1;
     381        }
     382        if(insert) {
     383          for(G4int k=n-1; k>=idx; --k) {   
     384            modelAtRegion[k+1] = modelAtRegion[k];
     385            modelOrd[k+1] = modelOrd[k];
     386            eLow[k+1]  = eLow[k];
     387            eHigh[k+1] = eHigh[k];
    400388          }
    401389        }
    402       }
    403     } else {
    404       n = 1;
    405       models.push_back(0);
    406       modelAtRegion.push_back(nEmModels);
    407       eLow.push_back(0.0);
    408       eHigh.push_back(DBL_MAX);
     390        //G4cout << "push= " << push << " insert= " << insert
     391        //<< " idx= " << idx <<G4endl;
     392        if (push || insert) {
     393          ++n;
     394          modelAtRegion[idx] = ii;
     395          modelOrd[idx] = ord;
     396          eLow[idx]  = tmin;
     397          eHigh[idx] = tmax;
     398          isUsed[ii] = 1;
     399        }
     400      }
    409401    }
    410402    eLow[0] = 0.0;
     
    415407      if (region) G4cout << region->GetName();
    416408      G4cout << ">  Elow(MeV)= ";
    417       for(G4int ii=0; ii<=n; ii++) {G4cout << eLow[ii]/MeV << " ";}
     409      for(G4int ii=0; ii<=n; ++ii) {G4cout << eLow[ii]/MeV << " ";}
    418410      G4cout << G4endl;
    419411    }
    420412    G4RegionModels* rm = new G4RegionModels(n, modelAtRegion, eLow, region);
    421413    setOfRegionModels[reg] = rm;
     414    if(1 == nEmModels) break;
    422415  }
    423416
     
    425418
    426419  // Access to materials and build cuts
    427   for(G4int i=0; i<numOfCouples; i++) {
     420  size_t idx = 1;
     421  if(secondaryParticle) {
     422    if( secondaryParticle == G4Gamma::Gamma() )           idx = 0;
     423    else if( secondaryParticle == G4Positron::Positron()) idx = 2;
     424  }
     425
     426  if(numOfCouples > theCuts.size()) {theCuts.resize(numOfCouples);}
     427  if(minSubRange < 1.0 && numOfCouples > theSubCuts.size()) {
     428    theSubCuts.resize(numOfCouples);
     429  }
     430  for(size_t i=0; i<numOfCouples; ++i) {
    428431
    429432    const G4MaterialCutsCouple* couple =
     
    433436 
    434437    G4int reg = 0;
    435     if(nRegions > 1) {
     438    if(nRegions > 1 && nEmModels > 1) {
    436439      reg = nRegions;
    437       do {reg--;} while (reg>0 && pcuts != (setr[reg]->GetProductionCuts()));
     440      do {--reg;} while (reg>0 && pcuts != (setr[reg]->GetProductionCuts()));
    438441      idxOfRegionModels[i] = reg;
    439442    }
     
    446449    }
    447450
    448     G4double cut = DBL_MAX;
     451    G4double cut = (*theCoupleTable->GetEnergyCutsVector(idx))[i];
    449452    G4double subcut = DBL_MAX;
    450453    if(secondaryParticle) {
    451       size_t idx = 1;
    452       if( secondaryParticle == theGamma ) idx = 0;
    453       cut = (*theCoupleTable->GetEnergyCutsVector(idx))[i];
    454       if( secondaryParticle == thePositron && cut < DBL_MAX )
    455         cut += (*theCoupleTable->GetEnergyCutsVector(2))[i] +
    456                2.0*electron_mass_c2;
    457454
    458455      // compute subcut
    459       if( cut < DBL_MAX ) subcut = minSubRange*cut;
    460       if(pcuts->GetProductionCut(idx) < maxCutInRange) {
     456      if( cut < DBL_MAX && minSubRange < 1.0) {
     457        subcut = minSubRange*cut;
     458        G4double rcut = std::min(minSubRange*pcuts->GetProductionCut(idx),
     459                                 maxSubCutInRange);
    461460        G4double tcutmax =
    462           theCoupleTable->ConvertRangeToEnergy(secondaryParticle,
    463                                                material,maxSubCutInRange);
     461          theCoupleTable->ConvertRangeToEnergy(secondaryParticle,material,rcut);
    464462        if(tcutmax < subcut) subcut = tcutmax;
    465463      }
     
    467465
    468466    G4int nm = setOfRegionModels[reg]->NumberOfModels();
    469     for(G4int j=0; j<nm; j++) {
     467    for(G4int j=0; j<nm; ++j) {
    470468
    471469      G4VEmModel* model = models[setOfRegionModels[reg]->ModelIndex(j)];
     
    484482      }
    485483    }
    486     theCuts.push_back(cut);
    487     theSubCuts.push_back(subcut);
    488   }
    489 
    490   for(G4int jj=0; jj<nEmModels; jj++) {
     484    theCuts[i] = cut;
     485    if(minSubRange < 1.0) theSubCuts[i] = subcut;
     486  }
     487
     488  // initialize models
     489  G4int nn = 0;
     490  severalModels = true;
     491  for(G4int jj=0; jj<nEmModels; ++jj) {
    491492    if(1 == isUsed[jj]) {
    492       models[jj]->Initialise(particle, theCuts);
     493      ++nn;
     494      currModel = models[jj];
     495      currModel->Initialise(particle, theCuts);
    493496      if(flucModels[jj]) flucModels[jj]->InitialiseMe(particle);
    494497    }
    495498  }
     499  if(1 == nn) severalModels = false;
    496500
    497501  if(1 < verboseLevel) {
     
    510514                                      G4EmTableType tType)
    511515{
    512 
    513   G4double e;
    514 
    515516  size_t i = couple->GetIndex();
    516517  G4double cut = theCuts[i];
    517   G4double subcut = 0.0;
     518  G4double emin = 0.0;
    518519
    519520  if(fTotal == tType) cut = DBL_MAX;
    520   else if(fSubRestricted == tType) subcut = theSubCuts[i];
     521  else if(fSubRestricted == tType) {
     522    emin = cut;
     523    if(theSubCuts.size() > 0) emin = theSubCuts[i];
     524  }
    521525
    522526  if(1 < verboseLevel) {
     
    524528           << couple->GetMaterial()->GetName()
    525529           << "  cut(MeV)= " << cut
    526            << "  subcut(MeV)= " << subcut
     530           << "  emin(MeV)= " << emin
    527531           << "  Type " << tType
    528532           << "  for " << particle->GetParticleName()
     
    531535
    532536  G4int reg  = 0;
    533   if(nRegions > 1) reg = idxOfRegionModels[i];
     537  if(nRegions > 1 && nEmModels > 1) reg = idxOfRegionModels[i];
    534538  const G4RegionModels* regModels = setOfRegionModels[reg];
    535539  G4int nmod = regModels->NumberOfModels();
    536540
    537   // vectors to provide continues dE/dx
    538   G4DataVector factor(nmod);
    539   G4DataVector eLow(nmod+1);
    540   G4DataVector dedxLow(nmod);
    541   G4DataVector dedxHigh(nmod);
    542 
    543   if(1 < verboseLevel) {
    544       G4cout << "There are " << nmod << " models for "
    545              << couple->GetMaterial()->GetName()
    546              << " at the region #" << reg
    547              << G4endl;
    548   }
    549 
    550   // calculate factors to provide continuity of energy loss
    551 
    552 
    553   factor[0] = 1.0;
    554   G4int j;
    555 
    556   G4int totBinsLoss = aVector->GetVectorLength();
    557 
    558   dedxLow[0] = 0.0;
    559   eLow[0]    = 0.0;
    560 
    561   e = regModels->LowEdgeEnergy(1);
    562   eLow[1]    = e;
    563   G4VEmModel* model = models[regModels->ModelIndex(0)];
    564   dedxHigh[0] = 0.0;
    565   if(model && cut > subcut) {
    566     dedxHigh[0] = model->ComputeDEDX(couple,particle,e,cut);
    567     if(subcut > 0.0) {
    568       dedxHigh[0] -= model->ComputeDEDX(couple,particle,e,subcut);
    569     }
    570   }
    571   if(nmod > 1) {
    572     for(j=1; j<nmod; j++) {
    573 
    574       e = regModels->LowEdgeEnergy(j);
    575       eLow[j]   = e;
    576       G4int idx = regModels->ModelIndex(j);
    577 
    578       dedxLow[j] = models[idx]->ComputeDEDX(couple,particle,e,cut);
    579       if(subcut > 0.0) {
    580         dedxLow[j] -= models[idx]->ComputeDEDX(couple,particle,e,subcut);
    581       }
    582       if(subcut == cut) dedxLow[j] = 0.0;
    583 
    584       e = regModels->LowEdgeEnergy(j+1);
    585       eLow[j+1] = e;
    586       dedxHigh[j] = models[idx]->ComputeDEDX(couple,particle,e,cut);
    587       if(subcut > 0.0) {
    588         dedxHigh[j] -= models[idx]->ComputeDEDX(couple,particle,e,subcut);
    589       }
    590       if(subcut == cut) dedxHigh[j] = 0.0;
    591     }
    592     if(1 < verboseLevel) {
    593       G4cout << " model #0" 
    594              << "  dedx(" << eLow[0] << ")=  " << dedxLow[0]
    595              << "  dedx(" << eLow[1] << ")=  " << dedxHigh[0]
    596              << G4endl;
    597     }
    598 
    599     for(j=1; j<nmod; j++) {
    600       if(dedxLow[j] > 0.0) {
    601         factor[j] = (dedxHigh[j-1]/dedxLow[j] - 1.0)*eLow[j];
    602       } else  factor[j] = 0.0;
    603       if(1 < verboseLevel) {
    604         G4cout << " model #" << j
    605                << "  dedx(" << eLow[j] << ")=  " << dedxLow[j]
    606                << "  dedx(" << eLow[j+1] << ")=  " << dedxHigh[j]
    607                << "  factor= " << factor[j]/eLow[j]
    608                << G4endl;
    609       }
    610     }
    611 
    612     if(2 < verboseLevel) {
    613       G4cout << "Loop over " << totBinsLoss << " bins start " << G4endl;
    614     }
    615   }
    616 
    617541  // Calculate energy losses vector
    618   for(j=0; j<totBinsLoss; j++) {
    619 
    620     G4double e = aVector->GetLowEdgeEnergy(j);
    621     G4double fac = 1.0;
    622 
    623       // Choose a model of energy losses
     542
     543  //G4cout << "nmod= " << nmod << G4endl;
     544  size_t totBinsLoss = aVector->GetVectorLength();
     545  for(size_t j=0; j<totBinsLoss; ++j) {
     546
     547    G4double e = aVector->Energy(j);
     548    G4double del = 0.0;
     549
     550    // Choose a model of energy losses
    624551    G4int k = 0;
    625     if (nmod > 1 && e > eLow[1]) {
    626       do {
    627         k++;
    628         fac *= (1.0 + factor[k]/e);
    629       } while (k+1 < nmod && e > eLow[k+1]);
    630     }
    631 
    632     model = models[regModels->ModelIndex(k)];
    633     G4double dedx = 0.0;
    634     G4double dedx0 = 0.0;
    635     if(model && cut > subcut) {
    636       dedx = model->ComputeDEDX(couple,particle,e,cut);
    637       dedx0 = dedx;
    638       if(subcut > 0.0) dedx -= model->ComputeDEDX(couple,particle,e,subcut);
    639       dedx *= fac;
    640     }
     552    if (nmod > 1) {
     553      k = nmod;
     554      do {--k;} while (k>0 && e <= regModels->LowEdgeEnergy(k));
     555      //G4cout << "k= " << k << G4endl;
     556      if(k > 0) {
     557        G4double elow = regModels->LowEdgeEnergy(k);
     558        G4double dedx1 = ComputeDEDX(models[regModels->ModelIndex(k-1)],
     559                                     couple,elow,cut,emin);
     560        G4double dedx2 = ComputeDEDX(models[regModels->ModelIndex(k)],
     561                                     couple,elow,cut,emin);
     562        del = (dedx1 - dedx2)*elow/e;
     563        //G4cout << "elow= " << elow
     564        //       << " dedx1= " << dedx1 << " dedx2= " << dedx2 << G4endl;
     565      }
     566    }
     567    G4double dedx = ComputeDEDX(models[regModels->ModelIndex(k)],
     568                                couple,e,cut,emin) + del;
    641569
    642570    if(dedx < 0.0) dedx = 0.0;
    643571    if(2 < verboseLevel) {
    644         G4cout << "Material= " << couple->GetMaterial()->GetName()
    645                << "   E(MeV)= " << e/MeV
    646                << "  dEdx(MeV/mm)= " << dedx*mm/MeV
    647                << "  dEdx0(MeV/mm)= " << dedx0*mm/MeV
    648                << "  fac= " << fac
    649                << G4endl;
     572      G4cout << "Material= " << couple->GetMaterial()->GetName()
     573             << "   E(MeV)= " << e/MeV
     574             << "  dEdx(MeV/mm)= " << dedx*mm/MeV
     575             << "  del= " << del*mm/MeV<< " k= " << k
     576             << " modelIdx= " << regModels->ModelIndex(k)
     577             << G4endl;
    650578    }
    651579    aVector->PutValue(j, dedx);
     
    660588                                        G4EmTableType tType)
    661589{
    662   G4double e;
    663 
    664590  size_t i = couple->GetIndex();
    665591  G4double cut  = theCuts[i];
     
    667593  if (fSubRestricted == tType) {
    668594    tmax = cut;
    669     cut  = theSubCuts[i];
    670   }
    671 
     595    if(theSubCuts.size() > 0) cut  = theSubCuts[i];
     596  }
     597
     598  G4int reg  = 0;
     599  if(nRegions > 1 && nEmModels > 1) reg  = idxOfRegionModels[i];
     600  const G4RegionModels* regModels = setOfRegionModels[reg];
     601  G4int nmod = regModels->NumberOfModels();
    672602  if(1 < verboseLevel) {
    673     G4cout << "G4EmModelManager::FillLambdaVector() for particle "
     603    G4cout << "G4EmModelManager::FillLambdaVector() for "
    674604           << particle->GetParticleName()
    675605           << " in " << couple->GetMaterial()->GetName()
    676            << "  Ecut(MeV)= " << cut
    677            << "  Emax(MeV)= " << tmax
    678            << "  Type " << tType   
     606           << " Ecut(MeV)= " << cut
     607           << " Emax(MeV)= " << tmax
     608           << " Type " << tType   
     609           << " nmod= " << nmod
    679610           << G4endl;
    680611  }
    681612
    682   G4int reg  = 0;
    683   if(nRegions > 1) reg  = idxOfRegionModels[i];
    684   const G4RegionModels* regModels = setOfRegionModels[reg];
    685   G4int nmod = regModels->NumberOfModels();
    686 
    687   // vectors to provide continues dE/dx
    688   G4DataVector factor(nmod);
    689   G4DataVector eLow(nmod+1);
    690   G4DataVector sigmaLow(nmod);
    691   G4DataVector sigmaHigh(nmod);
    692 
    693   if(2 < verboseLevel) {
    694       G4cout << "There are " << nmod << " models for "
    695              << couple->GetMaterial()->GetName() << G4endl;
    696   }
    697 
    698   // calculate factors to provide continuity of energy loss
    699   factor[0] = 1.0;
    700   G4int j;
    701   G4int totBinsLambda = aVector->GetVectorLength();
    702 
    703   sigmaLow[0] = 0.0;
    704   eLow[0]     = 0.0;
    705 
    706   e = regModels->LowEdgeEnergy(1);
    707   eLow[1]     = e;
    708   G4VEmModel* model = models[regModels->ModelIndex(0)];
    709   sigmaHigh[0] = 0.0;
    710   if(model) sigmaHigh[0] = model->CrossSection(couple,particle,e,cut,tmax);
    711 
    712   if(2 < verboseLevel) {
    713       G4cout << "### For material " << couple->GetMaterial()->GetName()
    714              << "  " << nmod
    715              << " models"
    716              << " Ecut(MeV)= " << cut/MeV
    717              << " Emax(MeV)= " << e/MeV
    718              << " nbins= "  << totBinsLambda
    719              << G4endl;
    720       G4cout << " model #0   eUp= " << e
    721              << "  sigmaUp= " << sigmaHigh[0] << G4endl;
    722   }
    723 
    724 
    725   if(nmod > 1) {
    726 
    727     for(j=1; j<nmod; j++) {
    728 
    729       e  = regModels->LowEdgeEnergy(j);
    730       eLow[j]   = e;
    731       G4int idx = regModels->ModelIndex(j);
    732 
    733       sigmaLow[j] = models[idx]->CrossSection(couple,particle,e,cut,tmax);
    734       e  = regModels->LowEdgeEnergy(j+1);
    735       eLow[j+1] = e;
    736       sigmaHigh[j] = models[idx]->CrossSection(couple,particle,e,cut,tmax);
    737     }
    738     if(1 < verboseLevel) {
    739       G4cout << " model #0" 
    740              << "  sigma(" << eLow[0] << ")=  " << sigmaLow[0]
    741              << "  sigma(" << eLow[1] << ")=  " << sigmaHigh[0]
    742              << G4endl;
    743     }
    744     for(j=1; j<nmod; j++) {
    745       if(sigmaLow[j] > 0.0) {
    746         factor[j] = (sigmaHigh[j-1]/sigmaLow[j] - 1.0)*eLow[j];
    747       } else  factor[j] = 0.0;
    748       if(1 < verboseLevel) {
    749         G4cout << " model #" << j
    750                << "  sigma(" << eLow[j] << ")=  " << sigmaLow[j]
    751                << "  sigma(" << eLow[j+1] << ")=  " << sigmaHigh[j]
    752                << "  factor= " << factor[j]/eLow[j]
    753                << G4endl;
    754       }
    755     }
    756   }
    757613
    758614  // Calculate lambda vector
    759   for(j=0; j<totBinsLambda; j++) {
    760 
    761     e = aVector->GetLowEdgeEnergy(j);
    762 
    763     // Choose a model of energy losses
     615  size_t totBinsLambda = aVector->GetVectorLength();
     616  for(size_t j=0; j<totBinsLambda; ++j) {
     617
     618    G4double e = aVector->Energy(j);
     619
     620    G4double del = 0.0;
     621
     622    // Choose a model
    764623    G4int k = 0;
    765     G4double fac = 1.0;
    766     if (nmod > 1 && e > eLow[1]) {
    767       do {
    768         k++;
    769         fac *= (1.0 + factor[k]/e);
    770       } while ( k+1 < nmod && e > eLow[k+1] );
    771     }
    772 
    773     model = models[regModels->ModelIndex(k)];
    774     G4double cross = 0.0;
    775     if(model) cross = model->CrossSection(couple,particle,e,cut,tmax)*fac;
     624    G4VEmModel* mod = models[regModels->ModelIndex(0)];
     625    if (nmod > 1) {
     626      k = nmod;
     627      do {--k;} while (k>0 && e <= regModels->LowEdgeEnergy(k));
     628      if(k > 0) {
     629        G4double elow = regModels->LowEdgeEnergy(k);
     630        G4VEmModel* m = models[regModels->ModelIndex(k-1)];
     631        G4double xs1  = m->CrossSection(couple,particle,elow,cut,tmax);
     632        mod = models[regModels->ModelIndex(k)];
     633        G4double xs2 = mod->CrossSection(couple,particle,elow,cut,tmax);
     634        del = (xs1 - xs2)*elow/e;
     635      }
     636    }
     637    G4double cross = mod->CrossSection(couple,particle,e,cut,tmax) + del;
     638   
    776639    if(j==0 && startFromNull) cross = 0.0;
    777640
     
    779642      G4cout << "FillLambdaVector: " << j << ".   e(MeV)= " << e/MeV
    780643             << "  cross(1/mm)= " << cross*mm
    781              << " fac= " << fac << " k= " << k
    782              << " model= " << regModels->ModelIndex(k)
     644             << " del= " << del*mm << " k= " << k
     645             << " modelIdx= " << regModels->ModelIndex(k)
    783646             << G4endl;
    784647    }
     
    794657{
    795658  if(verb == 0) return;
    796   for(G4int i=0; i<nRegions; i++) {
     659  for(G4int i=0; i<nRegions; ++i) {
    797660    G4RegionModels* r = setOfRegionModels[i];
    798661    const G4Region* reg = r->Region();
    799     //    if(verb > -1 || nRegions > 1) {
    800     // }
    801662    G4int n = r->NumberOfModels(); 
    802     if(verb > -1 || n > 0) {
     663    if(n > 0) {
    803664      G4cout << "      ===== EM models for the G4Region  " << reg->GetName()
    804665             << " ======" << G4endl;;
    805       for(G4int j=0; j<n; j++) {
     666      for(G4int j=0; j<n; ++j) {
    806667        const G4VEmModel* m = models[r->ModelIndex(j)];
    807668        G4cout << std::setw(20);
     
    813674      } 
    814675    }
    815   }
    816 }
    817 
    818 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
     676    if(1 == nEmModels) break;
     677  }
     678}
     679
     680//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
  • trunk/source/processes/electromagnetic/utils/src/G4EmMultiModel.cc

    r1007 r1196  
    2525//
    2626// $Id: G4EmMultiModel.cc,v 1.6 2007/05/22 17:31:58 vnivanch Exp $
    27 // GEANT4 tag $Name: geant4-09-02 $
     27// GEANT4 tag $Name: geant4-09-03-cand-01 $
    2828//
    2929// -------------------------------------------------------------------
  • trunk/source/processes/electromagnetic/utils/src/G4EmProcessOptions.cc

    r1055 r1196  
    2424// ********************************************************************
    2525//
    26 // $Id: G4EmProcessOptions.cc,v 1.26 2009/02/18 14:43:27 vnivanch Exp $
    27 // GEANT4 tag $Name: geant4-09-03-beta-cand-01 $
     26// $Id: G4EmProcessOptions.cc,v 1.27 2009/10/29 19:25:28 vnivanch Exp $
     27// GEANT4 tag $Name: geant4-09-03-cand-01 $
    2828//
    2929// -------------------------------------------------------------------
     
    516516//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
    517517
     518void G4EmProcessOptions::SetFactorForAngleLimit(G4double val)
     519{
     520  theManager->SetFactorForAngleLimit(val);
     521}
     522
     523//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
     524
    518525void G4EmProcessOptions::SetLPMFlag(G4bool val)
    519526{
  • trunk/source/processes/electromagnetic/utils/src/G4EmSaturation.cc

    r1007 r1196  
    2424// ********************************************************************
    2525//
    26 // $Id: G4EmSaturation.cc,v 1.9 2008/11/12 15:37:33 vnivanch Exp $
    27 // GEANT4 tag $Name: geant4-09-02 $
     26// $Id: G4EmSaturation.cc,v 1.10 2009/09/25 09:16:40 vnivanch Exp $
     27// GEANT4 tag $Name: geant4-09-03-cand-01 $
    2828//
    2929// -------------------------------------------------------------------
     
    4646
    4747#include "G4EmSaturation.hh"
    48 #include "G4Gamma.hh"
    49 #include "G4Electron.hh"
    50 #include "G4Neutron.hh"
    51 #include "G4Proton.hh"
    5248#include "G4LossTableManager.hh"
    5349#include "G4NistManager.hh"
    5450#include "G4Material.hh"
    5551#include "G4MaterialCutsCouple.hh"
     52#include "G4Electron.hh"
     53#include "G4Proton.hh"
    5654
    5755//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
     
    6664  curChargeSq = 1.0;
    6765  nMaterials = 0;
    68   Initialise();
     66  electron = 0;
     67  Initialise();
    6968}
    7069
     
    9089  if(bfactor > 0.0) {
    9190
    92     // atomic relaxations
    93     if(p == gamma) {
     91    G4int pdgCode = p->GetPDGEncoding();
     92    // atomic relaxations for gamma incident
     93    if(22 == pdgCode) {
    9494      evis /= (1.0 + bfactor*edep/manager->GetRange(electron,edep,couple));
    9595
     
    101101      if(nloss < 0.0) nloss = 0.0;
    102102      G4double eloss = edep - nloss;
    103       if(p == neutron || eloss < 0.0 || length <= 0.0) {
     103
     104      // neutrons
     105      if(2112 == pdgCode || eloss < 0.0 || length <= 0.0) {
    104106        nloss = edep;
    105107        eloss = 0.0;
     
    111113      // non-ionizing energy loss
    112114      if(nloss > 0.0) {
     115        if(!proton) {proton = G4Proton::Proton();}
    113116        G4double escaled = nloss*curRatio;
    114117        G4double s = manager->GetRange(proton,escaled,couple)/curChargeSq;
     
    146149G4double G4EmSaturation::FindBirksCoefficient(const G4Material* mat)
    147150{
     151  // electron should exist in any case
     152  if(!manager) {
     153    manager = G4LossTableManager::Instance();
     154    nist    = G4NistManager::Instance();
     155    electron= G4Electron::Electron();
     156    proton  = 0;
     157  }
     158
    148159  if(mat == curMaterial) return curBirks;
    149160
     
    161172      return curBirks;
    162173    }
    163   }
    164 
    165   if(!manager) {
    166     manager = G4LossTableManager::Instance();
    167     nist    = G4NistManager::Instance();
    168     gamma   = G4Gamma::Gamma();
    169     electron= G4Electron::Electron();
    170     proton  = G4Proton::Proton();
    171     neutron = G4Neutron::Neutron();
    172174  }
    173175
  • trunk/source/processes/electromagnetic/utils/src/G4EnergyLossMessenger.cc

    r1055 r1196  
    2525//
    2626//
    27 // $Id: G4EnergyLossMessenger.cc,v 1.37 2009/02/18 14:43:27 vnivanch Exp $
    28 // GEANT4 tag $Name: geant4-09-03-beta-cand-01 $
     27// $Id: G4EnergyLossMessenger.cc,v 1.38 2009/10/29 19:25:28 vnivanch Exp $
     28// GEANT4 tag $Name: geant4-09-03-cand-01 $
    2929//
    3030// -------------------------------------------------------------------
     
    196196  dedxCmd->SetGuidance("Set number of bins for DEDX tables");
    197197  dedxCmd->SetParameterName("binsDEDX",true);
    198   dedxCmd->SetDefaultValue(120);
     198  dedxCmd->SetDefaultValue(77);
    199199  dedxCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
    200200
     
    202202  lamCmd->SetGuidance("Set number of bins for Lambda tables");
    203203  lamCmd->SetParameterName("binsL",true);
    204   lamCmd->SetDefaultValue(120);
     204  lamCmd->SetDefaultValue(77);
    205205  lamCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
    206206
     
    242242  frCmd->SetParameterName("Fr",true);
    243243  frCmd->SetRange("Fr>0");
    244   frCmd->SetDefaultValue(0.02);
     244  frCmd->SetDefaultValue(0.04);
    245245  frCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
    246246
     
    252252  fgCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
    253253
     254  mscfCmd = new G4UIcmdWithADouble("/process/msc/FactorForAngleLimit",this);
     255  mscfCmd->SetGuidance("Set factor for computation of a limit for -t (invariant trasfer)");
     256  mscfCmd->SetParameterName("Fact",true);
     257  mscfCmd->SetRange("Fact>0");
     258  mscfCmd->SetDefaultValue(1.);
     259  mscfCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
     260
    254261  skinCmd = new G4UIcmdWithADouble("/process/msc/Skin",this);
    255262  skinCmd->SetGuidance("Set skin parameter for msc processes");
     
    258265
    259266  angCmd = new G4UIcmdWithADoubleAndUnit("/process/msc/ThetaLimit",this);
    260   angCmd->SetGuidance("Set the limit on the polar angle");
     267  angCmd->SetGuidance("Set the limit on the polar angle for msc and single scattering");
    261268  angCmd->SetParameterName("theta",true);
    262269  angCmd->SetUnitCategory("Angle");
     
    297304  delete skinCmd;
    298305  delete angCmd;
     306  delete mscfCmd;
    299307}
    300308
     
    432440    G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
    433441  }
     442  if (command == mscfCmd) {
     443    opt->SetFactorForAngleLimit(mscfCmd->GetNewDoubleValue(newValue));
     444    G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
     445  }
    434446  if (command == angCmd) {
    435447    opt->SetPolarAngleLimit(angCmd->GetNewDoubleValue(newValue));
  • trunk/source/processes/electromagnetic/utils/src/G4EnergyLossTables.cc

    r1007 r1196  
    2626//
    2727// $Id: G4EnergyLossTables.cc,v 1.34 2008/07/08 10:57:22 vnivanch Exp $
    28 // GEANT4 tag $Name: geant4-09-02 $
     28// GEANT4 tag $Name: geant4-09-03-cand-01 $
    2929//
    3030// -------------------------------------------------------------------
  • trunk/source/processes/electromagnetic/utils/src/G4LossTableBuilder.cc

    r1055 r1196  
    2424// ********************************************************************
    2525//
    26 // $Id: G4LossTableBuilder.cc,v 1.28 2009/02/18 16:24:47 vnivanch Exp $
    27 // GEANT4 tag $Name: geant4-09-03-beta-cand-01 $
     26// $Id: G4LossTableBuilder.cc,v 1.32 2009/08/11 17:24:53 vnivanch Exp $
     27// GEANT4 tag $Name: geant4-09-03-cand-01 $
    2828//
    2929// -------------------------------------------------------------------
     
    4747// 16-01-07 Fill new (not old) DEDX table (V.Ivanchenko)
    4848// 12-02-07 Use G4LPhysicsFreeVector for the inverse range table (V.Ivanchenko)
     49// 24-06-09 Removed hidden bin in G4PhysicsVector (V.Ivanchenko)
    4950//
    5051// Class Description:
     
    8586  if(0 >= n_vectors) return;
    8687
    87   G4bool b;
    88 
    89   G4PhysicsVector* pv = (*(list[0]))[0];
    90   size_t nbins = pv->GetVectorLength();
    91   G4double elow = pv->GetLowEdgeEnergy(0);
    92   G4double ehigh = pv->GetLowEdgeEnergy(nbins);
     88  G4PhysicsLogVector* pv0 = static_cast<G4PhysicsLogVector*>((*(list[0]))[0]);
     89  size_t npoints = pv0->GetVectorLength();
    9390  for (size_t i=0; i<n_vectors; i++) {
    9491
    95     pv = new G4PhysicsLogVector(elow, ehigh, nbins);
     92    G4PhysicsLogVector* pv = new G4PhysicsLogVector(*pv0);
     93    //    pv = new G4PhysicsLogVector(elow, ehigh, npoints-1);
    9694    pv->SetSpline(splineFlag);
    97     for (size_t j=0; j<nbins; j++) {
     95    for (size_t j=0; j<npoints; j++) {
    9896      G4double dedx = 0.0;
    99       G4double energy = pv->GetLowEdgeEnergy(j);
    100 
    10197      for (size_t k=0; k<n_processes; k++) {
    102         dedx += ((*(list[k]))[i])->GetValue(energy, b);
     98        G4PhysicsVector* pv1   = (*(list[k]))[i];
     99        dedx += (*pv1)[j];
    103100      }
    104101      pv->PutValue(j, dedx);
    105       G4PhysicsTableHelper::SetPhysicsVector(dedxTable, i, pv);
    106102    }
     103    if(splineFlag) pv->FillSecondDerivatives();
     104    G4PhysicsTableHelper::SetPhysicsVector(dedxTable, i, pv);
    107105  }
    108106}
     
    118116  if(!n_vectors) return;
    119117
    120   G4bool b;
    121118  size_t n = 100;
    122119  G4double del = 1.0/(G4double)n;
     
    125122
    126123    if (rangeTable->GetFlag(i) || !isIonisation) {
    127       G4PhysicsVector* pv = (*dedxTable)[i];
    128       size_t nbins = pv->GetVectorLength();
    129       size_t bin0  = 0;
    130       G4double elow = pv->GetLowEdgeEnergy(0);
    131       G4double ehigh = pv->GetLowEdgeEnergy(nbins);
    132       G4double dedx1  = pv->GetValue(elow, b);
     124      G4PhysicsLogVector* pv =
     125        static_cast<G4PhysicsLogVector*>((*dedxTable)[i]);
     126      size_t npoints = pv->GetVectorLength();
     127      size_t bin0    = 0;
     128      G4double elow  = pv->Energy(0);
     129      G4double ehigh = pv->Energy(npoints-1);
     130      G4double dedx1 = pv->Value(elow);
    133131
    134132      //G4cout << "nbins= " << nbins << " dedx1= " << dedx1 << G4endl;
     
    136134      // protection for specific cases dedx=0
    137135      if(dedx1 == 0.0) {
    138         for (size_t k=1; k<nbins-1; k++) {
     136        for (size_t k=1; k<npoints; k++) {
    139137          bin0++;
    140           elow  = pv->GetLowEdgeEnergy(k);
    141           dedx1 = pv->GetValue(elow, b);
     138          elow  = pv->Energy(k);
     139          dedx1 = (*pv)[k];
    142140          if(dedx1 > 0.0) break;
    143141        }
    144         nbins -= bin0;
    145       }
    146 
    147       //G4cout << "nbins= " << nbins << " elow= " << elow << " ehigh= " << ehigh << G4endl;
     142        npoints -= bin0;
     143      }
     144      // G4cout<<"New Range vector" << G4endl;
     145      // G4cout<<"nbins= "<<npoints-1<<" elow= "<<elow<<" ehigh= "<<ehigh<<G4endl;
    148146      // initialisation of a new vector
    149       G4PhysicsLogVector* v = new G4PhysicsLogVector(elow, ehigh, nbins);
     147      if(npoints < 2) npoints = 2;
     148      G4PhysicsLogVector* v;
     149      if(0 == bin0) { v = new G4PhysicsLogVector(*pv); }
     150      else          { v = new G4PhysicsLogVector(elow, ehigh, npoints-1); }
    150151      // dedx is exect zero
    151       if(nbins <= 2) {
     152      if(2 == npoints) {
    152153        v->PutValue(0,1000.);
    153154        v->PutValue(1,2000.);
     
    162163      G4double energy1 = elow;
    163164
    164       for (size_t j=1; j<nbins; j++) {
    165 
    166         G4double energy2 = pv->GetLowEdgeEnergy(j+bin0);
     165      for (size_t j=1; j<npoints; j++) {
     166
     167        G4double energy2 = pv->Energy(j+bin0);
    167168        G4double de      = (energy2 - energy1) * del;
    168169        G4double energy  = energy2 + de*0.5;
     170        G4double sum = 0.0;
    169171        for (size_t k=0; k<n; k++) {
    170172          energy -= de;
    171           dedx1 = pv->GetValue(energy, b);
    172           if(dedx1 > 0.0) range += de/dedx1;
     173          dedx1 = pv->Value(energy);
     174          if(dedx1 > 0.0) sum += de/dedx1;
    173175        }
    174 
     176        range += sum;
    175177        //      G4cout << "Range i= " <<i << " j= " << j << G4endl;
    176178        v->PutValue(j,range);
    177179        energy1 = energy2;
    178180      }
     181      if(splineFlag) v->FillSecondDerivatives();
    179182      G4PhysicsTableHelper::SetPhysicsVector(rangeTable, i, v);
    180183    }
     
    191194  size_t n_vectors = rangeTable->length();
    192195  if(!n_vectors) return;
    193   G4bool b;
    194196
    195197  for (size_t i=0; i<n_vectors; i++) {
     
    197199    if (invRangeTable->GetFlag(i) || !isIonisation) {
    198200      G4PhysicsVector* pv = (*rangeTable)[i];
    199       size_t nbins   = pv->GetVectorLength();
    200       G4double elow  = pv->GetLowEdgeEnergy(0);
    201       G4double ehigh = pv->GetLowEdgeEnergy(nbins-1);
    202       G4double rlow  = pv->GetValue(elow, b);
    203       G4double rhigh = pv->GetValue(ehigh, b);
     201      size_t npoints = pv->GetVectorLength();
     202      G4double rlow  = (*pv)[0];
     203      G4double rhigh = (*pv)[npoints-1];
    204204     
    205       G4LPhysicsFreeVector* v = new G4LPhysicsFreeVector(nbins,rlow,rhigh);
     205      G4LPhysicsFreeVector* v = new G4LPhysicsFreeVector(npoints,rlow,rhigh);
    206206      v->SetSpline(splineFlag);
    207207
    208       for (size_t j=0; j<nbins; j++) {
    209         G4double e  = pv->GetLowEdgeEnergy(j);
    210         G4double r  = pv->GetValue(e, b);
     208      for (size_t j=0; j<npoints; j++) {
     209        G4double e  = pv->Energy(j);
     210        G4double r  = (*pv)[j];
    211211        v->PutValues(j,r,e);
    212212      }
    213       v->PutValues(nbins,rhigh+rlow,ehigh);
     213      if(splineFlag) v->FillSecondDerivatives();
    214214
    215215      G4PhysicsTableHelper::SetPhysicsVector(invRangeTable, i, v);
  • trunk/source/processes/electromagnetic/utils/src/G4LossTableManager.cc

    r1055 r1196  
    2424// ********************************************************************
    2525//
    26 // $Id: G4LossTableManager.cc,v 1.96 2009/04/09 16:10:57 vnivanch Exp $
    27 // GEANT4 tag $Name: geant4-09-03-beta-cand-01 $
     26// $Id: G4LossTableManager.cc,v 1.97 2009/10/29 19:25:28 vnivanch Exp $
     27// GEANT4 tag $Name: geant4-09-03-cand-01 $
    2828//
    2929// -------------------------------------------------------------------
     
    176176  splineFlag = true;
    177177  bremsTh = DBL_MAX;
     178  factorForAngleLimit = 1.0;
    178179  verbose = 1;
    179180  tableBuilder->SetSplineFlag(splineFlag);
     
    920921}
    921922
     923//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
     924
     925void G4LossTableManager::SetFactorForAngleLimit(G4double val)
     926{
     927  if(val > 0.0) factorForAngleLimit = val;
     928}
     929
     930//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
     931
     932G4double G4LossTableManager::FactorForAngleLimit() const
     933{
     934  return factorForAngleLimit;
     935}
     936
    922937//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
    923938
  • trunk/source/processes/electromagnetic/utils/src/G4VEmFluctuationModel.cc

    r1055 r1196  
    2525//
    2626// $Id: G4VEmFluctuationModel.cc,v 1.4 2009/02/19 11:25:50 vnivanch Exp $
    27 // GEANT4 tag $Name: geant4-09-03-beta-cand-01 $
     27// GEANT4 tag $Name: geant4-09-03-cand-01 $
    2828//
    2929// -------------------------------------------------------------------
  • trunk/source/processes/electromagnetic/utils/src/G4VEmModel.cc

    r1055 r1196  
    2424// ********************************************************************
    2525//
    26 // $Id: G4VEmModel.cc,v 1.27 2009/05/26 15:00:49 vnivanch Exp $
    27 // GEANT4 tag $Name: geant4-09-03-beta-cand-01 $
     26// $Id: G4VEmModel.cc,v 1.30 2009/09/23 14:42:47 vnivanch Exp $
     27// GEANT4 tag $Name: geant4-09-03-cand-01 $
    2828//
    2929// -------------------------------------------------------------------
     
    6262G4VEmModel::G4VEmModel(const G4String& nam):
    6363  fluc(0), name(nam), lowLimit(0.1*keV), highLimit(100.0*TeV),
     64  eMinActive(0.0),eMaxActive(DBL_MAX),
    6465  polarAngleLimit(0.0),secondaryThreshold(DBL_MAX),theLPMflag(false),
    6566  pParticleChange(0),nuclearStopping(false),
     
    9495  } else {
    9596    p = new G4ParticleChangeForLoss();
     97    pParticleChange = p;
    9698  }
    9799  return p;
     
    107109  } else {
    108110    p = new G4ParticleChangeForGamma();
     111    pParticleChange = p;
    109112  }
    110113  return p;
     
    132135  // initialise vector
    133136  for(G4int i=0; i<numOfCouples; i++) {
    134     const G4MaterialCutsCouple* couple =
    135       theCoupleTable->GetMaterialCutsCouple(i);
    136     const G4Material* material = couple->GetMaterial();
    137     G4int idx = couple->GetIndex();
     137    currentCouple = theCoupleTable->GetMaterialCutsCouple(i);
     138    const G4Material* material = currentCouple->GetMaterial();
     139    G4int idx = currentCouple->GetIndex();
    138140
    139141    // selector already exist check if should be deleted
     
    202204//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
    203205
     206void G4VEmModel::DefineForRegion(const G4Region*)
     207{}
     208
     209//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
     210
    204211G4double G4VEmModel::MinEnergyCut(const G4ParticleDefinition*,
    205212                                  const G4MaterialCutsCouple*)
     
    249256//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
    250257
    251 void G4VEmModel::DefineForRegion(const G4Region*)
    252 {}
    253 
    254 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
    255 
    256258void G4VEmModel::SetupForMaterial(const G4ParticleDefinition*,
    257259                                  const G4Material*, G4double)
  • trunk/source/processes/electromagnetic/utils/src/G4VEmProcess.cc

    r1055 r1196  
    2424// ********************************************************************
    2525//
    26 // $Id: G4VEmProcess.cc,v 1.66 2009/04/17 10:35:32 vnivanch Exp $
    27 // GEANT4 tag $Name: geant4-09-03-beta-cand-01 $
     26// $Id: G4VEmProcess.cc,v 1.79 2009/11/10 20:30:55 vnivanch Exp $
     27// GEANT4 tag $Name: geant4-09-03-cand-01 $
    2828//
    2929// -------------------------------------------------------------------
     
    5252// 12-04-07 remove double call to Clear model manager (V.Ivanchenko)
    5353// 27-10-07 Virtual functions moved to source (V.Ivanchenko)
     54// 24-06-09 Removed hidden bin in G4PhysicsVector (V.Ivanchenko)
    5455//
    5556// Class Description:
     
    172173{
    173174  G4int n = emModels.size();
    174   if(index >= n) for(G4int i=n; i<index+1; i++) {emModels.push_back(0);}
     175  if(index >= n) { for(G4int i=n; i<=index; ++i) {emModels.push_back(0);} }
    175176  emModels[index] = p;
    176177}
     
    181182{
    182183  G4VEmModel* p = 0;
    183   if(index >= 0 && index <  G4int(emModels.size())) p = emModels[index];
     184  if(index >= 0 && index <  G4int(emModels.size())) { p = emModels[index]; }
    184185  return p;
    185186}
     
    218219    Clear();
    219220    InitialiseProcess(particle);
     221
     222    // initialisation of models
     223    G4int nmod = modelManager->NumberOfModels();
     224    for(G4int i=0; i<nmod; ++i) {
     225      G4VEmModel* mod = modelManager->GetModel(i);
     226      mod->SetPolarAngleLimit(polarAngleLimit);
     227      if(mod->HighEnergyLimit() > maxKinEnergy) {
     228        mod->SetHighEnergyLimit(maxKinEnergy);
     229      }
     230    }
     231
    220232    theCuts = modelManager->Initialise(particle,secondaryParticle,2.,verboseLevel);
    221233    const G4ProductionCutsTable* theCoupleTable=
     
    224236    theCutsElectron = theCoupleTable->GetEnergyCutsVector(idxG4ElectronCut);
    225237    theCutsPositron = theCoupleTable->GetEnergyCutsVector(idxG4PositronCut);
     238
     239    // prepare tables
    226240    if(buildLambdaTable){
    227241      theLambdaTable = G4PhysicsTableHelper::PreparePhysicsTable(theLambdaTable);
     
    237251    idxDERegions = new G4bool[numOfCouples];
    238252
    239     for (size_t j=0; j<numOfCouples; j++) {
     253    for (size_t j=0; j<numOfCouples; ++j) {
    240254
    241255      const G4MaterialCutsCouple* couple =
     
    243257      const G4ProductionCuts* pcuts = couple->GetProductionCuts();
    244258      G4bool reg = false;
    245       for(G4int i=0; i<nDERegions; i++) {
     259      for(G4int i=0; i<nDERegions; ++i) {
    246260        if(deRegions[i]) {
    247261          if(pcuts == deRegions[i]->GetProductionCuts()) reg = true;
     
    253267  if (1 < verboseLevel && nDERegions>0) {
    254268    G4cout << " Deexcitation is activated for regions: " << G4endl;
    255     for (G4int i=0; i<nDERegions; i++) {
     269    for (G4int i=0; i<nDERegions; ++i) {
    256270      const G4Region* r = deRegions[i];
    257271      G4cout << "           " << r->GetName() << G4endl;
     
    264278void G4VEmProcess::BuildPhysicsTable(const G4ParticleDefinition& part)
    265279{
     280  G4String partname = part.GetParticleName();
    266281  if(1 < verboseLevel) {
    267282    G4cout << "G4VEmProcess::BuildPhysicsTable() for "
    268283           << GetProcessName()
    269            << " and particle " << part.GetParticleName()
     284           << " and particle " << partname
    270285           << " buildLambdaTable= " << buildLambdaTable
    271286           << G4endl;
     
    276291    FindLambdaMax();
    277292  }
    278   if(0 < verboseLevel) PrintInfoDefinition();
     293
     294  // reduce printout for nuclear stopping
     295  G4bool gproc = true;
     296  if(GetProcessName() == "nuclearStopping" &&
     297     partname != "GenericIon" && partname != "alpha") { gproc = false; }
     298
     299  if(gproc && 0 < verboseLevel) { PrintInfoDefinition(); }
    279300
    280301  if(1 < verboseLevel) {
    281302    G4cout << "G4VEmProcess::BuildPhysicsTable() done for "
    282303           << GetProcessName()
    283            << " and particle " << part.GetParticleName()
     304           << " and particle " << partname
    284305           << G4endl;
    285306  }
     
    301322        G4ProductionCutsTable::GetProductionCutsTable();
    302323  size_t numOfCouples = theCoupleTable->GetTableSize();
    303   for(size_t i=0; i<numOfCouples; i++) {
     324
     325  G4bool splineFlag = (G4LossTableManager::Instance())->SplineFlag();
     326
     327  G4PhysicsLogVector* aVector = 0;
     328  G4PhysicsLogVector* bVector = 0;
     329
     330  for(size_t i=0; i<numOfCouples; ++i) {
    304331
    305332    if (theLambdaTable->GetFlag(i)) {
    306333
    307334      // create physics vector and fill it
    308       const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(i);
    309       G4PhysicsVector* aVector = LambdaPhysicsVector(couple);
     335      const G4MaterialCutsCouple* couple =
     336        theCoupleTable->GetMaterialCutsCouple(i);
     337      if(!bVector) {
     338        aVector =
     339          static_cast<G4PhysicsLogVector*>(LambdaPhysicsVector(couple));
     340        bVector = aVector;
     341      } else {
     342        aVector = new G4PhysicsLogVector(*bVector);
     343      }
     344        //      G4PhysicsVector* aVector = LambdaPhysicsVector(couple);
     345      aVector->SetSpline(splineFlag);
    310346      modelManager->FillLambdaVector(aVector, couple, startFromNull);
     347      if(splineFlag) aVector->FillSecondDerivatives();
    311348      G4PhysicsTableHelper::SetPhysicsVector(theLambdaTable, i, aVector);
    312349    }
     
    364401  if(previousStepSize <= DBL_MIN) theNumberOfInteractionLengthLeft = -1.0;
    365402  InitialiseStep(track);
     403  if(!currentModel->IsActive(preStepKinEnergy)) return x;
    366404
    367405  if(preStepKinEnergy < mfpKinEnergy) {
     
    444482  }
    445483
    446   SelectModel(finalT);
     484  SelectModel(finalT, currentCoupleIndex);
     485  if(!currentModel->IsActive(finalT)) return &fParticleChange;
    447486  if(useDeexcitation) {
    448     currentModel->SetDeexcitationFlag(idxDERegions[currentMaterialIndex]);
     487    currentModel->SetDeexcitationFlag(idxDERegions[currentCoupleIndex]);
    449488  }
    450489  /* 
     
    464503                                  currentCouple,
    465504                                  track.GetDynamicParticle(),
    466                                   (*theCuts)[currentMaterialIndex]);
     505                                  (*theCuts)[currentCoupleIndex]);
    467506
    468507  // save secondaries
     
    473512    G4double edep = fParticleChange.GetLocalEnergyDeposit();
    474513     
    475     for (G4int i=0; i<num; i++) {
     514    for (G4int i=0; i<num; ++i) {
    476515      G4DynamicParticle* dp = secParticles[i];
    477516      const G4ParticleDefinition* p = dp->GetDefinition();
     
    480519      if(applyCuts) {
    481520        if (p == theGamma) {
    482           if (e < (*theCutsGamma)[currentMaterialIndex]) good = false;
     521          if (e < (*theCutsGamma)[currentCoupleIndex]) good = false;
    483522
    484523        } else if (p == theElectron) {
    485           if (e < (*theCutsElectron)[currentMaterialIndex]) good = false;
     524          if (e < (*theCutsElectron)[currentCoupleIndex]) good = false;
    486525
    487526        } else if (p == thePositron) {
    488           if (electron_mass_c2 < (*theCutsGamma)[currentMaterialIndex] &&
    489               e < (*theCutsPositron)[currentMaterialIndex]) {
     527          if (electron_mass_c2 < (*theCutsGamma)[currentCoupleIndex] &&
     528              e < (*theCutsPositron)[currentCoupleIndex]) {
    490529            good = false;
    491530            e += 2.0*electron_mass_c2;
     
    539578G4bool G4VEmProcess::RetrievePhysicsTable(const G4ParticleDefinition* part,
    540579                                          const G4String& directory,
    541                                                 G4bool ascii)
     580                                          G4bool ascii)
    542581{
    543582  if(1 < verboseLevel) {
     
    558597  if ( yes ) {
    559598    if (0 < verboseLevel) {
    560       G4cout << "Lambda table for " << particleName << " is Retrieved from <"
     599      G4cout << "Lambda table for " << particleName
     600             << " is Retrieved from <"
    561601             << filename << ">"
    562602             << G4endl;
     
    564604    if((G4LossTableManager::Instance())->SplineFlag()) {
    565605      size_t n = theLambdaTable->length();
    566       for(size_t i=0; i<n; i++) {(* theLambdaTable)[i]->SetSpline(true);}
     606      for(size_t i=0; i<n; ++i) {
     607        if((* theLambdaTable)[i]) {
     608          (* theLambdaTable)[i]->SetSpline(true);
     609        }
     610      }
    567611    }
    568612  } else {
     
    587631  // the region is in the list
    588632  if (nDERegions) {
    589     for (G4int i=0; i<nDERegions; i++) {
     633    for (G4int i=0; i<nDERegions; ++i) {
    590634      if (reg == deRegions[i]) {
    591635        if(!val) deRegions[i] = 0;
     
    613657  DefineMaterial(couple);
    614658  G4double cross = 0.0;
    615   G4bool b;
    616659  if(theLambdaTable) {
    617     cross = (((*theLambdaTable)[currentMaterialIndex])->
    618                            GetValue(kineticEnergy, b));
     660    cross = (((*theLambdaTable)[currentCoupleIndex])->Value(kineticEnergy));
    619661  } else {
    620     SelectModel(kineticEnergy);
     662    SelectModel(kineticEnergy, currentCoupleIndex);
    621663    cross = currentModel->CrossSectionPerVolume(currentMaterial,
    622664                                                particle,kineticEnergy);
     
    650692  theEnergyOfCrossSectionMax = new G4double [n];
    651693  theCrossSectionMax = new G4double [n];
    652   G4bool b;
    653 
    654   for (size_t i=0; i<n; i++) {
     694
     695  for (size_t i=0; i<n; ++i) {
    655696    pv = (*theLambdaTable)[i];
    656697    emax = DBL_MAX;
     
    658699    if(pv) {
    659700      size_t nb = pv->GetVectorLength();
    660       emax = pv->GetLowEdgeEnergy(nb);
     701      emax = DBL_MAX;
    661702      smax = 0.0;
    662       for (size_t j=0; j<nb; j++) {
    663         e = pv->GetLowEdgeEnergy(j);
    664         s = pv->GetValue(e,b);
    665         if(s > smax) {
    666           smax = s;
    667           emax = e;
     703      if(nb > 0) {
     704        for (size_t j=0; j<nb; ++j) {
     705          e = pv->Energy(j);
     706          s = (*pv)(j);
     707          if(s > smax) {
     708            smax = s;
     709            emax = e;
     710          }
    668711        }
    669712      }
  • trunk/source/processes/electromagnetic/utils/src/G4VEnergyLoss.cc

    r1007 r1196  
    2626//
    2727// $Id: G4VEnergyLoss.cc,v 1.46 2006/06/29 19:55:21 gunter Exp $
    28 // GEANT4 tag $Name: geant4-09-02 $
     28// GEANT4 tag $Name: geant4-09-03-cand-01 $
    2929//
    3030
  • trunk/source/processes/electromagnetic/utils/src/G4VEnergyLossProcess.cc

    r1055 r1196  
    2424// ********************************************************************
    2525//
    26 // $Id: G4VEnergyLossProcess.cc,v 1.149 2009/04/17 10:35:32 vnivanch Exp $
    27 // GEANT4 tag $Name: geant4-09-03-beta-cand-01 $
     26// $Id: G4VEnergyLossProcess.cc,v 1.158 2009/10/29 18:07:08 vnivanch Exp $
     27// GEANT4 tag $Name: geant4-09-03-cand-01 $
    2828//
    2929// -------------------------------------------------------------------
     
    107107// 25-04-07 move initialisation of safety helper to BuildPhysicsTable (VI)
    108108// 27-10-07 Virtual functions moved to source (V.Ivanchenko)
     109// 24-06-09 Removed hidden bin in G4PhysicsVector (V.Ivanchenko)
    109110//
    110111// Class Description:
     
    230231  vstrag->SetSpline(true);
    231232  G4double s[nrbins] = {-0.2, -0.85, -1.3, -1.578, -1.76, -1.85, -1.9};
    232   for(G4int i=0; i<nrbins; i++) {vstrag->PutValue(i, s[i]);}
     233  for(G4int i=0; i<nrbins; ++i) {vstrag->PutValue(i, s[i]);}
    233234}
    234235
     
    351352{
    352353  G4int n = emModels.size();
    353   if(index >= n) for(G4int i=n; i<index+1; i++) {emModels.push_back(0);}
     354  if(index >= n) { for(G4int i=n; i<=index; ++i) {emModels.push_back(0);} }
    354355  emModels[index] = p;
    355356}
     
    360361{
    361362  G4VEmModel* p = 0;
    362   if(index >= 0 && index <  G4int(emModels.size())) p = emModels[index];
     363  if(index >= 0 && index <  G4int(emModels.size())) { p = emModels[index]; }
    363364  return p;
    364365}
     
    466467    G4double q = initialCharge/baseParticle->GetPDGCharge();
    467468    chargeSqRatio = q*q;
    468     if(chargeSqRatio > 0.0) reduceFactor = 1.0/(chargeSqRatio*massRatio);
     469    if(chargeSqRatio > 0.0) { reduceFactor = 1.0/(chargeSqRatio*massRatio); }
     470  }
     471
     472  // initialisation of models
     473  G4int nmod = modelManager->NumberOfModels();
     474  for(G4int i=0; i<nmod; ++i) {
     475    G4VEmModel* mod = modelManager->GetModel(i);
     476    if(mod->HighEnergyLimit() > maxKinEnergy) {
     477      mod->SetHighEnergyLimit(maxKinEnergy);
     478    }
    469479  }
    470480
     
    483493    if(nDERegions>0) idxDERegions = new G4bool[numOfCouples];
    484494 
    485     for (size_t j=0; j<numOfCouples; j++) {
     495    for (size_t j=0; j<numOfCouples; ++j) {
    486496
    487497      const G4MaterialCutsCouple* couple =
     
    491501      if(nSCoffRegions>0) {
    492502        G4bool reg = false;
    493         for(G4int i=0; i<nSCoffRegions; i++) {
     503        for(G4int i=0; i<nSCoffRegions; ++i) {
    494504          if( pcuts == scoffRegions[i]->GetProductionCuts()) reg = true;
    495505        }
     
    498508      if(nDERegions>0) {
    499509        G4bool reg = false;
    500         for(G4int i=0; i<nDERegions; i++) {
     510        for(G4int i=0; i<nDERegions; ++i) {
    501511          if( pcuts == deRegions[i]->GetProductionCuts()) reg = true;
    502512        }
     
    517527    if (nSCoffRegions) {
    518528      G4cout << " SubCutoff Regime is ON for regions: " << G4endl;
    519       for (G4int i=0; i<nSCoffRegions; i++) {
     529      for (G4int i=0; i<nSCoffRegions; ++i) {
    520530        const G4Region* r = scoffRegions[i];
    521531        G4cout << "           " << r->GetName() << G4endl;
     
    524534    if (nDERegions) {
    525535      G4cout << " Deexcitation is ON for regions: " << G4endl;
    526       for (G4int i=0; i<nDERegions; i++) {
     536      for (G4int i=0; i<nDERegions; ++i) {
    527537        const G4Region* r = deRegions[i];
    528538        G4cout << "           " << r->GetName() << G4endl;
     
    556566    }
    557567  }
     568
     569  // Added tracking cut to avoid tracking artifacts
     570  if(isIonisation) fParticleChange.SetLowEnergyLimit(lowestKinEnergy);
    558571
    559572  if(1 < verboseLevel) {
     
    613626  if(!table) return table;
    614627
    615   for(size_t i=0; i<numOfCouples; i++) {
     628  G4bool splineFlag = (G4LossTableManager::Instance())->SplineFlag();
     629  G4PhysicsLogVector* aVector = 0;
     630  G4PhysicsLogVector* bVector = 0;
     631
     632  for(size_t i=0; i<numOfCouples; ++i) {
    616633
    617634    if(1 < verboseLevel) {
     
    624641      const G4MaterialCutsCouple* couple =
    625642        theCoupleTable->GetMaterialCutsCouple(i);
    626       G4PhysicsVector* aVector = new G4PhysicsLogVector(emin, emax, bin);
    627       aVector->SetSpline((G4LossTableManager::Instance())->SplineFlag());
     643      if(!bVector) {
     644        aVector = new G4PhysicsLogVector(emin, emax, bin);
     645        bVector = aVector;
     646      } else {
     647        aVector = new G4PhysicsLogVector(*bVector);
     648      }
     649      //      G4PhysicsVector* aVector = new G4PhysicsLogVector(emin, emax, bin);
     650      aVector->SetSpline(splineFlag);
    628651
    629652      modelManager->FillDEDXVector(aVector, couple, tType);
     653      if(splineFlag) aVector->FillSecondDerivatives();
    630654
    631655      // Insert vector for this material into the table
     
    676700  size_t numOfCouples = theCoupleTable->GetTableSize();
    677701
    678   for(size_t i=0; i<numOfCouples; i++) {
     702  G4bool splineFlag = (G4LossTableManager::Instance())->SplineFlag();
     703
     704  for(size_t i=0; i<numOfCouples; ++i) {
    679705
    680706    if (table->GetFlag(i)) {
     
    686712      if(fSubRestricted == tType) cut = (*theSubCuts)[i];
    687713      G4PhysicsVector* aVector = LambdaPhysicsVector(couple, cut);
     714      aVector->SetSpline(splineFlag);
     715
    688716      modelManager->FillLambdaVector(aVector, couple, true, tType);
     717      if(splineFlag) aVector->FillSecondDerivatives();
    689718
    690719      // Insert vector for this material into the table
     
    787816  // the region is in the list
    788817  if (nSCoffRegions) {
    789     for (G4int i=0; i<nSCoffRegions; i++) {
     818    for (G4int i=0; i<nSCoffRegions; ++i) {
    790819      if (reg == scoffRegions[i]) {
    791820        if(!val) deRegions[i] = 0;
     
    799828    useSubCutoff = true;
    800829    scoffRegions.push_back(reg);
    801     nSCoffRegions++;
     830    ++nSCoffRegions;
    802831  } else {
    803832    useSubCutoff = false;
     
    815844  // the region is in the list
    816845  if (nDERegions) {
    817     for (G4int i=0; i<nDERegions; i++) {
     846    for (G4int i=0; i<nDERegions; ++i) {
    818847      if (reg == deRegions[i]) {
    819848        if(!val) deRegions[i] = 0;
     
    827856    useDeexcitation = true;
    828857    deRegions.push_back(reg);
    829     nDERegions++;
     858    ++nDERegions;
    830859  } else {
    831860    useDeexcitation = false;
     
    883912  preStepScaledEnergy = preStepKinEnergy*massRatio;
    884913  SelectModel(preStepScaledEnergy);
     914  if(!currentModel->IsActive(preStepScaledEnergy)) return x;
    885915
    886916  if(isIon) {
     
    951981  fParticleChange.InitializeForAlongStep(track);
    952982  // The process has range table - calculate energy loss
    953   if(!isIonisation) return &fParticleChange;
     983  if(!isIonisation || !currentModel->IsActive(preStepScaledEnergy)) {
     984    return &fParticleChange;
     985  }
    954986
    955987  // Get the actual (true) Step length
     
    10761108        /*
    10771109        if(nProcesses > 0) {
    1078           for(G4int i=0; i<nProcesses; i++) {
     1110          for(G4int i=0; i<nProcesses; ++i) {
    10791111            (scProcesses[i])->SampleSubCutSecondaries(
    10801112                scTracks, step, (scProcesses[i])->
     
    10881120          G4ThreeVector mom = dynParticle->GetMomentum();
    10891121          fParticleChange.SetNumberOfSecondaries(n);
    1090           for(G4int i=0; i<n; i++) {
     1122          for(G4int i=0; i<n; ++i) {
    10911123            G4Track* t = scTracks[i];
    10921124            G4double e = t->GetKineticEnergy();
     
    11821214  const G4DynamicParticle* dp = track->GetDynamicParticle();
    11831215  G4double e = dp->GetKineticEnergy()*massRatio;
    1184   G4bool b;
    1185   G4double cross = chargeSqRatio*(((*theSubLambdaTable)[idx])->GetValue(e,b));
     1216  G4double cross = chargeSqRatio*(((*theSubLambdaTable)[idx])->Value(e));
    11861217  G4double length = step.GetStepLength();
    11871218
     
    12201251    G4ThreeVector r = prepoint + fragment*dr;
    12211252    std::vector<G4DynamicParticle*>::iterator it;
    1222     for(it=secParticles.begin(); it!=secParticles.end(); it++) {
     1253    for(it=secParticles.begin(); it!=secParticles.end(); ++it) {
    12231254
    12241255      G4bool addSec = true;
     
    12261257      // do not track very low-energy delta-electrons
    12271258      if(theSecondaryRangeTable && (*it)->GetDefinition() == theElectron) {
    1228         G4bool b;
    12291259        G4double ekin = (*it)->GetKineticEnergy();
    1230         G4double rg = ((*theSecondaryRangeTable)[idx]->GetValue(ekin, b));
     1260        G4double rg = ((*theSecondaryRangeTable)[idx]->Value(ekin));
    12311261        //          if(rg < currentMinSafety) {
    12321262        if(rg < safetyHelper->ComputeSafety(r)) {
     
    12651295
    12661296  G4double postStepScaledEnergy = finalT*massRatio;
     1297
     1298  if(!currentModel->IsActive(postStepScaledEnergy)) return &fParticleChange;
    12671299  /*
    12681300  if(-1 < verboseLevel) {
     
    12831315             << " < " << lx << " (postLambda) "
    12841316             << G4endl;
    1285       nWarnings++;
     1317      ++nWarnings;
    12861318    }
    12871319    */
     
    13081340  if(num > 0) {
    13091341    fParticleChange.SetNumberOfSecondaries(num);
    1310     for (G4int i=0; i<num; i++) {
     1342    for (G4int i=0; i<num; ++i) {
    13111343      fParticleChange.AddSecondary(secParticles[i]);
    13121344    }
     
    13901422//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
    13911423
    1392 G4bool G4VEnergyLossProcess::RetrievePhysicsTable(
    1393        const G4ParticleDefinition* part, const G4String& directory,
    1394        G4bool ascii)
     1424G4bool
     1425G4VEnergyLossProcess::RetrievePhysicsTable(const G4ParticleDefinition* part,
     1426                                           const G4String& directory,
     1427                                           G4bool ascii)
    13951428{
    13961429  G4bool res = true;
     
    14051438  if(particle == part) {
    14061439
    1407     //    G4bool yes = true;
    14081440    if ( !baseParticle ) {
    14091441
     
    14121444        {fpi = false;}
    14131445
    1414       if(!RetrieveTable(part,theIonisationTable,ascii,directory,"Ionisation",false))
     1446      // ionisation table keeps individual dEdx and not sum of sub-processes
     1447      if(!RetrieveTable(part,theDEDXTable,ascii,directory,"Ionisation",false))
    14151448        {fpi = false;}
    14161449
     
    14401473
    14411474      if(!fpi) yes = false;
    1442       if(!RetrieveTable(part,theIonisationSubTable,ascii,directory,"SubIonisation",yes)) 
     1475      if(!RetrieveTable(part,theIonisationSubTable,ascii,directory,"SubIonisation",yes))
    14431476        {res = false;}
    14441477    }
     
    14651498//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
    14661499
    1467 G4bool G4VEnergyLossProcess::RetrieveTable(const G4ParticleDefinition* part,
    1468                                            G4PhysicsTable* aTable, G4bool ascii,
    1469                                            const G4String& directory,
    1470                                            const G4String& tname,
    1471                                            G4bool mandatory)
     1500G4bool
     1501G4VEnergyLossProcess::RetrieveTable(const G4ParticleDefinition* part,
     1502                                    G4PhysicsTable* aTable,
     1503                                    G4bool ascii,
     1504                                    const G4String& directory,
     1505                                    const G4String& tname,
     1506                                    G4bool mandatory)
    14721507{
    14731508  G4bool res = true;
     
    14751510  G4bool yes = aTable->ExistPhysicsTable(filename);
    14761511  if(yes) {
     1512    if(!aTable) aTable = G4PhysicsTableHelper::PreparePhysicsTable(0);
    14771513    yes = G4PhysicsTableHelper::RetrievePhysicsTable(aTable,filename,ascii);
     1514
    14781515    if((G4LossTableManager::Instance())->SplineFlag()) {
    14791516      size_t n = aTable->length();
    1480       for(size_t i=0; i<n; i++) {(*aTable)[i]->SetSpline(true);}
     1517      for(size_t i=0; i<n; ++i) {
     1518        if((*aTable)[i]) {
     1519          (*aTable)[i]->SetSpline(true);
     1520        }
     1521      }
    14811522    }
    14821523  }
     
    15251566  DefineMaterial(couple);
    15261567  G4double cross = 0.0;
    1527   G4bool b;
    15281568  if(theLambdaTable) {
    1529     cross =
    1530       ((*theLambdaTable)[currentMaterialIndex])->GetValue(kineticEnergy, b);
     1569    cross = ((*theLambdaTable)[currentMaterialIndex])->Value(kineticEnergy);
    15311570  } else {
    15321571    SelectModel(kineticEnergy);
    1533     cross =
    1534       currentModel->CrossSectionPerVolume(currentMaterial,
    1535                                           particle, kineticEnergy,
    1536                                           (*theCuts)[currentMaterialIndex]);
     1572    cross = currentModel->CrossSectionPerVolume(currentMaterial,
     1573                                                particle, kineticEnergy,
     1574                                                (*theCuts)[currentMaterialIndex]);
    15371575  }
    15381576
     
    15871625                 const G4MaterialCutsCouple* couple, G4double cut)
    15881626{
    1589   //  G4double cut  = (*theCuts)[couple->GetIndex()];
    1590   //  G4int nbins = nLambdaBins;
    15911627  G4double tmin =
    15921628    std::max(MinPrimaryEnergy(particle, couple->GetMaterial(), cut),
     
    15951631  G4PhysicsVector* v = new G4PhysicsLogVector(tmin, maxKinEnergy, nBins);
    15961632  v->SetSpline((G4LossTableManager::Instance())->SplineFlag());
    1597 
    15981633  return v;
    15991634}
     
    16071642  if(p->GetProcessName() != "eBrem") add = false;
    16081643  if(add && nProcesses > 0) {
    1609     for(G4int i=0; i<nProcesses; i++) {
     1644    for(G4int i=0; i<nProcesses; ++i) {
    16101645      if(p == scProcesses[i]) {
    16111646        add = false;
     
    16161651  if(add) {
    16171652    scProcesses.push_back(p);
    1618     nProcesses++;
     1653    ++nProcesses;
    16191654    if (1 < verboseLevel) {
    16201655      G4cout << "### The process " << p->GetProcessName()
     
    16361671      G4PhysicsVector* pv = (*p)[0];
    16371672      G4double emax = maxKinEnergyCSDA;
    1638       G4bool b;
    16391673      theDEDXAtMaxEnergy = new G4double [n];
    16401674
    1641       for (size_t i=0; i<n; i++) {
     1675      for (size_t i=0; i<n; ++i) {
    16421676        pv = (*p)[i];
    1643         G4double dedx = pv->GetValue(emax, b);
     1677        G4double dedx = pv->Value(emax);
    16441678        theDEDXAtMaxEnergy[i] = dedx;
    16451679        //G4cout << "i= " << i << " emax(MeV)= " << emax/MeV<< " dedx= "
     
    16711705    G4PhysicsVector* pv = (*p)[0];
    16721706    G4double emax = maxKinEnergyCSDA;
    1673     G4bool b;
    16741707    theRangeAtMaxEnergy = new G4double [n];
    16751708
    1676     for (size_t i=0; i<n; i++) {
     1709    for (size_t i=0; i<n; ++i) {
    16771710      pv = (*p)[i];
    1678       G4double r2 = pv->GetValue(emax, b);
     1711      G4double r2 = pv->Value(emax);
    16791712      theRangeAtMaxEnergy[i] = r2;
    16801713      //G4cout << "i= " << i << " e2(MeV)= " << emax/MeV << " r2= "
     
    17441777    theEnergyOfCrossSectionMax = new G4double [n];
    17451778    theCrossSectionMax = new G4double [n];
    1746     G4bool b;
    1747 
    1748     for (size_t i=0; i<n; i++) {
     1779
     1780    for (size_t i=0; i<n; ++i) {
    17491781      pv = (*p)[i];
    17501782      emax = DBL_MAX;
     
    17521784      if(pv) {
    17531785        size_t nb = pv->GetVectorLength();
    1754         emax = pv->GetLowEdgeEnergy(nb);
    1755         for (size_t j=0; j<nb; j++) {
    1756           e = pv->GetLowEdgeEnergy(j);
    1757           s = pv->GetValue(e,b);
    1758           if(s > smax) {
    1759             smax = s;
    1760             emax = e;
     1786        if(nb > 0) {
     1787          for (size_t j=0; j<nb; ++j) {
     1788            e = pv->Energy(j);
     1789            s = (*pv)(j);
     1790            if(s > smax) {
     1791              smax = s;
     1792              emax = e;
     1793            }
    17611794          }
    17621795        }
  • trunk/source/processes/electromagnetic/utils/src/G4VMscModel.cc

    r1055 r1196  
    2424// ********************************************************************
    2525//
    26 // $Id: G4VMscModel.cc,v 1.12 2009/05/10 19:36:19 vnivanch Exp $
    27 // GEANT4 tag $Name: geant4-09-03-beta-cand-01 $
     26// $Id: G4VMscModel.cc,v 1.13 2009/07/20 17:32:47 vnivanch Exp $
     27// GEANT4 tag $Name: geant4-09-03-cand-01 $
    2828//
    2929// -------------------------------------------------------------------
     
    6060  facrange(0.04),
    6161  facgeom(2.5),
    62   facsafety(0.25),
     62  facsafety(0.3),
    6363  skin(3.0),
    6464  dtrl(0.05),
  • trunk/source/processes/electromagnetic/utils/src/G4VMultipleScattering.cc

    r1055 r1196  
    2424// ********************************************************************
    2525//
    26 // $Id: G4VMultipleScattering.cc,v 1.66 2009/05/27 11:55:02 vnivanch Exp $
    27 // GEANT4 tag $Name: geant4-09-03-beta-cand-01 $
     26// $Id: G4VMultipleScattering.cc,v 1.77 2009/10/29 18:07:08 vnivanch Exp $
     27// GEANT4 tag $Name: geant4-09-03-cand-01 $
    2828//
    2929// -------------------------------------------------------------------
     
    5656// 27-10-07 Virtual functions moved to source (V.Ivanchenko)
    5757// 11-03-08 Set skin value does not effect step limit type (V.Ivanchenko)
     58// 24-06-09 Removed hidden bin in G4PhysicsVector (V.Ivanchenko)
    5859//
    5960// Class Description:
     
    9899  facgeom(2.5),
    99100  latDisplasment(true),
     101  isIon(false),
    100102  currentParticle(0),
    101103  currentCouple(0)
     
    144146  if(p) p->SetParticleChange(pParticleChange);
    145147}
    146 
    147 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
    148 
    149 G4VEmModel* G4VMultipleScattering::GetModelByIndex(G4int idx, G4bool ver)
     148//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
     149
     150void G4VMultipleScattering::SetModel(G4VMscModel* p, G4int index)
     151{
     152  G4int n = mscModels.size();
     153  if(index >= n) { for(G4int i=n; i<=index; ++i) {mscModels.push_back(0);} }
     154  mscModels[index] = p;
     155}
     156
     157//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
     158
     159G4VMscModel* G4VMultipleScattering::Model(G4int index)
     160{
     161  G4VMscModel* p = 0;
     162  if(index >= 0 && index <  G4int(mscModels.size())) { p = mscModels[index]; }
     163  return p;
     164}
     165
     166//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
     167
     168G4VEmModel*
     169G4VMultipleScattering::GetModelByIndex(G4int idx, G4bool ver) const
    150170{
    151171  return modelManager->GetModel(idx, ver);
     
    170190    size_t numOfCouples = theCoupleTable->GetTableSize();
    171191
    172     for (size_t i=0; i<numOfCouples; i++) {
     192    G4bool splineFlag = (G4LossTableManager::Instance())->SplineFlag();
     193
     194    G4PhysicsLogVector* aVector = 0;
     195    G4PhysicsLogVector* bVector = 0;
     196
     197    for (size_t i=0; i<numOfCouples; ++i) {
    173198
    174199      if (theLambdaTable->GetFlag(i)) {
     
    176201        const G4MaterialCutsCouple* couple =
    177202          theCoupleTable->GetMaterialCutsCouple(i);
    178         G4PhysicsVector* aVector = PhysicsVector(couple);
     203        if(!bVector) {
     204          aVector = static_cast<G4PhysicsLogVector*>(PhysicsVector(couple));
     205          bVector = aVector;
     206        } else {
     207          aVector = new G4PhysicsLogVector(*bVector);
     208        }       
     209        //G4PhysicsVector* aVector = PhysicsVector(couple);
     210        aVector->SetSpline(splineFlag);
    179211        modelManager->FillLambdaVector(aVector, couple, false);
     212        if(splineFlag) aVector->FillSecondDerivatives();
    180213        G4PhysicsTableHelper::SetPhysicsVector(theLambdaTable, i, aVector);
    181214      }
     
    212245       part.GetParticleSubType() == "generic") {
    213246      firstParticle = G4GenericIon::GenericIon();
     247      isIon = true;
    214248    } else {
    215249      firstParticle = &part;
     250      if(part.GetParticleType() == "nucleus" ||
     251         part.GetPDGMass() > GeV) {isIon = true;}
    216252    }
    217 
     253    // limitations for ions
     254    if(isIon) {
     255      SetStepLimitType(fMinimal);
     256      SetLateralDisplasmentFlag(false);
     257      SetBuildLambdaTable(false);
     258    }
    218259    currentParticle = &part;
    219260  }
     
    232273
    233274    InitialiseProcess(firstParticle);
    234     if(buildLambdaTable)
     275
     276    // initialisation of models
     277    G4int nmod = modelManager->NumberOfModels();
     278    for(G4int i=0; i<nmod; ++i) {
     279      G4VMscModel* msc = static_cast<G4VMscModel*>(modelManager->GetModel(i));
     280      if(isIon) {
     281        msc->SetStepLimitType(fMinimal);
     282        msc->SetLateralDisplasmentFlag(false);
     283        msc->SetRangeFactor(0.2);
     284      } else {
     285        msc->SetStepLimitType(StepLimitType());
     286        msc->SetLateralDisplasmentFlag(LateralDisplasmentFlag());
     287        msc->SetSkin(Skin());
     288        msc->SetRangeFactor(RangeFactor());
     289        msc->SetGeomFactor(GeomFactor());
     290      }
     291      msc->SetPolarAngleLimit(polarAngleLimit);
     292      if(msc->HighEnergyLimit() > maxKinEnergy) {
     293        msc->SetHighEnergyLimit(maxKinEnergy);
     294      }
     295    }
     296
     297    modelManager->Initialise(firstParticle, G4Electron::Electron(),
     298                             10.0, verboseLevel);
     299
     300    // prepare tables
     301    if(buildLambdaTable) {
    235302      theLambdaTable = G4PhysicsTableHelper::PreparePhysicsTable(theLambdaTable);
    236     const G4DataVector* theCuts =
    237       modelManager->Initialise(firstParticle,
    238                                G4Electron::Electron(),
    239                                10.0, verboseLevel);
    240 
    241     if(2 < verboseLevel) G4cout << theCuts << G4endl;
    242 
     303    }
    243304  }
    244305}
     
    277338                             G4double,
    278339                             G4double currentMinimalStep,
    279                              G4double& currentSafety,
     340                             G4double&,
    280341                             G4GPILSelection* selection)
    281342{
    282343  // get Step limit proposed by the process
    283   valueGPILSelectionMSC = NotCandidateForSelection;
    284   G4double steplength = GetMscContinuousStepLimit(track,
    285                                                   track.GetKineticEnergy(),
    286                                                   currentMinimalStep,
    287                                                   currentSafety);
    288   // G4cout << "StepLimit= " << steplength << G4endl;
    289   // set return value for G4GPILSelection
    290   *selection = valueGPILSelectionMSC;
    291   return  steplength;
    292 }
    293 
    294 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
    295 
    296 G4double G4VMultipleScattering::PostStepGetPhysicalInteractionLength(
    297               const G4Track&, G4double, G4ForceCondition* condition)
    298 {
    299   *condition = Forced;
    300   return DBL_MAX;
     344  *selection = NotCandidateForSelection;
     345  G4double x = currentMinimalStep;
     346  DefineMaterial(track.GetMaterialCutsCouple());
     347  G4double ekin = track.GetKineticEnergy();
     348  if(isIon) { ekin *= proton_mass_c2/track.GetDefinition()->GetPDGMass(); }
     349  currentModel = static_cast<G4VMscModel*>(SelectModel(ekin));
     350  if(x > 0.0 && ekin > 0.0 && currentModel->IsActive(ekin)) {
     351    G4double tPathLength =
     352      currentModel->ComputeTruePathLengthLimit(track, theLambdaTable, x);
     353    if (tPathLength < x) *selection = CandidateForSelection;
     354    x = currentModel->ComputeGeomPathLength(tPathLength);
     355    //  G4cout << "tPathLength= " << tPathLength
     356    //         << " stepLimit= " << x
     357    //        << " currentMinimalStep= " << currentMinimalStep<< G4endl;
     358  }
     359  return x;
    301360}
    302361
     
    309368                                       G4double& currentSafety)
    310369{
    311   return GetMscContinuousStepLimit(track,previousStepSize,currentMinimalStep,
    312                                    currentSafety);
     370  G4GPILSelection* selection = 0;
     371  return AlongStepGetPhysicalInteractionLength(track,previousStepSize,currentMinimalStep,
     372                                               currentSafety, selection);
    313373}
    314374
     
    320380  *condition = Forced;
    321381  return DBL_MAX;
    322 }
    323 
    324 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
    325 
    326 G4VParticleChange* G4VMultipleScattering::AlongStepDoIt(const G4Track&,
    327                                                         const G4Step& step)
    328 {
    329   fParticleChange.ProposeTrueStepLength(
    330     currentModel->ComputeTrueStepLength(step.GetStepLength()));
    331   return &fParticleChange;
    332 }
    333 
    334 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
    335 
    336 G4VParticleChange* G4VMultipleScattering::PostStepDoIt(const G4Track& track,
    337                                                        const G4Step& step)
    338 {
    339   fParticleChange.Initialize(track);
    340   currentModel->SampleScattering(track.GetDynamicParticle(),
    341                                  step.GetPostStepPoint()->GetSafety());
    342   return &fParticleChange;
    343382}
    344383
     
    384423//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
    385424
    386 G4bool G4VMultipleScattering::RetrievePhysicsTable(const G4ParticleDefinition* part,
    387                                                    const G4String& directory,
    388                                                          G4bool ascii)
     425G4bool
     426G4VMultipleScattering::RetrievePhysicsTable(const G4ParticleDefinition* part,
     427                                            const G4String& directory,
     428                                            G4bool ascii)
    389429{
    390430  if(0 < verboseLevel) {
    391 //    G4cout << "========================================================" << G4endl;
    392431    G4cout << "G4VMultipleScattering::RetrievePhysicsTable() for "
    393432           << part->GetParticleName() << " and process "
     
    401440
    402441  G4String filename = GetPhysicsTableFileName(part,directory,"Lambda",ascii);
    403   yes = G4PhysicsTableHelper::RetrievePhysicsTable(theLambdaTable,filename,ascii);
     442  yes =
     443    G4PhysicsTableHelper::RetrievePhysicsTable(theLambdaTable,filename,ascii);
    404444  if ( yes ) {
    405445    if (0 < verboseLevel) {
    406         G4cout << "Lambda table for " << part->GetParticleName() << " is retrieved from <"
     446        G4cout << "Lambda table for " << part->GetParticleName()
     447               << " is retrieved from <"
    407448               << filename << ">"
    408449               << G4endl;
     
    410451    if((G4LossTableManager::Instance())->SplineFlag()) {
    411452      size_t n = theLambdaTable->length();
    412       for(size_t i=0; i<n; i++) {(* theLambdaTable)[i]->SetSpline(true);}
     453      for(size_t i=0; i<n; ++i) {
     454        if((* theLambdaTable)[i]) {
     455          (* theLambdaTable)[i]->SetSpline(true);
     456        }
     457      }
    413458    }
    414459  } else {
    415460    if (1 < verboseLevel) {
    416         G4cout << "Lambda table for " << part->GetParticleName() << " in file <"
     461        G4cout << "Lambda table for " << part->GetParticleName()
     462               << " in file <"
    417463               << filename << "> is not exist"
    418464               << G4endl;
  • trunk/source/processes/electromagnetic/utils/src/G4ionEffectiveCharge.cc

    r1007 r1196  
    2424// ********************************************************************
    2525//
    26 // $Id: G4ionEffectiveCharge.cc,v 1.24 2008/12/18 13:01:46 gunter Exp $
    27 // GEANT4 tag $Name: geant4-09-02 $
     26// $Id: G4ionEffectiveCharge.cc,v 1.25 2009/10/29 16:57:39 vnivanch Exp $
     27// GEANT4 tag $Name: geant4-09-03-cand-01 $
    2828//
    2929// -------------------------------------------------------------------
     
    105105  // Fast ions or hadrons
    106106  G4double reducedEnergy = kineticEnergy * proton_mass_c2/mass ;
     107
     108  //G4cout << "e= " << reducedEnergy << " Zi= " << Zi << "  " << material->GetName() << G4endl;
     109
    107110  if( reducedEnergy > Zi*energyHighLimit || Zi < 1.5 || !material) return charge;
    108111
    109112  G4double z    = material->GetIonisation()->GetZeffective();
    110   //  reducedEnergy = std::max(reducedEnergy,energyLowLimit);
     113  reducedEnergy = std::max(reducedEnergy,energyLowLimit);
    111114
    112115  // Helium ion case
Note: See TracChangeset for help on using the changeset viewer.