Import Geant4 10.1.0 source tree
This commit is contained in:
@@ -29,16 +29,19 @@
|
||||
#include "BrachyPrimaryGeneratorAction.hh"
|
||||
#include "BrachySteppingAction.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4GeneralParticleSource.hh"
|
||||
|
||||
BrachyActionInitialization::BrachyActionInitialization(BrachyAnalysisManager* analysis_manager):
|
||||
BrachyActionInitialization::BrachyActionInitialization():
|
||||
G4VUserActionInitialization()
|
||||
{
|
||||
analysis = analysis_manager;
|
||||
masterGPS = new G4GeneralParticleSource();
|
||||
}
|
||||
|
||||
|
||||
BrachyActionInitialization::~BrachyActionInitialization()
|
||||
{}
|
||||
{
|
||||
delete masterGPS;
|
||||
}
|
||||
|
||||
void BrachyActionInitialization::BuildForMaster() const
|
||||
{
|
||||
@@ -52,10 +55,10 @@ void BrachyActionInitialization::BuildForMaster() const
|
||||
void BrachyActionInitialization::Build() const
|
||||
{
|
||||
// Initialize the primary particles
|
||||
BrachyPrimaryGeneratorAction* primary = new BrachyPrimaryGeneratorAction(analysis);
|
||||
BrachyPrimaryGeneratorAction* primary = new BrachyPrimaryGeneratorAction();
|
||||
SetUserAction(primary);
|
||||
|
||||
BrachySteppingAction* stepping = new BrachySteppingAction(analysis);
|
||||
BrachySteppingAction* stepping = new BrachySteppingAction();
|
||||
SetUserAction(stepping);
|
||||
|
||||
}
|
||||
|
||||
@@ -35,103 +35,69 @@ Author: Susanna Guatelli
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
BrachyAnalysisManager* BrachyAnalysisManager::instance = 0;
|
||||
|
||||
BrachyAnalysisManager::BrachyAnalysisManager()
|
||||
{
|
||||
|
||||
factoryOn = false;
|
||||
|
||||
// Initialization
|
||||
// histograms
|
||||
for (G4int k=0; k<MaxHisto; k++) fHistId[k] = 0;
|
||||
|
||||
// Initialization ntuple
|
||||
for (G4int k=0; k<MaxNtCol; k++) {
|
||||
fNtColId[k] = 0;
|
||||
}
|
||||
|
||||
primaryParticleSpectrum = 0;
|
||||
|
||||
#ifdef ANALYSIS_USE
|
||||
theTFile = 0;
|
||||
histo = 0;
|
||||
ntuple = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
BrachyAnalysisManager::~BrachyAnalysisManager()
|
||||
{
|
||||
#ifdef G4ANALYSIS_USE
|
||||
delete theTFile; theTFile = 0;
|
||||
delete histo; histo = 0;
|
||||
delete ntuple; ntuple = 0;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
BrachyAnalysisManager* BrachyAnalysisManager::GetInstance()
|
||||
{
|
||||
if (instance == 0) instance = new BrachyAnalysisManager;
|
||||
return instance;
|
||||
}
|
||||
|
||||
void BrachyAnalysisManager::book()
|
||||
{
|
||||
G4AnalysisManager* AnalysisManager = G4AnalysisManager::Instance();
|
||||
|
||||
AnalysisManager->SetVerboseLevel(2);
|
||||
#ifdef ANALYSIS_USE
|
||||
delete theTFile;
|
||||
theTFile = new TFile("brachytherapy.root", "RECREATE");
|
||||
|
||||
// Create a root file
|
||||
G4String fileName = "brachytherapy.root";
|
||||
histo = new TH1F("h10","energy spectrum", 800, 0., 800);
|
||||
ntuple = new TNtuple("ntuple","edep3D","xx:yy:zz:edep");
|
||||
#endif
|
||||
}
|
||||
|
||||
// Create directories
|
||||
AnalysisManager->SetHistoDirectoryName("brachy_histo");
|
||||
AnalysisManager->SetNtupleDirectoryName("brachy_ntuple");
|
||||
|
||||
|
||||
G4bool fileOpen = AnalysisManager->OpenFile(fileName);
|
||||
if (!fileOpen) {
|
||||
G4cout << "\n---> HistoManager::book(): cannot open "
|
||||
<< fileName[1]
|
||||
<< G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
//creating a 1D histograms
|
||||
AnalysisManager->SetFirstHistoId(1);
|
||||
|
||||
// Histogram containing the primary particle energy (MeV)
|
||||
fHistId[1] = AnalysisManager -> CreateH1("1",
|
||||
"Initial energy",
|
||||
1000, 0., 1000.);
|
||||
|
||||
//Parameters of CreateH1: histoID, histo name, bins' number, xmin, xmax
|
||||
|
||||
primaryParticleSpectrum = AnalysisManager-> GetH1(fHistId[1]);
|
||||
|
||||
//creating a ntuple, containg 3D energy deposition in the phantom
|
||||
AnalysisManager -> CreateNtuple("1", "3Dedep");
|
||||
fNtColId[0] = AnalysisManager->CreateNtupleDColumn("xx");
|
||||
fNtColId[1] = AnalysisManager->CreateNtupleDColumn("yy");
|
||||
fNtColId[2] = AnalysisManager->CreateNtupleDColumn("zz");
|
||||
fNtColId[3] = AnalysisManager->CreateNtupleDColumn("edep");
|
||||
AnalysisManager->FinishNtuple();
|
||||
|
||||
factoryOn = true;
|
||||
}
|
||||
|
||||
void BrachyAnalysisManager::FillPrimaryParticleHistogram(G4double primaryParticleEnergy)
|
||||
{
|
||||
// 1DHistogram: energy spectrum of primary particles
|
||||
primaryParticleSpectrum -> fill(primaryParticleEnergy);
|
||||
}
|
||||
|
||||
#ifdef ANALYSIS_USE
|
||||
void BrachyAnalysisManager::FillNtupleWithEnergyDeposition(G4double xx,
|
||||
G4double yy,
|
||||
G4double zz,
|
||||
G4double energyDep)
|
||||
{
|
||||
G4AnalysisManager* AnalysisManager = G4AnalysisManager::Instance();
|
||||
AnalysisManager->FillNtupleDColumn(fNtColId[0], xx);
|
||||
AnalysisManager->FillNtupleDColumn(fNtColId[1], yy);
|
||||
AnalysisManager->FillNtupleDColumn(fNtColId[2], zz);
|
||||
AnalysisManager->FillNtupleDColumn(fNtColId[3], energyDep);
|
||||
AnalysisManager->AddNtupleRow();
|
||||
ntuple -> Fill(xx, yy, zz, energyDep);
|
||||
}
|
||||
|
||||
void BrachyAnalysisManager::FillPrimaryParticleHistogram(G4double primaryParticleEnergy)
|
||||
{
|
||||
// 1DHistogram: energy spectrum of primary particles
|
||||
histo-> Fill(primaryParticleEnergy);
|
||||
}
|
||||
#endif
|
||||
|
||||
void BrachyAnalysisManager::save()
|
||||
{
|
||||
if (factoryOn)
|
||||
{
|
||||
G4AnalysisManager* AnalysisManager = G4AnalysisManager::Instance();
|
||||
AnalysisManager->Write();
|
||||
AnalysisManager->CloseFile();
|
||||
|
||||
delete G4AnalysisManager::Instance();
|
||||
factoryOn = false;
|
||||
}
|
||||
#ifdef ANALYSIS_USE
|
||||
if (theTFile)
|
||||
{
|
||||
theTFile -> Write();
|
||||
theTFile -> Close();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -37,25 +37,28 @@
|
||||
// * *
|
||||
// ********************************************
|
||||
//
|
||||
// $Id: BrachyPrimaryGeneratorAction.cc 74021 2013-09-19 13:41:54Z gcosmo $
|
||||
// $Id: BrachyPrimaryGeneratorAction.cc 84280 2014-10-13 07:21:10Z gcosmo $
|
||||
//
|
||||
|
||||
#include "globals.hh"
|
||||
|
||||
#include "BrachyPrimaryGeneratorAction.hh"
|
||||
#include "Randomize.hh"
|
||||
#include "G4Event.hh"
|
||||
#include "G4GeneralParticleSource.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "BrachyAnalysisManager.hh"
|
||||
|
||||
BrachyPrimaryGeneratorAction::BrachyPrimaryGeneratorAction(BrachyAnalysisManager* analysis_manager)
|
||||
#ifdef ANALYSIS_USE
|
||||
#include "BrachyAnalysisManager.hh"
|
||||
#endif
|
||||
|
||||
BrachyPrimaryGeneratorAction::BrachyPrimaryGeneratorAction()
|
||||
{
|
||||
// Use the GPS to generate primary particles,
|
||||
// Particle type, energy position, direction are specified in the
|
||||
// the macro file primary.mac
|
||||
gun = new G4GeneralParticleSource();
|
||||
analysis = analysis_manager;
|
||||
}
|
||||
|
||||
BrachyPrimaryGeneratorAction::~BrachyPrimaryGeneratorAction()
|
||||
@@ -70,8 +73,9 @@ void BrachyPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
|
||||
#ifdef ANALYSIS_USE
|
||||
if (gun -> GetParticleDefinition()-> GetParticleName()== "gamma")
|
||||
{
|
||||
BrachyAnalysisManager* analysis = BrachyAnalysisManager::GetInstance();
|
||||
G4double energy = gun -> GetParticleEnergy();
|
||||
analysis -> FillPrimaryParticleHistogram(energy);
|
||||
analysis -> FillPrimaryParticleHistogram(energy/keV);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -41,11 +41,15 @@
|
||||
#include "G4TrackStatus.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4Gamma.hh"
|
||||
|
||||
#ifdef ANALYSIS_USE
|
||||
#include "BrachyAnalysisManager.hh"
|
||||
#endif
|
||||
|
||||
#include "BrachySteppingAction.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
BrachySteppingAction::BrachySteppingAction(BrachyAnalysisManager* analysisMan):analysis(analysisMan)
|
||||
BrachySteppingAction::BrachySteppingAction()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -84,6 +88,7 @@ void BrachySteppingAction::UserSteppingAction(const G4Step* aStep)
|
||||
if (process == "RadioactiveDecay")
|
||||
{
|
||||
#ifdef ANALYSIS_USE
|
||||
BrachyAnalysisManager* analysis = BrachyAnalysisManager::GetInstance();
|
||||
G4double energy = (*fSecondary)[lp1] -> GetKineticEnergy();
|
||||
// Store the initial energy of particles in a 1D histogram
|
||||
analysis -> FillPrimaryParticleHistogram(energy/keV);
|
||||
|
||||
@@ -34,7 +34,11 @@ Original code from geant4/examples/extended/runAndEvent/RE03, by M. Asai
|
||||
#include <fstream>
|
||||
#include "BrachyUserScoreWriter.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
#ifdef ANALYSIS_USE
|
||||
#include "BrachyAnalysisManager.hh"
|
||||
#endif
|
||||
|
||||
#include "G4MultiFunctionalDetector.hh"
|
||||
#include "G4SDParticleFilter.hh"
|
||||
#include "G4VPrimitiveScorer.hh"
|
||||
@@ -47,10 +51,9 @@ Original code from geant4/examples/extended/runAndEvent/RE03, by M. Asai
|
||||
// The same information is stored in a ntuple, in the
|
||||
// brachytherapy.root file
|
||||
|
||||
BrachyUserScoreWriter::BrachyUserScoreWriter(BrachyAnalysisManager* analysis_manager):
|
||||
BrachyUserScoreWriter::BrachyUserScoreWriter():
|
||||
G4VScoreWriter()
|
||||
{
|
||||
analysis = analysis_manager;
|
||||
}
|
||||
|
||||
BrachyUserScoreWriter::~BrachyUserScoreWriter()
|
||||
@@ -124,6 +127,7 @@ for(int x = 0; x < fNMeshSegments[0]; x++) {
|
||||
|
||||
#ifdef ANALYSIS_USE
|
||||
// Save the same information in the output analysis file
|
||||
BrachyAnalysisManager* analysis = BrachyAnalysisManager::GetInstance();
|
||||
analysis -> FillNtupleWithEnergyDeposition(xx, yy, zz, *(value->second)/keV);
|
||||
#endif
|
||||
}}}}
|
||||
|
||||
Reference in New Issue
Block a user