Import Geant4 10.4.0 source tree

This commit is contained in:
Gabriele Cosmo
2017-12-08 12:52:30 +01:00
parent 98e455a940
commit fc6af9e721
2166 changed files with 276760 additions and 100873 deletions
@@ -26,7 +26,7 @@
/// \file electromagnetic/TestEm18/src/DetectorConstruction.cc
/// \brief Implementation of the DetectorConstruction class
//
// $Id: DetectorConstruction.cc 68348 2013-03-22 10:00:19Z maire $
// $Id: DetectorConstruction.cc 105252 2017-07-17 09:40:37Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -121,7 +121,7 @@ void DetectorConstruction::DefineMaterials()
new G4Material("ArgonGas" , z=18., a=39.948*g/mole, density= 1.782*mg/cm3,
kStateGas, 273.15*kelvin, 1*atmosphere);
G4cout << *(G4Material::GetMaterialTable()) << G4endl;
////G4cout << *(G4Material::GetMaterialTable()) << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -162,7 +162,8 @@ G4VPhysicalVolume* DetectorConstruction::ConstructVolumes()
void DetectorConstruction::PrintParameters()
{
G4cout << "\n The Box is " << G4BestUnit(fBoxSize,"Length")
<< " of " << fMaterial->GetName() << G4endl;
<< " of " << fMaterial->GetName()
<< "\n " << fMaterial << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -26,7 +26,7 @@
/// \file electromagnetic/TestEm18/src/EventAction.cc
/// \brief Implementation of the EventAction class
//
// $Id: EventAction.cc 82401 2014-06-18 14:43:54Z gcosmo $
// $Id: EventAction.cc 105927 2017-08-29 13:25:29Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -54,19 +54,71 @@ EventAction::~EventAction()
void EventAction::BeginOfEventAction(const G4Event*)
{
// initialisation per event
fEnergyDeposit = fEnergySecondary = 0.;
fEdepPrimary = fEdepSecondary = 0.;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void EventAction::SumEnergyDeposited(G4int trackID, G4double edep)
{
if (trackID == 1) fEdepPrimary += edep;
else fEdepSecondary += edep;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void EventAction::SumEnergyTransfered(const G4VProcess* process,G4double energy)
{
G4String procName = process->GetProcessName();
std::map<G4String,G4double>::iterator it = fEnergyTransfered.find(procName);
if ( it == fEnergyTransfered.end()) {
fEnergyTransfered[procName] = energy;
}
else {
fEnergyTransfered[procName] += energy;
}
G4int subtype = process-> GetProcessSubType();
fProcessSubType[procName] = subtype;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void EventAction::EndOfEventAction(const G4Event*)
{
fRunAction->AddEnergyDeposit(fEnergyDeposit);
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
analysisManager->FillH1(1, fEnergyDeposit);
analysisManager->FillH1(2, fEnergySecondary);
analysisManager->FillH1(3, fEnergyDeposit+fEnergySecondary);
G4double EtransferedTotal = 0.;
std::map<G4String,G4double>::iterator it;
for (it = fEnergyTransfered.begin(); it != fEnergyTransfered.end(); it++) {
G4String procName = it->first;
G4double energy = it->second;
fRunAction->EnergyTransferedByProcess(procName, energy);
EtransferedTotal += energy;
//
G4int ih = 0;
if(fProcessSubType[procName] == 2) ih = 3;
else if(fProcessSubType[procName] == 3) ih = 4;
else if(fProcessSubType[procName] == 4) ih = 5;
if (ih > 0) analysisManager->FillH1(ih, energy);
}
fRunAction->EnergyDeposited(fEdepPrimary, fEdepSecondary);
if (EtransferedTotal > 0.) fRunAction->EnergyTransfered(EtransferedTotal);
G4double energyLostTotal = fEdepPrimary + EtransferedTotal;
fRunAction->TotalEnergyLost(energyLostTotal);
G4double energyDepositTotal = fEdepPrimary + fEdepSecondary;
fRunAction->TotalEnergyDeposit(energyDepositTotal);
analysisManager->FillH1( 2, fEdepPrimary);
analysisManager->FillH1( 6, EtransferedTotal);
analysisManager->FillH1( 7, energyLostTotal);
analysisManager->FillH1( 9, fEdepSecondary);
analysisManager->FillH1(10, energyDepositTotal);
fEnergyTransfered.clear();
fProcessSubType.clear();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: HistoManager.cc 72242 2013-07-12 08:44:19Z gcosmo $
// $Id: HistoManager.cc 105927 2017-08-29 13:25:29Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -60,17 +60,25 @@ void HistoManager::Book()
analysisManager->SetActivation(true); //enable inactivation of histograms
// Define histograms start values
const G4int kMaxHisto = 7;
const G4String id[] = { "0", "1", "2", "3" , "4", "5", "6"};
const G4int kMaxHisto = 14;
const G4String id[] = { "0", "1", "2", "3" , "4", "5", "6", "7", "8", "9",
"10", "11", "12", "13"};
const G4String title[] =
{ "dummy", //0
"continuous energy loss along primary track", //1
"energy from secondaries", //2
"total energy lost by primary track", //3
"energy spectrum of e-+", //4
"energy spectrum of gamma", //5
"step size" //6
};
{ "dummy", //0
"step size of primary track", //1
"energy continuously deposited along primary track", //2
"energy transfered to secondaries by ionisation", //3
"energy transfered to secondaries by Bremsstrahlung", //4
"energy transfered to secondaries by (e+,e-) production", //5
"total energy transfered to secondaries", //6
"total energy lost by primary track", //7
"total energy lost by primary track from energy balance", //8
"energy continuously deposited along secondary tracks", //9
"total energy deposited", //10
"energy spectrum of gamma", //11
"energy spectrum of e-", //12
"energy spectrum of e+" //13
};
// Default values (to be reset via /analysis/h1/set command)
G4int nbins = 100;
@@ -27,7 +27,7 @@
/// \brief Implementation of the PhysListEmLivermore class
//
//
// $Id: PhysListEmLivermore.cc 100275 2016-10-17 08:29:19Z gcosmo $
// $Id: PhysListEmLivermore.cc 105252 2017-07-17 09:40:37Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -88,7 +88,11 @@ PhysListEmLivermore::PhysListEmLivermore(const G4String& name)
param->SetMaxEnergy(10*TeV);
param->SetNumberOfBinsPerDecade(10);
param->SetBuildCSDARange(true);
param->SetMaxEnergyForCSDARange(10*TeV);
SetPhysicsType(bElectromagnetic);
param->SetVerbose(0);
param->Dump();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -27,7 +27,7 @@
/// \brief Implementation of the PhysListEmPenelope class
//
//
// $Id: PhysListEmPenelope.cc 100275 2016-10-17 08:29:19Z gcosmo $
// $Id: PhysListEmPenelope.cc 105252 2017-07-17 09:40:37Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -89,7 +89,11 @@ PhysListEmPenelope::PhysListEmPenelope(const G4String& name)
param->SetMaxEnergy(10*TeV);
param->SetNumberOfBinsPerDecade(10);
param->SetBuildCSDARange(true);
param->SetMaxEnergyForCSDARange(10*TeV);
SetPhysicsType(bElectromagnetic);
param->SetVerbose(0);
param->Dump();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -26,7 +26,7 @@
/// \file electromagnetic/TestEm18/src/PhysListEmStandard.cc
/// \brief Implementation of the PhysListEmStandard class
//
// $Id: PhysListEmStandard.cc 100275 2016-10-17 08:29:19Z gcosmo $
// $Id: PhysListEmStandard.cc 105252 2017-07-17 09:40:37Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -76,7 +76,11 @@ PhysListEmStandard::PhysListEmStandard(const G4String& name)
param->SetMaxEnergy(10*TeV);
param->SetNumberOfBinsPerDecade(10);
param->SetBuildCSDARange(true);
param->SetMaxEnergyForCSDARange(10*TeV);
SetPhysicsType(bElectromagnetic);
param->SetVerbose(0);
param->Dump();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -169,9 +173,6 @@ void PhysListEmStandard::ConstructProcess()
// Deexcitation
//
G4VAtomDeexcitation* de = new G4UAtomicDeexcitation();
de->SetFluo(true);
de->SetAuger(false);
de->SetPIXE(false);
G4LossTableManager::Instance()->SetAtomDeexcitation(de);
}
@@ -26,7 +26,7 @@
/// \file electromagnetic/TestEm18/src/RunAction.cc
/// \brief Implementation of the RunAction class
//
// $Id: RunAction.cc 103621 2017-04-19 13:21:45Z gcosmo $
// $Id: RunAction.cc 105930 2017-08-31 08:39:49Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -64,22 +64,33 @@ void RunAction::BeginOfRunAction(const G4Run*)
{
//initialisation
//
fEnergyDeposit = 0.;
fNbCharged = fNbNeutral = 0;
fEnergyCharged = fEnergyNeutral = 0.;
fEmin[0] = fEmin[1] = DBL_MAX;
fEmax[0] = fEmax[1] = 0.;
fNbSteps = 0;
fTrackLength = 0.;
fStepMin = DBL_MAX;
fStepMax = 0.;
fEdepPrimary = fEdepSecondary = fEdepTotal = 0.;
fEdepPrimMin = fEdepSecMin = fEdepTotMin = DBL_MAX;
fEdepPrimMax = fEdepSecMax = fEdepTotMax = 0.;
fEnergyTransfered = 0.;
fEtransfMin = DBL_MAX;
fEtransfMax = 0.;
fEnergyLost = 0.;
fElostMin = DBL_MAX;
fElostMax = 0.;
fEnergyBalance = 0.;
fEbalMin = DBL_MAX;
fEbalMax = 0.;
//histograms
//
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
if ( analysisManager->IsActive() ) {
analysisManager->OpenFile();
}
}
// show Rndm status
CLHEP::HepRandom::showEngineStatus();
@@ -87,6 +98,117 @@ void RunAction::BeginOfRunAction(const G4Run*)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void RunAction::CountProcesses(G4String procName)
{
std::map<G4String,G4int>::iterator it = fProcCounter.find(procName);
if ( it == fProcCounter.end()) {
fProcCounter[procName] = 1;
}
else {
fProcCounter[procName]++;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void RunAction::TrackLength (G4double step)
{
fTrackLength += step; fNbSteps++;
if (step<fStepMin) fStepMin = step;
if (step>fStepMax) fStepMax = step;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void RunAction::EnergyDeposited (G4double edepPrim, G4double edepSecond)
{
fEdepPrimary += edepPrim;
if (edepPrim<fEdepPrimMin) fEdepPrimMin = edepPrim;
if (edepPrim>fEdepPrimMax) fEdepPrimMax = edepPrim;
fEdepSecondary += edepSecond;
if (edepSecond<fEdepSecMin) fEdepSecMin = edepSecond;
if (edepSecond>fEdepSecMax) fEdepSecMax = edepSecond;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void RunAction::EnergyTransferedByProcess(G4String process, G4double energy)
{
std::map<G4String, MinMaxData>::iterator it = fEtransfByProcess.find(process);
if ( it == fEtransfByProcess.end()) {
fEtransfByProcess[process] = MinMaxData(1, energy, energy, energy);
}
else {
MinMaxData& data = it->second;
data.fCount++;
data.fVsum += energy;
//update min max
G4double emin = data.fVmin;
if (energy < emin) data.fVmin = energy;
G4double emax = data.fVmax;
if (energy > emax) data.fVmax = energy;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void RunAction::EnergyTransfered (G4double energy)
{
fEnergyTransfered += energy;
if (energy<fEtransfMin) fEtransfMin = energy;
if (energy>fEtransfMax) fEtransfMax = energy;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void RunAction::TotalEnergyLost (G4double energy)
{
fEnergyLost += energy;
if (energy<fElostMin) fElostMin = energy;
if (energy>fElostMax) fElostMax = energy;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void RunAction::EnergyBalance (G4double energy)
{
fEnergyBalance += energy;
if (energy<fEbalMin) fEbalMin = energy;
if (energy>fEbalMax) fEbalMax = energy;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void RunAction::TotalEnergyDeposit (G4double energy)
{
fEdepTotal += energy;
if (energy<fEdepTotMin) fEdepTotMin = energy;
if (energy>fEdepTotMax) fEdepTotMax = energy;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void RunAction::EnergySpectrumOfSecondaries(G4String particle, G4double energy)
{
std::map<G4String,MinMaxData>::iterator it = fEkinOfSecondaries.find(particle);
if ( it == fEkinOfSecondaries.end()) {
fEkinOfSecondaries[particle] = MinMaxData(1, energy, energy, energy);
}
else {
MinMaxData& data = it->second;
data.fCount++;
data.fVsum += energy;
//update min max
G4double emin = data.fVmin;
if (energy < emin) data.fVmin = energy;
G4double emax = data.fVmax;
if (energy > emax) data.fVmax = energy;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void RunAction::EndOfRunAction(const G4Run* aRun)
{
G4int nbEvents = aRun->GetNumberOfEvent();
@@ -108,20 +230,25 @@ void RunAction::EndOfRunAction(const G4Run* aRun)
<< G4BestUnit(length,"Length") << " of "
<< material->GetName() << " (density: "
<< G4BestUnit(density,"Volumic Mass") << ")";
G4cout << "\n ===========================================================\n";
G4cout << G4endl;
//save histograms
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
if ( analysisManager->IsActive() ) {
analysisManager->Write();
analysisManager->CloseFile();
}
if (particle->GetPDGCharge() == 0.) return;
G4cout.precision(5);
G4cout.precision(4);
//frequency of processes
//
G4cout << "\n Process defining step :" << G4endl;
G4int index = 0;
for ( const auto& procCounter : fProcCounter ) {
G4String procName = procCounter.first;
G4int count = procCounter.second;
G4String space = " "; if (++index%4 == 0) space = "\n";
G4cout << " " << std::setw(15) << procName << "="<< std::setw(7) << count
<< space;
}
G4cout << G4endl;
//track length
//
G4double trackLPerEvent = fTrackLength/nbEvents;
@@ -129,52 +256,31 @@ void RunAction::EndOfRunAction(const G4Run* aRun)
G4double stepSize = fTrackLength/fNbSteps;
G4cout
<< "\n TrackLength= "
<< "\n TrackLength = "
<< G4BestUnit(trackLPerEvent, "Length")
<< "\t nb of steps= " << nbStepPerEvent
<< " stepSize= " << G4BestUnit(stepSize, "Length")
<< " nb of steps = " << nbStepPerEvent
<< " stepSize = " << G4BestUnit(stepSize, "Length")
<< " (" << G4BestUnit(fStepMin, "Length")
<< "--> " << G4BestUnit(fStepMax, "Length") << ")"
<< G4endl;
//charged secondaries (ionization, direct pair production)
//
G4double energyPerEvent = fEnergyCharged/nbEvents;
G4double nbPerEvent = double(fNbCharged)/nbEvents;
G4double meanEkin = 0.;
if (fNbCharged) meanEkin = fEnergyCharged/fNbCharged;
G4cout
<< "\n d-rays : eLoss/primary= "
<< G4BestUnit(energyPerEvent, "Energy")
<< "\t nb of d-rays= " << nbPerEvent
<< " <Tkin>= " << G4BestUnit(meanEkin, "Energy")
<< " Tmin= " << G4BestUnit(fEmin[0], "Energy")
<< " Tmax= " << G4BestUnit(fEmax[0], "Energy")
<< G4endl;
//neutral secondaries (bremsstrahlung, pixe)
//
energyPerEvent = fEnergyNeutral/nbEvents;
nbPerEvent = double(fNbNeutral)/nbEvents;
meanEkin = 0.;
if (fNbNeutral) meanEkin = fEnergyNeutral/fNbNeutral;
G4cout
<< "\n gamma : eLoss/primary= "
<< G4BestUnit(energyPerEvent, "Energy")
<< "\t nb of gammas= " << nbPerEvent
<< " <Tkin>= " << G4BestUnit(meanEkin, "Energy")
<< " Tmin= " << G4BestUnit(fEmin[1], "Energy")
<< " Tmax= " << G4BestUnit(fEmax[1], "Energy")
<< G4endl;
//continuous energy deposited by primary track dE1
//
G4double energyPerEvent = fEdepPrimary/nbEvents;
G4cout
<< "\n Energy continuously deposited along primary track"
<< " (restricted dE/dx) dE1 = "
<< G4BestUnit(energyPerEvent, "Energy")
<< " (" << G4BestUnit(fEdepPrimMin, "Energy")
<< " --> " << G4BestUnit(fEdepPrimMax, "Energy") << ")"
<< G4endl;
//eveluation of dE1 from reading restricted Range table
//
G4EmCalculator emCal;
//local energy deposit
//
energyPerEvent = fEnergyDeposit/nbEvents;
//
G4double r0 = emCal.GetRangeFromRestricteDEDX(ePrimary,particle,material);
G4double r0 = emCal.GetRangeFromRestricteDEDX(ePrimary,particle,material);
G4double r1 = r0 - trackLPerEvent;
G4double etry = ePrimary - energyPerEvent;
G4double efinal = 0.;
@@ -184,21 +290,67 @@ void RunAction::EndOfRunAction(const G4Run* aRun)
if (dEtable > 0.) ratio = energyPerEvent/dEtable;
G4cout
<< "\n deposit : eLoss/primary= "
<< G4BestUnit(energyPerEvent, "Energy")
<< "\t <dEcut > table= "
<< "\n Evaluation of dE1 from reading restricted Range table : dE1_table = "
<< G4BestUnit(dEtable, "Energy")
<< " ---> simul/reference= " << ratio
<< " ---> dE1/dE1_table = " << ratio
<< G4endl;
//total energy transferred
// energy transfered to secondary particles by process : dE2
//
G4double energyTotal = fEnergyDeposit + fEnergyCharged + fEnergyNeutral;
energyPerEvent = energyTotal/nbEvents;
G4cout << "\n Energy transfered to secondary particles :" << G4endl;
std::map<G4String,MinMaxData>::iterator it1;
for (it1 = fEtransfByProcess.begin(); it1 != fEtransfByProcess.end(); it1++) {
G4String name = it1->first;
MinMaxData data = it1->second;
energyPerEvent = data.fVsum/nbEvents;
G4double eMin = data.fVmin;
G4double eMax = data.fVmax;
G4cout << " " << std::setw(17) << "due to " + name << ": dE2 = "
<< std::setw(6) << G4BestUnit(energyPerEvent, "Energy")
<< " (" << G4BestUnit(eMin, "Energy")
<< " --> " << G4BestUnit(eMax, "Energy")
<< ")" << G4endl;
}
// total energy tranfered : dE3 = sum of dE2
//
r0 = emCal.GetCSDARange(ePrimary,particle,material);
energyPerEvent = fEnergyTransfered/nbEvents;
G4cout
<< "\n Total energy transfered to secondaries : dE3 = sum of dE2 = "
<< G4BestUnit(energyPerEvent, "Energy")
<< " (" << G4BestUnit(fEtransfMin, "Energy")
<< " --> " << G4BestUnit(fEtransfMax, "Energy") << ")"
<< G4endl;
// total energy lost by incident particle : dE4 = dE1 + dE3
//
energyPerEvent = fEnergyLost/nbEvents;
G4cout
<< "\n Total energy lost by incident particle : dE4 = dE1 + dE3 = "
<< G4BestUnit(energyPerEvent, "Energy")
<< " (" << G4BestUnit(fElostMin, "Energy")
<< " --> " << G4BestUnit(fElostMax, "Energy") << ")"
<< G4endl;
// calcul of energy lost from energy balance : dE4_bal = E_in - E_out
//
energyPerEvent = fEnergyBalance/nbEvents;
G4cout
<< "\n calcul of dE4 from energy balance : dE4_bal = E_in - E_out = "
<< G4BestUnit(energyPerEvent, "Energy")
<< " (" << G4BestUnit(fEbalMin, "Energy")
<< " --> " << G4BestUnit(fEbalMax, "Energy") << ")"
<< G4endl;
//eveluation of dE4 from reading full Range table
//
r0 = emCal.GetCSDARange(ePrimary,particle,material);
r1 = r0 - trackLPerEvent;
etry = ePrimary - energyPerEvent;
etry = ePrimary - energyPerEvent;
efinal = 0.;
if (r1 > 0.) efinal = GetEnergyFromCSDARange(r1,particle,material,etry);
dEtable = ePrimary - efinal;
@@ -206,14 +358,71 @@ void RunAction::EndOfRunAction(const G4Run* aRun)
if (dEtable > 0.) ratio = energyPerEvent/dEtable;
G4cout
<< "\n total : eLoss/primary= "
<< G4BestUnit(energyPerEvent, "Energy")
<< "\t <dEfull> table= "
<< "\n Evaluation of dE4 from reading full Range table : dE4_table = "
<< G4BestUnit(dEtable, "Energy")
<< " ---> simul/reference= " << ratio
<< G4endl;
<< " ---> dE4/dE4_table = " << ratio
<< G4endl;
//energy spectrum of secondary particles
//
G4cout << "\n Energy spectrum of secondary particles :" << G4endl;
std::map<G4String,MinMaxData>::iterator it2;
for (it2 = fEkinOfSecondaries.begin();it2 != fEkinOfSecondaries.end(); it2++){
G4String name = it2->first;
MinMaxData data = it2->second;
G4int count = data.fCount;
G4double eMean = data.fVsum/count;
G4double eMin = data.fVmin;
G4double eMax = data.fVmax;
G4cout << " " << std::setw(13) << name << ": " << std::setw(7) << count
<< " Emean = " << std::setw(6) << G4BestUnit(eMean, "Energy")
<< " (" << G4BestUnit(eMin, "Energy")
<< " --> " << G4BestUnit(eMax, "Energy")
<< ")" << G4endl;
}
G4cout << G4endl;
//continuous energy deposited by secondary tracks dE5
// (only if secondary particles are tracked)
//
if (fEdepSecondary > 0.) {
energyPerEvent = fEdepSecondary/nbEvents;
G4cout
<< "\n Energy continuously deposited along secondary tracks"
<< " (restricted dE/dx) dE5 = "
<< G4BestUnit(energyPerEvent, "Energy")
<< " (" << G4BestUnit(fEdepSecMin, "Energy")
<< " --> " << G4BestUnit(fEdepSecMax, "Energy") << ")"
<< G4endl;
// total energy deposited : dE6 = dE1 + dE5
//
energyPerEvent = fEdepTotal/nbEvents;
G4cout
<< "\n Total energy deposited : dE6 = dE1 + dE5 = "
<< G4BestUnit(energyPerEvent, "Energy")
<< " (" << G4BestUnit(fEdepTotMin, "Energy")
<< " --> " << G4BestUnit(fEdepTotMax, "Energy") << ") \n"
<< G4endl;
}
G4cout.precision(prec);
//clear maps
//
fProcCounter.clear();
fEtransfByProcess.clear();
fEkinOfSecondaries.clear();
//save histograms
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
if ( analysisManager->IsActive() ) {
analysisManager->Write();
analysisManager->CloseFile();
}
// show Rndm status
CLHEP::HepRandom::showEngineStatus();
@@ -248,7 +457,7 @@ G4double RunAction::GetEnergyFromRestrictedRange(G4double range,
<< " iter = " << iter << G4endl;
}
return Energy;
return Energy;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -280,7 +489,7 @@ G4double RunAction::GetEnergyFromCSDARange(G4double range,
<< " iter = " << iter << G4endl;
}
return Energy;
return Energy;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -26,55 +26,38 @@
/// \file electromagnetic/TestEm18/src/StackingAction.cc
/// \brief Implementation of the StackingAction class
//
// $Id: StackingAction.cc 67268 2013-02-13 11:38:40Z ihrivnac $
// $Id: StackingAction.cc 105927 2017-08-29 13:25:29Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "StackingAction.hh"
#include "RunAction.hh"
#include "EventAction.hh"
#include "HistoManager.hh"
#include "StackingMessenger.hh"
#include "G4Track.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
StackingAction::StackingAction(RunAction* RA,EventAction* EA)
:G4UserStackingAction(),fRunaction(RA), fEventaction(EA)
{}
StackingAction::StackingAction()
:G4UserStackingAction(), fTrackSecondaries(false)
{
fStackMessenger = new StackingMessenger(this);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
StackingAction::~StackingAction()
{}
{
///delete fStackMessenger;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4ClassificationOfNewTrack
StackingAction::ClassifyNewTrack(const G4Track* track)
{
//keep primary particle
if (track->GetParentID() == 0) return fUrgent;
//energy spectrum of secondaries
//
G4double energy = track->GetKineticEnergy();
G4bool charged = (track->GetDefinition()->GetPDGCharge() != 0.);
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
if (charged) {
fRunaction->AddChargedSecondary(energy);
analysisManager->FillH1(4,energy);
} else {
fRunaction->AddNeutralSecondary(energy);
analysisManager->FillH1(5,energy);
}
fEventaction->AddSecondary(energy);
return fKill;
if ((track->GetTrackID() == 1) || (fTrackSecondaries)) return fUrgent;
else return fKill;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,65 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file electromagnetic/TestEm5/src/StackingMessenger.cc
/// \brief Implementation of the StackingMessenger class
//
// $Id: StackingMessenger.cc 67268 2013-02-13 11:38:40Z ihrivnac $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "StackingMessenger.hh"
#include "StackingAction.hh"
#include "G4UIcmdWithABool.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
StackingMessenger::StackingMessenger(StackingAction* stack)
:G4UImessenger(),fStackAction(stack),fTrackCmd(nullptr)
{
fTrackCmd = new G4UIcmdWithABool("/testem/trackSecondaries",this);
fTrackCmd->SetGuidance(" kill or keep secondary tracks");
fTrackCmd->SetParameterName("flag",true);
fTrackCmd->SetDefaultValue(true);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
StackingMessenger::~StackingMessenger()
{
delete fTrackCmd;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void StackingMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
{
if (command == fTrackCmd)
{fStackAction->SetTrackSecondaries(fTrackCmd->GetNewBoolValue(newValue));}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -26,7 +26,7 @@
/// \file electromagnetic/TestEm18/src/SteppingAction.cc
/// \brief Implementation of the SteppingAction class
//
// $Id: SteppingAction.cc 67268 2013-02-13 11:38:40Z ihrivnac $
// $Id: SteppingAction.cc 105927 2017-08-29 13:25:29Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -38,6 +38,7 @@
#include "HistoManager.hh"
#include "G4Step.hh"
#include "G4ParticleTypes.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -54,13 +55,53 @@ SteppingAction::~SteppingAction()
void SteppingAction::UserSteppingAction(const G4Step* step)
{
//continuous energy deposit per event
fEventaction->AddEnergyDeposit (step->GetTotalEnergyDeposit());
// energy continuously deposited along trajectory
//
G4int trackID = step->GetTrack()->GetTrackID();
G4double Edep = step->GetTotalEnergyDeposit();
if (Edep > 0.) fEventaction->SumEnergyDeposited(trackID, Edep);
//step size
// the rest for primary track only
if (trackID > 1) return;
// count processes
//
const G4StepPoint* endPoint = step->GetPostStepPoint();
const G4VProcess* process = endPoint->GetProcessDefinedStep();
G4String procName = process->GetProcessName();
G4int subtype = process-> GetProcessSubType();
G4int nbsec = step->GetNumberOfSecondariesInCurrentStep();
if ((subtype == 2)&&(nbsec == 0)) procName = "Edep alone";
fRunaction->CountProcesses(procName);
// step size and track length
//
G4double stepSize = step->GetStepLength();
fRunaction->AddTrackLength(stepSize);
G4AnalysisManager::Instance()->FillH1(6,stepSize);
fRunaction->TrackLength(stepSize);
G4AnalysisManager::Instance()->FillH1(1,stepSize);
if (nbsec == 0) return; // no secondary particles
// energy transfered to secondary particles
//
const std::vector<const G4Track*>* secondaries
= step->GetSecondaryInCurrentStep();
G4double Etransfer = 0.;
for (G4int itr=0; itr<nbsec; itr++) {
const G4Track* trk = (*secondaries)[itr];
const G4ParticleDefinition* particle = trk->GetParticleDefinition();
G4String name = particle->GetParticleName();
G4double energy = trk->GetKineticEnergy();
fRunaction->EnergySpectrumOfSecondaries(name,energy);
G4int ih = 0;
if (particle == G4Gamma::Gamma()) ih = 11;
else if (particle == G4Electron::Electron()) ih = 12;
else if (particle == G4Positron::Positron()) ih = 13;
if (ih > 0) G4AnalysisManager::Instance()->FillH1(ih,energy);
if (subtype == 4) energy = trk->GetTotalEnergy(); //(e+,e-) production
Etransfer += energy;
}
fEventaction->SumEnergyTransfered(process, Etransfer);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,68 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file electromagnetic/TestEm12/src/TrackingAction.cc
/// \brief Implementation of the TrackingAction class
//
// $Id: TrackingAction.cc 78723 2014-01-20 10:32:17Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "TrackingAction.hh"
#include "RunAction.hh"
#include "HistoManager.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
TrackingAction::TrackingAction(RunAction* runaction)
:G4UserTrackingAction(), fRunAction(runaction)
{
fEkin1 = 0.;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void TrackingAction::PreUserTrackingAction(const G4Track* track)
{
if (track->GetTrackID() == 1) fEkin1 = track->GetKineticEnergy();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void TrackingAction::PostUserTrackingAction(const G4Track* track)
{
// energy balance of primary particle
if (track->GetTrackID() == 1) {
G4double Ekin2 = track->GetKineticEnergy();
G4double dElost = fEkin1 - Ekin2;
fRunAction->EnergyBalance(dElost);
G4AnalysisManager::Instance()->FillH1(8,dElost);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......