Вычисление методом Монте-Карло. ВЫЧИСЛЕНИЕ МЕТОДОМ МОНТЕ-КАРЛО КОЛИЧЕСТВА ПЕРВИЧНЫХ ДЕФЕКТОВ В К. вычисление методом монтекарло количества первичных дефектов в кристаллическом кремнии, создаваемых протонами и нейтронами различных энергий
Скачать 0.62 Mb.
|
PhysicsList();hpw/GHAD/HomePage/lists/LHEP_PRECO_HP/index.html)ExN02SteppingVerbose(); |
void StepInfo();
void TrackingStarted();
};
#endif
ExN02TrackingAction.cc:
#include "ExN02TrackingAction.hh"
#include "G4TrackingManager.hh"
#include "G4Track.hh"
#include "G4UnitsTable.hh"
ExN02TrackingAction::ExN02TrackingAction()
{
//Инициализация массивов для спектров
N = 0;
E_total=0;
for(int j=0; j
O16_spectr[j]=0;
Ne20_spectr[j]=0; Ne22_spectr[j]=0;
Na22_spectr[j]=0; Na23_spectr[j]=0;
Mg23_spectr[j]=0; Mg24_spectr[j]=0; Mg25_spectr[j]=0; Mg26_spectr[j]=0; Mg27_spectr[j]=0;
Al26_spectr[j]=0; Al27_spectr[j]=0; Al28_spectr[j]=0; Al29_spectr[j]=0;
Si27_spectr[j]=0; Si28_spectr[j]=0; Si29_spectr[j]=0; Si30_spectr[j]=0; Si31_spectr[j]=0;
P29_spectr[j]=0;
Elastic_spectr[j]=0;
Inelastic_spectr[j]=0;
}
}
void ExN02TrackingAction::PreUserTrackingAction(const G4Track* aTrack)
{
double energy;
G4Track* Track = (G4Track*)aTrack;
name = aTrack->GetDefinition()->GetParticleName();
energy = aTrack->GetKineticEnergy();
if ((name=="neutron" && energy <= 1.*keV) ||
(name!="neutron" && name!="proton")) {
Track->SetKineticEnergy(0);
}
if (name == "O16[0.0]") {
PutIntoSpectr(aTrack, O16_spectr, energy);
} else
if (name == "Ne20[0.0]") {
PutIntoSpectr(aTrack, Ne20_spectr, energy);
} else
if (name == "Ne22[0.0]") {
PutIntoSpectr(aTrack, Ne22_spectr, energy);
} else
if (name == "Na22[0.0]") {
PutIntoSpectr(aTrack, Na22_spectr, energy);
} else
if (name == "Na23[0.0]") {
PutIntoSpectr(aTrack, Na23_spectr, energy);
} else
if (name == "Mg23[0.0]") {
PutIntoSpectr(aTrack, Mg23_spectr, energy);
} else
if (name == "Mg24[0.0]") {
PutIntoSpectr(aTrack, Mg24_spectr, energy);
} else
if (name == "Mg25[0.0]") {
PutIntoSpectr(aTrack, Mg25_spectr, energy);
} else
if (name == "Mg26[0.0]") {
PutIntoSpectr(aTrack, Mg26_spectr, energy);
} else
if (name == "Mg27[0.0]") {
PutIntoSpectr(aTrack, Mg27_spectr, energy);
} else
if (name == "Al26[0.0]") {
PutIntoSpectr(aTrack, Al26_spectr, energy);
} else
if (name == "Al27[0.0]") {
PutIntoSpectr(aTrack, Al27_spectr, energy);
} else
if (name == "Al28[0.0]") {
PutIntoSpectr(aTrack, Al28_spectr, energy);
} else
if (name == "Al29[0.0]") {
PutIntoSpectr(aTrack, Al29_spectr, energy);
} else
if (name == "Si27[0.0]") {
PutIntoSpectr(aTrack, Si27_spectr, energy);
} else
if (name == "Si28[0.0]") {
PutIntoSpectr(aTrack, Si28_spectr, energy);
} else
if (name == "Si29[0.0]") {
PutIntoSpectr(aTrack, Si29_spectr, energy);
} else
if (name == "Si30[0.0]") {
PutIntoSpectr(aTrack, Si30_spectr, energy);
} else
if (name == "Si31[0.0]") {
PutIntoSpectr(aTrack, Si31_spectr, energy);
} else
if (name == "P29[0.0]") {
PutIntoSpectr(aTrack, P29_spectr, energy);
}
}
void ExN02TrackingAction::PutIntoSpectr(const G4Track* aTrack, t_spectr spectr, double energy)
{
FILE *f;
int bin;
N++;
if (aTrack->GetCreatorProcess())
proc = aTrack->GetCreatorProcess()->GetProcessName(); //Получили имя родительского процесса
else
proc = "starting";
E_total = E_total + energy; //Полные потери энергии
energy = energy * 1000 / BINSIZE;
bin = (int)energy; //Определили бин в спектре
//заполняем спектры
if (bin >=0 && bin <= MAX-1)
if (proc=="LElastic") {
Elastic_spectr[bin] = Elastic_spectr[bin] + 1;
}
else
if (proc=="ProtonInelastic" || proc=="NeutronInelastic") {
spectr[bin] = spectr[bin] + 1;
Inelastic_spectr[bin] = Inelastic_spectr[bin] + 1;
}
if (N%10000 == 0) { //Если накопилось 10000 новых событий, то скидываем спектры в файл
if ((f=fopen("spectr.txt", "w"))==NULL) {
G4cout << "error Output!\n";
exit(1);
}
G4cout << N << " putted.\n";
fprintf(f, "%i\nE=%f MeV\n", N, E_total);
fprintf(f,"Elastic(Si28,Si29,Si30):\n");
for(int i=0; i
fprintf(f,"Inelastic(All):\n");
for(i=0; i
fprintf(f,"Inelastic(O16):\n");
for(i=0; i
fprintf(f,"Inelastic(Ne20):\n");
for(i=0; i
fprintf(f,"Inelastic(Ne22):\n");
for(i=0; i
fprintf(f,"Inelastic(Na22):\n");
for(i=0; i
fprintf(f,"Inelastic(Na23):\n");
for(i=0; i
fprintf(f,"Inelastic(Mg23):\n");
for(i=0; i
fprintf(f,"Inelastic(Mg24):\n");
for(i=0; i
fprintf(f,"Inelastic(Mg25):\n");
for(i=0; i
fprintf(f,"Inelastic(Mg26):\n");
for(i=0; i
fprintf(f,"Inelastic(Mg27):\n");
for(i=0; i
fprintf(f,"Inelastic(Al26):\n");
for(i=0; i
fprintf(f,"Inelastic(Al27):\n");
for(i=0; i
fprintf(f,"Inelastic(Al28):\n");
for(i=0; i
fprintf(f,"Inelastic(Al29):\n");
for(i=0; i
fprintf(f,"Inelastic(Si27):\n");
for(i=0; i
fprintf(f,"Inelastic(Si28):\n");
for(i=0; i
fprintf(f,"Inelastic(Si29):\n");
for(i=0; i
fprintf(f,"Inelastic(Si30):\n");
for(i=0; i
fprintf(f,"Inelastic(Si31):\n");
for(i=0; i
fprintf(f,"Inelastic(P29):\n");
for(i=0; i
fclose(f);
}
if (N>=EVMAX) { //Если набрали нужное количество событий, то выходим из программы
G4cout << "Work done ! :)\n";
exit(0);
}
}
ExN02TrackingAction.hh:
#ifndef ExN02TrackingAction_h
#define ExN02TrackingAction_h 1
#include "G4UserTrackingAction.hh"
#include "G4String.hh"
#define MAX 300 // Число каналов в спектре
#define EVMAX 1000000 // общее число событий
#define BINSIZE 10 // размер канала в кевах
typedef int t_spectr[MAX];
class ExN02TrackingAction : public G4UserTrackingAction {
public:
ExN02TrackingAction();
virtual
#include "PhysicsList.hh"
#include "globals.hh"
#include "G4ParticleDefinition.hh"
#include "G4ParticleWithCuts.hh"
#include "G4ProcessManager.hh"
#include "G4ProcessVector.hh"
#include "G4ParticleTypes.hh"
#include "G4ParticleTable.hh"
#include "G4Material.hh"
#include "G4MaterialTable.hh"
#include "G4ios.hh"
#include "g4std/iomanip"
#include "GeneralPhysics.hh"
#include "EMPhysics.hh"
#include "MuonPhysics.hh"
#include "HadronPhysicsLHEP_PRECO_HP.hh"
#include "IonPhysics.hh"
PhysicsList::PhysicsList(): G4VModularPhysicsList()
{
defaultCutValue = 1.0*mm; //граница обрезания по умолчанию
SetVerboseLevel(1);
RegisterPhysics( new GeneralPhysics("general") ); //Основные физические процессы
RegisterPhysics( new EMPhysics("standard EM")); //Электро-магнитные взаимодействия
RegisterPhysics( new MuonPhysics("muon")); //Мюонные взаимодействия
RegisterPhysics( new HadronPhysicsLHEP_PRECO_HP("hadron")); //Физические процессы для нейтронов и протонов средних энергий
RegisterPhysics( new IonPhysics("ion")); //Взаимодействия для ионов
}
PhysicsList::