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

update processes

File:
1 edited

Legend:

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

    r819 r961  
    2424// ********************************************************************
    2525//
    26 // $Id: G4VEmProcess.cc,v 1.48 2007/10/29 08:38:58 vnivanch Exp $
    27 // GEANT4 tag $Name: geant4-09-01-patch-02 $
     26// $Id: G4VEmProcess.cc,v 1.62 2009/02/19 09:57:36 vnivanch Exp $
     27// GEANT4 tag $Name: geant4-09-02-ref-02 $
    2828//
    2929// -------------------------------------------------------------------
     
    8282
    8383G4VEmProcess::G4VEmProcess(const G4String& name, G4ProcessType type):
    84                       G4VDiscreteProcess(name, type),
    85   selectedModel(0),                   
     84  G4VDiscreteProcess(name, type),
     85  secondaryParticle(0),
     86  buildLambdaTable(true),
    8687  theLambdaTable(0),
    8788  theEnergyOfCrossSectionMax(0),
    8889  theCrossSectionMax(0),
    89   particle(0),
    90   secondaryParticle(0),
    91   nLambdaBins(90),
    92   lambdaFactor(0.8),
    93   currentCouple(0),
    9490  integral(false),
    95   buildLambdaTable(true),
    9691  applyCuts(false),
    9792  startFromNull(true),
    98   nRegions(0)
     93  useDeexcitation(false),
     94  nDERegions(0),
     95  idxDERegions(0),
     96  currentModel(0),
     97  particle(0),
     98  currentCouple(0)
    9999{
    100100  SetVerboseLevel(1);
     101
     102  // Size of tables assuming spline
    101103  minKinEnergy = 0.1*keV;
    102   maxKinEnergy = 100.0*GeV;
     104  maxKinEnergy = 100.0*TeV;
     105  nLambdaBins  = 84;
     106
     107  // default lambda factor
     108  lambdaFactor  = 0.8;
     109
     110  // default limit on polar angle
     111  polarAngleLimit = 0.0;
     112
     113  // particle types
    103114  theGamma     = G4Gamma::Gamma();
    104115  theElectron  = G4Electron::Electron();
     
    126137  delete modelManager;
    127138  (G4LossTableManager::Instance())->DeRegister(this);
     139}
     140
     141//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
     142
     143void G4VEmProcess::Clear()
     144{
     145  delete [] theEnergyOfCrossSectionMax;
     146  delete [] theCrossSectionMax;
     147  delete [] idxDERegions;
     148  theEnergyOfCrossSectionMax = 0;
     149  theCrossSectionMax = 0;
     150  idxDERegions = 0;
     151  currentCouple = 0;
     152  preStepLambda = 0.0;
     153  mfpKinEnergy  = DBL_MAX;
     154  deRegions.clear();
     155  nDERegions = 0;
    128156}
    129157
     
    153181      theLambdaTable = G4PhysicsTableHelper::PreparePhysicsTable(theLambdaTable);
    154182  }
    155 }
    156 
    157 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
    158 
    159 void G4VEmProcess::Clear()
    160 {
    161   if(theEnergyOfCrossSectionMax) delete [] theEnergyOfCrossSectionMax;
    162   if(theCrossSectionMax) delete [] theCrossSectionMax;
    163   theEnergyOfCrossSectionMax = 0;
    164   theCrossSectionMax = 0;
    165   currentCouple = 0;
    166   preStepLambda = 0.0;
    167   mfpKinEnergy  = DBL_MAX;
     183  // Sub Cutoff and Deexcitation
     184  if (nDERegions>0) {
     185
     186    const G4ProductionCutsTable* theCoupleTable=
     187          G4ProductionCutsTable::GetProductionCutsTable();
     188    size_t numOfCouples = theCoupleTable->GetTableSize();
     189
     190    idxDERegions = new G4bool[numOfCouples];
     191
     192    for (size_t j=0; j<numOfCouples; j++) {
     193
     194      const G4MaterialCutsCouple* couple =
     195        theCoupleTable->GetMaterialCutsCouple(j);
     196      const G4ProductionCuts* pcuts = couple->GetProductionCuts();
     197      G4bool reg = false;
     198      for(G4int i=0; i<nDERegions; i++) {
     199        if(deRegions[i]) {
     200          if(pcuts == deRegions[i]->GetProductionCuts()) reg = true;
     201        }
     202      }
     203      idxDERegions[j] = reg;
     204    }
     205  }
     206  if (1 < verboseLevel && nDERegions>0) {
     207    G4cout << " Deexcitation is activated for regions: " << G4endl;
     208    for (G4int i=0; i<nDERegions; i++) {
     209      const G4Region* r = deRegions[i];
     210      G4cout << "           " << r->GetName() << G4endl;
     211    }
     212  }
    168213}
    169214
     
    228273      G4cout << *theLambdaTable << G4endl;
    229274    }
     275  }
     276}
     277
     278//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
     279
     280void G4VEmProcess::PrintInfoDefinition()
     281{
     282  if(verboseLevel > 0) {
     283    G4cout << G4endl << GetProcessName() << ":   for  "
     284           << particle->GetParticleName();
     285    if(integral) G4cout << ", integral: 1 ";
     286    if(applyCuts) G4cout << ", applyCuts: 1 ";
     287    G4cout << "    SubType= " << GetProcessSubType() << G4endl;
     288    if(buildLambdaTable) {
     289      G4cout << "      Lambda tables from "
     290             << G4BestUnit(minKinEnergy,"Energy")
     291             << " to "
     292             << G4BestUnit(maxKinEnergy,"Energy")
     293             << " in " << nLambdaBins << " bins, spline: "
     294             << (G4LossTableManager::Instance())->SplineFlag()
     295             << G4endl;
     296    }
     297    PrintInfo();
     298    modelManager->DumpModelList(verboseLevel);
     299  }
     300
     301  if(verboseLevel > 2 && buildLambdaTable) {
     302    G4cout << "      LambdaTable address= " << theLambdaTable << G4endl;
     303    if(theLambdaTable) G4cout << (*theLambdaTable) << G4endl;
    230304  }
    231305}
     
    295369//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
    296370
    297 G4double G4VEmProcess::GetMeanFreePath(const G4Track& track,
    298                                        G4double,
    299                                        G4ForceCondition* condition)
    300 {
    301   *condition = NotForced;
    302   return G4VEmProcess::MeanFreePath(track);
    303 }
    304 
    305 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
    306 
    307371G4VParticleChange* G4VEmProcess::PostStepDoIt(const G4Track& track,
    308372                                              const G4Step&)
     
    333397  }
    334398
    335   G4VEmModel* currentModel = SelectModel(finalT);
    336 
     399  SelectModel(finalT);
     400  if(useDeexcitation) {
     401    currentModel->SetDeexcitationFlag(idxDERegions[currentMaterialIndex]);
     402  }
    337403  /* 
    338404  if(0 < verboseLevel) {
     
    373439
    374440        } else if (p == thePositron) {
    375           if (e < (*theCutsPositron)[currentMaterialIndex]) {
     441          if (electron_mass_c2 < (*theCutsGamma)[currentMaterialIndex] &&
     442              e < (*theCutsPositron)[currentMaterialIndex]) {
    376443            good = false;
    377444            e += 2.0*electron_mass_c2;
     
    394461//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
    395462
    396 void G4VEmProcess::PrintInfoDefinition()
    397 {
    398   if(verboseLevel > 0) {
    399     G4cout << G4endl << GetProcessName() << ": " ;
    400     PrintInfo();
    401     if(integral) {
    402       G4cout << "      Integral mode is used  "<< G4endl;
    403     }
    404   }
    405 
    406   if (!buildLambdaTable)  return;
    407  
    408   if(verboseLevel > 0) {
    409     G4cout << "      tables are built for  "
    410            << particle->GetParticleName()
    411            << G4endl
    412            << "      Lambda tables from "
    413            << G4BestUnit(minKinEnergy,"Energy")
    414            << " to "
    415            << G4BestUnit(maxKinEnergy,"Energy")
    416            << " in " << nLambdaBins << " bins."
    417            << G4endl;
    418   }
    419 
    420   if(verboseLevel > 1) {
    421     G4cout << "Tables are built for " << particle->GetParticleName()
    422            << G4endl;
    423 
    424   if(verboseLevel > 2) {
    425     G4cout << "LambdaTable address= " << theLambdaTable << G4endl;
    426     if(theLambdaTable) G4cout << (*theLambdaTable) << G4endl;
    427     }
    428   }
    429 }
    430 
    431 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
    432 
    433 G4double G4VEmProcess::MicroscopicCrossSection(G4double kineticEnergy,
    434                                          const G4MaterialCutsCouple* couple)
    435 {
    436   // Cross section per atom is calculated
    437   DefineMaterial(couple);
    438   G4double cross = 0.0;
    439   G4bool b;
    440   if(theLambdaTable) {
    441     cross = (((*theLambdaTable)[currentMaterialIndex])->
    442                            GetValue(kineticEnergy, b));
    443 
    444     cross /= currentMaterial->GetTotNbOfAtomsPerVolume();
    445   } else {
    446     G4VEmModel* model = SelectModel(kineticEnergy);
    447     cross =
    448       model->CrossSectionPerVolume(currentMaterial,particle,kineticEnergy);
    449   }
    450 
    451   return cross;
    452 }
    453 
    454 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
    455 
    456463G4bool G4VEmProcess::StorePhysicsTable(const G4ParticleDefinition* part,
    457464                                       const G4String& directory,
     
    508515             << G4endl;
    509516    }
     517    if((G4LossTableManager::Instance())->SplineFlag()) {
     518      size_t n = theLambdaTable->length();
     519      for(size_t i=0; i<n; i++) {(* theLambdaTable)[i]->SetSpline(true);}
     520    }
    510521  } else {
    511522    if (1 < verboseLevel) {
     
    517528
    518529  return yes;
     530}
     531
     532//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
     533
     534void G4VEmProcess::ActivateDeexcitation(G4bool val, const G4Region* r)
     535{
     536  G4RegionStore* regionStore = G4RegionStore::GetInstance();
     537  const G4Region* reg = r;
     538  if (!reg) {reg = regionStore->GetRegion("DefaultRegionForTheWorld", false);}
     539
     540  // the region is in the list
     541  if (nDERegions) {
     542    for (G4int i=0; i<nDERegions; i++) {
     543      if (reg == deRegions[i]) {
     544        if(!val) deRegions[i] = 0;
     545        return;
     546      }
     547    }
     548  }
     549
     550  // new region
     551  if(val) {
     552    useDeexcitation = true;
     553    deRegions.push_back(reg);
     554    nDERegions++;
     555  } else {
     556    useDeexcitation = false;
     557  }
     558}
     559
     560//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
     561
     562G4double G4VEmProcess::CrossSectionPerVolume(G4double kineticEnergy,
     563                                             const G4MaterialCutsCouple* couple)
     564{
     565  // Cross section per atom is calculated
     566  DefineMaterial(couple);
     567  G4double cross = 0.0;
     568  G4bool b;
     569  if(theLambdaTable) {
     570    cross = (((*theLambdaTable)[currentMaterialIndex])->
     571                           GetValue(kineticEnergy, b));
     572  } else {
     573    SelectModel(kineticEnergy);
     574    cross = currentModel->CrossSectionPerVolume(currentMaterial,
     575                                                particle,kineticEnergy);
     576  }
     577
     578  return cross;
     579}
     580
     581//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
     582
     583G4double G4VEmProcess::GetMeanFreePath(const G4Track& track,
     584                                       G4double,
     585                                       G4ForceCondition* condition)
     586{
     587  *condition = NotForced;
     588  return G4VEmProcess::MeanFreePath(track);
    519589}
    520590
     
    568638  G4PhysicsVector* v =
    569639    new G4PhysicsLogVector(minKinEnergy, maxKinEnergy, nLambdaBins);
     640  v->SetSpline((G4LossTableManager::Instance())->SplineFlag());
    570641  return v;
    571642}
Note: See TracChangeset for help on using the changeset viewer.