Import Geant4 10.1.0 source tree
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ProcessManager.hh"
|
||||
#include "G4ProcessTable.hh"
|
||||
|
||||
// Processes
|
||||
|
||||
@@ -79,65 +80,81 @@ NeutronHPphysics::~NeutronHPphysics()
|
||||
|
||||
void NeutronHPphysics::ConstructProcess()
|
||||
{
|
||||
G4ProcessManager* pManager = G4Neutron::Neutron()->GetProcessManager();
|
||||
G4ParticleDefinition* neutron = G4Neutron::Neutron();
|
||||
G4ProcessManager* pManager = neutron->GetProcessManager();
|
||||
|
||||
// process: elastic
|
||||
//
|
||||
G4HadronElasticProcess* process1 = new G4HadronElasticProcess();
|
||||
pManager->AddDiscreteProcess(process1);
|
||||
//
|
||||
// cross section data set
|
||||
G4NeutronHPElasticData* dataSet1a = new G4NeutronHPElasticData();
|
||||
G4NeutronHPThermalScatteringData* dataSet1b
|
||||
= new G4NeutronHPThermalScatteringData();
|
||||
process1->AddDataSet(dataSet1a);
|
||||
if (fThermal) process1->AddDataSet(dataSet1b);
|
||||
//
|
||||
// models
|
||||
G4NeutronHPElastic* model1a = new G4NeutronHPElastic();
|
||||
G4NeutronHPThermalScattering* model1b = new G4NeutronHPThermalScattering();
|
||||
if (fThermal) model1a->SetMinEnergy(4*eV);
|
||||
process1->RegisterMe(model1a);
|
||||
if (fThermal) process1->RegisterMe(model1b);
|
||||
// delete all neutron processes if already registered
|
||||
//
|
||||
G4ProcessTable* processTable = G4ProcessTable::GetProcessTable();
|
||||
G4VProcess* process = 0;
|
||||
process = processTable->FindProcess("hadElastic", neutron);
|
||||
if (process) pManager->RemoveProcess(process);
|
||||
//
|
||||
process = processTable->FindProcess("neutronInelastic", neutron);
|
||||
if (process) pManager->RemoveProcess(process);
|
||||
//
|
||||
process = processTable->FindProcess("nCapture", neutron);
|
||||
if (process) pManager->RemoveProcess(process);
|
||||
//
|
||||
process = processTable->FindProcess("nFission", neutron);
|
||||
if (process) pManager->RemoveProcess(process);
|
||||
|
||||
// (re) create process: elastic
|
||||
//
|
||||
G4HadronElasticProcess* process1 = new G4HadronElasticProcess();
|
||||
pManager->AddDiscreteProcess(process1);
|
||||
//
|
||||
// model1a
|
||||
G4NeutronHPElastic* model1a = new G4NeutronHPElastic();
|
||||
process1->RegisterMe(model1a);
|
||||
process1->AddDataSet(new G4NeutronHPElasticData());
|
||||
//
|
||||
// model1b
|
||||
if (fThermal) {
|
||||
model1a->SetMinEnergy(4*eV);
|
||||
G4NeutronHPThermalScattering* model1b = new G4NeutronHPThermalScattering();
|
||||
process1->RegisterMe(model1b);
|
||||
process1->AddDataSet(new G4NeutronHPThermalScatteringData());
|
||||
}
|
||||
|
||||
// process: inelastic
|
||||
//
|
||||
G4NeutronInelasticProcess* process2 = new G4NeutronInelasticProcess();
|
||||
pManager->AddDiscreteProcess(process2);
|
||||
//
|
||||
// cross section data set
|
||||
G4NeutronHPInelasticData* dataSet2 = new G4NeutronHPInelasticData();
|
||||
process2->AddDataSet(dataSet2);
|
||||
//
|
||||
// models
|
||||
G4NeutronHPInelastic* model2 = new G4NeutronHPInelastic();
|
||||
process2->RegisterMe(model2);
|
||||
// (re) create process: inelastic
|
||||
//
|
||||
G4NeutronInelasticProcess* process2 = new G4NeutronInelasticProcess();
|
||||
pManager->AddDiscreteProcess(process2);
|
||||
//
|
||||
// cross section data set
|
||||
G4NeutronHPInelasticData* dataSet2 = new G4NeutronHPInelasticData();
|
||||
process2->AddDataSet(dataSet2);
|
||||
//
|
||||
// models
|
||||
G4NeutronHPInelastic* model2 = new G4NeutronHPInelastic();
|
||||
process2->RegisterMe(model2);
|
||||
|
||||
// process: nCapture
|
||||
//
|
||||
G4HadronCaptureProcess* process3 = new G4HadronCaptureProcess();
|
||||
pManager->AddDiscreteProcess(process3);
|
||||
//
|
||||
// cross section data set
|
||||
G4NeutronHPCaptureData* dataSet3 = new G4NeutronHPCaptureData();
|
||||
process3->AddDataSet(dataSet3);
|
||||
//
|
||||
// models
|
||||
G4NeutronHPCapture* model3 = new G4NeutronHPCapture();
|
||||
process3->RegisterMe(model3);
|
||||
// (re) create process: nCapture
|
||||
//
|
||||
G4HadronCaptureProcess* process3 = new G4HadronCaptureProcess();
|
||||
pManager->AddDiscreteProcess(process3);
|
||||
//
|
||||
// cross section data set
|
||||
G4NeutronHPCaptureData* dataSet3 = new G4NeutronHPCaptureData();
|
||||
process3->AddDataSet(dataSet3);
|
||||
//
|
||||
// models
|
||||
G4NeutronHPCapture* model3 = new G4NeutronHPCapture();
|
||||
process3->RegisterMe(model3);
|
||||
|
||||
// process: nFission
|
||||
//
|
||||
G4HadronFissionProcess* process4 = new G4HadronFissionProcess();
|
||||
pManager->AddDiscreteProcess(process4);
|
||||
//
|
||||
// cross section data set
|
||||
G4NeutronHPFissionData* dataSet4 = new G4NeutronHPFissionData();
|
||||
process4->AddDataSet(dataSet4);
|
||||
//
|
||||
// models
|
||||
G4NeutronHPFission* model4 = new G4NeutronHPFission();
|
||||
process4->RegisterMe(model4);
|
||||
// (re) create process: nFission
|
||||
//
|
||||
G4HadronFissionProcess* process4 = new G4HadronFissionProcess();
|
||||
pManager->AddDiscreteProcess(process4);
|
||||
//
|
||||
// cross section data set
|
||||
G4NeutronHPFissionData* dataSet4 = new G4NeutronHPFissionData();
|
||||
process4->AddDataSet(dataSet4);
|
||||
//
|
||||
// models
|
||||
G4NeutronHPFission* model4 = new G4NeutronHPFission();
|
||||
process4->RegisterMe(model4);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -33,6 +33,8 @@
|
||||
|
||||
#include "Run.hh"
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
#include "HistoManager.hh"
|
||||
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
@@ -41,7 +43,7 @@
|
||||
|
||||
Run::Run(DetectorConstruction* det)
|
||||
: G4Run(),
|
||||
fDetector(det),
|
||||
fDetector(det), fParticle(0), fEkin(0.),
|
||||
fNbStep1(0), fNbStep2(0),
|
||||
fTrackLen1(0.), fTrackLen2(0.),
|
||||
fTime1(0.),fTime2(0.)
|
||||
@@ -53,14 +55,23 @@ Run::~Run()
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::SetPrimary(G4ParticleDefinition* particle, G4double energy)
|
||||
{
|
||||
fParticle = particle;
|
||||
fEkin = energy;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::CountProcesses(const G4VProcess* process)
|
||||
{
|
||||
std::map<const G4VProcess*,G4int>::iterator it = fProcCounter.find(process);
|
||||
G4String procName = process->GetProcessName();
|
||||
std::map<G4String,G4int>::iterator it = fProcCounter.find(procName);
|
||||
if ( it == fProcCounter.end()) {
|
||||
fProcCounter[process] = 1;
|
||||
fProcCounter[procName] = 1;
|
||||
}
|
||||
else {
|
||||
fProcCounter[process]++;
|
||||
fProcCounter[procName]++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,18 +108,95 @@ void Run::SumTrackLength(G4int nstep1, G4int nstep2,
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::ComputeStatistics()
|
||||
void Run::Merge(const G4Run* run)
|
||||
{
|
||||
const Run* localRun = static_cast<const Run*>(run);
|
||||
|
||||
//primary particle info
|
||||
//
|
||||
fParticle = localRun->fParticle;
|
||||
fEkin = localRun->fEkin;
|
||||
|
||||
// accumulate sums
|
||||
//
|
||||
fNbStep1 += localRun->fNbStep1;
|
||||
fNbStep2 += localRun->fNbStep2;
|
||||
fTrackLen1 += localRun->fTrackLen1;
|
||||
fTrackLen2 += localRun->fTrackLen2;
|
||||
fTime1 += localRun->fTime1;
|
||||
fTime2 += localRun->fTime2;
|
||||
|
||||
//map: processes count
|
||||
std::map<G4String,G4int>::const_iterator itp;
|
||||
for ( itp = localRun->fProcCounter.begin();
|
||||
itp != localRun->fProcCounter.end(); ++itp ) {
|
||||
|
||||
G4String procName = itp->first;
|
||||
G4int localCount = itp->second;
|
||||
if ( fProcCounter.find(procName) == fProcCounter.end()) {
|
||||
fProcCounter[procName] = localCount;
|
||||
}
|
||||
else {
|
||||
fProcCounter[procName] += localCount;
|
||||
}
|
||||
}
|
||||
|
||||
//map: created particles count
|
||||
std::map<G4String,ParticleData>::const_iterator itn;
|
||||
for (itn = localRun->fParticleDataMap.begin();
|
||||
itn != localRun->fParticleDataMap.end(); ++itn) {
|
||||
|
||||
G4String name = itn->first;
|
||||
const ParticleData& localData = itn->second;
|
||||
if ( fParticleDataMap.find(name) == fParticleDataMap.end()) {
|
||||
fParticleDataMap[name]
|
||||
= ParticleData(localData.fCount,
|
||||
localData.fEmean,
|
||||
localData.fEmin,
|
||||
localData.fEmax);
|
||||
}
|
||||
else {
|
||||
ParticleData& data = fParticleDataMap[name];
|
||||
data.fCount += localData.fCount;
|
||||
data.fEmean += localData.fEmean;
|
||||
G4double emin = localData.fEmin;
|
||||
if (emin < data.fEmin) data.fEmin = emin;
|
||||
G4double emax = localData.fEmax;
|
||||
if (emax > data.fEmax) data.fEmax = emax;
|
||||
}
|
||||
}
|
||||
|
||||
G4Run::Merge(run);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::EndOfRun()
|
||||
{
|
||||
G4int prec = 5, wid = prec + 2;
|
||||
G4int dfprec = G4cout.precision(prec);
|
||||
|
||||
//run condition
|
||||
//
|
||||
G4Material* material = fDetector->GetMaterial();
|
||||
G4double density = material->GetDensity();
|
||||
|
||||
G4String Particle = fParticle->GetParticleName();
|
||||
G4cout << "\n The run is " << numberOfEvent << " "<< Particle << " of "
|
||||
<< G4BestUnit(fEkin,"Energy") << " through "
|
||||
<< G4BestUnit(0.5*(fDetector->GetSize()),"Length") << " of "
|
||||
<< material->GetName() << " (density: "
|
||||
<< G4BestUnit(density,"Volumic Mass") << ")" << G4endl;
|
||||
|
||||
if (numberOfEvent == 0) { G4cout.precision(dfprec); return;}
|
||||
|
||||
//frequency of processes
|
||||
//
|
||||
G4cout << "\n Process calls frequency --->";
|
||||
G4cout << "\n Process calls frequency :" << G4endl;
|
||||
G4int survive = 0;
|
||||
std::map<const G4VProcess*,G4int>::iterator it;
|
||||
std::map<G4String,G4int>::iterator it;
|
||||
for (it = fProcCounter.begin(); it != fProcCounter.end(); it++) {
|
||||
G4String procName = it->first->GetProcessName();
|
||||
G4String procName = it->first;
|
||||
G4int count = it->second;
|
||||
G4cout << "\t" << procName << "= " << count;
|
||||
if (procName == "Transportation") survive = count;
|
||||
@@ -170,71 +258,18 @@ void Run::ComputeStatistics()
|
||||
<< " --> " << G4BestUnit(eMax, "Energy")
|
||||
<< ")" << G4endl;
|
||||
}
|
||||
|
||||
//restore default format
|
||||
G4cout.precision(dfprec);
|
||||
|
||||
//normalize histograms
|
||||
////G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
|
||||
////G4double factor = 1./numberOfEvent;
|
||||
////analysisManager->ScaleH1(3,factor);
|
||||
|
||||
// remove all contents in fProcCounter
|
||||
//remove all contents in fProcCounter, fCount
|
||||
fProcCounter.clear();
|
||||
// remove all contents in fCount
|
||||
fParticleDataMap.clear();
|
||||
fParticleDataMap.clear();
|
||||
|
||||
//restore default format
|
||||
G4cout.precision(dfprec);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::Merge(const G4Run* run)
|
||||
{
|
||||
const Run* localRun = static_cast<const Run*>(run);
|
||||
|
||||
// accumulate sums
|
||||
//
|
||||
fNbStep1 += localRun->fNbStep1;
|
||||
fNbStep2 += localRun->fNbStep2;
|
||||
fTrackLen1 += localRun->fTrackLen1;
|
||||
fTrackLen2 += localRun->fTrackLen2;
|
||||
fTime1 += localRun->fTime1;
|
||||
fTime2 += localRun->fTime2;
|
||||
|
||||
//maps
|
||||
std::map<const G4VProcess*,G4int>::const_iterator itp;
|
||||
for ( itp = localRun->fProcCounter.begin();
|
||||
itp != localRun->fProcCounter.end(); ++itp ) {
|
||||
|
||||
const G4VProcess* process = itp->first;
|
||||
G4int localCount = itp->second;
|
||||
if ( fProcCounter.find(process) == fProcCounter.end()) {
|
||||
fProcCounter[process] = localCount;
|
||||
}
|
||||
else {
|
||||
fProcCounter[process] += localCount;
|
||||
}
|
||||
}
|
||||
|
||||
std::map<G4String,ParticleData>::const_iterator itn;
|
||||
for (itn = localRun->fParticleDataMap.begin();
|
||||
itn != localRun->fParticleDataMap.end(); ++itn) {
|
||||
|
||||
G4String name = itn->first;
|
||||
const ParticleData& localData = itn->second;
|
||||
if ( fParticleDataMap.find(name) == fParticleDataMap.end()) {
|
||||
fParticleDataMap[name]
|
||||
= ParticleData(localData.fCount,
|
||||
localData.fEmean,
|
||||
localData.fEmin,
|
||||
localData.fEmax);
|
||||
}
|
||||
else {
|
||||
ParticleData& data = fParticleDataMap[name];
|
||||
data.fCount += localData.fCount;
|
||||
data.fEmean += localData.fEmean;
|
||||
G4double emin = localData.fEmin;
|
||||
if (emin < data.fEmin) data.fEmin = emin;
|
||||
G4double emax = localData.fEmax;
|
||||
if (emax > data.fEmax) data.fEmax = emax;
|
||||
}
|
||||
}
|
||||
|
||||
G4Run::Merge(run);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -32,11 +32,10 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "RunAction.hh"
|
||||
|
||||
#include "Run.hh"
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
#include "HistoManager.hh"
|
||||
#include "Run.hh"
|
||||
|
||||
#include "G4Run.hh"
|
||||
#include "G4RunManager.hh"
|
||||
@@ -77,8 +76,16 @@ void RunAction::BeginOfRunAction(const G4Run*)
|
||||
{
|
||||
// save Rndm status
|
||||
G4RunManager::GetRunManager()->SetRandomNumberStore(false);
|
||||
G4Random::showEngineStatus();
|
||||
|
||||
if (isMaster) G4Random::showEngineStatus();
|
||||
|
||||
// keep run condition
|
||||
if (fPrimary) {
|
||||
G4ParticleDefinition* particle
|
||||
= fPrimary->GetParticleGun()->GetParticleDefinition();
|
||||
G4double energy = fPrimary->GetParticleGun()->GetParticleEnergy();
|
||||
fRun->SetPrimary(particle, energy);
|
||||
}
|
||||
|
||||
//histograms
|
||||
//
|
||||
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
|
||||
@@ -89,47 +96,19 @@ void RunAction::BeginOfRunAction(const G4Run*)
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void RunAction::EndOfRunAction(const G4Run* aRun)
|
||||
void RunAction::EndOfRunAction(const G4Run*)
|
||||
{
|
||||
G4int nbOfEvents = aRun->GetNumberOfEvent();
|
||||
|
||||
if ( fPrimary && nbOfEvents ) {
|
||||
|
||||
G4int prec = 5;
|
||||
G4int dfprec = G4cout.precision(prec);
|
||||
|
||||
G4Material* material = fDetector->GetMaterial();
|
||||
G4double density = material->GetDensity();
|
||||
|
||||
G4ParticleDefinition* particle =
|
||||
fPrimary->GetParticleGun()->GetParticleDefinition();
|
||||
G4String Particle = particle->GetParticleName();
|
||||
G4double energy = fPrimary->GetParticleGun()->GetParticleEnergy();
|
||||
G4cout << "\n The run is of " << nbOfEvents << " "<< Particle << " of "
|
||||
<< G4BestUnit(energy,"Energy") << " through "
|
||||
<< G4BestUnit(fDetector->GetSize(),"Length") << " of "
|
||||
<< material->GetName() << " (density: "
|
||||
<< G4BestUnit(density,"Volumic Mass") << ")" << G4endl;
|
||||
|
||||
//restore default format
|
||||
G4cout.precision(dfprec);
|
||||
}
|
||||
|
||||
//compute and print statistics
|
||||
//
|
||||
if (isMaster) fRun->ComputeStatistics();
|
||||
if (isMaster) fRun->EndOfRun();
|
||||
|
||||
//save histograms
|
||||
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
|
||||
////G4double factor = 1./nbOfEvents;
|
||||
////analysisManager->ScaleH1(3,factor);
|
||||
if ( analysisManager->IsActive() ) {
|
||||
analysisManager->Write();
|
||||
analysisManager->CloseFile();
|
||||
}
|
||||
|
||||
// show Rndm status
|
||||
G4Random::showEngineStatus();
|
||||
if (isMaster) G4Random::showEngineStatus();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
Reference in New Issue
Block a user