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

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

File:
1 edited

Legend:

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

    r1228 r1315  
    2424// ********************************************************************
    2525//
    26 // $Id: G4VEnergyLossProcess.cc,v 1.158 2009/10/29 18:07:08 vnivanch Exp $
    27 // GEANT4 tag $Name: geant4-09-03 $
     26// $Id: G4VEnergyLossProcess.cc,v 1.167 2010/05/26 10:41:34 vnivanch Exp $
     27// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
    2828//
    2929// -------------------------------------------------------------------
     
    336336{
    337337  modelManager->AddEmModel(order, p, fluc, region);
    338   if(p) p->SetParticleChange(pParticleChange, fluc);
     338  if(p) { p->SetParticleChange(pParticleChange, fluc); }
    339339}
    340340
     
    406406    particle = ∂
    407407    if(part.GetParticleType() == "nucleus") {
    408       if(!theGenericIon) theGenericIon = G4GenericIon::GenericIon();
     408      if(!theGenericIon) { theGenericIon = G4GenericIon::GenericIon(); }
    409409      if(particle == theGenericIon) { isIon = true; }
    410410      else if(part.GetPDGCharge() > eplus) {
     
    426426      lManager->RegisterExtraParticle(&part, this);
    427427    }
     428    if(1 < verboseLevel) {
     429      G4cout << "### G4VEnergyLossProcess::PreparePhysicsTable() end for "
     430             << part.GetParticleName() << G4endl;
     431    }
    428432    return;
    429433  }
    430434
    431435  Clean();
    432   lManager->EmConfigurator()->AddModels();
     436  lManager->PreparePhysicsTable(&part, this);
    433437
    434438  // Base particle and set of models can be defined here
     
    502506        G4bool reg = false;
    503507        for(G4int i=0; i<nSCoffRegions; ++i) {
    504           if( pcuts == scoffRegions[i]->GetProductionCuts()) reg = true;
     508          if( pcuts == scoffRegions[i]->GetProductionCuts()) { reg = true; }
    505509        }
    506510        idxSCoffRegions[j] = reg;
     
    509513        G4bool reg = false;
    510514        for(G4int i=0; i<nDERegions; ++i) {
    511           if( pcuts == deRegions[i]->GetProductionCuts()) reg = true;
     515          if( pcuts == deRegions[i]->GetProductionCuts()) { reg = true; }
    512516        }
    513517        idxDERegions[j] = reg;
     
    515519    }
    516520  }
    517 
    518   lManager->EnergyLossProcessIsInitialised(particle, this);
    519521
    520522  if (1 < verboseLevel) {
     
    568570
    569571  // Added tracking cut to avoid tracking artifacts
    570   if(isIonisation) fParticleChange.SetLowEnergyLimit(lowestKinEnergy);
     572  if(isIonisation) { fParticleChange.SetLowEnergyLimit(lowestKinEnergy); }
    571573
    572574  if(1 < verboseLevel) {
     
    574576           << GetProcessName()
    575577           << " and particle " << part.GetParticleName();
    576     if(isIonisation) G4cout << "  isIonisation  flag = 1";
     578    if(isIonisation) { G4cout << "  isIonisation  flag = 1"; }
    577579    G4cout << G4endl;
    578580  }
     
    590592  }
    591593  G4PhysicsTable* table = 0;
    592   G4double emin = minKinEnergy;
    593594  G4double emax = maxKinEnergy;
    594595  G4int bin = nBins;
     
    619620    G4cout << numOfCouples << " materials"
    620621           << " minKinEnergy= " << minKinEnergy
    621            << " maxKinEnergy= " << maxKinEnergy
     622           << " maxKinEnergy= " << emax
     623           << " nbin= " << bin
    622624           << " EmTableType= " << tType
    623625           << " table= " << table
     
    642644        theCoupleTable->GetMaterialCutsCouple(i);
    643645      if(!bVector) {
    644         aVector = new G4PhysicsLogVector(emin, emax, bin);
     646        aVector = new G4PhysicsLogVector(minKinEnergy, emax, bin);
    645647        bVector = aVector;
    646648      } else {
    647649        aVector = new G4PhysicsLogVector(*bVector);
    648650      }
    649       //      G4PhysicsVector* aVector = new G4PhysicsLogVector(emin, emax, bin);
    650651      aVector->SetSpline(splineFlag);
    651652
    652653      modelManager->FillDEDXVector(aVector, couple, tType);
    653       if(splineFlag) aVector->FillSecondDerivatives();
     654      if(splineFlag) { aVector->FillSecondDerivatives(); }
    654655
    655656      // Insert vector for this material into the table
     
    701702
    702703  G4bool splineFlag = (G4LossTableManager::Instance())->SplineFlag();
     704  G4PhysicsLogVector* aVector = 0;
     705  G4PhysicsLogVector* bVector = 0;
    703706
    704707  for(size_t i=0; i<numOfCouples; ++i) {
     
    709712      const G4MaterialCutsCouple* couple =
    710713        theCoupleTable->GetMaterialCutsCouple(i);
    711       G4double cut = (*theCuts)[i];
    712       if(fSubRestricted == tType) cut = (*theSubCuts)[i];
    713       G4PhysicsVector* aVector = LambdaPhysicsVector(couple, cut);
     714      if(!bVector) {
     715        aVector = new G4PhysicsLogVector(minKinEnergy, maxKinEnergy, nBins);
     716        bVector = aVector;
     717      } else {
     718        aVector = new G4PhysicsLogVector(*bVector);
     719      }
    714720      aVector->SetSpline(splineFlag);
    715721
    716722      modelManager->FillLambdaVector(aVector, couple, true, tType);
    717       if(splineFlag) aVector->FillSecondDerivatives();
     723      if(splineFlag) { aVector->FillSecondDerivatives(); }
    718724
    719725      // Insert vector for this material into the table
     
    881887    if(x > finalRange && y < currentMinStep) {
    882888      x = y + finalRange*(1.0 - dRoverRange)*(2.0 - finalRange/fRange);
    883     } else if (rndmStepFlag) {x = SampleRange();}
     889    } else if (rndmStepFlag) { x = SampleRange(); }
    884890    //G4cout<<GetProcessName()<<": e= "<<preStepKinEnergy
    885891    //  <<" range= "<<fRange <<" cMinSt="<<currentMinStep
     
    912918  preStepScaledEnergy = preStepKinEnergy*massRatio;
    913919  SelectModel(preStepScaledEnergy);
    914   if(!currentModel->IsActive(preStepScaledEnergy)) return x;
    915 
    916   if(isIon) {
    917     chargeSqRatio =
    918       currentModel->GetChargeSquareRatio(currPart,currentMaterial,preStepKinEnergy);
     920  if(!currentModel->IsActive(preStepScaledEnergy)) { return x; }
     921
     922  if(isIon) {
     923    chargeSqRatio = currentModel->ChargeSquareRatio(track);
    919924    reduceFactor  = 1.0/(chargeSqRatio*massRatio);
    920925  }
    921926  //G4cout << "q2= " << chargeSqRatio << " massRatio= " << massRatio << G4endl;
    922927  // initialisation for sampling of the interaction length
    923   if(previousStepSize <= DBL_MIN) theNumberOfInteractionLengthLeft = -1.0;
    924   if(theNumberOfInteractionLengthLeft < 0.0) mfpKinEnergy = DBL_MAX;
     928  if(previousStepSize <= DBL_MIN) { theNumberOfInteractionLengthLeft = -1.0; }
     929  if(theNumberOfInteractionLengthLeft < 0.0) { mfpKinEnergy = DBL_MAX; }
    925930
    926931  // compute mean free path
    927932  if(preStepScaledEnergy < mfpKinEnergy) {
    928     if (integral) ComputeLambdaForScaledEnergy(preStepScaledEnergy);
    929     else  preStepLambda = GetLambdaForScaledEnergy(preStepScaledEnergy);
    930     if(preStepLambda <= DBL_MIN) mfpKinEnergy = 0.0;
     933    if (integral) { ComputeLambdaForScaledEnergy(preStepScaledEnergy); }
     934    else  { preStepLambda = GetLambdaForScaledEnergy(preStepScaledEnergy); }
     935    if(preStepLambda <= DBL_MIN) { mfpKinEnergy = 0.0; }
    931936  }
    932937
     
    940945      // subtract NumberOfInteractionLengthLeft
    941946      SubtractNumberOfInteractionLengthLeft(previousStepSize);
    942       if(theNumberOfInteractionLengthLeft < 0.)
     947      if(theNumberOfInteractionLengthLeft < 0.) {
    943948        theNumberOfInteractionLengthLeft = perMillion;
     949      }
    944950    }
    945951
     
    966972      // subtract NumberOfInteractionLengthLeft
    967973      SubtractNumberOfInteractionLengthLeft(previousStepSize);
    968       if(theNumberOfInteractionLengthLeft < 0.)
     974      if(theNumberOfInteractionLengthLeft < 0.) {
    969975        theNumberOfInteractionLengthLeft = perMillion;
     976      }
    970977    }
    971978    currentInteractionLength = DBL_MAX;
     
    987994  // Get the actual (true) Step length
    988995  G4double length = step.GetStepLength();
    989   if(length <= DBL_MIN) return &fParticleChange;
     996  if(length <= DBL_MIN) { return &fParticleChange; }
    990997  G4double eloss  = 0.0;
    991   G4double esecdep = 0.0;
    992998 
    993999  /* 
     
    10711077
    10721078      // Check boundary
    1073       if(prePoint->GetStepStatus() == fGeomBoundary) yes = true;
     1079      if(prePoint->GetStepStatus() == fGeomBoundary) { yes = true; }
    10741080
    10751081      // Check PrePoint
     
    10831089        }
    10841090
    1085         if(preSafety < rcut) yes = true;
     1091        if(preSafety < rcut) { yes = true; }
    10861092
    10871093        // Check PostPoint
     
    10911097            postSafety =
    10921098              safetyHelper->ComputeSafety(step.GetPostStepPoint()->GetPosition());
    1093             if(postSafety < rcut) yes = true;
     1099            if(postSafety < rcut) { yes = true; }
    10941100          }
    10951101        }
     
    11031109        scTracks.clear();
    11041110        SampleSubCutSecondaries(scTracks, step,
    1105                                 currentModel,currentMaterialIndex,
    1106                                 esecdep);
     1111                                currentModel,currentMaterialIndex);
    11071112        // add bremsstrahlung sampling
    11081113        /*
     
    11121117                scTracks, step, (scProcesses[i])->
    11131118                SelectModelForMaterial(preStepKinEnergy, currentMaterialIndex),
    1114                 currentMaterialIndex,esecdep);
     1119                currentMaterialIndex);
    11151120          }
    11161121        }
     
    11231128            G4Track* t = scTracks[i];
    11241129            G4double e = t->GetKineticEnergy();
    1125             if (t->GetDefinition() == thePositron) e += 2.0*electron_mass_c2;
     1130            if (t->GetDefinition() == thePositron) { e += 2.0*electron_mass_c2; }
    11261131            esec += e;
    11271132            pParticleChange->AddSecondary(t);
     
    11331138
    11341139  // Corrections, which cannot be tabulated
    1135   currentModel->CorrectionsAlongStep(currentCouple, dynParticle,
    1136                                      eloss, esecdep, length);
     1140  if(isIon) {
     1141    G4double eadd = 0.0;
     1142    currentModel->CorrectionsAlongStep(currentCouple, dynParticle,
     1143                                       eloss, eadd, length);
     1144  }
    11371145
    11381146  // Sample fluctuations
     
    11401148    G4VEmFluctuationModel* fluc = currentModel->GetModelOfFluctuations();
    11411149    if(fluc &&
    1142       (eloss + esec + esecdep + lowestKinEnergy) < preStepKinEnergy) {
     1150      (eloss + esec + lowestKinEnergy) < preStepKinEnergy) {
    11431151
    11441152      G4double tmax =
     
    11581166    }
    11591167  }
    1160   // add low-energy subcutoff particles
    1161   eloss += esecdep;
    1162   if(eloss < 0.0) eloss = 0.0;
    11631168
    11641169  // deexcitation
    1165   else if (useDeexcitation) {
    1166     if(idxDERegions[currentMaterialIndex]) {
     1170  if (useDeexcitation) {
     1171    if(idxDERegions[currentMaterialIndex] && eloss > 0.0) {
    11671172      currentModel->SampleDeexcitationAlongStep(currentMaterial, track, eloss);
    1168       if(eloss < 0.0) eloss = 0.0;
     1173      if(eloss < 0.0) { eloss = 0.0; }
    11691174    }
    11701175  }
     
    12031208       const G4Step& step,
    12041209       G4VEmModel* model,
    1205        G4int idx,
    1206        G4double& /*extraEdep*/)
     1210       G4int idx)
    12071211{
    12081212  // Fast check weather subcutoff can work
    12091213  G4double subcut = (*theSubCuts)[idx];
    12101214  G4double cut = (*theCuts)[idx];
    1211   if(cut <= subcut) return;
     1215  if(cut <= subcut) { return; }
    12121216
    12131217  const G4Track* track = step.GetTrack();
     
    12181222
    12191223  // negligible probability to get any interaction
    1220   if(length*cross < perMillion) return;
     1224  if(length*cross < perMillion) { return; }
    12211225  /*     
    12221226  if(-1 < verboseLevel)
     
    12691273      if(addSec) {
    12701274        G4Track* t = new G4Track((*it), pretime + fragment*dt, r);
    1271         //G4Track* t = new G4Track((*it), pretime, r);
    12721275        t->SetTouchableHandle(track->GetTouchableHandle());
    12731276        tracks.push_back(t);
     
    12961299  G4double postStepScaledEnergy = finalT*massRatio;
    12971300
    1298   if(!currentModel->IsActive(postStepScaledEnergy)) return &fParticleChange;
     1301  if(!currentModel->IsActive(postStepScaledEnergy)) { return &fParticleChange; }
    12991302  /*
    13001303  if(-1 < verboseLevel) {
     
    15061509                                    G4bool mandatory)
    15071510{
    1508   G4bool res = true;
     1511  G4bool isRetrieved = false;
    15091512  G4String filename = GetPhysicsTableFileName(part,directory,tname,ascii);
    1510   G4bool yes = aTable->ExistPhysicsTable(filename);
    1511   if(yes) {
    1512     if(!aTable) aTable = G4PhysicsTableHelper::PreparePhysicsTable(0);
    1513     yes = G4PhysicsTableHelper::RetrievePhysicsTable(aTable,filename,ascii);
    1514 
    1515     if((G4LossTableManager::Instance())->SplineFlag()) {
    1516       size_t n = aTable->length();
    1517       for(size_t i=0; i<n; ++i) {
    1518         if((*aTable)[i]) {
    1519           (*aTable)[i]->SetSpline(true);
     1513  if(aTable) {
     1514    if(aTable->ExistPhysicsTable(filename)) {
     1515      if(G4PhysicsTableHelper::RetrievePhysicsTable(aTable,filename,ascii)) {
     1516        isRetrieved = true;
     1517        if((G4LossTableManager::Instance())->SplineFlag()) {
     1518          size_t n = aTable->length();
     1519          for(size_t i=0; i<n; ++i) {
     1520            if((*aTable)[i]) { (*aTable)[i]->SetSpline(true); }
     1521          }
    15201522        }
    1521       }
    1522     }
    1523   }
    1524   if(yes) {
    1525     if (0 < verboseLevel) {
    1526       G4cout << tname << " table for " << part->GetParticleName()
    1527              << " is Retrieved from <" << filename << ">"
    1528              << G4endl;
    1529     }
    1530   } else {
    1531     if(mandatory) res = false;
    1532     if(mandatory || 1 < verboseLevel) {
     1523        if (0 < verboseLevel) {
     1524          G4cout << tname << " table for " << part->GetParticleName()
     1525                 << " is Retrieved from <" << filename << ">"
     1526                 << G4endl;
     1527        }
     1528      }
     1529    }
     1530  }
     1531  if(mandatory && !isRetrieved) {
     1532    if(0 < verboseLevel) {
    15331533      G4cout << tname << " table for " << part->GetParticleName()
    15341534             << " from file <"
     
    15361536             << G4endl;
    15371537    }
    1538   }
    1539   return res;
     1538    return false;
     1539  }
     1540  return true;
    15401541}
    15411542
     
    15741575                                                (*theCuts)[currentMaterialIndex]);
    15751576  }
    1576 
     1577  if(cross < 0.0) { cross = 0.0; }
    15771578  return cross;
    15781579}
     
    15851586  preStepLambda = GetLambdaForScaledEnergy(track.GetKineticEnergy()*massRatio);
    15861587  G4double x = DBL_MAX;
    1587   if(DBL_MIN < preStepLambda) x = 1.0/preStepLambda;
     1588  if(DBL_MIN < preStepLambda) { x = 1.0/preStepLambda; }
    15881589  return x;
    15891590}
     
    16221623//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
    16231624
    1624 G4PhysicsVector* G4VEnergyLossProcess::LambdaPhysicsVector(
    1625                  const G4MaterialCutsCouple* couple, G4double cut)
    1626 {
     1625G4PhysicsVector*
     1626G4VEnergyLossProcess::LambdaPhysicsVector(const G4MaterialCutsCouple* /*couple*/,
     1627                                          G4double /*cut*/)
     1628{
     1629  /*
    16271630  G4double tmin =
    16281631    std::max(MinPrimaryEnergy(particle, couple->GetMaterial(), cut),
    16291632             minKinEnergy);
    1630   if(tmin >= maxKinEnergy) tmin = 0.5*maxKinEnergy;
     1633  if(tmin >= maxKinEnergy) { tmin = 0.5*maxKinEnergy; }
    16311634  G4PhysicsVector* v = new G4PhysicsLogVector(tmin, maxKinEnergy, nBins);
     1635  */
     1636  G4PhysicsVector* v = new G4PhysicsLogVector(minKinEnergy, maxKinEnergy, nBins);
    16321637  v->SetSpline((G4LossTableManager::Instance())->SplineFlag());
    16331638  return v;
     
    16401645{
    16411646  G4bool add = true;
    1642   if(p->GetProcessName() != "eBrem") add = false;
     1647  if(p->GetProcessName() != "eBrem") { add = false; }
    16431648  if(add && nProcesses > 0) {
    16441649    for(G4int i=0; i<nProcesses; ++i) {
     
    16991704void G4VEnergyLossProcess::SetCSDARangeTable(G4PhysicsTable* p)
    17001705{
    1701   if(theCSDARangeTable != p) theCSDARangeTable = p;
     1706  if(theCSDARangeTable != p) { theCSDARangeTable = p; }
    17021707
    17031708  if(p) {
     
    17681773           << " and process " << GetProcessName() << G4endl;
    17691774  }
    1770   if(theLambdaTable != p) theLambdaTable = p;
     1775  if(theLambdaTable != p) { theLambdaTable = p; }
    17711776  tablesAreBuilt = true;
    17721777
     
    18221827//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
    18231828
     1829const G4Element* G4VEnergyLossProcess::GetCurrentElement() const
     1830{
     1831  const G4Element* elm = 0;
     1832  if(currentModel) { elm = currentModel->GetCurrentElement(); }
     1833  return elm;
     1834}
     1835
     1836//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
     1837
Note: See TracChangeset for help on using the changeset viewer.